Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
AO3-5133 Rails BOT: Use first_chapter when posting a work and its first chapter #3022
Conversation
sarken
added some commits
Aug 30, 2017
sarken
added
Awaiting review
Priority: Broken on Test (High)
labels
Aug 30, 2017
| - self.chapters.first.published_at = Date.today unless self.backdate | ||
| - self.chapters.first.posted = self.posted | ||
| - self.chapters.first.save | ||
| + if self.saved_change_to_posted? || (self.first_chapter && self.first_chapter.posted != self.posted) |
| - self.chapters.first.posted = self.posted | ||
| - self.chapters.first.save | ||
| + if self.saved_change_to_posted? || (self.first_chapter && self.first_chapter.posted != self.posted) | ||
| + self.first_chapter.published_at = Date.today unless self.backdate |
| - self.chapters.first.save | ||
| + if self.saved_change_to_posted? || (self.first_chapter && self.first_chapter.posted != self.posted) | ||
| + self.first_chapter.published_at = Date.today unless self.backdate | ||
| + self.first_chapter.posted = self.posted |
| + if self.saved_change_to_posted? || (self.first_chapter && self.first_chapter.posted != self.posted) | ||
| + self.first_chapter.published_at = Date.today unless self.backdate | ||
| + self.first_chapter.posted = self.posted | ||
| + self.first_chapter.save |
sarken
closed this
Aug 30, 2017
sarken
added some commits
Aug 30, 2017
sarken
reopened this
Aug 31, 2017
| @@ -3,6 +3,19 @@ | ||
| describe Chapter do | ||
| + it "has a valid factory" do | ||
| + expect(build(:chapter)).to be_valid |
| + | ||
| + it "is unposted by default" do | ||
| + chapter = create(:chapter) | ||
| + chapter.posted.should == false |
| + chapter = create(:chapter) | ||
| + chapter.posted.should == false | ||
| + end | ||
| + |
| @@ -7,6 +7,13 @@ | ||
| expect(create(:work)).to be_valid | ||
| end | ||
| + context "when posted" do | ||
| + it "posts the first chapter" do | ||
| + work = create(:posted_work) |
| + work = create(:posted_work) | ||
| + work.first_chapter.posted.should == true | ||
| + end | ||
| + end |
sarken
added
Reviewed: Ready to Merge
and removed
Awaiting review
labels
Sep 1, 2017
sarken
merged commit bcf6e10
into
otwcode:master
Sep 1, 2017
|
(Ariana reviewed, I just merged) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sarken commentedAug 30, 2017
Issue
https://otwarchive.atlassian.net/browse/AO3-5133
Purpose
If you imported a multi-chapter work as a draft and tried to use the Post Draft option on your drafts page, the first chapter would not be posted, making the work inaccessible to anyone other than you. This is because importing URLs as chapters creates the chapters in an unexpected order, and it was interacting badly with the
post_first_chaptermethod.For example, here is an unposted work:
And here are its chapters:
Notice that the chapter with
position: 1is actually the second chapter if you order by id.This led to problems with the
post_first_chaptermethod in the work model, which usedself.chapters.firstto determine the first chapter. Switching toself.first_chaptermeans we'll now useself.chapters.firston new records, but that we'll check the chapter positions on existing drafts to make sure we're getting the chapter that will display first on the work.Testing
Refer to JIRA