26 lines
738 B
Ruby
26 lines
738 B
Ruby
# frozen_string_literal: true
|
|||
|
|
|
||
|
|
require 'rails_helper'
|
||
|
|
|
||
|
|
module DiscoursePatrons
|
||
|
|
RSpec.describe SubscriptionsController do
|
||
|
|
describe "create" do
|
||
|
|
let(:user) { Fabricate(:user, email: '[email protected]') }
|
||
|
|
|
||
|
|
before do
|
||
|
|
sign_in(user)
|
||
|
|
end
|
||
|
|
|
||
|
|
it "creates a subscription with a customer" do
|
||
|
|
::Stripe::Subscription.expects(:create).with(has_entry(customer: 'cus_1234'))
|
||
|
|
post "/patrons/subscriptions.json", params: { customer: 'cus_1234' }
|
||
|
|
end
|
||
|
|||
|
|
it "creates a subscription with a plan" do
|
||
|
|
::Stripe::Subscription.expects(:create).with(has_entry(items: [ plan: 'plan_1234' ]))
|
||
|
|
post "/patrons/subscriptions.json", params: { plan: 'plan_1234' }
|
||
|
|
end
|
||
end
|
|||
|
|
end
|
||
|
|
end
|