Browse Source

Remove feature toggle for schemes and locations (#1700)

* remove scheme toggle

* remove location toggle

* minor linting complaint
pull/1705/head
Arthur Campbell 2 years ago committed by GitHub
parent
commit
c53f4a770b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      app/helpers/locations_helper.rb
  2. 5
      app/helpers/schemes_helper.rb
  3. 8
      app/services/feature_toggle.rb
  4. 68
      app/views/locations/index.html.erb
  5. 4
      app/views/locations/show.html.erb
  6. 20
      app/views/schemes/_scheme_list.html.erb
  7. 13
      app/views/schemes/show.html.erb
  8. 17
      spec/features/schemes_spec.rb
  9. 8
      spec/helpers/schemes_helper_spec.rb
  10. 26
      spec/requests/locations_controller_spec.rb

9
app/helpers/locations_helper.rb

@ -24,7 +24,7 @@ module LocationsHelper
end end
def display_location_attributes(location) def display_location_attributes(location)
base_attributes = [ [
{ name: "Postcode", value: location.postcode, attribute: "postcode" }, { name: "Postcode", value: location.postcode, attribute: "postcode" },
{ name: "Location name", value: location.name, attribute: "name" }, { name: "Location name", value: location.name, attribute: "name" },
{ name: "Local authority", value: formatted_local_authority_timeline(location, "name"), attribute: "local_authority" }, { name: "Local authority", value: formatted_local_authority_timeline(location, "name"), attribute: "local_authority" },
@ -33,13 +33,8 @@ module LocationsHelper
{ name: "Mobility standards", value: location.mobility_type, attribute: "mobility_standards" }, { name: "Mobility standards", value: location.mobility_type, attribute: "mobility_standards" },
{ name: "Location code", value: formatted_local_authority_timeline(location, "code"), attribute: "location_code" }, { name: "Location code", value: formatted_local_authority_timeline(location, "code"), attribute: "location_code" },
{ name: "Availability", value: location_availability(location), attribute: "availability" }, { name: "Availability", value: location_availability(location), attribute: "availability" },
{ name: "Status", value: location.status, attribute: "status" },
] ]
if FeatureToggle.location_toggle_enabled?
base_attributes.append({ name: "Status", value: location.status, attribute: "status" })
end
base_attributes
end end
def display_location_attributes_for_check_answers(location) def display_location_attributes_for_check_answers(location)

5
app/helpers/schemes_helper.rb

@ -14,12 +14,9 @@ module SchemesHelper
{ name: "Level of support given", value: scheme.support_type }, { name: "Level of support given", value: scheme.support_type },
{ name: "Intended length of stay", value: scheme.intended_stay }, { name: "Intended length of stay", value: scheme.intended_stay },
{ name: "Availability", value: scheme_availability(scheme) }, { name: "Availability", value: scheme_availability(scheme) },
{ name: "Status", value: status_tag(scheme.status) },
] ]
if FeatureToggle.scheme_toggle_enabled?
base_attributes.append({ name: "Status", value: status_tag(scheme.status) })
end
if user.data_coordinator? if user.data_coordinator?
base_attributes.delete_if { |item| item[:name] == "Housing stock owned by" } base_attributes.delete_if { |item| item[:name] == "Housing stock owned by" }
end end

8
app/services/feature_toggle.rb

@ -12,14 +12,6 @@ class FeatureToggle
Rails.env.production? || Rails.env.test? || Rails.env.staging? || Rails.env.review? Rails.env.production? || Rails.env.test? || Rails.env.staging? || Rails.env.review?
end end
def self.scheme_toggle_enabled?
true
end
def self.location_toggle_enabled?
true
end
def self.bulk_upload_duplicate_log_check_enabled? def self.bulk_upload_duplicate_log_check_enabled?
!Rails.env.staging? !Rails.env.staging?
end end

68
app/views/locations/index.html.erb

@ -10,10 +10,8 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% if FeatureToggle.location_toggle_enabled? %> <div class="govuk-grid-row">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop"> <div class="govuk-grid-column-two-thirds-from-desktop">
<% end %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<h2 class="govuk-visually-hidden">Locations</h2> <h2 class="govuk-visually-hidden">Locations</h2>
@ -21,13 +19,10 @@
<%= render SearchComponent.new(current_user:, search_label: "Search by location name or postcode", value: @searched) %> <%= render SearchComponent.new(current_user:, search_label: "Search by location name or postcode", value: @searched) %>
<%= govuk_section_break(visible: true, size: "m") %> <%= govuk_section_break(visible: true, size: "m") %>
<% if FeatureToggle.location_toggle_enabled? %>
</div>
</div> </div>
<% end %> </div>
<% if FeatureToggle.location_toggle_enabled? %> <div class="govuk-grid-row">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop"> <div class="govuk-grid-column-two-thirds-from-desktop">
<%= govuk_table do |table| %> <%= govuk_table do |table| %>
<%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
@ -69,61 +64,6 @@
<%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %> <%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %>
<% end %> <% end %>
</div> </div>
</div> </div>
<% else %>
<%= govuk_table do |table| %>
<%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<%= render(SearchResultCaptionComponent.new(searched: @searched, count: @pagy.count, item_label:, total_count: @total_count, item: "locations", path: request.path)) %>
<% end %>
<%= table.head do |head| %>
<%= head.row do |row| %>
<% row.cell(header: true, text: "Code", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Postcode", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Units", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Common unit type", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Mobility type", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Local authority", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Available from", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @locations.each do |location| %>
<%= table.body do |body| %>
<%= body.row do |row| %>
<% row.cell(text: location.id) %>
<% row.cell(text: simple_format(location_cell_postcode(location, if location.confirmed
scheme_location_path(@scheme, location)
else
location.postcode.present? ? scheme_location_check_answers_path(@scheme, location, route: "locations") : scheme_location_postcode_path(@scheme, location)
end), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.units) %>
<% row.cell do %>
<span><%= simple_format(location.type_of_unit) %></span>
<% end %>
<% row.cell(text: location.mobility_type) %>
<% row.cell(text: location.location_admin_district) %>
<% row.cell(text: location.startdate&.to_formatted_s(:govuk_date)) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% if user_can_edit_scheme?(current_user, @scheme) %>
<%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %>
<% end %>
<% end %>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %>

4
app/views/locations/show.html.erb

@ -25,8 +25,6 @@
</div> </div>
</div> </div>
<% if FeatureToggle.location_toggle_enabled? %> <% if LocationPolicy.new(current_user, @location).deactivate? %>
<% if LocationPolicy.new(current_user, @location).deactivate? %>
<%= toggle_location_link(@location) %> <%= toggle_location_link(@location) %>
<% end %>
<% end %> <% end %>

20
app/views/schemes/_scheme_list.html.erb

@ -5,20 +5,10 @@
<% end %> <% end %>
<%= table.head do |head| %> <%= table.head do |head| %>
<%= head.row do |row| %> <%= head.row do |row| %>
<% row.cell(header: true, text: "Scheme", html_attributes: { <% row.cell(header: true, text: "Scheme", html_attributes: { scope: "col" }) %>
scope: "col", <% row.cell(header: true, text: "Code", html_attributes: { scope: "col" }) %>
}) %> <% row.cell(header: true, text: "Locations", html_attributes: { scope: "col" }) %>
<% row.cell(header: true, text: "Code", html_attributes: { <% row.cell(header: true, text: "Status", html_attributes: { scope: "col" }) %>
scope: "col",
}) %>
<% row.cell(header: true, text: "Locations", html_attributes: {
scope: "col",
}) %>
<% if FeatureToggle.scheme_toggle_enabled? %>
<% row.cell(header: true, text: "Status", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% @schemes.each do |scheme| %> <% @schemes.each do |scheme| %>
@ -27,11 +17,9 @@
<% row.cell(text: simple_format(scheme_cell(scheme), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: simple_format(scheme_cell(scheme), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: scheme.id_to_display) %> <% row.cell(text: scheme.id_to_display) %>
<% row.cell(text: scheme.locations&.count) %> <% row.cell(text: scheme.locations&.count) %>
<% if FeatureToggle.scheme_toggle_enabled? %>
<% row.cell(text: status_tag(scheme.status)) %> <% row.cell(text: status_tag(scheme.status)) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %>
</section> </section>

13
app/views/schemes/show.html.erb

@ -9,10 +9,8 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% if FeatureToggle.location_toggle_enabled? %> <div class="govuk-grid-row">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop"> <div class="govuk-grid-column-two-thirds-from-desktop">
<% end %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<h2 class="govuk-visually-hidden">Scheme</h2> <h2 class="govuk-visually-hidden">Scheme</h2>
@ -28,14 +26,9 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% if FeatureToggle.location_toggle_enabled? %>
</div>
</div> </div>
<% end %> </div>
<% if FeatureToggle.scheme_toggle_enabled? %> <% if SchemePolicy.new(current_user, @scheme).deactivate? %>
<% if SchemePolicy.new(current_user, @scheme).deactivate? %>
<%= toggle_scheme_link(@scheme) %> <%= toggle_scheme_link(@scheme) %>
<% end %>
<% end %> <% end %>

17
spec/features/schemes_spec.rb

@ -211,23 +211,6 @@ RSpec.describe "Schemes scheme Features" do
end 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(:location_toggle_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
context "when I search for a specific location" do context "when I search for a specific location" do
before do before do
click_link("Locations") click_link("Locations")

8
spec/helpers/schemes_helper_spec.rb

@ -195,14 +195,6 @@ RSpec.describe SchemesHelper do
expect(display_scheme_attributes(scheme, coordinator_user)).to eq(attributes) expect(display_scheme_attributes(scheme, coordinator_user)).to eq(attributes)
end end
context "when the scheme toggle is disabled" do
it "doesn't show the scheme status" do
allow(FeatureToggle).to receive(:scheme_toggle_enabled?).and_return(false)
attributes = display_scheme_attributes(scheme, support_user).find { |x| x[:name] == "Status" }
expect(attributes).to be_nil
end
end
context "when the managing organisation is the owning organisation" do context "when the managing organisation is the owning organisation" do
it "doesn't show the organisation providing support" do it "doesn't show the organisation providing support" do
attributes = display_scheme_attributes(scheme_where_managing_organisation_is_owning_organisation, support_user).find { |x| x[:name] == "Organisation providing support" } attributes = display_scheme_attributes(scheme_where_managing_organisation_is_owning_organisation, support_user).find { |x| x[:name] == "Organisation providing support" }

26
spec/requests/locations_controller_spec.rb

@ -153,19 +153,6 @@ RSpec.describe LocationsController, type: :request do
end end
end end
it "shows locations with correct data when the new locations layout feature toggle is disabled" do
allow(FeatureToggle).to receive(:location_toggle_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
it "has page heading" do it "has page heading" do
expect(page).to have_content(scheme.service_name) expect(page).to have_content(scheme.service_name)
end end
@ -294,19 +281,6 @@ RSpec.describe LocationsController, type: :request do
expect(page).to have_button("Add a location") expect(page).to have_button("Add a location")
end end
it "shows locations with correct data when the new locations layout feature toggle is disabled" do
allow(FeatureToggle).to receive(:location_toggle_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
it "has page heading" do it "has page heading" do
expect(page).to have_content(scheme.service_name) expect(page).to have_content(scheme.service_name)
end end

Loading…
Cancel
Save