Browse Source

CLDC-2863: add tests for when both feature toggles are on

pull/2022/head
Sam Seed 3 years ago
parent
commit
7d5158a70a
  1. 15
      spec/features/user_spec.rb
  2. 35
      spec/requests/content_controller_spec.rb
  3. 21
      spec/requests/cookies_controller_spec.rb
  4. 39
      spec/requests/maintenance_controller_spec.rb

15
spec/features/user_spec.rb

@ -151,6 +151,13 @@ RSpec.describe "User Features" do
visit("/lettings-logs")
expect(page).not_to have_link("Sign in")
end
it "does not show 'Sign in' link when both the service_moved? and service_unavailable? feature toggles are on" do
allow(FeatureToggle).to receive(:service_moved?).and_return(true)
allow(FeatureToggle).to receive(:service_unavailable?).and_return(true)
visit("/lettings-logs")
expect(page).not_to have_link("Sign in")
end
end
context "when the user is trying to log in with incorrect credentials" do
@ -350,6 +357,14 @@ RSpec.describe "User Features" do
expect(page).not_to have_link("Your account")
expect(page).not_to have_link("Sign out")
end
it "does not show 'Your account' or 'Sign out' links when both the service_moved? and service_unavailable? feature toggles are on" do
allow(FeatureToggle).to receive(:service_moved?).and_return(true)
allow(FeatureToggle).to receive(:service_unavailable?).and_return(true)
visit("/lettings-logs")
expect(page).not_to have_link("Your account")
expect(page).not_to have_link("Sign out")
end
end
context "when adding a new user" do

35
spec/requests/content_controller_spec.rb

@ -115,4 +115,39 @@ RSpec.describe ContentController, type: :request do
end
end
end
describe "when both the service_moved? and service_unavailable? feature toggles are on" do
before do
allow(FeatureToggle).to receive(:service_moved?).and_return(true)
allow(FeatureToggle).to receive(:service_unavailable?).and_return(true)
end
describe "render privacy notice content page" do
before do
get "/privacy-notice", headers:, params: {}
end
it "returns a 200" do
expect(response).to have_http_status(:success)
end
it "returns the page" do
expect(page).to have_title("Privacy notice")
end
end
describe "render accessibility statement content page" do
before do
get "/accessibility-statement", headers:, params: {}
end
it "returns a 200" do
expect(response).to have_http_status(:success)
end
it "returns the page" do
expect(page).to have_title("Accessibility statement")
end
end
end
end

21
spec/requests/cookies_controller_spec.rb

@ -59,4 +59,25 @@ RSpec.describe CookiesController, type: :request do
end
end
end
describe "when both the service_moved? and service_unavailable? feature toggles are on" do
before do
allow(FeatureToggle).to receive(:service_moved?).and_return(true)
allow(FeatureToggle).to receive(:service_unavailable?).and_return(true)
end
describe "render cookies page" do
before do
get "/cookies", headers:, params: {}
end
it "returns a 200" do
expect(response).to have_http_status(:success)
end
it "returns the page" do
expect(page).to have_title("Cookies")
end
end
end
end

39
spec/requests/maintenance_controller_spec.rb

@ -84,6 +84,45 @@ RSpec.describe MaintenanceController, type: :request do
end
end
describe "when both the service_moved? and service_unavailable? feature toggles are on" do
before do
allow(FeatureToggle).to receive(:service_moved?).and_return(true)
allow(FeatureToggle).to receive(:service_unavailable?).and_return(true)
end
context "when a user visits a page other than the service moved page" do
before do
get "/service-unavailable"
end
it "redirects the user to the service moved page" do
expect(response).to redirect_to(service_moved_path)
follow_redirect!
expect(page).to have_content("The URL for this service has changed.")
end
it "the cookie banner is visible" do
follow_redirect!
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.")
end
end
context "when a user visits the service moved page" do
before do
get "/service-moved"
end
it "keeps the user on the service moved page" do
expect(response).not_to redirect_to(service_moved_path)
expect(page).to have_content("The URL for this service has changed.")
end
it "the cookie banner is visible" do
expect(page).to have_content("We’d like to use analytics cookies so we can understand how you use the service and make improvements.")
end
end
end
describe "when the service is available" do
before do
allow(FeatureToggle).to receive(:service_unavailable?).and_return(false)

Loading…
Cancel
Save