How can i test if an account is subscribed?
I'm trying to add to the test suite, but realised that subscription information is handled by the Pay gem.
So in my fixtures, I have a list of users, accounts etc. But several of my controllers check to see whether the account is subscribed before allowing access.
How can I setup fixtures / controller tests to create a user/account that is `subscribed?` to a plan and has an active subscription?
So in my fixtures, I have a list of users, accounts etc. But several of my controllers check to see whether the account is subscribed before allowing access.
How can I setup fixtures / controller tests to create a user/account that is `subscribed?` to a plan and has an active subscription?
I ran into an error trying to do this. When I run my tests I get:
Minitest::UnexpectedError: ActiveRecord::Fixture::FixtureError: table "pay_customers" has no columns named "owner".
in pay_customers.yml:
customer_one: owner: one (Account) processor: stripe processor_id: cus_abc123 default: true
It feels like the Pay::Customer class isn't loaded yet to tell the DB to split the owner into type and ID. Anyone else see this problem?
I found this tutorial which led me to make the following additions in
test/test_helper.rb
:class ActiveSupport::TestCase ... fixtures :all self.set_fixture_class pay_subscriptions: Pay::Subscription self.set_fixture_class pay_customers: Pay::Customer ... end
This seems to have convinced rails tests to load the right class to know that
owner
is polymorphic.Notifications
You’re not receiving notifications from this thread.