Skip to content
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

Open
wants to merge 80 commits into
base: master
Choose a base branch
from
Open

Conversation

DioFun
Copy link
Member

@DioFun DioFun commented Jul 4, 2024

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

@nymous nymous marked this pull request as draft July 4, 2024 18:11
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (01e1374) to head (1a799a5).
Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

@DioFun DioFun self-assigned this Jul 5, 2024
@DioFun DioFun requested a review from nymous July 8, 2024 22:38
@DioFun DioFun marked this pull request as ready for review August 3, 2024 09:36
@DioFun DioFun requested review from nymous and Letiste August 3, 2024 09:37
app/controllers/sales_controller.rb Outdated Show resolved Hide resolved
app/javascript/controllers/sales_controller.js Outdated Show resolved Hide resolved
app/models/articles_sale.rb Outdated Show resolved Hide resolved
app/models/sale.rb Outdated Show resolved Hide resolved
app/models/sale.rb Outdated Show resolved Hide resolved
app/models/setting.rb Show resolved Hide resolved
app/models/subscription.rb Show resolved Hide resolved
app/assets/fonts/DejaVuSans-Bold.ttf Outdated Show resolved Hide resolved
app/controllers/admin/articles_controller.rb Outdated Show resolved Hide resolved
app/controllers/admin/dashboard_controller.rb Outdated Show resolved Hide resolved
app/controllers/admin/payment_methods_controller.rb Outdated Show resolved Hide resolved
app/controllers/admin/subscription_offers_controller.rb Outdated Show resolved Hide resolved
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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

Comment on lines +59 to +71
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
Copy link
Member

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?

Suggested change
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

Copy link
Member

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!

@nymous
Copy link
Member

nymous commented Nov 2, 2024

Just to show you what the errors look like in the reworked sale form:
image
The duplicate articles are shown in red

@nymous nymous mentioned this pull request Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review in progress
Development

Successfully merging this pull request may close these issues.

Subscription management modelisation
5 participants