-
Notifications
You must be signed in to change notification settings - Fork 662
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.
+102
−61
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,9 @@ Feature: Orphan work | |
| Background: | ||
| Given I have an orphan account | ||
| And the following activated users exists | ||
| | login | password | email | | ||
| | orphaneer | password | [email protected] | | ||
| | author_subscriber | password | [email protected] | | ||
| | login | password | email | | ||
| | orphaneer | password | [email protected] | | ||
| | author_subscriber | password | [email protected] | | ||
| And "author_subscriber" subscribes to author "orphaneer" | ||
| And all emails have been delivered | ||
| And I am logged in as "orphaneer" | ||
|
|
@@ -53,7 +53,7 @@ Feature: Orphan work | |
| When I follow "Orphan Work" | ||
| Then I should see "Read More About The Orphaning Process" | ||
| When I choose "Leave a copy of my pseud on" | ||
| And I press "Yes, I'm sure" | ||
| And I press "Yes, I'm sure" | ||
| Then I should see "Orphaning was successful." | ||
| When I go to orphaneer's works page | ||
| Then I should not see "Shenanigans2" | ||
|
|
@@ -84,68 +84,72 @@ Feature: Orphan work | |
| Then 0 emails should be delivered | ||
|
|
||
|
|
||
| Scenario: Orphan a work (leave pseud) and don't notify subscribers to the work | ||
| Scenario: Orphan a work (leave pseud) but do notify subscribers to the work | ||
|
|
||
| Given the following activated user exists | ||
| | login | password | email | | ||
| | work_subscriber | password | [email protected] | | ||
| | login | password | email | | ||
| | work_subscriber | password | [email protected] | | ||
| And I post the work "Torrid Idfic" | ||
| And I am logged in as "work_subscriber" | ||
| And I view the work "Torrid Idfic" | ||
| And I press "Subscribe" | ||
| And I am logged in as "orphaneer" | ||
| And a chapter is added to "Torrid Idfic" | ||
| And I follow "Edit" | ||
| And I follow "Orphan Work" | ||
| And I choose "Leave a copy of my pseud on" | ||
| And I press "Yes, I'm sure" | ||
| When subscription notifications are sent | ||
| Then 0 emails should be delivered | ||
| Then 1 email should be delivered | ||
|
|
||
|
|
||
| Scenario: Orphan a work (leave pseud) and don't notify subscribers to the work's series | ||
| Scenario: Orphan a work (leave pseud) but do notify subscribers to the work's series | ||
|
|
||
| Given the following activated user exists | ||
| | login | password | email | | ||
| | series_subscriber | password | [email protected] | | ||
| And I add the work "Lazy Purple Sausage" to series "Shame Series" | ||
| | login | password | email | | ||
| | series_subscriber | password | [email protected] | | ||
| # Create the series, so we can subscribe to it before we add a work-to-be-orphaned | ||
| And I add the work "Work to create the series" to series "Shame Series" | ||
| # Subscribe | ||
| And I am logged in as "series_subscriber" | ||
| And I view the series "Shame Series" | ||
| And I press "Subscribe" | ||
| # Add a new work to the series, which we then immediately orphan | ||
| And I am logged in as "orphaneer" | ||
| And I add the work "Lazy Purple Sausage" to series "Shame Series" | ||
| And I view the work "Lazy Purple Sausage" | ||
| And I follow "Edit" | ||
| And I follow "Orphan Work" | ||
| And I choose "Leave a copy of my pseud on" | ||
| And I press "Yes, I'm sure" | ||
| When subscription notifications are sent | ||
| Then 0 emails should be delivered | ||
| Then 1 email should be delivered | ||
|
|
||
| Scenario: I can orphan multiple works at once | ||
| Given I am logged in as "author" | ||
| And I post the work "Glorious" with fandom "SGA" | ||
| And I post the work "Excellent" with fandom "Star Trek" | ||
| And I post the work "Lovely" with fandom "Steven Universe" | ||
| And I go to author's works page | ||
| When I follow "Edit Works" | ||
| Then I should see "Edit Multiple Works" | ||
| When I select "Glorious" for editing | ||
| And I select "Excellent" for editing | ||
| And I press "Delete" | ||
| Then I should see "Are you sure you want to delete these works PERMANENTLY?" | ||
| And I should see "Glorious" | ||
| And I should see "Excellent" | ||
| And I should not see "Lovely" | ||
| # Delay before orphaning to make sure the cache is expired | ||
| And it is currently 1 second from now | ||
| When I follow "Orphan Works Instead" | ||
| Then I should see "Orphaning a work removes it from your account and re-attaches it to the specially created orphan_account." | ||
| When I press "Yes, I'm sure" | ||
| And all indexing jobs have been run | ||
| Then I should see "Orphaning was successful." | ||
| When I go to author's works page | ||
| Then I should not see "Glorious" | ||
| And I should not see "Excellent" | ||
| And I should see "Lovely" | ||
| Given I am logged in as "author" | ||
| And I post the work "Glorious" with fandom "SGA" | ||
| And I post the work "Excellent" with fandom "Star Trek" | ||
| And I post the work "Lovely" with fandom "Steven Universe" | ||
| And I go to author's works page | ||
| When I follow "Edit Works" | ||
| Then I should see "Edit Multiple Works" | ||
| When I select "Glorious" for editing | ||
| And I select "Excellent" for editing | ||
| And I press "Delete" | ||
| Then I should see "Are you sure you want to delete these works PERMANENTLY?" | ||
| And I should see "Glorious" | ||
| And I should see "Excellent" | ||
| And I should not see "Lovely" | ||
| # Delay before orphaning to make sure the cache is expired | ||
| And it is currently 1 second from now | ||
| When I follow "Orphan Works Instead" | ||
| Then I should see "Orphaning a work removes it from your account and re-attaches it to the specially created orphan_account." | ||
| When I press "Yes, I'm sure" | ||
| And all indexing jobs have been run | ||
| Then I should see "Orphaning was successful." | ||
| When I go to author's works page | ||
| Then I should not see "Glorious" | ||
| And I should not see "Excellent" | ||
| And I should see "Lovely" | ||
|
|
||
| Scenario: Orphaning a shared work should not affect chapters created solely by the other creator | ||
|
|
||
|
|
||
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