Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix payment error #12695

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/checkout_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@

def clear_invalid_payments
@order.payments.with_state(:invalid).delete_all
# todo: delete all invalid payments, and somehow remove them from the association without reloading any valid payments?

Check warning on line 71 in app/controllers/checkout_controller.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Line is too long. [123/100] Raw Output: app/controllers/checkout_controller.rb:71:101: C: Layout/LineLength: Line is too long. [123/100]
# how about loop through them, delete and reload one by one.
end

def confirm_order
Expand Down
17 changes: 17 additions & 0 deletions spec/controllers/checkout_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,23 @@
expect(response).to redirect_to checkout_step_path(:summary)
end
end

context "with existing invalid payments" do
let(:invalid_payments) { [

Check warning on line 311 in spec/controllers/checkout_controller_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Block body expression is on the same line as the block start. Raw Output: spec/controllers/checkout_controller_spec.rb:311:36: C: Layout/MultilineBlockLayout: Block body expression is on the same line as the block start.
create(:payment, state: :failed),

Check warning on line 312 in spec/controllers/checkout_controller_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is. Raw Output: spec/controllers/checkout_controller_spec.rb:312:15: C: Layout/FirstArrayElementIndentation: Use 2 spaces for indentation in an array, relative to the start of the line where the left square bracket is.
create(:payment, state: :void),
] }

Check warning on line 314 in spec/controllers/checkout_controller_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Indent the right bracket the same as the start of the line where the left bracket is. Raw Output: spec/controllers/checkout_controller_spec.rb:314:13: C: Layout/FirstArrayElementIndentation: Indent the right bracket the same as the start of the line where the left bracket is.

Check warning on line 314 in spec/controllers/checkout_controller_spec.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Expression at 314, 15 should be on its own line. Raw Output: spec/controllers/checkout_controller_spec.rb:314:15: C: Layout/BlockEndNewline: Expression at 314, 15 should be on its own line.

before do
order.payments = invalid_payments
end

it "deletes invalid payments" do
expect{
put(:update, params:)
}.to change { order.payments.to_a }.from(invalid_payments)
end
end
end

context "with no payment source" do
Expand Down
Loading