Browse Source

testing and coding pagy bits for locations

pull/662/head
JG 3 years ago
parent
commit
d9d219fae4
  1. 2
      app/controllers/schemes_controller.rb
  2. 2
      app/views/schemes/locations.html.erb
  3. 6
      spec/requests/schemes_controller_spec.rb

2
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

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

@ -37,3 +37,5 @@
<% end %>
</div>
</div>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %>

6
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("<strong>25</strong> total schemes.")
end
it "shows which schemes are being shown on the current page" do
expect(CGI.unescape_html(response.body)).to match("Showing <b>1</b> to <b>20</b> of <b>25</b> schemes")
expect(CGI.unescape_html(response.body)).to match("Showing <b>1</b> to <b>20</b> of <b>25</b> locations")
end
it "has correct page 1 of 2 title" do

Loading…
Cancel
Save