From 9aba4de8c15407bfedd720a9c604c926e16d18b4 Mon Sep 17 00:00:00 2001 From: Lubos Hricak Date: Fri, 21 Jun 2024 17:41:53 +0200 Subject: [PATCH] Add `nickname` to factories to fix specs --- .../steps/application_form_creation_steps.rb | 1 + spec/controllers/form_controller_spec.rb | 20 ++++++++++++++++--- spec/factories/form_answer_factory.rb | 2 ++ .../eligibility_form_fulfillment_spec.rb | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/spec/acceptance/steps/application_form_creation_steps.rb b/spec/acceptance/steps/application_form_creation_steps.rb index 64fb942a1..34ac258de 100644 --- a/spec/acceptance/steps/application_form_creation_steps.rb +++ b/spec/acceptance/steps/application_form_creation_steps.rb @@ -31,6 +31,7 @@ step "I create innovation form" do step "I go to dashboard" click_link "New application", href: "/apply_innovation_award" + fill_in "nickname", with: "Innovation" click_button "Save and start eligibility questionnaire" click_link "Continue to eligibility questions" click_button "Continue" # eligibility step diff --git a/spec/controllers/form_controller_spec.rb b/spec/controllers/form_controller_spec.rb index d0e0d6d3f..809fb8bba 100644 --- a/spec/controllers/form_controller_spec.rb +++ b/spec/controllers/form_controller_spec.rb @@ -51,7 +51,21 @@ describe "#new_social_mobility_form" do it "allows to open mobility form" do - expect(get(:new_social_mobility_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) + expect(get(:new_social_mobility_form, params: {nickname: "Promoting Opportunity"})).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) + end + + it "does not allow to create an application without nickname/reference field filled" do + expect { get(:new_social_mobility_form, params: {nickname: ""}) }.to raise_error(ActiveRecord::RecordInvalid) + end + end + + describe "#new_innovation_form" do + it "allows to open innovation form" do + expect(get(:new_innovation_form, params: {nickname: "Innovation"})).to redirect_to(edit_form_url(FormAnswer.where(award_type: "innovation").last)) + end + + it "does not allow to create an application without nickname/reference field filled" do + expect { get(:new_innovation_form, params: {nickname: ""}) }.to raise_error(ActiveRecord::RecordInvalid) end end @@ -69,7 +83,7 @@ describe "#new_social_mobility_form" do it "allows to create an application if mobility deadline has past" do - expect(get(:new_social_mobility_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) + expect(get(:new_social_mobility_form, params: {nickname: "Promoting Opportunity"})).to redirect_to(edit_form_url(FormAnswer.where(award_type: "mobility").last)) end it "does not allow to create an application if mobility start deadline has not past" do @@ -91,7 +105,7 @@ describe "#new_innovation_form" do it "allows to create an application if innovation start deadline has past" do - expect(get(:new_innovation_form)).to redirect_to(edit_form_url(FormAnswer.where(award_type: "innovation").last)) + expect(get(:new_innovation_form, params: {nickname: "Innovation"})).to redirect_to(edit_form_url(FormAnswer.where(award_type: "innovation").last)) end it "does not allow to create an application if innovation start deadline has not past" do diff --git a/spec/factories/form_answer_factory.rb b/spec/factories/form_answer_factory.rb index a22ee15b4..67e6a3bee 100644 --- a/spec/factories/form_answer_factory.rb +++ b/spec/factories/form_answer_factory.rb @@ -51,6 +51,7 @@ trait :innovation do award_type { "innovation" } + nickname { "Innovation" } document do FormAnswer::DocumentParser.parse_json_document( JSON.parse( @@ -73,6 +74,7 @@ trait :mobility do award_type { "mobility" } + nickname { "Promoting Opportunity" } document do FormAnswer::DocumentParser.parse_json_document( JSON.parse( diff --git a/spec/features/users/eligibility_form_fulfillment_spec.rb b/spec/features/users/eligibility_form_fulfillment_spec.rb index bcf88db95..0360c7b7f 100644 --- a/spec/features/users/eligibility_form_fulfillment_spec.rb +++ b/spec/features/users/eligibility_form_fulfillment_spec.rb @@ -43,7 +43,7 @@ it "process the eligibility form" do visit dashboard_path new_application("Innovation Award") - # fill_in("nickname", with: "innovation nick") + fill_in("nickname", with: "innovation nick") click_button("Save and start eligibility questionnaire") click_link("Continue to eligibility questions") form_choice(["Yes", "Yes", /Business/, /Product/, "Yes", "No", "Yes", "Yes", "Yes", "Yes"])