WIP Check for zaps, send zap receipt on incoming zap tx

This commit is contained in:
2024-04-21 10:35:30 +02:00
parent b36baf26eb
commit e27c64b5f1
4 changed files with 70 additions and 9 deletions

View File

@@ -53,9 +53,7 @@ RSpec.describe "Webhooks", type: :request do
let(:user) { create :user, ln_account: "123456abcdef" }
let(:payload) { JSON.parse(File.read(File.expand_path("../fixtures/lndhub/incoming.json", File.dirname(__FILE__)))) }
before do
user.save! #FIXME this should not be necessary
end
before { user.save! } #FIXME this should not be necessary
it "returns a 200 status" do
post "/webhooks/lndhub", params: payload.to_json
@@ -63,9 +61,15 @@ RSpec.describe "Webhooks", type: :request do
end
it "does not send notifications by default" do
post "/webhooks/lndhub", params: payload.to_json
expect(enqueued_jobs.size).to eq(0)
end
it "does not send a zap receipt" do
expect(NostrManager::PublishZapReceipt).not_to receive(:call)
post "/webhooks/lndhub", params: payload.to_json
end
context "notification preference set to 'xmpp'" do
before do
Setting.xmpp_notifications_from_address = "botka@kosmos.org"
@@ -103,5 +107,22 @@ RSpec.describe "Webhooks", type: :request do
end
end
end
describe "Valid payload for zap transaction" do
let(:user) { create :user, ln_account: "123456abcdef" }
let(:payload) { JSON.parse(File.read(File.expand_path("../fixtures/lndhub/incoming-zap.json", File.dirname(__FILE__)))) }
before { user.save! } #FIXME this should not be necessary
it "returns a 200 status" do
post "/webhooks/lndhub", params: payload.to_json
expect(response).to have_http_status(:ok)
end
it "sends a zap receipt" do
expect(NostrManager::PublishZapReceipt).to receive(:call)
post "/webhooks/lndhub", params: payload.to_json
end
end
end
end