From 74466eab98fde6bce0839258e34c9e24da917ef3 Mon Sep 17 00:00:00 2001 From: Luke Bacon Date: Wed, 2 Aug 2017 13:45:33 +1000 Subject: [PATCH] Split integration spec file in two This creates a new file that covers the different options for contribution for providing their information to us. We split this out to make the original spec file more focused and easier to understand. This now means there isn't a single spec for working through the whole contribution process from beginning to end. But we think that's ok for now, because the contribution and the stage of providing details are quite separate. --- ..._can_provide_their_contact_details_spec.rb | 44 +++++++++++++++++++ .../user_contributes_new_councillor_spec.rb | 35 --------------- 2 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 spec/features/contributor_can_provide_their_contact_details_spec.rb diff --git a/spec/features/contributor_can_provide_their_contact_details_spec.rb b/spec/features/contributor_can_provide_their_contact_details_spec.rb new file mode 100644 index 000000000..bd9a84b4b --- /dev/null +++ b/spec/features/contributor_can_provide_their_contact_details_spec.rb @@ -0,0 +1,44 @@ +require "spec_helper" + +feature "Contributor can contribute their contact information" do + context "when the feature flag is off" do + it "isn't available" do + visit new_contributor_path + + expect(page.status_code).to eq 404 + end + end + + context "when the feature flag is on" do + around do |test| + with_modified_env CONTRIBUTE_COUNCILLORS_ENABLED: "true" do + test.run + end + end + + before :each do + CouncillorContribution.new(id: 1).save + end + + it "successfully" do + visit new_contributor_path(councillor_contribution_id: 1) + + within_fieldset "Please tell us about yourself, so we can send you a little note of appreciation and updates about your contribution when it goes live." do + fill_in "Name", with: "Jane Contributes" + fill_in "Email", with: "jane@contributor.com" + end + + click_button "Submit" + + expect(page).to have_content "Thank you" + end + + it "or not if they choose" do + visit new_contributor_path(councillor_contribution_id: 1) + + click_link "I prefer not to" + + expect(page).to have_content "Thank you" + end + end +end diff --git a/spec/features/user_contributes_new_councillor_spec.rb b/spec/features/user_contributes_new_councillor_spec.rb index 42ca1431a..f92182324 100644 --- a/spec/features/user_contributes_new_councillor_spec.rb +++ b/spec/features/user_contributes_new_councillor_spec.rb @@ -18,41 +18,6 @@ end end - it "after landing on the contribution page, works successfully when the contributor provides their information" do - visit new_authority_councillor_contribution_path(authority.short_name_encoded) - - within ".councillor-contribution-councillors fieldset" do - fill_in "Full name", with: "Mila Gilic" - fill_in "Email", with: "mgilic@casey.vic.gov.au" - end - - click_button "Submit 1 new councillor" - - within_fieldset "Please tell us about yourself, so we can send you a little note of appreciation and updates about your contribution when it goes live." do - fill_in "Name", with: "Jane Contributes" - fill_in "Email", with: "jane@contributor.com" - end - - click_button "Submit" - - expect(page).to have_content "Thank you" - end - - it "works successfully when the contributor does not provide their information" do - visit new_authority_councillor_contribution_path(authority.short_name_encoded) - - within ".councillor-contribution-councillors fieldset" do - fill_in "Full name", with: "Mila Gilic" - fill_in "Email", with: "mgilic@casey.vic.gov.au" - end - - click_button "Submit 1 new councillor" - - click_link "I prefer not to" - - expect(page).to have_content "Thank you" - end - it "successfully with three councillors and one blank councillor" do visit new_authority_councillor_contribution_path(authority.short_name_encoded)