Merge pull request #2515 from Ana06/pre-rails-5-1

Some prerequisites to update to Rails 5.1
This commit is contained in:
Ana María Martínez Gómez 2019-05-10 20:22:07 +02:00 committed by GitHub
commit c587cf1998
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 14 additions and 21 deletions

View file

@ -1,2 +1,2 @@
web: bundle exec puma -C config/puma.rb
web: bundle exec rails server -b 0.0.0.0
worker: bundle exec rails jobs:work

View file

@ -70,7 +70,7 @@ module Admin
flash[:error] = errors_text
end
redirect_to :back
redirect_back(fallback_location: root_path)
end
private

View file

@ -6,6 +6,6 @@ class OpenidsController < ApplicationController
def destroy
@openid.destroy
redirect_to :back
redirect_back(fallback_location: root_path)
end
end

View file

@ -104,7 +104,7 @@ class ProposalsController < ApplicationController
@event.event_schedules.destroy_all
end
rescue Transitions::InvalidTransition
redirect_to :back, error: "Event can't be withdrawn"
redirect_back(fallback_location: root_path, error: "Event can't be withdrawn")
return
end
@ -124,7 +124,7 @@ class ProposalsController < ApplicationController
begin
@event.confirm
rescue Transitions::InvalidTransition
redirect_to :back, error: "Event can't be confirmed"
redirect_back(fallback_location: root_path, error: "Event can't be confirmed")
return
end

View file

@ -40,6 +40,6 @@ class SurveysController < ApplicationController
end
end
redirect_to :back
redirect_back(fallback_location: root_path)
end
end

View file

@ -2,7 +2,7 @@
module Users
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
skip_before_filter :verify_authenticity_token
skip_before_action :verify_authenticity_token
skip_authorization_check
User.omniauth_providers.each do |provider|

View file

@ -88,10 +88,9 @@ module ApplicationHelper
end
end
# Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to()
def redirect_back_or_to(options = {}, response_status = {})
if request.env['HTTP_REFERER']
redirect_to :back
redirect_back(fallback_location: root_path)
else
redirect_to options, response_status
end

View file

@ -1120,7 +1120,6 @@ class Conference < ApplicationRecord
#
def create_email_settings
build_email_settings
true
end
##

View file

@ -211,7 +211,6 @@ class Program < ApplicationRecord
EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice',
minimum_abstract_length: 0,
maximum_abstract_length: 500, program_id: id)
true
end
##
@ -227,7 +226,6 @@ class Program < ApplicationRecord
DifficultyLevel.create(title: 'Hard',
description: 'Events require expert knowledge of the topic.',
color: '#EF6E69', program_id: id)
true
end
##

View file

@ -76,7 +76,7 @@ class Registration < ApplicationRecord
end
def registration_limit_not_exceed
if conference.registration_limit > 0 && conference.registrations(:reload).count >= conference.registration_limit
if conference.registration_limit > 0 && conference.registrations.count >= conference.registration_limit
errors.add(:base, 'Registration limit exceeded')
end
end

View file

@ -18,6 +18,6 @@ class Role < ApplicationRecord
# Needed to ensure that removing all user from role doesn't remove role.
def cancel
false
throw(:abort)
end
end

View file

@ -11,6 +11,7 @@ class User < ApplicationRecord
# prevent N+1 queries with has_cached_role? by preloading roles *always*
default_scope { preload(:roles) }
has_many :ticket_purchases, dependent: :destroy
has_many :physical_tickets, through: :ticket_purchases do
def by_conference(conference)
where('ticket_purchases.conference_id = ?', conference)
@ -67,7 +68,6 @@ class User < ApplicationRecord
end
end
has_many :events_registrations, through: :registrations
has_many :ticket_purchases, dependent: :destroy
has_many :payments, dependent: :destroy
has_many :tickets, through: :ticket_purchases, source: :ticket do
def for_registration conference

View file

@ -20,6 +20,3 @@ 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

View file

@ -21,7 +21,7 @@ environment ENV.fetch("RAILS_ENV") { "development" }
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
workers ENV.fetch("WEB_CONCURRENCY") { 1 }
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code

View file

@ -4,8 +4,8 @@ require 'spec_helper'
describe Role do
let(:conference) { create(:conference) }
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
let!(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
let!(:organizer_role) { Role.find_or_create_by(name: 'organizer', resource: conference) }
let!(:cfp_role) { Role.find_or_create_by(name: 'cfp', resource: conference) }
let!(:organizer) { create(:organizer, resource: conference) }
let(:user) { create(:user) }