Commit 9c74f63f authored by Alexandre Friquet's avatar Alexandre Friquet

Upgrades rails to 5.1.4: refs #23.

parent 41f9e9b2
......@@ -22,7 +22,7 @@
#
source 'https://rubygems.org'
gem 'rails', '5.0.6'
gem 'rails', '5.1.4'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
......@@ -48,7 +48,7 @@ gem "nested_form"
gem 'geocoder'
gem 'gmaps4rails'
gem 'gretel'
gem 'gretel-trails', git: 'https://github.com/infoPiiaf/gretel-trails.git'
gem 'gretel-trails', git: 'https://github.com/infoPiiaf/gretel-trails.git', branch: 'fix-alias-method-chain-error'
gem 'piwik_analytics', git: 'https://git.framasoft.org/infopiiaf/piwik_analytics.git'
gem 'jquery-ui-rails'
gem 'compass-rails'
......@@ -63,6 +63,7 @@ group :development, :test do
gem "sqlite3"
gem 'rspec-rails'
gem 'byebug'
gem 'listen'
end
group :test do
......
......@@ -18,7 +18,8 @@ GIT
GIT
remote: https://github.com/infoPiiaf/gretel-trails.git
revision: 462404527fe31710c5676a774d80246fa142c1ba
revision: 1c4ae2a214ddd7de61dea205cd5e598fd61b81ec
branch: fix-alias-method-chain-error
specs:
gretel-trails (0.0.5)
gretel (>= 3.0)
......@@ -36,39 +37,39 @@ GEM
remote: https://rubygems.org/
specs:
RedCloth (4.3.2)
actioncable (5.0.6)
actionpack (= 5.0.6)
nio4r (>= 1.2, < 3.0)
actioncable (5.1.4)
actionpack (= 5.1.4)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
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 (~> 2.0)
actionpack (5.0.6)
actionview (= 5.0.6)
activesupport (= 5.0.6)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
rack (~> 2.0)
rack-test (~> 0.6.3)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.0.6)
activesupport (= 5.0.6)
actionview (5.1.4)
activesupport (= 5.1.4)
builder (~> 3.1)
erubis (~> 2.7.0)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.6)
activesupport (= 5.0.6)
activejob (5.1.4)
activesupport (= 5.1.4)
globalid (>= 0.3.6)
activemodel (5.0.6)
activesupport (= 5.0.6)
activerecord (5.0.6)
activemodel (= 5.0.6)
activesupport (= 5.0.6)
arel (~> 7.0)
activesupport (5.0.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)
......@@ -77,7 +78,7 @@ GEM
activerecord (>= 3.0)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (7.1.4)
arel (8.0.0)
autoparse (0.3.3)
addressable (>= 2.3.1)
extlib (>= 0.9.15)
......@@ -127,6 +128,7 @@ GEM
concurrent-ruby (1.0.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.2)
daemons (1.2.4)
database_cleaner (1.6.1)
delayed_job (4.1.3)
......@@ -140,7 +142,7 @@ GEM
dotenv-rails (2.2.1)
dotenv (= 2.2.1)
railties (>= 3.2, < 5.2)
erubis (2.7.0)
erubi (1.6.1)
execjs (2.7.0)
extlib (0.9.16)
factory_girl (4.8.0)
......@@ -204,16 +206,21 @@ GEM
jwt (1.5.6)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
loofah (2.0.3)
loofah (2.1.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
memoist (0.16.0)
method_source (0.8.2)
method_source (0.9.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
......@@ -245,28 +252,28 @@ GEM
public_suffix (3.0.0)
puma (3.10.0)
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.6)
actioncable (= 5.0.6)
actionmailer (= 5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
activemodel (= 5.0.6)
activerecord (= 5.0.6)
activesupport (= 5.0.6)
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.0.6)
railties (= 5.1.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.0.6)
actionpack (= 5.0.6)
activesupport (= 5.0.6)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
......@@ -294,6 +301,7 @@ GEM
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
ruby-progressbar (1.8.3)
ruby_dep (1.5.0)
safe_yaml (1.0.4)
sass (3.4.25)
sass-rails (5.0.6)
......@@ -387,6 +395,7 @@ DEPENDENCIES
jquery-rails
jquery-ui-rails
launchy
listen
momentjs-rails
nested_form
paperclip
......@@ -394,7 +403,7 @@ DEPENDENCIES
piwik_analytics!
prettyphoto-rails
puma
rails (= 5.0.6)
rails (= 5.1.4)
rdoc
rspec-rails
sass-rails
......
......@@ -24,7 +24,7 @@ class Contact < ApplicationRecord
has_many :phone_numbers, :dependent => :destroy
accepts_nested_attributes_for :phone_numbers, :allow_destroy => true
belongs_to :member
belongs_to :contact_type
belongs_to :contact_type, optional: true
attr_accessor :new_function
......
......@@ -21,7 +21,7 @@
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
#
class Event < ApplicationRecord
belongs_to :event_type
belongs_to :event_type, optional: true
has_many :attached_files, :as => :attachable, :dependent => :destroy
accepts_nested_attributes_for :attached_files, :allow_destroy => true
has_and_belongs_to_many :activities
......
......@@ -21,7 +21,7 @@
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
#
class Novel < ApplicationRecord
belongs_to :novel_type
belongs_to :novel_type, optional: true
has_many :attached_files, :as => :attachable, :dependent => :destroy
accepts_nested_attributes_for :attached_files, :allow_destroy => true
has_many :emails, :dependent => :destroy
......
......@@ -23,7 +23,7 @@
class Page < ApplicationRecord
include URLEncoding
belongs_to :menu
belongs_to :menu, optional: true
has_many :attached_files, :as => :attachable, :dependent => :destroy
accepts_nested_attributes_for :attached_files, :allow_destroy => true
has_many :logos, :dependent => :destroy
......
......@@ -21,8 +21,8 @@
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
#
class Partner < ApplicationRecord
belongs_to :website
belongs_to :group, class_name: "PartnersGroup"
belongs_to :website, optional: true
belongs_to :group, class_name: "PartnersGroup", optional: true
has_attached_file :logo, :styles => { :thumb => "100x86", :standard => "160x120" }, :convert_options => { :all => '-strip -colorspace RGB'}
do_not_validate_attachment_file_type :logo
validates_attachment_size :logo, :less_than => 1.megabyte, :message => "doit faire moins de 1 Mo"
......
......@@ -18,6 +18,9 @@ chdir APP_ROOT do
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')
# cp 'config/database.yml.sample', 'config/database.yml'
......
#!/usr/bin/env ruby
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(" ")}"
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
......@@ -33,6 +33,9 @@ module OLIGAA
class Application < Rails::Application
config.autoload_paths += %W(#{Rails.root}/lib)
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
config.time_zone = 'UTC'
config.i18n.default_locale = :fr
......
......@@ -29,3 +29,4 @@ test:
production:
adapter: redis
url: redis://localhost:6379/1
channel_prefix: oligaa_production
......@@ -40,7 +40,7 @@ Rails.application.configure do
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => 'public, max-age=172800'
'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
......@@ -72,5 +72,5 @@ Rails.application.configure do
# 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
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
end
......@@ -14,6 +14,11 @@ Rails.application.configure do
config.consider_all_requests_local = false
config.action_controller.perform_caching = 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.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
......
......@@ -15,7 +15,7 @@ Rails.application.configure do
# 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=3600'
'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
}
# Show full error reports and disable caching.
......
......@@ -27,6 +27,8 @@ Rails.application.config.assets.version = '1.0'
# 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.
......
......@@ -24,4 +24,4 @@
# Specify a serializer for the signed and encrypted cookie jars.
# Valid options are :json, :marshal, and :hybrid.
Rails.application.config.action_dispatch.cookies_serializer = :marshal
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
#
# OLIGAA - Stands for "Outil en Ligne d'Information et de Gestion des Activités
# des Associations" which is an online tool for associations to manage news,
# actors and activities.
# Copyright (C) 2010-2016 Comité Départemental du Sport Adapté de la Gironde (CDSA
# 33) <contact@cdsa33.org>
#
# This file is part of OLIGAA.
#
# OLIGAA is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# OLIGAA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OLIGAA. If not, see <http://www.gnu.org/licenses/>.
#
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 5.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
Rails.application.config.action_controller.raise_on_unfiltered_parameters = true
# Enable per-form CSRF tokens. Previous versions had false.
Rails.application.config.action_controller.per_form_csrf_tokens = false
# Enable origin-checking CSRF mitigation. Previous versions had false.
Rails.application.config.action_controller.forgery_protection_origin_check = false
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = false
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = false
# Do not halt callback chains when a callback returns false. Previous versions had true.
ActiveSupport.halt_callback_chains_on_return_false = true
......@@ -32,6 +32,14 @@ environment ENV.fetch("RAILS_ENV") { "development" }
#
# preload_app!
# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
before_fork do
ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
end
# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
......
......@@ -29,5 +29,6 @@ FactoryGirl.define do
street "Rue Untel"
postal_code "01 234"
city "Ma Ville"
member
end
end
\ No newline at end of file
end
......@@ -25,5 +25,7 @@ FactoryGirl.define do
sender "sender@example.com"
recipients "recipient1@example.com, recipient2@example.com"
other_recipients "others@example.com"
member
novel
end
end
......@@ -24,5 +24,6 @@ FactoryGirl.define do
factory :phone_number do
number "0102030405"
kind "fixe"
contact
end
end
......@@ -207,8 +207,7 @@ feature "Manage Activities" do
end
scenario "I can remove a file", :js do
attached_file = create :attached_file
@activity.attached_files << attached_file
attached_file = create :attached_file, attachable: @activity
visit edit_activity_path @activity
within "form" do
click_link "Pièces jointes"
......
......@@ -158,8 +158,7 @@ feature "Manage events" do
end
scenario "I can remove a file", :js do
attached_file = create :attached_file
@event.attached_files << attached_file
attached_file = create :attached_file, attachable: @event
visit edit_event_path @event
within "form" do
click_link "Pièces jointes"
......@@ -173,4 +172,4 @@ feature "Manage events" do
end
end
end
end
\ No newline at end of file
end
......@@ -314,8 +314,7 @@ feature "Manage members" do
end
scenario "I can reset the password", :js do
contact = create :contact, email: "jean.dupont@example.com", member: nil
@member.contacts << contact
contact = create :contact, email: "jean.dupont@example.com", member: @member
visit members_path
within "section#content" do
click_link "Membres sans groupe"
......
......@@ -53,13 +53,11 @@ feature "Manage newsletters" do
scenario "the partners are pre-set" do
title = "Lettre d'information"
p1 = create :partner
p1 = create :partner, website: @settings
p2 = create :partner
p3 = create :partner
@settings.partners << [p1, p3]
p3 = create :partner, website: @settings
visit new_newsletter_path
within "form" do
fill_in "Intitulé", with: title
within "div#partners" do
expect(page).to have_checked_field(p1.name)
expect(page).to have_no_checked_field(p2.name)
......@@ -203,10 +201,8 @@ feature "Manage newsletters" do
end
scenario "I can remove an image" do
item = create :newsletter_item
@newsletter.items << item
image = create :image
item.images << image
item = create :newsletter_item, newsletter: @newsletter
image = create :image, imageable: item
visit edit_newsletter_path @newsletter
within "form" do
click_link "Informations"
......@@ -246,10 +242,8 @@ feature "Manage newsletters" do
end
scenario "I can remove a file", :js do
item = create :newsletter_item
@newsletter.items << item
attached_file = create :attached_file
item.attached_files << attached_file
item = create :newsletter_item, newsletter: @newsletter
attached_file = create :attached_file, attachable: item
visit edit_newsletter_path @newsletter
within "form" do
click_link "Informations"
......
......@@ -173,8 +173,7 @@ feature "Manage Novels" do
end
scenario "I can remove a file", :js do
attached_file = create :attached_file
@novel.attached_files << attached_file
attached_file = create :attached_file, attachable: @novel
visit edit_novel_path @novel
within "form" do
click_link "Pièces jointes"
......
......@@ -139,8 +139,7 @@ feature "Manage Pages" do
end
scenario "I can remove a file", :js do
attached_file = create :attached_file
@my_page.attached_files << attached_file
attached_file = create :attached_file, attachable: @my_page
visit edit_page_path @my_page
within "form" do
click_link "Pièces jointes"
......@@ -255,4 +254,4 @@ feature "Manage Pages" do
end
end
end
end
\ No newline at end of file
end
......@@ -58,9 +58,9 @@ describe Contact do
it ".untyped lists all contacts with no associated type" do
ct = create :contact_type
c1 = create :contact, contact_type: ct, member: nil
c2 = create :contact, contact_type: nil, member: nil
(c1 = build(:contact, contact_type: ct, member: nil)).save(validate: false)
(c2 = build(:contact, contact_type: nil, member: nil)).save(validate: false)
expect(Contact.untyped).to eq [c2]
end
end
end
\ No newline at end of file
end
......@@ -67,20 +67,17 @@ describe Email do
expect(subject.reload.sent_at).not_to be_nil
end
it "returns the name of a know member or 'Inconnu'" do
member = create :member
email = create :email, member: nil
expect(email.member_name).to eq("Inconnu")
email.member = member and email.save!
expect(email.member_name).to eq(member.name)
end
context "#member_name" do
it "returns the name of the member" do
email = create :email, member: create(:member, name: "Alex")
expect(email.member_name).to eq("Alex")
end
it "#member_name returns the name or 'Inconnu'" do
email = create :email
expect(email.member_name).to eq("Inconnu")
member = create :member, name: "Alex"
email.update_attribute(:member, member)
expect(email.member_name).to eq("Alex")
it "returns 'Inconnu' if no member found" do
email = create :email
Member.find(email.member.id).destroy
expect(email.reload.member_name).to eq('Inconnu')
end
end
context "private methods" do
......@@ -104,10 +101,10 @@ describe Email do
end
it "#unused_contacts returns " do
c1 = create :contact, email: "c1@ip.fr"
c2 = create :contact, email: "c2@ip.fr"
c3 = create :contact, email: "c1@ip.fr"
email = create :email, recipients: "c1@ip.fr"
(c1 = build :contact, email: "c1@ip.fr", member: nil).save(validate: false)
(c2 = build :contact, email: "c2@ip.fr", member: nil).save(validate: false)
(c3 = build :contact, email: "c1@ip.fr", member: nil).save(validate: false)
(email = build :email, recipients: "c1@ip.fr", member: nil).save(validate: false)
expect(email.unused_contacts).to eq [c2]
end
......@@ -116,4 +113,4 @@ describe Email do
expect(email.all_recipients).to eq(%w[c1@ip.fr c2@ip.fr c3@ip.fr])
end
end
end
\ No newline at end of file
end
......@@ -30,7 +30,7 @@ describe Image do
context "validations" do
it "default factory is valid" do
expect(build(:image)).to be_valid
expect(build(:image, imageable: (create :page))).to be_valid
end
it { is_expected.to validate_presence_of :title }
it { is_expected.to validate_attachment_presence :img_file }
......
......@@ -30,18 +30,19 @@ describe Logo do
describe "validations" do
it "default factory is valid" do
expect(build(:logo)).to be_valid
expect(build(:logo, page: (create :page))).to be_valid
end
end
describe "scopes" do
it ".displayed returns only displayed ones" do
l1 = create :logo
l2 = create :logo, displayed: true
my_page = create :page
l1 = create :logo, page: my_page
l2 = create :logo, displayed: true, page: my_page
expect(Logo.displayed).to eq [l2]
end
end
describe "behaviors" do
end
end
\ No newline at end of file
end
......@@ -107,8 +107,7 @@ describe Novel do
it ".duplicate duplicates a novel as a non template private one" do
n1 = create :novel_with_picture
attached_file = create :attached_file
n1.attached_files << attached_file
attached_file = create :attached_file, attachable: n1
n2 = Novel.duplicate(n1.id)
expect(n2.template).to be_falsey
expect(n2.public).to be_falsey
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment