Skip to content

Instantly share code, notes, and snippets.

@kolosek
Created February 13, 2015 16:12
Show Gist options
  • Save kolosek/a998dd43215ceb8b9769 to your computer and use it in GitHub Desktop.
Save kolosek/a998dd43215ceb8b9769 to your computer and use it in GitHub Desktop.
Rspec relation tests
Subscription
factories
should have :subscription factory
should assign the product price from the product record
should have :active_subscription factory
should have :cancelled_subscription factory
:active_subscription
status
should == "active"
:cancelled_subscription
status
should == "cancelled"
db table
should have db column named user_id of type integer of null false
should have db column named product_id of type integer of null false
should have db column named order_number of type string of null false
should have db column named product_price of type integer of null false
should have db column named keywords of type text
should have db column named comments of type text
should have db column named status of type string of limit 16 of default new of null false
should have db column named paypal_profile_id of type string of limit 14 of null true
should have a index on columns user_id
should have a index on columns product_id
should have a index on columns order_number
should have a index on columns status
should have a unique index on columns paypal_profile_id
should have a index on columns created_at
associations
should belong to user
should belong to product
should have many payments
validations
Subscription::SubscriptionUniquenessValidator
when user has no subscriptions
should allow to create new subscription
should allow to create active subscription
should allow to create cancelled subscription
when user has several new and cancelled subscriptions for the same product
should allow to create new subscription for this product
should allow to create active subscription for this product
should allow to create cancelled subscription for this product
when user has an active subscription for the given product
should not allow to create new subscription for this product
should not allow to create active subscription for this product
should allow to create cancelled subscription for this product
should not allow to change this product subscription status to active
should allow to change active subscription status
should allow to update active subscription
should allow to create new subscription for the other product
should allow to create active subscription for the other product
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment