diff --git a/app/models/registration.rb b/app/models/registration.rb index 9c920c34..443fe2d7 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -174,7 +174,7 @@ def update_payment_lane(id, iso_amount, currency_iso, status) # Dynamoid doesn't have a find_or_create_by so we need to use upsert # There are no validations to run anyway def update_waiting_list(update_params) - raise ArgumentError, 'Can only accept waiting list leader' if waiting_list_position != 1 && update_params[:status] == 'accepted' + raise ArgumentError.new('Can only accept waiting list leader') if waiting_list_position != 1 && update_params[:status] == 'accepted' waiting_list = WaitingList.find(competition_id) waiting_list.add(self.user_id) if update_params[:status] == 'waiting_list' diff --git a/app/models/waiting_list.rb b/app/models/waiting_list.rb index a86cdb89..076b20c8 100644 --- a/app/models/waiting_list.rb +++ b/app/models/waiting_list.rb @@ -21,7 +21,7 @@ def add(user_id) end def move_to_position(user_id, new_position) - raise ArgumentError, 'Target position out of waiting list range' if new_position > entries.length || new_position < 1 + raise ArgumentError.new('Target position out of waiting list range') if new_position > entries.length || new_position < 1 old_index = entries.find_index(user_id) return if old_index == new_position-1 diff --git a/app/services/registration_checker.rb b/app/services/registration_checker.rb index 1b280bd1..09aaea5c 100644 --- a/app/services/registration_checker.rb +++ b/app/services/registration_checker.rb @@ -150,7 +150,7 @@ def validate_update_status! new_status == 'accepted' && Registration.accepted_competitors_count(@competition_info.competition_id) == @competition_info.competitor_limit # Organizers cant accept someone from the waiting list who isn't in the leading position - waiting_list = begin + begin WaitingList.find(@competition_info.id) rescue Dynamoid::Errors::RecordNotFound WaitingList.create(id: @competition_info.id, entries: []) diff --git a/spec/factories/waiting_list_factory.rb b/spec/factories/waiting_list_factory.rb index 70ded476..e50a58c2 100644 --- a/spec/factories/waiting_list_factory.rb +++ b/spec/factories/waiting_list_factory.rb @@ -4,7 +4,7 @@ FactoryBot.define do factory :waiting_list do - transient do + transient do populate { nil } end diff --git a/spec/services/registration_checker_spec.rb b/spec/services/registration_checker_spec.rb index 616a3202..ed6c7331 100644 --- a/spec/services/registration_checker_spec.rb +++ b/spec/services/registration_checker_spec.rb @@ -9,7 +9,7 @@ it "user cant change 'status' => #{old_status} to: #{new_status}" do registration = FactoryBot.create(:registration, registration_status: old_status) if old_status == 'waiting_list' - waiting_list = FactoryBot.create(:waiting_list, entries: [registration.user_id]) + FactoryBot.create(:waiting_list, entries: [registration.user_id]) end competition_info = CompetitionInfo.new(FactoryBot.build(:competition)) update_request = FactoryBot.build(:update_request, user_id: registration[:user_id], competing: { 'status' => new_status }) @@ -28,7 +28,7 @@ it "organizer can change 'status' => #{old_status} to: #{new_status} before close" do registration = FactoryBot.create(:registration, registration_status: old_status) if old_status == 'waiting_list' - waiting_list = FactoryBot.create(:waiting_list, entries: [registration.user_id]) + FactoryBot.create(:waiting_list, entries: [registration.user_id]) end competition_info = CompetitionInfo.new(FactoryBot.build(:competition)) update_request = FactoryBot.build(:update_request, :organizer_for_user, user_id: registration[:user_id], competing: { 'status' => new_status }) @@ -45,7 +45,7 @@ it "site admin can change 'status' => #{old_status} to: #{new_status} before close" do registration = FactoryBot.create(:registration, registration_status: old_status) if old_status == 'waiting_list' - waiting_list = FactoryBot.create(:waiting_list, entries: [registration.user_id]) + FactoryBot.create(:waiting_list, entries: [registration.user_id]) end competition_info = CompetitionInfo.new(FactoryBot.build(:competition)) update_request = FactoryBot.build(:update_request, :site_admin, user_id: registration[:user_id], competing: { 'status' => new_status }) @@ -62,7 +62,7 @@ it "after edit deadline/reg close, organizer can change 'status' => #{old_status} to: #{new_status}" do registration = FactoryBot.create(:registration, registration_status: old_status) if old_status == 'waiting_list' - waiting_list = FactoryBot.create(:waiting_list, entries: [registration.user_id]) + FactoryBot.create(:waiting_list, entries: [registration.user_id]) end competition_info = CompetitionInfo.new(FactoryBot.build(:competition, :closed)) update_request = FactoryBot.build(:update_request, :organizer_for_user, user_id: registration[:user_id], competing: { 'status' => new_status })