Browse Source

Don’t show locations count in secondary navigation

pull/723/head
Paul Robert Lloyd 3 years ago
parent
commit
c9598e8f5d
  1. 3
      app/views/locations/index.html.erb
  2. 2
      app/views/schemes/check_answers.html.erb
  3. 2
      app/views/schemes/show.html.erb
  4. 6
      spec/features/schemes_spec.rb
  5. 8
      spec/helpers/navigation_items_helper_spec.rb
  6. 4
      spec/requests/locations_controller_spec.rb

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

@ -7,8 +7,7 @@
) %> ) %>
<% end %> <% end %>
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, location_caption)) %>
<%= 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| %>

2
app/views/schemes/check_answers.html.erb

@ -2,8 +2,6 @@
<%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %> <%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop"> <div class="govuk-grid-column-three-quarters-from-desktop">
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> <%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %>

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

@ -10,7 +10,7 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations")) %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop"> <div class="govuk-grid-column-three-quarters-from-desktop">

6
spec/features/schemes_spec.rb

@ -198,12 +198,12 @@ RSpec.describe "Schemes scheme Features" do
it "shows service and locations tab" do it "shows service and locations tab" do
expect(page).to have_link("Scheme") expect(page).to have_link("Scheme")
expect(page).to have_link("#{scheme.locations.count} locations") expect(page).to have_link("Locations")
end end
context "when I click locations link" do context "when I click locations link" do
before do before do
click_link("#{scheme.locations.count} locations") click_link("Locations")
end end
it "shows details of those locations" do it "shows details of those locations" do
@ -725,7 +725,7 @@ RSpec.describe "Schemes scheme Features" do
context "when I click to see locations" do context "when I click to see locations" do
before do before do
click_link "1 location" click_link "Locations"
end end
it "I see location details" do it "I see location details" do

8
spec/helpers/navigation_items_helper_spec.rb

@ -190,13 +190,13 @@ RSpec.describe NavigationItemsHelper do
let(:expected_scheme_items) do let(:expected_scheme_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", true), NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", true),
NavigationItemsHelper::NavigationItem.new("1 location", "/schemes/1/locations", false), NavigationItemsHelper::NavigationItem.new("Locations", "/schemes/1/locations", false),
] ]
end end
it "returns navigation items with Schemes item set as current" do it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items) expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1", 1, "1 location")).to eq(expected_scheme_items) expect(scheme_items("/schemes/1", 1, "Locations")).to eq(expected_scheme_items)
end end
end end
@ -213,13 +213,13 @@ RSpec.describe NavigationItemsHelper do
let(:expected_scheme_items) do let(:expected_scheme_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", false), NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", false),
NavigationItemsHelper::NavigationItem.new("1 location", "/schemes/1/locations", true), NavigationItemsHelper::NavigationItem.new("Locations", "/schemes/1/locations", true),
] ]
end end
it "returns navigation items with Schemes item set as current" do it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items) expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1/locations", 1, "1 location")).to eq(expected_scheme_items) expect(scheme_items("/schemes/1/locations", 1, "Locations")).to eq(expected_scheme_items)
end end
end end

4
spec/requests/locations_controller_spec.rb

@ -418,7 +418,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params and redirects to correct page" do it "updates existing location for scheme with valid params and redirects to correct page" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("1 location") expect(page).to have_content("Locations")
end end
it "updates existing location for scheme with valid params" do it "updates existing location for scheme with valid params" do
@ -541,7 +541,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params and redirects to correct page" do it "updates existing location for scheme with valid params and redirects to correct page" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("1 location") expect(page).to have_content("Locations")
end end
it "updates existing location for scheme with valid params" do it "updates existing location for scheme with valid params" do

Loading…
Cancel
Save