diff --git a/app/models/challenge_claim.rb b/app/models/challenge_claim.rb index ea104c56d03..5841ee42843 100755 --- a/app/models/challenge_claim.rb +++ b/app/models/challenge_claim.rb @@ -71,6 +71,8 @@ def self.order_by_offering_pseud(dir="ASC") CollectionItem.user_approval_statuses[:approved], CollectionItem.collection_approval_statuses[:approved]) } + # TODO: AO3-6024 for making sure we also exclude works hidden by admin + scope :work_visible_to_all, -> { where("works.restricted = 0") } scope :posted, -> { joins(WORKS_JOIN).where("challenge_claims.creation_id IS NOT NULL AND works.posted = 1") } diff --git a/app/models/prompt.rb b/app/models/prompt.rb index cdae4bb6a4a..9f18cef92d8 100755 --- a/app/models/prompt.rb +++ b/app/models/prompt.rb @@ -209,6 +209,9 @@ def fulfilled_claims self.request_claims.fulfilled end + def fulfilled_claims_visible_to_all + self.request_claims.fulfilled.work_visible_to_all + end # Computes the "full" tag set (tag_set + optional_tag_set), and stores the # result as an instance variable for speed. This is used by the matching # algorithm, which doesn't change any signup/prompt/tagset information, so diff --git a/app/views/prompts/_prompt_blurb.html.erb b/app/views/prompts/_prompt_blurb.html.erb index d4834502206..be901dc41e7 100755 --- a/app/views/prompts/_prompt_blurb.html.erb +++ b/app/views/prompts/_prompt_blurb.html.erb @@ -80,13 +80,15 @@ <% end %> <% # if prompt has been fulfilled list works %> - <% unless prompt.unfulfilled? %> + <% unless prompt.unfulfilled? || (guest? && prompt.fulfilled_claims_visible_to_all.empty?) %>
<%= ts("Fulfilled By")%>
diff --git a/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature b/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature index 106a38dbe52..ab084824435 100755 --- a/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature +++ b/features/prompt_memes_b/challenge_promptmeme_posting_fills.feature @@ -593,3 +593,22 @@ Feature: Prompt Meme Challenge And I uncheck "Battle 12 (prompter)" And I press "Update" Then I should see "For prompter." + + Scenario: When a prompt is filled with a restricted work, the work should only be visible to logged-in users + + Given I have Battle 12 prompt meme fully set up + And I am logged in as "myname1" + And I sign up for Battle 12 + And I am logged in as "myname2" + And I claim a prompt from "Battle 12" + And I start to fulfill my claim with "Restricted Fill" + And I lock the work + And I press "Post" + When I view prompts for "Battle 12" + Then I should see "Fulfilled By" + And I should see "Restricted Fill" + When I log out + And I go to "Battle 12" collection's page + And I follow "Prompts (" + Then I should not see "Fulfilled By" + And I should not see "Restricted Fill"