Once your site is live, you should allow time for testing before driving traffic to it. We advise leaving 1-2 days for no-cost campaigns, and at least a week for paid advertising campaigns. @@ -92,9 +106,24 @@ Proposed end date of campaign site* <% end %>
- - <%= r.text_field :end_date, required: true, aria: { required: true }, placeholder: "dd-mm-yyyy", value: r.object.end_date, class: "input-md-2 form-control", data: { module: "calendar", format: "dd-mm-yy", min_date: 0 } %> + +We expect the website to go live within 1 month of approval diff --git a/spec/features/campaign_requests_spec.rb b/spec/features/campaign_requests_spec.rb index 8091e4ebb..1854e46b8 100644 --- a/spec/features/campaign_requests_spec.rb +++ b/spec/features/campaign_requests_spec.rb @@ -92,9 +92,15 @@ accessibility_confirmation: true, cookie_and_privacy_notice_confirmation: true, signed_campaign: "John Smith", - start_date: "01-01-#{next_year}", - end_date: "01-02-#{next_year}", - development_start_date: "31-12-2019", + start_day: "01", + start_month: "01", + start_year: next_year.to_s, + end_day: "01", + end_month: "02", + end_year: next_year.to_s, + development_start_day: "31", + development_start_month: "12", + development_start_year: "2019", performance_review_contact_email: "john.smith@example.com", government_theme: "Example government theme", description: "Pensions", @@ -129,9 +135,15 @@ def user_makes_a_campaign_request(details) check "I/We agree to take responsibility to maintain and up-date the Cookie Notice and Privacy Notice as necessary, with our Data Protection Officer (NB : GDS will add a basic \"boilerplate\", however departments will need to identify if additions are needed)." if details[:cookie_and_privacy_notice_confirmation] fill_in "Name of the Head of Digital Communications who signed off the campaign website application*", with: details[:signed_campaign] - fill_in "Start date of campaign site*", with: details[:start_date] - fill_in "Proposed end date of campaign site*", with: details[:end_date] - fill_in "Site build to commence on", with: details[:development_start_date] + find("#start-day").set(details[:start_day]) + find("#start-month").set(details[:start_month]) + find("#start-year").set(details[:start_year]) + find("#end-day").set(details[:end_day]) + find("#end-month").set(details[:end_month]) + find("#end-year").set(details[:end_year]) + find("#development-start-day").set(details[:development_start_day]) + find("#development-start-month").set(details[:development_start_month]) + find("#development-start-year").set(details[:development_start_year]) fill_in "Contact email/s for website performance review every 6 months*", with: details[:performance_review_contact_email] fill_in "Which of the current Government Communications Plan priority themes does this campaign website support and how?*", with: details[:government_theme] fill_in "Campaign description*", with: details[:description] diff --git a/spec/models/support/gds/campaign_spec.rb b/spec/models/support/gds/campaign_spec.rb index 526eb3e80..8de96e875 100644 --- a/spec/models/support/gds/campaign_spec.rb +++ b/spec/models/support/gds/campaign_spec.rb @@ -7,34 +7,52 @@ def as_str(date) date.strftime("%d-%m-%Y") end - subject do - Campaign.new( + let(:required_attr) do + { signed_campaign: "Test Signer", has_read_guidance_confirmation: "Yes", has_read_oasis_guidance_confirmation: "Yes", full_responsibility_confirmation: "Yes", accessibility_confirmation: "Yes", cookie_and_privacy_notice_confirmation: "Yes", - start_date: as_str(Time.zone.today), - end_date: as_str(Date.tomorrow), - development_start_date: as_str(Time.zone.today), + start_day: Time.zone.today.strftime("%d"), + start_month: Time.zone.today.strftime("%m"), + start_year: Time.zone.today.strftime("%Y"), + end_day: Time.zone.tomorrow.strftime("%d"), + end_month: Time.zone.tomorrow.strftime("%m"), + end_year: Time.zone.tomorrow.strftime("%Y"), + development_start_day: Time.zone.today.strftime("%d"), + development_start_month: Time.zone.today.strftime("%m"), + development_start_year: Time.zone.today.strftime("%Y"), performance_review_contact_email: "test@digital.cabinet-office.gov.uk", government_theme: "Test theme", description: "Test Description", call_to_action: "Test Call to Action", proposed_url: "example.campaign.gov.uk", + site_title: "Some title", + site_tagline: "Some tagline", site_metadescription: "tag1, tag2", cost_of_campaign: 1200, hmg_code: "HMGXX-XXX", strategic_planning_code: "CSBXX-XXX", ga_contact_email: "ga_test@digital.cabinet-office.gov.uk", - ) + } + end + + subject do + Campaign.new(required_attr) end it { should validate_presence_of(:signed_campaign) } - it { should validate_presence_of(:start_date) } - it { should validate_presence_of(:end_date) } - it { should validate_presence_of(:development_start_date) } + it { should validate_presence_of(:start_day) } + it { should validate_presence_of(:start_month) } + it { should validate_presence_of(:start_year) } + it { should validate_presence_of(:end_day) } + it { should validate_presence_of(:end_month) } + it { should validate_presence_of(:end_year) } + it { should validate_presence_of(:development_start_day) } + it { should validate_presence_of(:development_start_month) } + it { should validate_presence_of(:development_start_year) } it { should validate_presence_of(:performance_review_contact_email) } it { should validate_presence_of(:government_theme) } it { should validate_presence_of(:description) } @@ -58,9 +76,32 @@ def as_str(date) it { should allow_value("example.campaign.gov.uk").for(:proposed_url) } it { should_not allow_value("Non Campaign platform").for(:proposed_url) } - it { should_not allow_value("xxx").for(:start_date) } - it { should_not allow_value("xxx").for(:end_date) } - it { should_not allow_value("xxx").for(:development_start_date) } + it "should not allow 'start date' values to be random characters " do + constraint = Campaign.new( + start_day: "xxx", + start_month: "xxx", + start_year: "xxx", + ) + expect(constraint).to_not be_valid + end + + it "should not allow 'end date' values to be random characters " do + constraint = Campaign.new( + end_day: "xxx", + end_month: "xxx", + end_year: "xxx", + ) + expect(constraint).to_not be_valid + end + + it "should not allow 'development start date' values to be random characters " do + constraint = Campaign.new( + development_start_day: "xxx", + development_start_month: "xxx", + development_start_year: "xxx", + ) + expect(constraint).to_not be_valid + end it { should allow_value("test@digital.cabinet-office.gov.uk").for(:performance_review_contact_email) } it { should allow_value("test@test.com").for(:performance_review_contact_email) } @@ -70,16 +111,77 @@ def as_str(date) it { should_not allow_value("test").for(:performance_review_contact_email) } it { should_not allow_value("test@").for(:performance_review_contact_email) } - it { should allow_value(as_str(Date.tomorrow)).for(:start_date) } - it { should allow_value(as_str(Time.zone.today)).for(:start_date) } - it { should_not allow_value(as_str(Time.zone.today - 1)).for(:start_date) } + it "allows the start date to be after today" do + required_attr[:start_day] = Time.zone.tomorrow.strftime("%d") + required_attr[:start_month] = Time.zone.tomorrow.strftime("%m") + required_attr[:start_year] = Time.zone.tomorrow.strftime("%Y") + + required_attr[:end_day] = (Time.zone.tomorrow + 1).strftime("%d") + required_attr[:end_month] = (Time.zone.tomorrow + 1).strftime("%m") + required_attr[:end_year] = (Time.zone.tomorrow + 1).strftime("%Y") + + constraint = Campaign.new(required_attr) + expect(constraint).to be_valid + end + + it "allows the start date to be today" do + constraint = Campaign.new(required_attr) + expect(constraint).to be_valid + end + + it "doesn't allow the start date to in the past" do + required_attr[:start_day] = Time.zone.yesterday.strftime("%d") + required_attr[:start_month] = Time.zone.yesterday.strftime("%m") + required_attr[:start_year] = Time.zone.yesterday.strftime("%Y") + + constraint = Campaign.new(required_attr) + expect(constraint).to_not be_valid + end + + it "allows the end date to be after the start day" do + required_attr[:end_day] = Time.zone.tomorrow.strftime("%d") + required_attr[:end_month] = Time.zone.tomorrow.strftime("%m") + required_attr[:end_year] = Time.zone.tomorrow.strftime("%Y") - it { should allow_value(as_str(Date.tomorrow)).for(:end_date) } - it { should_not(allow_value(as_str(Time.zone.today)).for(:end_date)) } + constraint = Campaign.new(required_attr) + expect(constraint).to be_valid + end + + it "should not allow the end date to be before the start date" do + required_attr[:end_day] = Time.zone.today.strftime("%d") + required_attr[:end_month] = Time.zone.today.strftime("%m") + required_attr[:end_year] = Time.zone.today.strftime("%Y") + + constraint = Campaign.new(required_attr) + expect(constraint).to_not be_valid + end - it { should_not allow_value(as_str(Date.tomorrow)).for(:development_start_date) } - it { should allow_value(as_str(Time.zone.today - 1)).for(:development_start_date) } - it { should allow_value(as_str(Time.zone.today)).for(:development_start_date) } + it "should not allow the development start date to be after start date" do + required_attr[:development_start_day] = Time.zone.tomorrow.strftime("%d") + required_attr[:development_start_month] = Time.zone.tomorrow.strftime("%m") + required_attr[:development_start_year] = Time.zone.tomorrow.strftime("%Y") + + constraint = Campaign.new(required_attr) + expect(constraint).to_not be_valid + end + + it "should allow the development start date to be before the start date" do + required_attr[:development_start_day] = Time.zone.yesterday.strftime("%d") + required_attr[:development_start_month] = Time.zone.yesterday.strftime("%m") + required_attr[:development_start_year] = Time.zone.yesterday.strftime("%Y") + + constraint = Campaign.new(required_attr) + expect(constraint).to be_valid + end + + it "should allow the development start date to be on the start date" do + required_attr[:development_start_day] = Time.zone.today.strftime("%d") + required_attr[:development_start_month] = Time.zone.today.strftime("%m") + required_attr[:development_start_year] = Time.zone.today.strftime("%Y") + + constraint = Campaign.new(required_attr) + expect(constraint).to be_valid + end it { should allow_value("test@digital.cabinet-office.gov.uk").for(:ga_contact_email) } it { should allow_value("test@test.com").for(:ga_contact_email) }