Add spec for reported regression
This commit is contained in:
parent
e3b96d5cff
commit
da22a9d448
@ -87,6 +87,43 @@ RSpec.describe "Donations", type: :request do
|
|||||||
expect(response).to redirect_to("https://btcpay.example.com/i/Q9GBe143HJIkdpZeH4Ftx5")
|
expect(response).to redirect_to("https://btcpay.example.com/i/Q9GBe143HJIkdpZeH4Ftx5")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "amount in sats" do
|
||||||
|
before do
|
||||||
|
expect(BtcpayManager::CreateInvoice).to receive(:call)
|
||||||
|
.with(amount: 0.0001, currency: "BTC", redirect_url: "http://www.example.com/contributions/donations/1/confirm_btcpay")
|
||||||
|
.and_return({
|
||||||
|
"id" => "Q9GBe143HJIkdpZeH4Ftx5",
|
||||||
|
"amount" => "0.0001",
|
||||||
|
"currency" => "BTC",
|
||||||
|
"checkoutLink" => "#{Setting.btcpay_api_url}/i/Q9GBe143HJIkdpZeH4Ftx5",
|
||||||
|
"expirationTime" => 1707908626,
|
||||||
|
"checkout" => { "redirectURL" => "http://www.example.com/contributions/donations/1/confirm_btcpay" }
|
||||||
|
})
|
||||||
|
|
||||||
|
post "/contributions/donations", params: {
|
||||||
|
donation_method: "btcpay", amount: "10000", currency: "sats",
|
||||||
|
public_name: "Garret Holmes"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates a new donation record" do
|
||||||
|
expect(user.donations.count).to eq(1)
|
||||||
|
donation = user.donations.first
|
||||||
|
expect(donation.donation_method).to eq("btcpay")
|
||||||
|
expect(donation.payment_method).to be_nil
|
||||||
|
expect(donation.paid_at).to be_nil
|
||||||
|
expect(donation.public_name).to eq("Garret Holmes")
|
||||||
|
expect(donation.amount_sats).to eq(10000)
|
||||||
|
expect(donation.fiat_amount).to be_nil
|
||||||
|
expect(donation.fiat_currency).to be_nil
|
||||||
|
expect(donation.btcpay_invoice_id).to eq("Q9GBe143HJIkdpZeH4Ftx5")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the BTCPay checkout page" do
|
||||||
|
expect(response).to redirect_to("https://btcpay.example.com/i/Q9GBe143HJIkdpZeH4Ftx5")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user