discourse-subscriptions/spec/requests/customers_controller_spec.rb

35 lines
893 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'rails_helper'
module DiscoursePatrons
RSpec.describe CustomersController do
describe "create" do
2019-10-25 20:31:19 -04:00
describe "authenticated" do
let(:user) { Fabricate(:user, email: 'hello.2@example.com') }
2019-10-25 20:31:19 -04:00
before do
sign_in(user)
end
it "creates a stripe customer" do
::Stripe::Customer.expects(:create).with(
email: 'hello.2@example.com',
source: 'tok_interesting'
)
post "/patrons/customers.json", params: { source: 'tok_interesting' }
end
2019-10-25 20:31:19 -04:00
it "saves the customer" do
::Stripe::Customer.expects(:create).returns(id: 'cus_id23456')
2019-10-25 20:31:19 -04:00
expect {
post "/patrons/customers.json", params: { source: 'tok_interesting' }
}.to change { DiscoursePatrons::Customer.count }
end
end
end
end
end