diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 300731e22..3173746b6 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -21,6 +21,8 @@ class SchemesController < ApplicationController def locations @scheme = Scheme.find_by(id: params[:id]) + @pagy, @locations = pagy(@scheme.locations) + @total_count = @scheme.locations.size end private diff --git a/app/views/schemes/locations.html.erb b/app/views/schemes/locations.html.erb index b9da65243..3c47cbe5f 100644 --- a/app/views/schemes/locations.html.erb +++ b/app/views/schemes/locations.html.erb @@ -37,3 +37,5 @@ <% end %> + +<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %> diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 4ac816bd8..9e1bdcb60 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -310,12 +310,8 @@ RSpec.describe SchemesController, type: :request do get "/schemes/#{scheme.id}/locations" end - it "shows the total locations count" do - expect(CGI.unescape_html(response.body)).to match("25 total schemes.") - end - it "shows which schemes are being shown on the current page" do - expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of 25 schemes") + expect(CGI.unescape_html(response.body)).to match("Showing 1 to 20 of 25 locations") end it "has correct page 1 of 2 title" do