diff --git a/app/views/seats/index.html.erb b/app/views/seats/index.html.erb index 29735b61..e697a911 100644 --- a/app/views/seats/index.html.erb +++ b/app/views/seats/index.html.erb @@ -109,7 +109,14 @@ <% sections.each do |section| %> - + = section.price %> + opacity="1.0" + <% else %> + opacity="0.3" + aria-hidden="true" + <% end %> + > <% section.seats.each do |seat| %>
-
+ <%= form_with( + url: venue_floor_seats_path(venue, floor), + method: :get, + local: true, + ) do |form| %>

@@ -153,7 +164,8 @@ type="radio" name="maximum" value="<%= maximum %>" - <% if next_maximum.nil? %> + <% if params[:maximum].to_i == maximum || + [params[:maximum], next_maximum].none? %> checked <% end %> > @@ -177,7 +189,7 @@

-
+ <% end %>

diff --git a/test/controllers/seats_controller_test.rb b/test/controllers/seats_controller_test.rb index 67e9ce76..814707a3 100644 --- a/test/controllers/seats_controller_test.rb +++ b/test/controllers/seats_controller_test.rb @@ -21,4 +21,51 @@ class SeatsControllerTest < ActionDispatch::IntegrationTest assert_equal Cart.last.token, cookies[:cart_token] end + + test "#index when including sections when filtering by price" do + maximum = 10_00 + price = maximum + venue = create(:benedum_center) + floor = create(:orchestra, venue: venue) + section = create(:section, floor: floor, price: price) + create(:seat, section: section) + + get venue_floor_seats_path(venue, floor, maximum: maximum) + + assert_select %{g[opacity="1.0"]} + assert_select %{g:not([aria-hidden])} + end + + test "#index when excluding sections when filtering by price" do + maximum = 5_00 + price = 10_00 + venue = create(:benedum_center) + floor = create(:orchestra, venue: venue) + section = create(:section, floor: floor, price: price) + create(:seat, section: section) + + get venue_floor_seats_path(venue, floor, maximum: maximum) + + assert_select %{g[opacity="0.3"]} + assert_select %{g[aria-hidden="true"]} + end + + test "#index with a ?maximum query parameter" do + venue = create(:benedum_center) + floor = create(:orchestra, venue: venue) + maximum = 10_00 + + get venue_floor_seats_path(venue, floor, maximum: maximum) + + assert_select %{input[type="radio"][value="#{maximum}"][checked]} + end + + test "#index without a ?maximum query parameter" do + venue = create(:benedum_center) + floor = create(:orchestra, venue: venue) + + get venue_floor_seats_path(venue, floor) + + assert_select %{input[type="radio"][value="1500"][checked]} + end end