-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: paid subscriptions system and articles #467
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: DioFun <[email protected]> Co-authored-by: Nymous <[email protected]>
todo: fix tests
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #467 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 26 48 +22
Lines 337 663 +326
Branches 35 66 +31
==========================================
+ Hits 337 663 +326 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With all the validation logic that I moved to the Sale model, this test will probably need more cases:
- test if sale is empty
- test if sale has duplicate articles
assert_not_predicate @subscription_offer, :valid? | ||
end | ||
|
||
test 'price should be positive' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also test for strictly positive? (a subscription offer that costs 0 is weird)
end | ||
|
||
test 'duration should be positive' do | ||
@subscription_offer.duration = -5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, test for strictly positive as well
test 'offer should be destroyed if no sales' do | ||
@subscription_offer.sales.destroy_all | ||
@subscription_offer.refunds.destroy_all | ||
assert_difference 'SubscriptionOffer.unscoped.count', -1 do | ||
@subscription_offer.destroy | ||
end | ||
end | ||
|
||
test 'offer should be destroyable' do | ||
@subscription_offer.sales.destroy_all | ||
@subscription_offer.refunds.destroy_all | ||
assert_predicate @subscription_offer, :destroy | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, should this be merged?
test 'offer should be destroyed if no sales' do | |
@subscription_offer.sales.destroy_all | |
@subscription_offer.refunds.destroy_all | |
assert_difference 'SubscriptionOffer.unscoped.count', -1 do | |
@subscription_offer.destroy | |
end | |
end | |
test 'offer should be destroyable' do | |
@subscription_offer.sales.destroy_all | |
@subscription_offer.refunds.destroy_all | |
assert_predicate @subscription_offer, :destroy | |
end | |
test 'offer should be destroyed if no sales' do | |
@subscription_offer.sales.destroy_all | |
@subscription_offer.refunds.destroy_all | |
assert_difference 'SubscriptionOffer.unscoped.count', -1 do | |
assert_predicate @subscription_offer, :destroy | |
end | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow very nice tests on a hard-to-test feature!
Le but est d'avoir un suivi et des correctifs aux fur et à mesure pour le moment quant au système d'abonnement payant.
Développement de la gestion des articles et abonnements payants.
La gestion des remboursements sera effectuée dans une autre PR
links to #455