diff --git a/backend/app/services/billing/request_bank_transfer.rb b/backend/app/services/billing/request_bank_transfer.rb index c95deca..d9906d2 100644 --- a/backend/app/services/billing/request_bank_transfer.rb +++ b/backend/app/services/billing/request_bank_transfer.rb @@ -28,7 +28,6 @@ module Billing existing = @club.billing_transfer_orders.awaiting_payment.first if existing if existing.plan_slug == @plan_slug && existing.billing_interval == @interval && existing.amount_cents == amount_cents - MatchLiveTv.deliver_mail(BankTransferMailer.with(order: existing).instructions) return existing end @@ -59,7 +58,8 @@ module Billing ) end - MatchLiveTv.deliver_mail(BankTransferMailer.with(order: order).instructions) + # Le istruzioni (IBAN/causale) le manda a mano l'admin da /admin/billing. + Rails.logger.info("[BankTransfer] ordine #{order.reference_code} in attesa, nessuna mail istruzioni") order end diff --git a/backend/spec/services/billing/request_bank_transfer_spec.rb b/backend/spec/services/billing/request_bank_transfer_spec.rb index 0d500ca..a6fa2d2 100644 --- a/backend/spec/services/billing/request_bank_transfer_spec.rb +++ b/backend/spec/services/billing/request_bank_transfer_spec.rb @@ -26,11 +26,11 @@ RSpec.describe Billing::RequestBankTransfer do ) end - it "crea l'ordine a listino e invia le istruzioni" do + it "crea l'ordine a listino senza inviare le istruzioni" do expect { described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly") }.to change { club.billing_transfer_orders.count }.by(1) - .and change { ActionMailer::Base.deliveries.size }.by(1) + .and change { ActionMailer::Base.deliveries.size }.by(0) order = club.billing_transfer_orders.last expect(order).to be_awaiting_payment @@ -41,16 +41,14 @@ RSpec.describe Billing::RequestBankTransfer do expect(club.reload.subscription.plan.slug).to eq("free") end - it "crea comunque l'ordine se in produzione manca SMTP" do - allow(MatchLiveTv).to receive(:smtp_configured?).and_return(false) - allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production")) + it "non reinvia istruzioni se l'ordine è già in attesa" do + first = described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly") + ActionMailer::Base.deliveries.clear expect { - described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly") - }.to change { club.billing_transfer_orders.count }.by(1) - .and change { ActionMailer::Base.deliveries.size }.by(0) - - expect(club.billing_transfer_orders.last).to be_awaiting_payment + second = described_class.call(club: club, user: user, plan_slug: "premium_light", interval: "yearly") + expect(second.id).to eq(first.id) + }.not_to change { ActionMailer::Base.deliveries.size } end it "usa l'importo concordato se presente" do