Browse Source

Migration to Ruby on Rails 5.1

rails5
echarp 4 years ago
parent
commit
4b7dfa2772
  1. 67
      Gemfile
  2. 188
      Gemfile.lock
  3. 5
      app/assets/stylesheets/form.sass
  4. 4
      app/controllers/digests_controller.rb
  5. 6
      app/models/event.rb
  6. 2
      app/models/event_callbacks.rb
  7. 2
      app/models/note.rb
  8. 2
      bin/rails
  9. 34
      bin/setup
  10. 6
      config/application.rb
  11. 2
      config/boot.rb
  12. 2
      config/environment.rb
  13. 39
      config/environments/development.rb
  14. 51
      config/environments/production.rb
  15. 12
      config/environments/test.rb
  16. 10
      config/initializers/assets.rb
  17. 2
      config/initializers/cookies_serializer.rb
  18. 3
      config/initializers/mime_types.rb
  19. 4
      config/initializers/wrap_parameters.rb
  20. 16
      config/secrets.yml
  21. 238
      db/schema.rb
  22. 16
      test/models/event_callbacks_test.rb

67
Gemfile

@ -1,25 +1,19 @@
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end
# The central piece of this application: the month calendar view
gem 'simple_calendar'
# The recurrence management library
gem 'ice_cube'
# Rails engine for static pages
gem 'high_voltage'
gem 'rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'rails', '~> 5.1.4'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder'
gem 'jbuilder', '~> 2.5'
gem 'haml-rails'
@ -56,25 +50,41 @@ gem 'geocoder'
gem 'tinymce-rails'
gem 'tinymce-rails-langs'
# The newer 5th version requires a newer ruby > 2.1
gem 'acts-as-taggable-on', '< 5'
gem 'acts-as-taggable-on'
gem 'tagsinput-rails'
# Rails engine for static pages
gem 'high_voltage'
# SEO optimisations
gem 'meta-tags'
gem 'twitter'
group :development do
gem 'quiet_assets'
gem 'webrick'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console'
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger
# console
gem 'byebug'
gem 'byebug', platforms: %i[mri mingw x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Access an IRB console on exception pages or by using <%= console %>
# anywhere in the code.
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application
# running in the background. Read more:
# https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Scanning the Gemfile for insecure dependencies based on published CVEs
gem 'bundler-audit'
@ -92,14 +102,6 @@ group :development do
gem 'guard-rails', require: false
end
group :test do
gem 'simplecov'
end
group :development, :test do
gem 'sqlite3'
end
group :development, :test, :assets do
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails'
@ -140,3 +142,6 @@ group :production do
# Use mysql as the database for Active Record
gem 'mysql2'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

188
Gemfile.lock

@ -2,24 +2,28 @@ GEM
remote: https://rubygems.org/
remote: https://rails-assets.org/
specs:
actionmailer (4.2.10)
actionpack (= 4.2.10)
actionview (= 4.2.10)
activejob (= 4.2.10)
actioncable (5.1.4)
actionpack (= 5.1.4)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.10)
actionview (= 4.2.10)
activesupport (= 4.2.10)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.10)
activesupport (= 4.2.10)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
actionview-encoded_mail_to (1.0.9)
rails
@ -35,30 +39,30 @@ GEM
ransack (~> 1.3)
sass (~> 3.1)
sprockets (< 4.1)
activejob (4.2.10)
activesupport (= 4.2.10)
globalid (>= 0.3.0)
activemodel (4.2.10)
activesupport (= 4.2.10)
builder (~> 3.1)
activerecord (4.2.10)
activemodel (= 4.2.10)
activesupport (= 4.2.10)
arel (~> 6.0)
activesupport (4.2.10)
activejob (5.1.4)
activesupport (= 5.1.4)
globalid (>= 0.3.6)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
arel (~> 8.0)
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
acts-as-taggable-on (4.0.0)
activerecord (>= 4.0)
acts-as-taggable-on (5.0.0)
activerecord (>= 4.2.8)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arbre (1.1.1)
activesupport (>= 3.0.0)
arel (6.0.4)
arel (8.0.0)
ast (2.3.0)
bcrypt (3.1.11)
bindex (0.5.0)
brakeman (4.0.1)
buftok (0.2.0)
builder (3.2.3)
@ -66,6 +70,15 @@ GEM
bundler (~> 1.2)
thor (~> 0.18)
byebug (9.1.0)
capybara (2.15.4)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
childprocess (0.8.0)
ffi (~> 1.0, >= 1.0.11)
coderay (1.1.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
@ -76,7 +89,6 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
crass (1.0.2)
debug_inspector (0.0.3)
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@ -86,7 +98,6 @@ GEM
devise-i18n (1.3.0)
devise (>= 2.0)
differ (0.1.2)
docile (1.1.5)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
em-websocket (0.5.1)
@ -95,6 +106,7 @@ GEM
email_validator (1.6.0)
activemodel
equalizer (0.0.11)
erubi (1.7.0)
erubis (2.7.0)
eventmachine (1.2.5)
execjs (2.7.0)
@ -181,7 +193,8 @@ GEM
http-form_data (1.0.3)
http_accept_language (2.1.1)
http_parser.rb (0.6.0)
i18n (0.8.6)
i18n (0.9.0)
concurrent-ruby (~> 1.0)
i18n-active_record (0.2.0)
i18n (>= 0.5.0)
ice_cube (0.16.2)
@ -232,7 +245,7 @@ GEM
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.3.0)
mini_mime (0.1.4)
minitest (5.10.3)
modernizr-rails (2.7.1)
multi_json (1.12.2)
@ -240,8 +253,8 @@ GEM
mysql2 (0.4.9)
naught (1.1.0)
nenv (0.3.0)
nio4r (2.1.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
@ -259,46 +272,44 @@ GEM
polyamorous (1.3.1)
activerecord (>= 3.0)
powerpack (0.1.1)
pry (0.11.1)
pry (0.11.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.0)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.8)
puma (3.10.0)
rack (2.0.3)
rack-livereload (0.3.16)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.10)
actionmailer (= 4.2.10)
actionpack (= 4.2.10)
actionview (= 4.2.10)
activejob (= 4.2.10)
activemodel (= 4.2.10)
activerecord (= 4.2.10)
activesupport (= 4.2.10)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.10)
sprockets-rails
rack-test (0.7.0)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
bundler (>= 1.3.0)
railties (= 5.1.4)
sprockets-rails (>= 2.0.0)
rails-assets-jquery-sparkline (2.1.3)
rails-assets-leaflet (1.2.0)
rails-assets-leaflet.markercluster (1.1.0)
rails-assets-leaflet (>= 1.0.3)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-i18n (4.0.9)
rails-i18n (5.0.4)
i18n (~> 0.7)
railties (~> 4.0)
railties (4.2.10)
actionpack (= 4.2.10)
activesupport (= 4.2.10)
railties (~> 5.0)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
@ -319,7 +330,7 @@ GEM
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rubocop (0.50.0)
rubocop (0.51.0)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
@ -330,6 +341,7 @@ GEM
ruby_dep (1.5.0)
ruby_parser (3.10.1)
sexp_processor (~> 4.9)
rubyzip (1.2.1)
sass (3.5.2)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
@ -344,16 +356,19 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
selenium-webdriver (3.6.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
sexp_processor (4.10.0)
shellany (0.0.1)
simple_calendar (2.2.7)
rails (>= 3.0)
simple_oauth (0.3.1)
simplecov (0.15.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
@ -374,7 +389,7 @@ GEM
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
tinymce-rails (4.6.7)
tinymce-rails (4.7.1)
railties (>= 3.1.1)
tinymce-rails-langs (4.20160310)
tinymce-rails (~> 4.1, >= 4.1.10)
@ -401,11 +416,16 @@ GEM
unicode-display_width (1.3.0)
warden (1.2.7)
rack (>= 1.0)
web-console (3.3.0)
activemodel (>= 4.2)
debug_inspector
railties (>= 4.2)
webrick (1.3.1)
web-console (3.5.1)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
xpath (2.1.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
@ -413,10 +433,11 @@ PLATFORMS
DEPENDENCIES
actionview-encoded_mail_to
activeadmin
acts-as-taggable-on (< 5)
acts-as-taggable-on
brakeman
bundler-audit
byebug
capybara (~> 2.13)
coffee-rails
devise
devise-i18n
@ -439,25 +460,28 @@ DEPENDENCIES
http_accept_language
i18n-active_record
ice_cube
jbuilder
jbuilder (~> 2.5)
jquery-ui-rails
kramdown
listen (>= 3.0.5, < 3.2)
meta-tags
modernizr-rails
mysql2
paper_trail
piwik_analytics
quiet_assets
puma (~> 3.7)
rack-livereload
rails
rails (~> 5.1.4)
rails-assets-jquery-sparkline!
rails-assets-leaflet!
rails-assets-leaflet.markercluster!
rails-i18n
sass-rails
sdoc
selenium-webdriver
simple_calendar
simplecov
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
strip_attributes
tagsinput-rails
@ -466,9 +490,9 @@ DEPENDENCIES
tinymce-rails-langs
turbolinks
twitter
tzinfo-data
uglifier
web-console
webrick
web-console (>= 3.3.0)
BUNDLED WITH
1.15.1

5
app/assets/stylesheets/form.sass

@ -66,6 +66,11 @@ input, textarea, select, a.button, .actions > button, .mce-tinymce, div.tagsinpu
letter-spacing: 2px
background-color: #9CC5EE
.mce-tinymce
box-shadow: none !important
.mce-top-part:before
box-shadow: 0 1px lightgray !important
.field_with_errors
display: inline
input, textarea, select, a.button

4
app/controllers/digests_controller.rb

@ -20,8 +20,8 @@ class DigestsController < ApplicationController
private
def set_week
@week = DateTime.commercial params[:period][:year].to_i,
params[:period][:week].to_i
@week = Time.commercial params[:period][:year].to_i,
params[:period][:week].to_i
end
def set_events

6
app/models/event.rb

@ -10,8 +10,8 @@ class Event < ApplicationRecord
decision_time latitude longitude]
belongs_to :region
# This is the scheduled first event
belongs_to :event
# This is the eventual scheduled first event
belongs_to :event, optional: true
has_many :notes, dependent: :destroy
has_many :events, dependent: :destroy
@ -59,7 +59,7 @@ class Event < ApplicationRecord
start_date.to_date.end_of_month.end_of_week.end_of_day
end)
scope :period, (lambda do |year, week|
start_date = DateTime.commercial(year.to_i, week.to_i)
start_date = Time.commercial(year.to_i, week.to_i)
where '? <= end_time and start_time <= ?',
start_date, start_date.end_of_week.end_of_day
end)

2
app/models/event_callbacks.rb

@ -14,7 +14,7 @@ class EventCallbacks
end
def self.before_update(event)
return unless event.moderated_changed? && event.moderated?
return unless event.will_save_change_to_moderated? && event.moderated?
event.decision_time = Time.zone.now
create_repeats event if event.repeat > 0 && event.rule
end

2
app/models/note.rb

@ -1,7 +1,7 @@
# Manages data related to events' moderation
class Note < ApplicationRecord
belongs_to :event
belongs_to :author, class_name: User
belongs_to :author, class_name: 'User'
validates :contents, presence: true

2
bin/rails

@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'

34
bin/setup

@ -1,29 +1,37 @@
#!/usr/bin/env ruby
require 'pathname'
require 'fileutils'
include FileUtils
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
system 'gem install bundler --conservative'
system 'bundle check || bundle install'
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts '\n== Preparing database =='
system 'bin/rake db:setup'
puts "\n== Preparing database =="
system! 'bin/rails db:setup'
puts '\n== Removing old logs and tempfiles =='
system 'rm -f log/*'
system 'rm -rf tmp/cache'
puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
puts '\n== Restarting application server =='
system 'touch tmp/restart.txt'
puts "\n== Restarting application server =="
system! 'bin/rails restart'
end

6
config/application.rb

@ -10,6 +10,8 @@ Bundler.require(*Rails.groups)
module AgendaDuLibreRails
# All the specific configuraton for ADL
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
# Settings in config/environments/* take precedence over those specified
# here.
# Application configuration should go into files in config/initializers
@ -36,12 +38,8 @@ module AgendaDuLibreRails
to: 'moderateurs@agendadulibre.org'
}
# config.quiet_assets = false
config.action_dispatch.default_headers['X-Frame-Options'] = 'ALLOWALL'
config.active_record.raise_in_transactional_callbacks = true
# In rails 4, plugin and vendor images need to be precompiled
config.assets.precompile += %w[*.png *.jpg *.jpeg *.gif]
end

2
config/boot.rb

@ -1,3 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.

2
config/environment.rb

@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!

39
config/environments/development.rb

@ -10,13 +10,28 @@ Rails.application.configure do
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
@ -28,24 +43,18 @@ Rails.application.configure do
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all
# assets, yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# Add Rack::LiveReload to the bottom of the middleware stack with the default
# options.
config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload
# To have assets Local Precompilation, we need to use another path in dev
config.assets.prefix = '/dev-assets'
config.sass.preferred_syntax = :sass
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end

51
config/environments/production.rb

@ -15,15 +15,14 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
# `config/secrets.yml.key`.
config.read_encrypted_secrets = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
@ -32,43 +31,46 @@ Rails.application.configure do
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all
# assets, yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to
# config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com',
# /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and
# use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :warn
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
config.log_tags = [:request_id]
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# config.action_controller.asset_host = '//assets%d.agendadulibre.org'
# Use a real queuing backend for Active Job (and separate queues per
# environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "agenda_du_libre_rails_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to
# raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.smtp_settings = { openssl_verify_mode: 'none' }
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
@ -80,6 +82,17 @@ Rails.application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new
# 'app-name')
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end

12
config/environments/test.rb

@ -13,9 +13,11 @@ Rails.application.configure do
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
}
# Show full error reports and disable caching.
config.consider_all_requests_local = true
@ -26,15 +28,13 @@ Rails.application.configure do
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

10
config/initializers/assets.rb

@ -3,10 +3,12 @@
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are
# already added.
# Rails.application.config.assets.precompile += %w( search.js )
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )

2
config/initializers/cookies_serializer.rb

@ -1,3 +1,5 @@
# Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :json

3
config/initializers/mime_types.rb

@ -1,7 +1,6 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register 'text/richtext', :rtf
# Mime::Type.register "text/richtext", :rtf
# Necessary for the /ical.php redirect to /events.ics
Mime::Type.register 'text/calendar', :ics, [], %w[ical]

4
config/initializers/wrap_parameters.rb

@ -6,10 +6,10 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format
# to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
wrap_parameters format: [:json]
end
# To enable root element in JSON for ActiveRecord objects.
# ActiveSupport.on_load(:active_record) do
# self.include_root_in_json = true
# self.include_root_in_json = true
# end

16
config/secrets.yml

@ -5,11 +5,18 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# You can use `rails secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
# Shared secrets are available across all environments.
# shared:
# api_key: a1B2c3D4e5F6
# Environmental secrets are only available for that specific environment.
development:
secret_key_base: dbe66d64011b60f265d7425be28bb09900e9b92dc858127490ac7c4294352aa360a562f60ee3efc554b7ce449b0244c04c5bed57cb28ca1df1e6a6e368ee5b9f
@ -19,8 +26,11 @@ test:
assets:
secret_key_base: hello world
# Do not keep production secrets in the repository,
# instead read values from the environment.
# Do not keep production secrets in the unencrypted secrets file.
# Instead, either read values from the environment.
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
# and move the `production:` environment over there.
production:
secret_key_base: <%= ENV['SECRET_KEY_BASE'] || 'hello world' %>
production_communs:

238
db/schema.rb

@ -1,4 +1,3 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@ -11,189 +10,186 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170701161358) do
ActiveRecord::Schema.define(version: 20171015143615) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace"
t.text "body"
t.string "resource_id", null: false
t.string "resource_type", null: false
t.integer "author_id"
t.string "author_type"
t.string "namespace"
t.text "body"
t.string "resource_id", null: false
t.string "resource_type", null: false
t.integer "author_id"
t.string "author_type"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
end
add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace"
add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
create_table "admin_users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["email"], name: "index_admin_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end
add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true
add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
create_table "cities", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
t.string "majname", limit: 255, default: "", null: false
t.string "name", limit: 255, default: "", null: false
t.string "majname", limit: 255, default: "", null: false
t.integer "postalcode", limit: 4
t.integer "inseecode", limit: 4
t.integer "inseecode", limit: 4
t.integer "regioncode", limit: 4
t.float "latitude", limit: 24
t.float "longitude", limit: 24
t.float "latitude", limit: 24
t.float "longitude", limit: 24
t.index ["name"], name: "cities_name"
end
add_index "cities", ["name"], name: "cities_name"
create_table "events", force: :cascade do |t|
t.string "title", limit: 255, default: "", null: false
t.text "description", limit: 65535, null: false
t.datetime "start_time", null: false
t.datetime "end_time", null: false
t.string "city", limit: 255, default: ""
t.integer "region_id", limit: 4, default: 0, null: false
t.integer "locality", limit: 4, default: 0, null: false
t.string "url", limit: 255, default: ""
t.string "contact", limit: 255, default: "", null: false
t.string "submitter", limit: 255, default: "", null: false
t.integer "moderated", limit: 4, default: 0, null: false
t.text "tags", limit: 255, default: ""
t.string "secret", limit: 255, default: "", null: false
t.string "title", limit: 255, default: "", null: false
t.text "description", limit: 65535, null: false
t.datetime "start_time", null: false
t.datetime "end_time", null: false
t.string "city", limit: 255, default: ""
t.integer "region_id", limit: 4, default: 0, null: false
t.integer "locality", limit: 4, default: 0, null: false
t.string "url", limit: 255, default: ""
t.string "contact", limit: 255, default: "", null: false
t.string "submitter", limit: 255, default: "", null: false
t.integer "moderated", limit: 4, default: 0, null: false
t.text "tags", limit: 255, default: ""
t.string "secret", limit: 255, default: "", null: false
t.datetime "decision_time"
t.datetime "submission_time"
t.string "moderator_mail_id", limit: 32
t.string "submitter_mail_id", limit: 32
t.text "address", limit: 65535
t.float "latitude", limit: 24
t.float "longitude", limit: 24
t.integer "lock_version", limit: 4, default: 0, null: false
t.string "place_name", limit: 255
t.integer "count", default: 1
t.integer "repeat", default: 0
t.text "rule"
t.integer "event_id"
t.string "moderator_mail_id", limit: 32
t.string "submitter_mail_id", limit: 32
t.text "address", limit: 65535
t.float "latitude", limit: 24
t.float "longitude", limit: 24
t.integer "lock_version", limit: 4, default: 0, null: false
t.string "place_name", limit: 255
t.integer "count", default: 1
t.integer "repeat", default: 0
t.text "rule"
t.integer "event_id"
t.index ["event_id"], name: "index_events_on_event_id"
t.index ["start_time", "end_time"], name: "events_date"
end
add_index "events", ["event_id"], name: "index_events_on_event_id"
add_index "events", ["start_time", "end_time"], name: "events_date"
create_table "kinds", force: :cascade do |t|
t.string "name", null: false
t.string "icon"
t.string "name", null: false
t.string "icon"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "notes", force: :cascade do |t|
t.text "contents", limit: 65535, null: false
t.datetime "date", null: false
t.integer "event_id", limit: 4
t.integer "author_id", limit: 4
t.text "contents", limit: 65535, null: false
t.datetime "date", null: false
t.integer "event_id", limit: 4
t.integer "author_id", limit: 4
end
create_table "orgas", force: :cascade do |t|
t.integer "region_id", limit: 4, default: 0, null: false
t.string "department", limit: 4, default: "0", null: false
t.string "name", limit: 255, default: "", null: false
t.string "url", limit: 255, default: "", null: false
t.string "city", limit: 255, default: ""
t.integer "kind_id", limit: 4
t.string "feed", limit: 255
t.string "contact", limit: 255
t.string "submitter", limit: 255
t.boolean "moderated", limit: 1, default: false
t.integer "region_id", limit: 4, default: 0, null: false
t.string "department", limit: 4, default: "0", null: false
t.string "name", limit: 255, default: "", null: false
t.string "url", limit: 255, default: "", null: false
t.string "city", limit: 255, default: ""
t.integer "kind_id", limit: 4
t.string "feed", limit: 255
t.string "contact", limit: 255
t.string "submitter", limit: 255
t.boolean "moderated", limit: 1, default: false
t.datetime "submission_time"
t.datetime "decision_time"
t.string "secret", limit: 255
t.boolean "deleted", limit: 1, default: false, null: false
t.boolean "active", default: true, null: false
t.text "description"
t.string "secret", limit: 255
t.boolean "deleted", limit: 1, default: false, null: false
t.boolean "active", default: true, null: false
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.text "tag"
t.text "tags", default: ""
t.text "diaspora"
t.text "object_changes"
t.text "place_name"
t.text "address"
t.float "latitude"
t.float "longitude"
t.text "tag"
t.text "tags", default: ""
t.text "diaspora"
t.text "object_changes"
t.text "place_name"
t.text "address"
t.float "latitude"
t.float "longitude"
t.index ["kind_id"], name: "index_orgas_on_kind_id"
end
add_index "orgas", ["kind_id"], name: "index_orgas_on_kind_id"
create_table "regions", force: :cascade do |t|
t.string "name", limit: 255, default: "", null: false
t.string "name", limit: 255, default: "", null: false
t.integer "region_id"
t.string "code"
t.string "url"
t.string "code"
t.string "url"
t.index ["region_id"], name: "index_regions_on_region_id"
end
add_index "regions", ["region_id"], name: "index_regions_on_region_id"
create_table "taggings", force: :cascade do |t|
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type"
t.integer "tagger_id"
t.string "tagger_type"
t.string "context", limit: 128
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type"
t.integer "tagger_id"
t.string "tagger_type"
t.string "context", limit: 128
t.datetime "created_at"
t.index ["context"], name: "index_taggings_on_context"
t.index ["tag_id"], name: "index_taggings_on_tag_id"
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
end
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id"
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
create_table "tags", force: :cascade do |t|
t.string "name"
t.string "name"
t.integer "taggings_count", default: 0
end
create_table "translations", force: :cascade do |t|
t.string "locale", limit: 255
t.string "key", limit: 255
t.text "value", limit: 65535
t.text "interpolations", limit: 65535
t.boolean "is_proc", limit: 1, default: false
t.string "locale", limit: 255
t.string "key", limit: 255
t.text "value", limit: 65535
t.text "interpolations", limit: 65535
t.boolean "is_proc", limit: 1, default: false
end
create_table "users", force: :cascade do |t|
t.string "login", limit: 255, default: "", null: false
t.string "password", limit: 255, default: "", null: false
t.string "email", limit: 255, default: "", null: false
t.string "lastname", limit: 255, default: "", null: false
t.string "firstname", limit: 255, default: "", null: false
t.string "confirmation_token"
t.string "login", limit: 255, default: "", null: false
t.string "password", limit: 255, default: "", null: false
t.string "email", limit: 255, default: "", null: false
t.string "lastname", limit: 255, default: "", null: false
t.string "firstname", limit: 255, default: "", null: false
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.datetime "remember_created_at"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
create_table "versions", force: :cascade do |t|
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.text "object"
t.string "item_type", null: false
t.integer "item_id", null: false
t.string "event", null: false
t.string "whodunnit"
t.text "object"
t.datetime "created_at"
t.text "object_changes", limit: 1073741823
t.text "object_changes", limit: 1073741823
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end
add_index "versions", ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
end

16
test/models/event_callbacks_test.rb

@ -4,12 +4,10 @@ require 'test_helper'
class EventCallbacksTest < ActiveSupport::TestCase
setup do
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
@event = events :one
end
test 'schedule' do
@event = Event.new(
event = Event.new(
title: 'hello world',
start_time: Time.zone.now, end_time: Time.zone.now + 1.hour,
description: 'et hop!',
@ -19,12 +17,12 @@ class EventCallbacksTest < ActiveSupport::TestCase
tag_list: 'hello world'
)
assert_difference 'Event.count' do
assert @event.save, @event.errors.messages
assert event.save, event.errors.messages
end
end
test 'moderation' do
@event = Event.new(
event = Event.new(
title: 'hello world',
start_time: Time.zone.now + 1.hour, end_time: Time.zone.now + 2.hours,
repeat: 1, rule: 'monthly',
@ -35,13 +33,13 @@ class EventCallbacksTest < ActiveSupport::TestCase
tag_list: 'hello world'
)
assert @event.save, @event.errors.messages
assert_not @event.moderated?
assert event.save, event.errors.messages
assert_not event.moderated?
assert_difference 'Event.count' do
@event.update moderated: 1
event.update moderated: 1
end
assert @event.moderated?, @event.errors.messages
assert event.moderated?, event.errors.messages
end
end

Loading…
Cancel
Save