Skip to content

Commit

Permalink
finish 186600411,186600434
Browse files Browse the repository at this point in the history
- friendly error for invalid max_sales_per_txn
- admin should see min/max purchase info for BOGO tix on storefront
- regular patron never sees "NNN available": if zero available due to min purchase > actual avail, just show "no tickets of this type available"
  • Loading branch information
armandofox committed Dec 2, 2023
1 parent 5121e44 commit 91af572
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions app/models/valid_voucher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def adjust_for_capacity
when INFINITE then "No performance-specific limit applies"
else "#{max_sales_for_this_patron} remaining"
end
self.explanation << " " << display_min_and_max_sales_per_txn
self.visible = true
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/store/_ticket_menus.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
- num_allowed = v.min_and_max_sales_for_this_txn(max_choices = 20)
= select_tag(fieldname, options_for_select(num_allowed), 'data-price' => v.price, 'data-zone' => v.zone_short_name, :class => "itemQty #{ticket_class} form-control form-control-sm col-sm-1")
- if num_allowed.last.zero?
%span.text-info.col-sm-7.border.border-danger.s-explain= v.explanation
%span.text-info.col-sm-7.border.border-danger.s-explain No seats remaining for tickets of this type
= hidden_field_tag "price[#{v.id}]", v.price, {:id => "valid_voucher_#{v.id}_price"}

- if ! @store.valid_vouchers.empty? && [email protected]?
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ en:
attributes:
valid_voucher:
min_sales_per_txn: "Minimum purchase per transaction"
max_sales_per_txn: "Maximum purchase per transaction"

reports:
revenue_details:
Expand Down
14 changes: 6 additions & 8 deletions spec/models/valid_voucher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
end
end

describe "has a friendly error message for min_sales_per_txn" do
specify "for min_sales_per_txn" do
@v = build(:valid_voucher)
@v.min_sales_per_txn = -1
expect(@v).not_to be_valid
expect(@v.errors.full_messages).to include_match_for /^Minimum purchase per transaction must be blank, or greater than or equal to 1$/
end
it "has a friendly error message for min/max_sales_per_txn" do
@v = build(:valid_voucher)
@v.min_sales_per_txn = @v.max_sales_per_txn = -1
expect(@v).not_to be_valid
expect(@v.errors.full_messages).to include_match_for /^Minimum purchase per transaction must be blank, or greater than or equal to 1$/
expect(@v.errors.full_messages).to include_match_for /^Maximum purchase per transaction must be blank, or greater than or equal to 1$/
end


describe "seats remaining" do
subject do
ValidVoucher.new(
Expand Down

0 comments on commit 91af572

Please sign in to comment.