1
0
mirror of synced 2026-08-05 22:56:55 +00:00

customer model

This commit is contained in:
Rimian Perkins
2019-10-26 11:31:19 +11:00
parent 1f7549060d
commit dcb4b82dec
5 changed files with 54 additions and 15 deletions
+20 -10
View File
@@ -5,19 +5,29 @@ require 'rails_helper'
module DiscoursePatrons
RSpec.describe CustomersController do
describe "create" do
let(:user) { Fabricate(:user, email: 'hello.2@example.com') }
describe "authenticated" do
let(:user) { Fabricate(:user, email: 'hello.2@example.com') }
before do
sign_in(user)
end
before do
sign_in(user)
end
it "creates a customer" do
::Stripe::Customer.expects(:create).with(
email: 'hello.2@example.com',
source: 'tok_interesting'
)
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' }
post "/patrons/customers.json", params: { source: 'tok_interesting' }
end
it "saves the customer" do
::Stripe::Customer.expects(:create).returns(id: 'cus_id23456')
expect {
post "/patrons/customers.json", params: { source: 'tok_interesting' }
}.to change { DiscoursePatrons::Customer.count }
end
end
end
end