Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moxvallix committed Dec 12, 2023
1 parent 94185ae commit 72e29f1
Show file tree
Hide file tree
Showing 21 changed files with 660 additions and 406 deletions.
2 changes: 1 addition & 1 deletion pay-lago.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

# Uncomment to register a new dependency of your gem
spec.add_dependency "pay", "~> 6.8"
spec.add_dependency "lago-ruby-client", "0.50.0-beta"
spec.add_dependency "lago-ruby-client", "0.52.2-beta"

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/pay/customers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ lago:
processor: lago
processor_id: gid://dummy/Pay::Customer/772847388
default: true
data: {}
2 changes: 1 addition & 1 deletion test/pay/lago/billable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Pay::Lago::Billable::Test < ActiveSupport::TestCase

test "add payment method to lago" do
assert_difference "Pay::PaymentMethod.count" do
@pay_customer.add_payment_method("x", default: true)
@pay_customer.add_payment_method(:stripe, "x", default: true)
end

payment_method = @pay_customer.default_payment_method
Expand Down
34 changes: 34 additions & 0 deletions test/pay/lago/payment_method_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require "test_helper"
require "uri"

class Pay::Lago::PaymentMethodTest < ActiveSupport::TestCase
setup do
@pay_customer = pay_customers(:lago)
end

test "Lago sync returns Pay::PaymentMethod" do
lago_customer = OpenStruct.new(
external_id: @pay_customer.processor_id,
billing_configuration: OpenStruct.new(
payment_provider: "stripe",
provider_customer_id: "x"
)
)
pay_payment_method = Pay::Lago::PaymentMethod.sync(lago_customer)
assert pay_payment_method.is_a?(Pay::PaymentMethod)
assert pay_payment_method.processor_id == "x"
assert @pay_customer.default_payment_method == pay_payment_method
end

test "PaymentMethod does not push or pull if not default" do
pay_payment_method = @pay_customer.add_payment_method(:stripe, "test_1234", default: false, sync: false).payment_processor
assert pay_payment_method.push! == false
assert pay_payment_method.pull! == false
end

test "PaymentMethod can be made default, updating Lago" do
pay_payment_method = @pay_customer.add_payment_method(:stripe, "test_1234_a", sync: true)
lago_customer = Pay::Lago.client.customers.get(@pay_customer.pay_external_id)
assert lago_customer.billing_configuration.provider_customer_id == pay_payment_method.processor_id
end
end
8 changes: 3 additions & 5 deletions test/pay/lago/subscription_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ class Pay::Lago::Subscription::Test < ActiveSupport::TestCase
end

test "lago processor swap" do
travel_to Date.parse("2023-09-18") do
@subscription.swap("another_plan")
assert_equal @subscription.changing_plan?, true
assert_equal @subscription.subscription.next_plan_code, "another_plan"
end
@subscription.swap("another_plan")
@subscription.subscription(reload: true)
assert_equal @subscription.subscription.plan.code, "another_plan"
end

test "lago cannot change quantity" do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 62 additions & 8 deletions test/vcr_cassettes/test_add_payment_method_to_lago.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions test/vcr_cassettes/test_can_get_lago_processor_customer.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 72e29f1

Please sign in to comment.