27 lines
734 B
Ruby
Raw Normal View History

2019-10-26 13:01:49 +11:00
# frozen_string_literal: true
require "rails_helper"
2019-10-26 13:01:49 +11:00
2019-12-04 11:23:45 +11:00
module DiscourseSubscriptions
2019-10-26 13:01:49 +11:00
RSpec.describe Customer do
let(:user) { Fabricate(:user) }
let(:stripe_customer) { { id: "cus_id4567" } }
2019-10-26 13:01:49 +11:00
it "has a table name" do
2019-12-03 13:03:10 +11:00
expect(described_class.table_name).to eq "discourse_subscriptions_customers"
2019-10-26 13:01:49 +11:00
end
it "creates" do
customer = described_class.create_customer(user, stripe_customer)
expect(customer.customer_id).to eq "cus_id4567"
2019-10-26 13:01:49 +11:00
expect(customer.user_id).to eq user.id
end
it "has a user scope" do
described_class.create_customer(user, stripe_customer)
customer = described_class.find_user(user)
expect(customer.customer_id).to eq "cus_id4567"
2019-10-26 13:01:49 +11:00
end
end
end