forked from seanpdoyle/select-your-own-seat
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For comparison [see this commit][commit] Nothing exciting here. The ergonomics is similar to the Stimulus version. [commit]: seanpdoyle@2e69ac9
- Loading branch information
Showing
7 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
json.venue_name venue.name | ||
|
||
json.sections(partial: ['sections', locals: local_assigns]) do | ||
json.sections(partial: ["sections", locals: local_assigns]) do | ||
end | ||
|
||
json.cart(partial: ['cart', locals: local_assigns]) do | ||
json.cart(partial: ["cart", locals: local_assigns]) do | ||
end | ||
|
||
json.seat do | ||
json.show true | ||
json.section_name seat.section.name | ||
json.row_number seat.row_number | ||
json.price number_to_currency(seat.section.price / 100.0) | ||
json.seat_selection_form do | ||
form_props(url: seat_selections_path(seat)) do |f| | ||
f.submit | ||
|
||
if Current.cart.include?(seat) | ||
json.seat_selection_form do | ||
form_props(url: seat_selections_path(seat), method: :delete) do |f| | ||
f.submit(text: "Remove") | ||
end | ||
end | ||
else | ||
json.seat_selection_form do | ||
form_props(url: seat_selections_path(seat)) do |f| | ||
f.submit(text: "Select") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "test_helper" | ||
|
||
class CartTest < ActiveSupport::TestCase | ||
test "#include? returns true when a seat is selected" do | ||
seat_selection = create(:seat_selection) | ||
seat = seat_selection.seat | ||
cart = seat_selection.cart | ||
|
||
included = cart.include?(seat) | ||
|
||
assert included, "cart includes selected seat" | ||
end | ||
|
||
test "#include? returns false when a seat is not yet selected" do | ||
seat = create(:seat) | ||
cart = create(:cart) | ||
|
||
included = cart.include?(seat) | ||
|
||
refute included, "cart includes selected seat" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters