diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 79d5fa79..6eb30b48 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,15 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 155 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. Layout/HeredocIndentation: diff --git a/app/helpers/activity_categories_helper.rb b/app/helpers/activity_categories_helper.rb index 8d65c526..8421fd5e 100644 --- a/app/helpers/activity_categories_helper.rb +++ b/app/helpers/activity_categories_helper.rb @@ -1,7 +1,8 @@ module ActivityCategoriesHelper def button_to_delete cat button_to "Delete this Category", - cat, :method => "delete", + cat, + :method => "delete", :data => {:confirm => 'Delete this category and all activities in it? Are you sure?'} end diff --git a/app/helpers/attendee_helper.rb b/app/helpers/attendee_helper.rb index 6f547fa5..900ac444 100644 --- a/app/helpers/attendee_helper.rb +++ b/app/helpers/attendee_helper.rb @@ -11,8 +11,10 @@ def plan_selection_inputs plan end def plan_date_fields plan, selection - render :partial => 'shared/plan_date_fields', + render( + :partial => 'shared/plan_date_fields', :locals => {plan: plan, selection: selection} + ) end def plan_cbx plan, selection diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 06e76bf5..e8682f13 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -2,8 +2,10 @@ class UserMailer < ActionMailer::Base def welcome_email(user) @user = user @year = Year.where(year: user.year).first - mail(:to => user.email, + mail( + :to => user.email, :reply_to => @year.reply_to_email, - :subject => "Welcome to the #{user.year} U.S. Go Congress") + :subject => "Welcome to the #{user.year} U.S. Go Congress" + ) end end diff --git a/app/models/activity.rb b/app/models/activity.rb index 64561155..838b093f 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -21,7 +21,8 @@ class Activity < ApplicationRecord set the price to 0, so that this #{model_name.human.downcase} will not show up on invoices." } - validates :url, :length => {:maximum => 200}, + validates :url, + :length => {:maximum => 200}, :format => { :with => /\Ahttps?:\/{2}/, :allow_blank => true, diff --git a/app/models/plan_category.rb b/app/models/plan_category.rb index 5be0b933..82c3a790 100644 --- a/app/models/plan_category.rb +++ b/app/models/plan_category.rb @@ -7,7 +7,8 @@ class PlanCategory < ApplicationRecord has_many :plans validates :event, :presence => true - validates :name, :presence => true, + validates :name, + :presence => true, :uniqueness => { :scope => :year, :case_sensitive => false, diff --git a/app/models/registration/plan_selection.rb b/app/models/registration/plan_selection.rb index f1157e3c..5c6ad8f7 100644 --- a/app/models/registration/plan_selection.rb +++ b/app/models/registration/plan_selection.rb @@ -37,8 +37,10 @@ def hash # Gotcha: Notice that dates are not included. def to_attendee_plan attendee - AttendeePlan.new(:attendee => attendee, - :plan_id => @plan.id, :quantity => @qty, :year => attendee.year) + AttendeePlan.new( + :attendee => attendee, + :plan_id => @plan.id, :quantity => @qty, :year => attendee.year + ) end private diff --git a/app/models/transaction.rb b/app/models/transaction.rb index 0f7021d3..3b728073 100644 --- a/app/models/transaction.rb +++ b/app/models/transaction.rb @@ -23,7 +23,8 @@ class Transaction < ApplicationRecord validates :updated_by_user, :presence => true, :on => :update validates_presence_of :instrument, :if => :requires_instrument? - validates_inclusion_of :instrument, :in => [nil, ''], :if => :forbids_instrument?, \ + validates_inclusion_of :instrument, + :in => [nil, ''], :if => :forbids_instrument?, \ :message => "must be blank. (Not applicable for selected transaction type)" validates_length_of :instrument, :is => 1, :if => :requires_instrument? validates_inclusion_of :instrument, :in => INSTRUMENTS.flatten, :if => :requires_instrument? @@ -56,7 +57,8 @@ class Transaction < ApplicationRecord validates_numericality_of :check_number, :greater_than => 0, :if => :requires_check_number? # Only refunds may have a check number - validates_inclusion_of :check_number, :unless => :requires_check_number?, \ + validates_inclusion_of :check_number, + :unless => :requires_check_number?, \ :allow_nil => false, :allow_blank => false, :in => [nil, ''], \ :message => "must be blank. (Only applicable for Refunds)" diff --git a/db/migrate/20110719022229_migrate_us_open_attendees.rb b/db/migrate/20110719022229_migrate_us_open_attendees.rb index fa40aa9b..3f021cbf 100644 --- a/db/migrate/20110719022229_migrate_us_open_attendees.rb +++ b/db/migrate/20110719022229_migrate_us_open_attendees.rb @@ -1,17 +1,18 @@ class MigrateUsOpenAttendees < ActiveRecord::Migration - # Faux model protects against validations which may be added in future class Tournament < ActiveRecord::Base end - + def up usopen = Tournament.find_by_name 'US Open' unless usopen.present? - usopen = Tournament.create!(name:'US Open', + usopen = Tournament.create!( + name: 'US Open', eligible: 'Anyone', description: 'The national championship', directors: 'TBA', - openness: 'O') + openness: 'O' + ) end execute <<-EOQ insert into attendee_tournaments (attendee_id, tournament_id) diff --git a/db/migrate/20111210051015_replace_is_player.rb b/db/migrate/20111210051015_replace_is_player.rb index 29556886..627db7b8 100644 --- a/db/migrate/20111210051015_replace_is_player.rb +++ b/db/migrate/20111210051015_replace_is_player.rb @@ -1,5 +1,4 @@ class ReplaceIsPlayer < ActiveRecord::Migration - # Faux models protect against validations which may be added in future # http://guides.rubyonrails.org/migrations.html#using-models-in-your-migrations # But, if I had to do this again, I'd just write SQL! @@ -25,36 +24,40 @@ class Attendee < ActiveRecord::Base has_many :attendee_plans, :dependent => :destroy has_many :plans, :through => :attendee_plans end - + def up # In order to drop attendees.is_player, we must first migrate # data from 2011, by creating plans and assigning attendees. # This effort is not necessary in 2012, because we have no # attendees yet. - + # 2011 had a plan category that represented registrations, but # it was just for show. Attendees were not allowed to select # the plans in that category. PlanCategory.yr(2011).where(name: "Registration", show_on_reg_form: false).destroy_all - + # Create a new plan category for 2011 to represent registrations. - cat = PlanCategory.yr(2011).create(year: 2011, + cat = PlanCategory.yr(2011).create( + year: 2011, name: "Registration", - show_on_reg_form: true) - + show_on_reg_form: true + ) + # The new registration category will have two records: plan_specs = [] plan_specs << {stem: "Player", price: 375} plan_specs << {stem: "Non-Player", price: 75} plan_specs.each do |p| plan_name = "#{p[:stem]} Registration" - cat.plans.create(year: 2011, + cat.plans.create( + year: 2011, name: plan_name, price: p[:price], age_min: 0, - description: plan_name) + description: plan_name + ) end - + # Check that the category has the expected number of plans unless cat.plans.count == plan_specs.count raise "Expected #{plan_specs.count} plans in category, found #{cat.plans.count}" diff --git a/db/migrate/20130923073837_insert_2014_record.rb b/db/migrate/20130923073837_insert_2014_record.rb index ea6e08d5..4d35d6c4 100644 --- a/db/migrate/20130923073837_insert_2014_record.rb +++ b/db/migrate/20130923073837_insert_2014_record.rb @@ -7,16 +7,16 @@ def up # error. Year.create( { - city: 'TBD', - date_range: 'TBD', - day_off_date: Date.new(2014, 8, 2), - ordinal_number: 30, - registration_phase: 'closed', - reply_to_email: 'rcristal3@netscape.net', - start_date: Date.new(2014, 8, 1), - state: 'TBD', - timezone: 'Eastern Time (US & Canada)', - year: 2014 + city: 'TBD', + date_range: 'TBD', + day_off_date: Date.new(2014, 8, 2), + ordinal_number: 30, + registration_phase: 'closed', + reply_to_email: 'rcristal3@netscape.net', + start_date: Date.new(2014, 8, 1), + state: 'TBD', + timezone: 'Eastern Time (US & Canada)', + year: 2014 }, :without_protection => true ) diff --git a/db/seeds.rb b/db/seeds.rb index e30735f6..c68c295c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,167 +1,167 @@ # Seed the years. Year.create!( { - city: 'Santa Barbara', - date_range: 'Jul 30 - Aug 7', - day_off_date: Date.new(2011, 8, 3), - ordinal_number: 27, - registration_phase: 'complete', - reply_to_email: 'registrar@gocongress.org', - start_date: Date.new(2011, 7, 30), - state: 'CA', - timezone: 'Pacific Time (US & Canada)', - twitter_url: nil, - year: 2011 + city: 'Santa Barbara', + date_range: 'Jul 30 - Aug 7', + day_off_date: Date.new(2011, 8, 3), + ordinal_number: 27, + registration_phase: 'complete', + reply_to_email: 'registrar@gocongress.org', + start_date: Date.new(2011, 7, 30), + state: 'CA', + timezone: 'Pacific Time (US & Canada)', + twitter_url: nil, + year: 2011 } ) Year.create!( { - city: 'Black Mountain', - date_range: 'August 4 - 12', - day_off_date: Date.new(2012, 8, 8), - ordinal_number: 28, - registration_phase: 'open', - reply_to_email: 'arlene@usgocongress12.org', - start_date: Date.new(2012, 8, 4), - state: 'North Carolina', - timezone: 'Eastern Time (US & Canada)', - twitter_url: 'https://twitter.com/#!/GoCongress12', - year: 2012 + city: 'Black Mountain', + date_range: 'August 4 - 12', + day_off_date: Date.new(2012, 8, 8), + ordinal_number: 28, + registration_phase: 'open', + reply_to_email: 'arlene@usgocongress12.org', + start_date: Date.new(2012, 8, 4), + state: 'North Carolina', + timezone: 'Eastern Time (US & Canada)', + twitter_url: 'https://twitter.com/#!/GoCongress12', + year: 2012 } ) Year.create!( { - city: 'Seattle', - date_range: 'TBD', - day_off_date: Date.new(2013, 8, 8), - ordinal_number: 29, - registration_phase: 'closed', - reply_to_email: 'szimmerman@ctipc.com', - start_date: Date.new(2013, 8, 4), - state: 'Washington', - timezone: 'Pacific Time (US & Canada)', - twitter_url: 'https://twitter.com/#!/GoCongress13', - year: 2013 + city: 'Seattle', + date_range: 'TBD', + day_off_date: Date.new(2013, 8, 8), + ordinal_number: 29, + registration_phase: 'closed', + reply_to_email: 'szimmerman@ctipc.com', + start_date: Date.new(2013, 8, 4), + state: 'Washington', + timezone: 'Pacific Time (US & Canada)', + twitter_url: 'https://twitter.com/#!/GoCongress13', + year: 2013 } ) Year.create!( { - city: 'New York', - date_range: 'August 9-17', - day_off_date: Date.new(2014, 8, 13), - ordinal_number: 30, - registration_phase: 'closed', - reply_to_email: 'rcristal3@netscape.net', - start_date: Date.new(2014, 8, 9), - state: 'NY', - timezone: 'Eastern Time (US & Canada)', - year: 2014 + city: 'New York', + date_range: 'August 9-17', + day_off_date: Date.new(2014, 8, 13), + ordinal_number: 30, + registration_phase: 'closed', + reply_to_email: 'rcristal3@netscape.net', + start_date: Date.new(2014, 8, 9), + state: 'NY', + timezone: 'Eastern Time (US & Canada)', + year: 2014 } ) Year.create!( { - city: 'Saint Paul', - date_range: 'August 1 - 9', - day_off_date: Date.new(2015, 8, 5), - ordinal_number: 31, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2015, 8, 1), - state: 'MN', - timezone: 'Central Time (US & Canada)', - year: 2015 + city: 'Saint Paul', + date_range: 'August 1 - 9', + day_off_date: Date.new(2015, 8, 5), + ordinal_number: 31, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2015, 8, 1), + state: 'MN', + timezone: 'Central Time (US & Canada)', + year: 2015 } ) Year.create!( { - city: 'Boston', - date_range: 'July 30 - August 7', - day_off_date: Date.new(2016, 8, 3), - ordinal_number: 32, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2016, 7, 30), - state: 'MA', - timezone: 'Eastern Time (US & Canada)', - year: 2016 + city: 'Boston', + date_range: 'July 30 - August 7', + day_off_date: Date.new(2016, 8, 3), + ordinal_number: 32, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2016, 7, 30), + state: 'MA', + timezone: 'Eastern Time (US & Canada)', + year: 2016 } ) Year.create!( { - city: 'San Diego', - date_range: 'August 5 - 12', - day_off_date: Date.new(2017, 8, 9), - ordinal_number: 33, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2017, 8, 5), - state: 'CA', - timezone: 'Pacific Time (US & Canada)', - year: 2017 + city: 'San Diego', + date_range: 'August 5 - 12', + day_off_date: Date.new(2017, 8, 9), + ordinal_number: 33, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2017, 8, 5), + state: 'CA', + timezone: 'Pacific Time (US & Canada)', + year: 2017 } ) Year.create!( { - city: 'Williamsburg', - date_range: 'July 21 - 28', - day_off_date: Date.new(2018, 7, 25), - ordinal_number: 34, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2018, 7, 21), - state: 'VA', - timezone: 'Eastern Time (US & Canada)', - year: 2018 + city: 'Williamsburg', + date_range: 'July 21 - 28', + day_off_date: Date.new(2018, 7, 25), + ordinal_number: 34, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2018, 7, 21), + state: 'VA', + timezone: 'Eastern Time (US & Canada)', + year: 2018 } ) Year.create!( { - city: 'Madison', - date_range: 'July 13 - 20', - day_off_date: Date.new(2019, 7, 17), - ordinal_number: 35, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2019, 7, 13), - state: 'WI', - timezone: 'Central Time (US & Canada)', - year: 2019 + city: 'Madison', + date_range: 'July 13 - 20', + day_off_date: Date.new(2019, 7, 17), + ordinal_number: 35, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2019, 7, 13), + state: 'WI', + timezone: 'Central Time (US & Canada)', + year: 2019 } ) Year.create!( { - city: 'Estes Park', - date_range: 'August 1 - 9', - day_off_date: Date.new(2020, 8, 5), - ordinal_number: 36, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2020, 8, 1), - state: 'CO', - timezone: 'Mountain Time (US & Canada)', - year: 2020 + city: 'Estes Park', + date_range: 'August 1 - 9', + day_off_date: Date.new(2020, 8, 5), + ordinal_number: 36, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2020, 8, 1), + state: 'CO', + timezone: 'Mountain Time (US & Canada)', + year: 2020 } ) Year.create!( { - event_type: 'online', - date_range: 'July 17 - 24', - day_off_date: Date.new(2021, 7, 21), - ordinal_number: 37, - registration_phase: 'closed', - reply_to_email: 'webmaster@gocongress.org', - start_date: Date.new(2021, 7, 17), - timezone: 'Eastern Time (US & Canada)', - year: 2021 + event_type: 'online', + date_range: 'July 17 - 24', + day_off_date: Date.new(2021, 7, 21), + ordinal_number: 37, + registration_phase: 'closed', + reply_to_email: 'webmaster@gocongress.org', + start_date: Date.new(2021, 7, 17), + timezone: 'Eastern Time (US & Canada)', + year: 2021 } ) diff --git a/spec/controllers/activities_controller_spec.rb b/spec/controllers/activities_controller_spec.rb index 5a0aa54d..dbecf105 100644 --- a/spec/controllers/activities_controller_spec.rb +++ b/spec/controllers/activities_controller_spec.rb @@ -35,8 +35,16 @@ end describe "#create" do it "is forbidden" do - post :create, params: { year: Time.now.year, - activity: { activity_category_id: activity_category.id, leave_time: DateTime.current + 2.days, name: "Activity", price: 1, return_time: Time.current + 3.days } } + post :create, params: { + year: Time.now.year, + activity: { + activity_category_id: activity_category.id, + leave_time: DateTime.current + 2.days, + name: "Activity", + price: 1, + return_time: Time.current + 3.days + } + } expect(response.status).to eq(403) end end diff --git a/spec/controllers/activity_categories_controller_spec.rb b/spec/controllers/activity_categories_controller_spec.rb index 0d604c99..d84ac570 100644 --- a/spec/controllers/activity_categories_controller_spec.rb +++ b/spec/controllers/activity_categories_controller_spec.rb @@ -22,8 +22,10 @@ it "succeeds" do sign_in create :admin expect { - patch :update, params: { year: activity_category.year, - id: activity_category.id, activity_category: { name: "Activity" } } + patch :update, params: { + year: activity_category.year, + id: activity_category.id, activity_category: { name: "Activity" } + } }.to change{ activity_category.reload.name }.to("Activity") end end diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 85e9ff9d..651abbb0 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -12,8 +12,10 @@ it "succeeds" do sign_in create :admin expect { - patch :update, params: { year: contact.year, id: contact.id, - contact: { list_order: 1 } } + patch :update, params: { + year: contact.year, id: contact.id, + contact: { list_order: 1 } + } }.to change{ contact.reload.list_order }.to(1) end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 36b43ab1..12b31548 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -160,7 +160,8 @@ attendee.plans << plan expect(attendee.get_plan_qty(plan.id)).to eq(1) - plan2 = create :plan, :disabled => true, \ + plan2 = create :plan, + :disabled => true, :name => "Plan Deux", :plan_category => plan.plan_category get :edit, params: { id: attendee.id, year: attendee.year } diff --git a/spec/controllers/tournaments_controller_spec.rb b/spec/controllers/tournaments_controller_spec.rb index 8283b3b1..b253c094 100644 --- a/spec/controllers/tournaments_controller_spec.rb +++ b/spec/controllers/tournaments_controller_spec.rb @@ -33,8 +33,10 @@ it "succeeds" do sign_in create :admin expect { - patch :update, params: { year: tnm.year, id: tnm.id, - tournament: { name: '9x9' } } + patch :update, params: { + year: tnm.year, id: tnm.id, + tournament: { name: '9x9' } + } }.to change{ tnm.reload.name }.to('9x9') end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index c988d47b..7a0fc52a 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -336,9 +336,11 @@ it "can change a user password" do new_pw = 'greeblesnarf' expect { - patch :update, params: { id: user.id, + patch :update, params: { + id: user.id, user: { password: new_pw }, - year: user.year } + year: user.year + } }.to change { user.reload.encrypted_password } end