-
Notifications
You must be signed in to change notification settings - Fork 653
AO3-3620 Fix subscriptions to other creator(s) for works co-authored with orphan_account #5523
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
Draft
irrationalpie7
wants to merge
14
commits into
otwcode:master
Choose a base branch
from
irrationalpie7:AO3-3620-orphan-subscriptions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
113e0da
First attempt at a solution
irrationalpie7 456e237
Fix syntax whoops
irrationalpie7 ab12d89
Add some tests
irrationalpie7 09b00a1
Fix user_mailer_spec
irrationalpie7 241f4c7
Tweak failing tests to see what happens
irrationalpie7 51bf1fa
Fix orphan_work.feature tests
irrationalpie7 64457f7
Fix typo
irrationalpie7 f64052e
Make some tweaks to try to undertand email tests
irrationalpie7 682cd80
Add another check to try to understand
irrationalpie7 3a3538a
Swap some 'build's to 'create's to see if that helps
irrationalpie7 367d19b
Test passes locally??
irrationalpie7 ef4eb54
Improve orphan_work.features test
irrationalpie7 687333c
Revert accidental failing test
irrationalpie7 db351a6
Tweak tests
irrationalpie7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| require 'spec_helper' | ||
| require "spec_helper" | ||
|
|
||
| describe Subscription do | ||
| let(:subscription) { build(:subscription) } | ||
|
|
@@ -22,7 +22,8 @@ | |
| end | ||
|
|
||
| it "should be destroyed" do | ||
| expect { subscription.reload }.to raise_error ActiveRecord::RecordNotFound | ||
| expect { subscription.reload } | ||
| .to raise_error ActiveRecord::RecordNotFound | ||
| end | ||
| end | ||
| end | ||
|
|
@@ -43,7 +44,8 @@ | |
| end | ||
|
|
||
| it "should be destroyed" do | ||
| expect { subscription.reload }.to raise_error ActiveRecord::RecordNotFound | ||
| expect { subscription.reload } | ||
| .to raise_error ActiveRecord::RecordNotFound | ||
| end | ||
| end | ||
| end | ||
|
|
@@ -64,7 +66,8 @@ | |
| end | ||
|
|
||
| it "should be destroyed" do | ||
| expect { subscription.reload }.to raise_error ActiveRecord::RecordNotFound | ||
| expect { subscription.reload } | ||
| .to raise_error ActiveRecord::RecordNotFound | ||
| end | ||
| end | ||
| end | ||
|
|
@@ -111,12 +114,13 @@ | |
| describe "#valid_notification_entry?" do | ||
| let(:subscription) { build(:subscription) } | ||
| let(:series) { build(:series) } | ||
| let(:work) { build(:work) } | ||
| let(:author_pseud) { create(:user).default_pseud } | ||
| let(:work) { create(:work, authors: [author_pseud]) } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we now compare the subscribable to the creation.pseuds, it made more sense to me to create |
||
| let(:draft) { build(:draft) } | ||
| let(:chapter) { build(:chapter) } | ||
| let(:anon_work) { build(:work, collections: [build(:anonymous_collection)]) } | ||
| let(:chapter) { create(:chapter, authors: [author_pseud]) } | ||
| let(:anon_work) { create(:work, authors: [author_pseud], collections: [build(:anonymous_collection)]) } | ||
| let(:anon_series) { build(:series, works: [anon_work]) } | ||
| let(:anon_chapter) { build(:chapter, work: anon_work) } | ||
| let(:anon_chapter) { create(:chapter, authors: [author_pseud], work: anon_work) } | ||
| let(:orphan_pseud) { create(:user, login: "orphan_account").default_pseud } | ||
|
|
||
| it "returns false when the creation is nil" do | ||
|
|
@@ -132,11 +136,6 @@ | |
| expect(subscription.valid_notification_entry?(draft)).to be_falsey | ||
| end | ||
|
|
||
| # TODO: AO3-3620 & AO3-5696: Allow subscriptions to orphan_account to receive notifications | ||
| it "returns false when the creation is by orphan_account" do | ||
| expect(subscription.valid_notification_entry?(create(:work, authors: [orphan_pseud]))).to be_falsey | ||
| end | ||
|
|
||
| it "returns false when the creation is hidden_by_admin" do | ||
| expect(subscription.valid_notification_entry?(build(:work, hidden_by_admin: true))).to be_falsey | ||
| end | ||
|
|
@@ -151,11 +150,6 @@ | |
| expect(subscription.valid_notification_entry?(build(:chapter, work: draft))).to be_falsey | ||
| end | ||
|
|
||
| # TODO: AO3-3620 & AO3-5696: Allow subscriptions to orphan_account to receive notifications | ||
| it "returns false when the creation is by orphan_account" do | ||
| expect(subscription.valid_notification_entry?(create(:chapter, authors: [orphan_pseud]))).to be_falsey | ||
| end | ||
|
|
||
| it "returns false when the chapter is on a hidden work" do | ||
| expect(subscription.valid_notification_entry?(build(:chapter, work: build(:work, hidden_by_admin: true)))).to be_falsey | ||
| end | ||
|
|
@@ -205,7 +199,7 @@ | |
| end | ||
|
|
||
| context "when subscribable is a user" do | ||
| let(:subscription) { build(:subscription, subscribable: create(:user)) } | ||
| let(:subscription) { build(:subscription, subscribable: author_pseud.user) } | ||
|
|
||
| it "returns true for a non-anonymous work" do | ||
| expect(subscription.valid_notification_entry?(work)).to be_truthy | ||
|
|
@@ -222,6 +216,31 @@ | |
| it "returns false for an anonymous chapter" do | ||
| expect(subscription.valid_notification_entry?(anon_chapter)).to be_falsey | ||
| end | ||
|
|
||
| it "returns false for a work by a different user (orphan_account)" do | ||
| expect(subscription.valid_notification_entry?(create(:work, authors: [orphan_pseud]))).to be_falsey | ||
| end | ||
|
|
||
| it "returns false for a chapter by a different user (orphan_account)" do | ||
| expect(subscription.valid_notification_entry?(create(:chapter, authors: [orphan_pseud]))).to be_falsey | ||
| end | ||
|
|
||
| it "returns false for a work by a different user" do | ||
| expect(subscription.valid_notification_entry?(create(:work, authors: [create(:user).default_pseud]))).to be_falsey | ||
| end | ||
|
|
||
| it "returns false for a chapter by a different user, even if the subscribed-to user is one of the work creators" do | ||
| # subscription is for author_pseud | ||
| author2 = create(:user).default_pseud | ||
| work = create(:work, authors: [author_pseud, author2]) | ||
| # chapter is by author2 only | ||
| chapter = create(:chapter, authors: [author2], work: work, position: 2) | ||
| expect(subscription.valid_notification_entry?(chapter)).to be_falsey | ||
| end | ||
|
|
||
| it "returns false for a chapter by a different user, even if the user is one of the work creators" do | ||
| expect(subscription.valid_notification_entry?(create(:chapter, authors: [create(:user).default_pseud]))).to be_falsey | ||
| end | ||
| end | ||
|
|
||
| context "when subscribable is a work" do | ||
|
|
@@ -232,6 +251,11 @@ | |
| it "returns true for a non-anonymous chapter" do | ||
| expect(subscription.valid_notification_entry?(chapter)).to be_truthy | ||
| end | ||
|
|
||
| # if the subscribable type is work, creation must be a chapter | ||
| it "returns false when the creation is a work" do | ||
| expect(subscription.valid_notification_entry?(work)).to be_falsey | ||
| end | ||
| end | ||
|
|
||
| context "when work is anonymous" do | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
My formatting settings appear to have changed a fair amount of whitespace in this file. If there's a specific formatter I could be using and some recommended settings, I'm happy to swap back! Otherwise it doesn't seem worth individually reverting the whitespace-only lines