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

AO3-5338 Work factories should create posted works by default #3602

Open
wants to merge 1 commit into
base: master
from

Conversation

@dlhardin
Copy link
Contributor

dlhardin commented Aug 2, 2019

Issue

https://otwarchive.atlassian.net/browse/AO3-5338 (please fill in issue number and remove this comment)

Purpose

This changes the default output of the works factory to create posted works by default, rather than defaulting to drafts.

Testing Instructions

Existing tests work, factory unchanged except for default.

Credit

dlhardin she/her

Copy link
Member

sarken left a comment

Unfortunately, this is a little more complex than updating the factory file. Any test that uses the now-deleted posted_work factory will need to be changed to use the plain work factory instead.

@dlhardin

This comment has been minimized.

Copy link
Contributor Author

dlhardin commented Aug 2, 2019

Thanks for letting me learn on your project. I've dug into this more, and I see where I need to replace the FactoryGirl calls to :posted_work with :work. But I see another potential problem, as there are a number of existing tests that call :work, with the old default behavior of creating draft works.

Do these existing tests need to be altered to explicitly call :draft_work? If you're expecting certain tests to produce a draft there's a problem.

@redsummernight

This comment has been minimized.

Copy link
Member

redsummernight commented Aug 3, 2019

Thanks for taking this on!

Most of the existing tests that call :work should be using posted works. We do want the majority of the tests to use posted works by default. But yeah, there's a small number of them that actually need to use drafts.

Some of them are already using the draft factory:

draft = Delorean.time_travel_to 27.days.ago do
create(:draft)
end

and some explicitly set posted to false (can be changed to :draft to be more concise):

create(:work, authors: [drafts_user.default_pseud], posted: false, title: "Default pseud work")

There's no way to tell for sure if we're always using the draft factory where the tests expect drafts, but we can check to some extent by text-searching for "draft" and "unposted" in the spec/ and features/ directories. For example, I see this test which needs to be updated to use drafts:

let(:unposted_work) { create(:work, authors: [user.pseuds.first]) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.