Merge pull request #2515 from Ana06/pre-rails-5-1
Some prerequisites to update to Rails 5.1
This commit is contained in:
commit
c587cf1998
15 changed files with 14 additions and 21 deletions
2
Procfile
2
Procfile
|
|
@ -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
|
worker: bundle exec rails jobs:work
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ module Admin
|
||||||
|
|
||||||
flash[:error] = errors_text
|
flash[:error] = errors_text
|
||||||
end
|
end
|
||||||
redirect_to :back
|
redirect_back(fallback_location: root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ class OpenidsController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@openid.destroy
|
@openid.destroy
|
||||||
redirect_to :back
|
redirect_back(fallback_location: root_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ class ProposalsController < ApplicationController
|
||||||
@event.event_schedules.destroy_all
|
@event.event_schedules.destroy_all
|
||||||
end
|
end
|
||||||
rescue Transitions::InvalidTransition
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ class ProposalsController < ApplicationController
|
||||||
begin
|
begin
|
||||||
@event.confirm
|
@event.confirm
|
||||||
rescue Transitions::InvalidTransition
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,6 @@ class SurveysController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to :back
|
redirect_back(fallback_location: root_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
module Users
|
module Users
|
||||||
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_action :verify_authenticity_token
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
User.omniauth_providers.each do |provider|
|
User.omniauth_providers.each do |provider|
|
||||||
|
|
|
||||||
|
|
@ -88,10 +88,9 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
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 = {})
|
def redirect_back_or_to(options = {}, response_status = {})
|
||||||
if request.env['HTTP_REFERER']
|
if request.env['HTTP_REFERER']
|
||||||
redirect_to :back
|
redirect_back(fallback_location: root_path)
|
||||||
else
|
else
|
||||||
redirect_to options, response_status
|
redirect_to options, response_status
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1120,7 +1120,6 @@ class Conference < ApplicationRecord
|
||||||
#
|
#
|
||||||
def create_email_settings
|
def create_email_settings
|
||||||
build_email_settings
|
build_email_settings
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,6 @@ class Program < ApplicationRecord
|
||||||
EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice',
|
EventType.create(title: 'Workshop', length: 60, color: '#0000FF', description: 'Interactive hands-on practice',
|
||||||
minimum_abstract_length: 0,
|
minimum_abstract_length: 0,
|
||||||
maximum_abstract_length: 500, program_id: id)
|
maximum_abstract_length: 500, program_id: id)
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
@ -227,7 +226,6 @@ class Program < ApplicationRecord
|
||||||
DifficultyLevel.create(title: 'Hard',
|
DifficultyLevel.create(title: 'Hard',
|
||||||
description: 'Events require expert knowledge of the topic.',
|
description: 'Events require expert knowledge of the topic.',
|
||||||
color: '#EF6E69', program_id: id)
|
color: '#EF6E69', program_id: id)
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class Registration < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def registration_limit_not_exceed
|
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')
|
errors.add(:base, 'Registration limit exceeded')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,6 @@ class Role < ApplicationRecord
|
||||||
|
|
||||||
# Needed to ensure that removing all user from role doesn't remove role.
|
# Needed to ensure that removing all user from role doesn't remove role.
|
||||||
def cancel
|
def cancel
|
||||||
false
|
throw(:abort)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class User < ApplicationRecord
|
||||||
# prevent N+1 queries with has_cached_role? by preloading roles *always*
|
# prevent N+1 queries with has_cached_role? by preloading roles *always*
|
||||||
default_scope { preload(:roles) }
|
default_scope { preload(:roles) }
|
||||||
|
|
||||||
|
has_many :ticket_purchases, dependent: :destroy
|
||||||
has_many :physical_tickets, through: :ticket_purchases do
|
has_many :physical_tickets, through: :ticket_purchases do
|
||||||
def by_conference(conference)
|
def by_conference(conference)
|
||||||
where('ticket_purchases.conference_id = ?', conference)
|
where('ticket_purchases.conference_id = ?', conference)
|
||||||
|
|
@ -67,7 +68,6 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
has_many :events_registrations, through: :registrations
|
has_many :events_registrations, through: :registrations
|
||||||
has_many :ticket_purchases, dependent: :destroy
|
|
||||||
has_many :payments, dependent: :destroy
|
has_many :payments, dependent: :destroy
|
||||||
has_many :tickets, through: :ticket_purchases, source: :ticket do
|
has_many :tickets, through: :ticket_purchases, source: :ticket do
|
||||||
def for_registration conference
|
def for_registration conference
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,3 @@ ActiveSupport.to_time_preserves_timezone = false
|
||||||
|
|
||||||
# Require `belongs_to` associations by default. Previous versions had false.
|
# Require `belongs_to` associations by default. Previous versions had false.
|
||||||
Rails.application.config.active_record.belongs_to_required_by_default = 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
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ environment ENV.fetch("RAILS_ENV") { "development" }
|
||||||
# Workers do not work on JRuby or Windows (both of which do not support
|
# Workers do not work on JRuby or Windows (both of which do not support
|
||||||
# processes).
|
# processes).
|
||||||
#
|
#
|
||||||
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
workers ENV.fetch("WEB_CONCURRENCY") { 1 }
|
||||||
|
|
||||||
# Use the `preload_app!` method when specifying a `workers` number.
|
# Use the `preload_app!` method when specifying a `workers` number.
|
||||||
# This directive tells Puma to first boot the application and load code
|
# This directive tells Puma to first boot the application and load code
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Role do
|
describe Role do
|
||||||
let(:conference) { create(:conference) }
|
let(:conference) { create(:conference) }
|
||||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
let!(:organizer_role) { Role.find_or_create_by(name: 'organizer', resource: conference) }
|
||||||
let!(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
let!(:cfp_role) { Role.find_or_create_by(name: 'cfp', resource: conference) }
|
||||||
let!(:organizer) { create(:organizer, resource: conference) }
|
let!(:organizer) { create(:organizer, resource: conference) }
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue