From efce9052f355828af0b8ec5b79afbd8518bde114 Mon Sep 17 00:00:00 2001 From: fumimowdan Date: Wed, 27 Sep 2023 14:57:45 +0100 Subject: [PATCH] Update code to used `Urn.next` * startup.sh * submitform service * factories --- app/services/submit_form.rb | 2 +- bin/app-startup.sh | 2 ++ spec/factories/applications.rb | 2 +- spec/services/submit_form_spec.rb | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/services/submit_form.rb b/app/services/submit_form.rb index 939f2756..23270446 100644 --- a/app/services/submit_form.rb +++ b/app/services/submit_form.rb @@ -88,7 +88,7 @@ def create_application date_of_entry: form.date_of_entry, start_date: form.start_date, subject: SubjectStep.new(form).answer.formatted_value, - urn: Urn.generate(form.application_route), + urn: Urn.next(form.application_route), visa_type: form.visa_type, ) end diff --git a/bin/app-startup.sh b/bin/app-startup.sh index 0df4c416..9da89774 100755 --- a/bin/app-startup.sh +++ b/bin/app-startup.sh @@ -7,6 +7,8 @@ set -e # run migrations bundle exec rails db:migrate +# Front load urn generation +bundle exec rake urn:generate # add seed data in review environment if [[ "$RAILS_ENV" = "review" || "$RAILS_ENV" = "development" ]]; then diff --git a/spec/factories/applications.rb b/spec/factories/applications.rb index 49d86172..712bf90b 100644 --- a/spec/factories/applications.rb +++ b/spec/factories/applications.rb @@ -31,7 +31,7 @@ visa_type { VisaStep::VALID_ANSWERS_OPTIONS.reject { _1 == "Other" }.sample } date_of_entry { Time.zone.today } start_date { 1.month.from_now.to_date } - urn { Urn.generate(application_route) } + urn { Urn.next(application_route) } factory :teacher_application do application_route { "teacher" } diff --git a/spec/services/submit_form_spec.rb b/spec/services/submit_form_spec.rb index 3c110afe..022582e0 100644 --- a/spec/services/submit_form_spec.rb +++ b/spec/services/submit_form_spec.rb @@ -133,7 +133,7 @@ context "applicant email" do before do - allow(Urn).to receive(:generate).and_return(urn) + allow(Urn).to receive(:next).and_return(urn) end let(:urn) { "SOMEURN" }