From ff4c78ebcf74ff1cb3a62b65e88e2ebce9ac7915 Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Thu, 31 Oct 2024 17:23:21 +0900 Subject: [PATCH 1/5] Hotfix: Results legacy schema whoopsie --- lib/check_regional_records.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/check_regional_records.rb b/lib/check_regional_records.rb index 3e440e5a75..d54ba0f70e 100644 --- a/lib/check_regional_records.rb +++ b/lib/check_regional_records.rb @@ -11,7 +11,7 @@ def self.add_to_lookup_table(competition_id = nil, table_name: LOOKUP_TABLE_NAME SELECT Results.id, Results.countryId, Results.eventId, Competitions.end_date, Results.best, Results.average FROM Results INNER JOIN Competitions ON Results.competitionId = Competitions.id - #{competition_id.present? ? "WHERE Results.competition_id = #{competition_id}" : ''} + #{competition_id.present? ? "WHERE Results.competitionId = #{competition_id}" : ''} ON DUPLICATE KEY UPDATE countryId = Results.countryId, eventId = Results.eventId, From 837a2e08b7c95d23853dc08371ce4543c9d6452e Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Thu, 31 Oct 2024 18:35:29 +0900 Subject: [PATCH 2/5] Hotfix: Properly quote string ID value in CRR --- lib/check_regional_records.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/check_regional_records.rb b/lib/check_regional_records.rb index d54ba0f70e..4be320aea4 100644 --- a/lib/check_regional_records.rb +++ b/lib/check_regional_records.rb @@ -11,7 +11,7 @@ def self.add_to_lookup_table(competition_id = nil, table_name: LOOKUP_TABLE_NAME SELECT Results.id, Results.countryId, Results.eventId, Competitions.end_date, Results.best, Results.average FROM Results INNER JOIN Competitions ON Results.competitionId = Competitions.id - #{competition_id.present? ? "WHERE Results.competitionId = #{competition_id}" : ''} + #{competition_id.present? ? "WHERE Results.competitionId = '#{competition_id}'" : ''} ON DUPLICATE KEY UPDATE countryId = Results.countryId, eventId = Results.eventId, From 95df812dbb9731a33305684808eee83ba97ce4bd Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Thu, 31 Oct 2024 20:25:09 +0900 Subject: [PATCH 3/5] Switch to sidekiq-cron version 2 RC (#10163) --- Gemfile | 2 +- Gemfile.lock | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index e8b4386539..9401dfe3c8 100644 --- a/Gemfile +++ b/Gemfile @@ -102,7 +102,7 @@ gem 'react-rails' gem 'sprockets-rails' gem 'fuzzy-string-match' gem 'sidekiq' -gem 'sidekiq-cron' +gem 'sidekiq-cron', github: 'sidekiq-cron' gem 'after_commit_everywhere' gem 'slack-ruby-client' gem 'puma' diff --git a/Gemfile.lock b/Gemfile.lock index 97e0bfb4e6..5a3fb8a031 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,6 +11,16 @@ GIT specs: selectize-rails (0.12.1) +GIT + remote: https://github.com/sidekiq-cron/sidekiq-cron.git + revision: f0ac4038da7b3c6bc09b2c3ca9f0b9979848a95a + specs: + sidekiq-cron (2.0.0.rc2) + cronex (>= 0.13.0) + fugit (~> 1.8, >= 1.11.1) + globalid (>= 1.0.1) + sidekiq (>= 6.5.0) + GIT remote: https://github.com/thewca/i18n-country-translations.git revision: e6706abe0eaa65729c1acb698be08b91dd2b6fde @@ -221,6 +231,9 @@ GEM bigdecimal rexml crass (1.0.6) + cronex (0.15.0) + tzinfo + unicode (>= 0.4.4.5) css_parser (1.16.0) addressable csv (3.3.0) @@ -696,10 +709,6 @@ GEM logger rack (>= 2.2.4) redis-client (>= 0.22.2) - sidekiq-cron (1.12.0) - fugit (~> 1.8) - globalid (>= 1.0.1) - sidekiq (>= 6) signet (0.19.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a) @@ -762,6 +771,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.9.1) + unicode (0.4.4.5) unicode-display_width (2.6.0) uniform_notifier (1.16.0) uri (0.13.1) @@ -902,7 +912,7 @@ DEPENDENCIES selectize-rails! shakapacker (= 8.0.2) sidekiq - sidekiq-cron + sidekiq-cron! simple_form simplecov simplecov-lcov From 3ca0c3c96e70f71e1c3fa23e953e1951cf501cf7 Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Thu, 31 Oct 2024 21:46:40 +0900 Subject: [PATCH 4/5] Make crr lookup foreign key cascade on delete (#10164) --- db/migrate/20241031120315_crr_foreign_key_cascade.rb | 8 ++++++++ db/schema.rb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20241031120315_crr_foreign_key_cascade.rb diff --git a/db/migrate/20241031120315_crr_foreign_key_cascade.rb b/db/migrate/20241031120315_crr_foreign_key_cascade.rb new file mode 100644 index 0000000000..269974576b --- /dev/null +++ b/db/migrate/20241031120315_crr_foreign_key_cascade.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class CrrForeignKeyCascade < ActiveRecord::Migration[7.2] + def change + remove_foreign_key :regional_records_lookup, :Results + add_foreign_key :regional_records_lookup, :Results, column: :resultId, on_update: :cascade, on_delete: :cascade + end +end diff --git a/db/schema.rb b/db/schema.rb index bb139e5dd6..398967cd13 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2024_10_25_161404) do +ActiveRecord::Schema[7.2].define(version: 2024_10_31_120315) do create_table "Competitions", id: { type: :string, limit: 32, default: "" }, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "name", limit: 50, default: "", null: false t.string "cityName", limit: 50, default: "", null: false @@ -1350,7 +1350,7 @@ add_foreign_key "oauth_openid_requests", "oauth_access_grants", column: "access_grant_id", on_delete: :cascade add_foreign_key "payment_intents", "users", column: "initiated_by_id" add_foreign_key "paypal_records", "paypal_records", column: "parent_record_id" - add_foreign_key "regional_records_lookup", "Results", column: "resultId" + add_foreign_key "regional_records_lookup", "Results", column: "resultId", on_update: :cascade, on_delete: :cascade add_foreign_key "registration_history_changes", "registration_history_entries" add_foreign_key "sanity_check_exclusions", "sanity_checks" add_foreign_key "sanity_checks", "sanity_check_categories" From f79c151998608360b9e18f6336e10ac5d7ce575c Mon Sep 17 00:00:00 2001 From: Duncan <52967253+dunkOnIT@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:15:50 +0200 Subject: [PATCH 5/5] v3 nits: Competition argument in validate_update and event_ids.nil check (#10161) * moved event_ids present check * event changes and bulk update changes * removed competition id from requests in bulk update * rubocop * fixing request tests --- .../registrations/registrations_controller.rb | 9 +- app/models/competition.rb | 2 +- lib/registrations/lanes/competing.rb | 5 +- lib/registrations/registration_checker.rb | 13 +- .../factories/registration_request_factory.rb | 4 +- .../registration_checker_spec.rb | 160 +++++++++--------- 6 files changed, 98 insertions(+), 95 deletions(-) diff --git a/app/controllers/api/v1/registrations/registrations_controller.rb b/app/controllers/api/v1/registrations/registrations_controller.rb index a384080a56..c122cce281 100644 --- a/app/controllers/api/v1/registrations/registrations_controller.rb +++ b/app/controllers/api/v1/registrations/registrations_controller.rb @@ -60,21 +60,24 @@ def validate_create_request def update if params[:competing] - updated_registration = Registrations::Lanes::Competing.update!(params, @current_user.id) + updated_registration = Registrations::Lanes::Competing.update!(params, @competition, @current_user.id) return render json: { status: 'ok', registration: updated_registration.to_v2_json(admin: true, history: true) }, status: :ok end render json: { status: 'bad request', message: 'You need to supply at least one lane' }, status: :bad_request end def validate_update_request - Registrations::RegistrationChecker.update_registration_allowed!(params, @current_user) + @competition = Competition.find(params[:competition_id]) + Registrations::RegistrationChecker.update_registration_allowed!(params, @competition, @current_user) end def bulk_update updated_registrations = {} update_requests = params[:requests] + competition = Competition.find(params[:competition_id]) + update_requests.each do |update| - updated_registrations[update['user_id']] = Registrations::Lanes::Competing.update!(update, @current_user) + updated_registrations[update['user_id']] = Registrations::Lanes::Competing.update!(update, competition, @current_user) end render json: { status: 'ok', updated_registrations: updated_registrations } diff --git a/app/models/competition.rb b/app/models/competition.rb index 9dae077e2d..8276f23852 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -400,7 +400,7 @@ def main_event end def events_held?(desired_event_ids) - desired_event_ids.present? && (desired_event_ids & self.event_ids) == desired_event_ids + (desired_event_ids & self.event_ids) == desired_event_ids end def enforces_qualifications? diff --git a/lib/registrations/lanes/competing.rb b/lib/registrations/lanes/competing.rb index 68670d2edc..7f08bc46c7 100644 --- a/lib/registrations/lanes/competing.rb +++ b/lib/registrations/lanes/competing.rb @@ -19,7 +19,7 @@ def self.process!(lane_params, user_id, competition_id) registration.add_history_entry(changes, "worker", user_id, "Worker processed") end - def self.update!(update_params, current_user_id) + def self.update!(update_params, competition, current_user_id) guests = update_params[:guests] status = update_params.dig('competing', 'status') comment = update_params.dig('competing', 'comment') @@ -27,9 +27,8 @@ def self.update!(update_params, current_user_id) admin_comment = update_params.dig('competing', 'admin_comment') waiting_list_position = update_params.dig('competing', 'waiting_list_position') user_id = update_params[:user_id] - competition_id = update_params[:competition_id] - registration = Registration.find_by(competition_id: competition_id, user_id: user_id) + registration = Registration.find_by(competition_id: competition.id, user_id: user_id) old_status = registration.competing_status if old_status == Registrations::Helper::STATUS_WAITING_LIST || status == Registrations::Helper::STATUS_WAITING_LIST diff --git a/lib/registrations/registration_checker.rb b/lib/registrations/registration_checker.rb index 7e8d22f508..d36dddab8c 100644 --- a/lib/registrations/registration_checker.rb +++ b/lib/registrations/registration_checker.rb @@ -15,12 +15,11 @@ def self.create_registration_allowed!(registration_request, current_user) validate_comment!(registration_request.dig('competing', 'comment'), competition) end - def self.update_registration_allowed!(update_request, current_user) - registration = Registration.find_by(competition_id: update_request['competition_id'], user_id: update_request['user_id']) + def self.update_registration_allowed!(update_request, competition, current_user) + registration = Registration.find_by(competition_id: competition.id, user_id: update_request['user_id']) raise WcaExceptions::RegistrationError.new(:not_found, Registrations::ErrorCodes::REGISTRATION_NOT_FOUND) unless registration.present? target_user = User.find(update_request['user_id']) - competition = Competition.find(update_request['competition_id']) waiting_list_position = update_request.dig('competing', 'waiting_list_position') comment = update_request.dig('competing', 'comment') guests = update_request['guests'] @@ -49,7 +48,7 @@ def self.bulk_update_allowed!(bulk_update_request, current_user) errors = {} bulk_update_request['requests'].each do |update_request| - update_registration_allowed!(update_request, current_user) + update_registration_allowed!(update_request, competition, current_user) rescue WcaExceptions::RegistrationError => e errors[update_request['user_id']] = e.error end @@ -98,7 +97,8 @@ def can_administer_or_current_user?(competition, current_user, target_user) def validate_create_events!(request, competition) event_ids = request['competing']['event_ids'] # Event submitted must be held at the competition - raise WcaExceptions::RegistrationError.new(:unprocessable_entity, Registrations::ErrorCodes::INVALID_EVENT_SELECTION) unless competition.events_held?(event_ids) + raise WcaExceptions::RegistrationError.new(:unprocessable_entity, Registrations::ErrorCodes::INVALID_EVENT_SELECTION) unless + event_ids.present? && competition.events_held?(event_ids) event_limit = competition.events_per_registration_limit raise WcaExceptions::RegistrationError.new(:forbidden, Registrations::ErrorCodes::INVALID_EVENT_SELECTION) if event_limit.present? && event_ids.count > event_limit @@ -197,7 +197,8 @@ def validate_update_status!(new_status, competition, current_user, target_user, end def validate_update_events!(event_ids, competition) - raise WcaExceptions::RegistrationError.new(:unprocessable_entity, Registrations::ErrorCodes::INVALID_EVENT_SELECTION) unless competition.events_held?(event_ids) + raise WcaExceptions::RegistrationError.new(:unprocessable_entity, Registrations::ErrorCodes::INVALID_EVENT_SELECTION) unless + event_ids.present? && competition.events_held?(event_ids) event_limit = competition.events_per_registration_limit raise WcaExceptions::RegistrationError.new(:forbidden, Registrations::ErrorCodes::INVALID_EVENT_SELECTION) if event_limit.present? && event_ids.count > event_limit diff --git a/spec/factories/registration_request_factory.rb b/spec/factories/registration_request_factory.rb index 34d8e84e40..007eb201db 100644 --- a/spec/factories/registration_request_factory.rb +++ b/spec/factories/registration_request_factory.rb @@ -71,7 +71,7 @@ submitted_by { other_user.id } end - initialize_with { attributes.stringify_keys } + initialize_with { attributes.compact.stringify_keys } after(:build) do |instance, evaluator| instance['guests'] = evaluator.guests if evaluator.guests @@ -90,7 +90,7 @@ requests do user_ids.map do |user_id| - FactoryBot.build(:update_request, user_id: user_id, competition_id: competition_id, competing: { 'status' => 'deleted' }) + FactoryBot.build(:update_request, user_id: user_id, competing: { 'status' => 'deleted' }) end end diff --git a/spec/lib/registrations/registration_checker_spec.rb b/spec/lib/registrations/registration_checker_spec.rb index cee9d0bcff..7dd51e168e 100644 --- a/spec/lib/registrations/registration_checker_spec.rb +++ b/spec/lib/registrations/registration_checker_spec.rb @@ -710,7 +710,7 @@ update_request = FactoryBot.build(:update_request, competition_id: default_competition.id, user_id: default_user.id) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::REGISTRATION_NOT_FOUND) expect(error.status).to eq(:not_found) @@ -725,7 +725,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -738,7 +738,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unauthorized) expect(error.error).to eq(Registrations::ErrorCodes::USER_INSUFFICIENT_PERMISSIONS) @@ -756,7 +756,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::USER_EDITS_NOT_ALLOWED) @@ -774,7 +774,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::USER_EDITS_NOT_ALLOWED) @@ -789,7 +789,7 @@ submitted_by: default_competition.organizers.first.id, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -806,7 +806,7 @@ submitted_by: edit_deadline_passed.organizers.first.id, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end end @@ -820,7 +820,7 @@ competing: { 'comment' => 'new comment' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -836,7 +836,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::USER_COMMENT_TOO_LONG) @@ -854,7 +854,7 @@ competing: { 'comment' => at_character_limit }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -866,7 +866,7 @@ competing: { 'comment' => '' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -882,7 +882,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::REQUIRED_COMMENT_MISSING) @@ -899,7 +899,7 @@ user_id: registration.user_id, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -917,7 +917,7 @@ competing: { 'status' => 'accepted' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -932,7 +932,7 @@ competing: { 'comment' => 'heres a random different comment' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -949,7 +949,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::USER_COMMENT_TOO_LONG) @@ -968,7 +968,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::USER_EDITS_NOT_ALLOWED) @@ -986,7 +986,7 @@ competing: { 'organizer_comment' => 'this is an admin comment' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1003,7 +1003,7 @@ competing: { 'organizer_comment' => 'this is an admin comment' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1016,7 +1016,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unauthorized) expect(error.error).to eq(Registrations::ErrorCodes::USER_INSUFFICIENT_PERMISSIONS) @@ -1032,7 +1032,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unauthorized) expect(error.error).to eq(Registrations::ErrorCodes::USER_INSUFFICIENT_PERMISSIONS) @@ -1054,7 +1054,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::USER_COMMENT_TOO_LONG) @@ -1073,7 +1073,7 @@ competing: { 'organizer_comment' => at_character_limit }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end end @@ -1087,7 +1087,7 @@ guests: 4, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1103,7 +1103,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::GUEST_LIMIT_EXCEEDED) expect(error.status).to eq(:unprocessable_entity) @@ -1122,7 +1122,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -1137,7 +1137,7 @@ guests: 0, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1153,7 +1153,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_REQUEST_DATA) @@ -1168,7 +1168,7 @@ guests: 99, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1181,7 +1181,7 @@ guests: 5, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1197,7 +1197,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::USER_EDITS_NOT_ALLOWED) @@ -1216,7 +1216,7 @@ guests: 5, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end end @@ -1231,7 +1231,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_REQUEST_DATA) @@ -1248,7 +1248,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_REQUEST_DATA) @@ -1269,7 +1269,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::COMPETITOR_LIMIT_REACHED) expect(error.status).to eq(:forbidden) @@ -1289,7 +1289,7 @@ competing: { 'status' => 'accepted' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1301,7 +1301,7 @@ competing: { 'status' => 'deleted' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1314,7 +1314,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_REQUEST_DATA) @@ -1331,7 +1331,7 @@ competing: { 'status' => 'pending' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1349,7 +1349,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unauthorized) expect(error.error).to eq(Registrations::ErrorCodes::ORGANIZER_MUST_CANCEL_REGISTRATION) @@ -1369,7 +1369,7 @@ competing: { 'status' => 'deleted' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1387,7 +1387,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::USER_EDITS_NOT_ALLOWED) @@ -1408,7 +1408,7 @@ competing: { 'status' => 'deleted' }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1424,7 +1424,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unauthorized) expect(error.error).to eq(Registrations::ErrorCodes::USER_INSUFFICIENT_PERMISSIONS) @@ -1464,7 +1464,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unauthorized) expect(error.error).to eq(Registrations::ErrorCodes::REGISTRATION_IS_REJECTED) @@ -1493,7 +1493,7 @@ submitted_by: default_competition.organizers.first.id, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1509,7 +1509,7 @@ submitted_by: admin.id, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1525,7 +1525,7 @@ submitted_by: competition.organizers.first.id, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end end @@ -1572,7 +1572,7 @@ competing: { 'event_ids' => ['333', '444', '555', 'minx'] }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1584,7 +1584,7 @@ competing: { 'event_ids' => ['333'] }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1596,7 +1596,7 @@ competing: { 'event_ids' => ['pyram', 'minx'] }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1609,7 +1609,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_EVENT_SELECTION) @@ -1625,7 +1625,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_EVENT_SELECTION) @@ -1641,7 +1641,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_EVENT_SELECTION) @@ -1657,7 +1657,7 @@ competing: { 'event_ids' => ['333', '555'] }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1671,7 +1671,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_EVENT_SELECTION) @@ -1686,7 +1686,7 @@ competing: { 'event_ids' => ['333', '333oh', '555', 'pyram', 'minx'] }, ) - expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) } + expect { Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) } .not_to raise_error end @@ -1699,7 +1699,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_EVENT_SELECTION) @@ -1717,7 +1717,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_EVENT_SELECTION) @@ -1745,7 +1745,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_WAITING_LIST_POSITION) @@ -1764,7 +1764,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -1778,7 +1778,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:unprocessable_entity) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_WAITING_LIST_POSITION) @@ -1797,7 +1797,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_WAITING_LIST_POSITION) @@ -1816,7 +1816,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.status).to eq(:forbidden) expect(error.error).to eq(Registrations::ErrorCodes::INVALID_WAITING_LIST_POSITION) @@ -1870,7 +1870,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -1902,7 +1902,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -1915,7 +1915,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -1928,7 +1928,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end end @@ -1964,7 +1964,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end @@ -1977,7 +1977,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end end @@ -2019,7 +2019,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2036,7 +2036,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2053,7 +2053,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2085,7 +2085,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2106,7 +2106,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2127,7 +2127,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2148,7 +2148,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::QUALIFICATION_NOT_MET) expect(error.status).to eq(:unprocessable_entity) @@ -2184,7 +2184,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::ALREADY_REGISTERED_IN_SERIES) expect(error.status).to eq(:forbidden) @@ -2201,7 +2201,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.to raise_error(WcaExceptions::RegistrationError) do |error| expect(error.error).to eq(Registrations::ErrorCodes::ALREADY_REGISTERED_IN_SERIES) expect(error.status).to eq(:forbidden) @@ -2218,7 +2218,7 @@ ) expect { - Registrations::RegistrationChecker.update_registration_allowed!(update_request, User.find(update_request['submitted_by'])) + Registrations::RegistrationChecker.update_registration_allowed!(update_request, Competition.find(update_request['competition_id']), User.find(update_request['submitted_by'])) }.not_to raise_error end end