Skip to content

Only subscribe for active subscriptions#31

Merged
joshmn merged 3 commits intomasterfrom
recreate-for-ended
Apr 22, 2023
Merged

Only subscribe for active subscriptions#31
joshmn merged 3 commits intomasterfrom
recreate-for-ended

Conversation

@joshmn
Copy link
Copy Markdown
Owner

@joshmn joshmn commented Apr 22, 2023

Campaign#subscribe should only find_or_create for subscriptions that haven't ended.

@joshmn joshmn requested a review from jon-sully April 22, 2023 14:36
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (925b939) 98.62% compared to head (9e25105) 98.63%.

❗ Current head 9e25105 differs from pull request most recent head c1dbb4d. Consider uploading reports for the commit c1dbb4d to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #31   +/-   ##
=======================================
  Coverage   98.62%   98.63%           
=======================================
  Files          98       98           
  Lines        2479     2497   +18     
=======================================
+ Hits         2445     2463   +18     
  Misses         34       34           
Impacted Files Coverage Δ
app/models/caffeinate/campaign.rb 100.00% <100.00%> (ø)
...ec/models/caffeinate/campaign_subscription_spec.rb 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +174 to +197
context 'multiple subscriptions' do
it 'creates a new active subscription' do
user = create(:user)
sub = campaign.subscribe!(user)
sub.end!
sub2 = campaign.subscribe!(user)
expect(sub2).to_not eq(sub)
end

it 'returns an existing subscription if it is only unsubscribed' do
user = create(:user)
sub = campaign.subscribe!(user)
sub.unsubscribe!
sub2 = campaign.subscribe!(user)
expect(sub2).to eq(sub)
end

it 'returns the existing if there is an active sub' do
user = create(:user)
sub = campaign.subscribe!(user)
sub2 = campaign.subscribe!(user)
expect(sub2).to eq(sub)
end
end
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, these are great behavior specs! 👍

Copy link
Copy Markdown
Collaborator

@jon-sully jon-sully left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

Comment thread CHANGELOG.md Outdated
Co-authored-by: Jon Sullivan <hey@jonsully.net>
@joshmn joshmn merged commit a7144c6 into master Apr 22, 2023
@jon-sully
Copy link
Copy Markdown
Collaborator

🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants