Browse Source

test: mock new locations layout feature toggle in tests

pull/987/head
Sam Seed 4 years ago
parent
commit
3f756365e7
  1. 29
      spec/features/schemes_spec.rb
  2. 52
      spec/requests/locations_controller_spec.rb

29
spec/features/schemes_spec.rb

@ -195,7 +195,7 @@ RSpec.describe "Schemes scheme Features" do
expect(page).to have_link("Locations")
end
context "when I click locations link" do
context "when I click locations link and the new locations layout feature toggle is enabled" do
before do
click_link("Locations")
end
@ -204,14 +204,25 @@ RSpec.describe "Schemes scheme Features" do
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
if FeatureToggle.new_locations_table_layout_enabled?
expect(page).to have_content(location.name)
expect(page).to have_content("Active")
else
expect(page).to have_content(location.units)
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end
expect(page).to have_content(location.name)
expect(page).to have_content("Active")
end
end
end
context "when I click locations link and the new locations layout feature toggle is disabled" do
before do
allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
click_link("Locations")
end
it "shows details of those locations" do
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.units)
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end
end
end

52
spec/requests/locations_controller_spec.rb

@ -867,19 +867,25 @@ RSpec.describe LocationsController, type: :request do
end
end
it "shows locations with correct data" do
it "shows locations with correct data wben the new locations layout feature toggle is enabled" do
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
if FeatureToggle.new_locations_table_layout_enabled?
expect(page).to have_content(location.name)
expect(page).to have_content(location.status)
else
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type)
expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end
expect(page).to have_content(location.name)
expect(page).to have_content(location.status)
end
end
it "shows locations with correct data wben the new locations layout feature toggle is disabled" do
allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
get "/schemes/#{scheme.id}/locations"
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type)
expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end
end
@ -977,19 +983,25 @@ RSpec.describe LocationsController, type: :request do
get "/schemes/#{scheme.id}/locations"
end
it "shows locations with correct data" do
it "shows locations with correct data wben the new locations layout feature toggle is enabled" do
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
if FeatureToggle.new_locations_table_layout_enabled?
expect(page).to have_content(location.name)
expect(page).to have_content(location.status)
else
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type)
expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end
expect(page).to have_content(location.name)
expect(page).to have_content(location.status)
end
end
it "shows locations with correct data wben the new locations layout feature toggle is disabled" do
allow(FeatureToggle).to receive(:new_locations_table_layout_enabled?).and_return(false)
get "/schemes/#{scheme.id}/locations"
locations.each do |location|
expect(page).to have_content(location.id)
expect(page).to have_content(location.postcode)
expect(page).to have_content(location.type_of_unit)
expect(page).to have_content(location.mobility_type)
expect(page).to have_content(location.location_admin_district)
expect(page).to have_content(location.startdate&.to_formatted_s(:govuk_date))
end
end

Loading…
Cancel
Save