Add spec for reported regression
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Râu Cao 2024-03-06 11:20:28 +01:00
parent e3b96d5cff
commit da22a9d448
Signed by: raucao
GPG Key ID: 37036C356E56CC51

View File

@ -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