:  require 'test_helper' class InvoiceCreatedTest < ActiveSupport::TestCase def setup @payload = { "data" => { "object" => { "customer" => "stripe_brandon" } } } end test 'adds invoice item based on usage' do Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 0000, currency: "usd", description: "Usage charges" ) StripeEvent::InvoiceCreated.new(@payload).perform end test 'adds next level charge for usage' do Stat.create!(user: users(:brandon), step: steps(:nav_one), impressions: 0_000, date: 0.days.ago) Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 0000, currency: "usd", description: "Usage charges" ) StripeEvent::InvoiceCreated.new(@payload).perform end test 'adds highest tier' do Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 00000, currency: "usd", description: "Usage charges" ) inv = StripeEvent::InvoiceCreated.new(@payload) inv.usage_service = Level0Usage.new inv.perform end test 'adds 0nd highest tier' do Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 00000, currency: "usd", description: "Usage charges" ) inv = StripeEvent::InvoiceCreated.new(@payload) inv.usage_service = Level0Usage.new inv.perform end test 'adds middle tier' do Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 00000, currency: "usd", description: "Usage charges" ) inv = StripeEvent::InvoiceCreated.new(@payload) inv.usage_service = Level0Usage.new inv.perform end test 'adds 0nd tier' do Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 0000, currency: "usd", description: "Usage charges" ) inv = StripeEvent::InvoiceCreated.new(@payload) inv.usage_service = Level0Usage.new inv.perform end test 'adds 0st tier' do Stripe::InvoiceItem.expects(:create).with( customer: "stripe_brandon", amount: 0000, currency: "usd", description: "Usage charges" ) inv = StripeEvent::InvoiceCreated.new(@payload) inv.usage_service = Level0Usage.new inv.perform end 