Skip to content

Commit

Permalink
Add nickname to factories to fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubosky committed Jun 24, 2024
1 parent c2048c6 commit 9aba4de
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions spec/acceptance/steps/application_form_creation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions spec/controllers/form_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check failure on line 54 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 54 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
end

Check failure on line 56 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/TrailingWhitespace: Trailing whitespace detected.
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)

Check failure on line 58 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 58 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
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))

Check failure on line 64 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 64 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
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)

Check failure on line 68 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 68 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
end
end

Expand All @@ -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))

Check failure on line 86 in spec/controllers/form_controller_spec.rb

View workflow job for this annotation

GitHub Actions / lint

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
end

it "does not allow to create an application if mobility start deadline has not past" do
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/factories/form_answer_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

trait :innovation do
award_type { "innovation" }
nickname { "Innovation" }
document do
FormAnswer::DocumentParser.parse_json_document(
JSON.parse(
Expand All @@ -73,6 +74,7 @@

trait :mobility do
award_type { "mobility" }
nickname { "Promoting Opportunity" }
document do
FormAnswer::DocumentParser.parse_json_document(
JSON.parse(
Expand Down
2 changes: 1 addition & 1 deletion spec/features/users/eligibility_form_fulfillment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit 9aba4de

Please sign in to comment.