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. 148
      app/views/locations/index.html.erb
  5. 6
      app/views/locations/show.html.erb
  6. 22
      app/views/schemes/_scheme_list.html.erb
  7. 37
      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

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

@ -10,120 +10,60 @@
<%= 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"> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<% end %>
<%= 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>
<%= 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-column-two-thirds-from-desktop">
<%= 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: "Postcode", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Name", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Location code", html_attributes: {
scope: "col",
}) %>
<% row.cell(header: true, text: "Status", html_attributes: {
scope: "col",
}) %>
<% end %>
<% end %>
<% @locations.each do |location| %>
<%= table.body do |body| %>
<%= body.row do |row| %>
<% 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.name) %>
<% row.cell(text: location.id) %>
<% row.cell(text: status_tag(location.status)) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% if LocationPolicy.new(current_user, @scheme.locations.new).create? %> <div class="govuk-grid-row">
<%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %> <div class="govuk-grid-column-two-thirds-from-desktop">
<%= 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 %> <% end %>
</div> <%= table.head do |head| %>
</div> <%= head.row do |row| %>
<% else %> <% row.cell(header: true, text: "Postcode", html_attributes: {
<%= govuk_table do |table| %> scope: "col",
<%= 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)) %> <% row.cell(header: true, text: "Name", html_attributes: {
<% end %> scope: "col",
<%= table.head do |head| %> }) %>
<%= head.row do |row| %> <% row.cell(header: true, text: "Location code", html_attributes: {
<% row.cell(header: true, text: "Code", html_attributes: { scope: "col",
scope: "col", }) %>
}) %> <% row.cell(header: true, text: "Status", html_attributes: {
<% row.cell(header: true, text: "Postcode", html_attributes: { scope: "col",
scope: "col", }) %>
}) %> <% end %>
<% 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 %>
<% end %> <% @locations.each do |location| %>
<% @locations.each do |location| %> <%= table.body do |body| %>
<%= table.body do |body| %> <%= body.row do |row| %>
<%= body.row do |row| %> <% row.cell(text: simple_format(location_cell_postcode(location, if location.confirmed
<% row.cell(text: location.id) %> scheme_location_path(@scheme, location)
<% row.cell(text: simple_format(location_cell_postcode(location, if location.confirmed else
scheme_location_path(@scheme, location) location.postcode.present? ? scheme_location_check_answers_path(@scheme, location, route: "locations") : scheme_location_postcode_path(@scheme, location)
else end), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
location.postcode.present? ? scheme_location_check_answers_path(@scheme, location, route: "locations") : scheme_location_postcode_path(@scheme, location) <% row.cell(text: location.name) %>
end), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: location.id) %>
<% row.cell(text: location.units) %> <% row.cell(text: status_tag(location.status)) %>
<% 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 %> <% 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 %> <% if LocationPolicy.new(current_user, @scheme.locations.new).create? %>
<%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %>
<% end %>
</div>
</div>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %>

6
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 %>

22
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,9 +17,7 @@
<% 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 %>

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

@ -9,33 +9,26 @@
<%= 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"> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<% end %>
<%= 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>
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% display_scheme_attributes(@scheme, current_user).each do |attr| %> <% display_scheme_attributes(@scheme, current_user).each do |attr| %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name] } %> <% row.key { attr[:name] } %>
<% row.value { details_html(attr) } %> <% row.value { details_html(attr) } %>
<% if SchemePolicy.new(current_user, @scheme).update? %> <% if SchemePolicy.new(current_user, @scheme).update? %>
<% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %> <% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %>
<% end %>
<% end %> <% 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