Skip to content

Commit

Permalink
Merge branch 'otwcode:master' into AO3-6834
Browse files Browse the repository at this point in the history
  • Loading branch information
minionluvr authored Nov 11, 2024
2 parents ce10aad + 6443729 commit 3bcead4
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ WARNING_NONE_TAG_DISPLAY_NAME: 'No Archive Warnings Apply'
WARNING_VIOLENCE_TAG_NAME: 'Graphic Depictions Of Violence'
WARNING_DEATH_TAG_NAME: 'Major Character Death'
WARNING_NONCON_TAG_NAME: 'Rape/Non-Con'
WARNING_CHAN_TAG_NAME: 'Underage'
WARNING_CHAN_TAG_NAME: 'Underage Sex'

RATING_CATEGORY_NAME: 'Rating'
RATING_DEFAULT_TAG_NAME: 'Not Rated'
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ services:
chrome:
profiles:
- test
image: selenium/standalone-chrome
image: selenium/standalone-chromium
ports:
- "4444:4444"
test:
Expand Down
5 changes: 5 additions & 0 deletions factories/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,9 @@
factory :banned do |f|
f.sequence(:name) { |n| "Banned #{n}" }
end

factory :archive_warning do |f|
f.sequence(:name) { |n| "Archive Warning #{n}" }
canonical { true }
end
end
2 changes: 1 addition & 1 deletion features/importing/work_import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Feature: Import Works
And I should see "Detected Title"
And I should see "Language: Deutsch"
And I should see "Explicit"
And I should see "Archive Warning: Underage"
And I should see "Archive Warning: Underage Sex"
And I should see "Fandom: Detected Fandom"
And I should see "Category: M/M"
And I should see "Relationship: Detected 1/Detected 2"
Expand Down
6 changes: 3 additions & 3 deletions features/search/works_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ Feature: Search works by tag

Scenario: Using the header search to exclude works with certain warnings using the warnings' filter_ids
Given a set of works with various warnings for searching
When I search for works without the "Rape/Non-Con" and "Underage" filter_ids
When I search for works without the "Rape/Non-Con" and "Underage Sex" filter_ids
Then the search summary should include the filter_id for "Rape/Non-Con"
And the search summary should include the filter_id for "Underage"
And the search summary should include the filter_id for "Underage Sex"
And I should see "5 Found"
And the results should not contain the warning tag "Underage"
And the results should not contain the warning tag "Underage Sex"
And the results should not contain the warning tag "Rape/Non-Con"

Scenario: Searching by category returns all works using that category; search
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/work_import_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

def content_fields
{
title: "Detected Title", summary: "Detected summary", fandoms: "Detected Fandom", warnings: "Underage",
title: "Detected Title", summary: "Detected summary", fandoms: "Detected Fandom", warnings: "Underage Sex",
characters: "Detected 1, Detected 2", rating: "Explicit", relationships: "Detected 1/Detected 2",
categories: "F/F", freeform: "Detected tag 1, Detected tag 2", external_author_name: "Detected Author",
external_author_email: "[email protected]", notes: "This is a <i>content note</i>.",
Expand Down
56 changes: 56 additions & 0 deletions lib/tasks/after_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,61 @@ namespace :After do
puts("Admin not found.")
end
end

desc "Add suffix to existing Underage Sex tag in prepartion for Underage warning rename"
task(add_suffix_to_underage_sex_tag: :environment) do
puts("Tags can only be renamed by an admin, who will be listed as the tag's last wrangler. Enter the admin login we should use:")
login = $stdin.gets.chomp.strip
admin = Admin.find_by(login: login)

if admin.present?
User.current_user = admin

tag = Tag.find_by_name("Underage Sex")

if tag.blank?
puts("No Underage Sex tag found.")
elsif tag.is_a?(ArchiveWarning)
puts("Underage Sex is already an Archive Warning.")
else
suffixed_name = "Underage Sex - #{tag.class}"
if tag.update(name: suffixed_name)
puts("Renamed Underage Sex tag to #{tag.reload.name}.")
else
puts("Failed to rename Underage Sex tag to #{suffixed_name}.")
end
$stdout.flush
end
else
puts("Admin not found.")
end
end

desc "Rename Underage warning to Underage Sex"
task(rename_underage_warning: :environment) do
puts("Tags can only be renamed by an admin, who will be listed as the tag's last wrangler. Enter the admin login we should use:")
login = $stdin.gets.chomp.strip
admin = Admin.find_by(login: login)

if admin.present?
User.current_user = admin

tag = ArchiveWarning.find_by_name("Underage")

if tag.blank?
puts("No Underage warning tag found.")
else
new_name = "Underage Sex"
if tag.update(name: new_name)
puts("Renamed Underage warning tag to #{tag.reload.name}.")
else
puts("Failed to rename Underage warning tag to #{new_name}.")
end
$stdout.flush
end
else
puts("Admin not found.")
end
end
# This is the end that you have to put new tasks above.
end
4 changes: 2 additions & 2 deletions public/help/warning-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h4>Warning Tags</h4>
The Archive of Our Own has chosen, for legal and other reasons, to mandate
that users either warn for&mdash;or explicitly choose not to warn for&mdash;a
short list of common warnings: Graphic Depictions of Violence, Major Character
Death, Rape/Non-Con, and Underage. We understand that creators may wish to not
Death, Rape/Non-Con, and Underage Sex. We understand that creators may wish to not
warn for some of these things, or to warn for additional content, and have
provided options for them to do so within this framework.
</p>
Expand Down Expand Up @@ -50,7 +50,7 @@ <h4>Warning Tags</h4>
"Choose Not to Use Archive Warnings" instead.
</dd>
<dt>
Underage:
Underage Sex:
</dt>
<dd>
This is for descriptions or depictions of sexual activity by characters
Expand Down
4 changes: 2 additions & 2 deletions public/help/work-search-text-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ <h5>Examples</h5>
<dd>will return all works from Fandom X tagged as F/F, and exclude those tagged Explicit</dd>
<dt><kbd>"Character A" OR "Character B" -"Character Death"</kbd></dt>
<dd>will return all works including Character A or Character B (or both), and no works tagged with "Character Death" in either the Warnings or the Additional tags</dd>
<dt><kbd>"Character A/Character B" Underage Mature OR Explicit</kbd></dt>
<dd>will return all works for this pairing that include an Underage warning and are either rated Mature or Explicit</dd>
<dt><kbd>"Character A/Character B" "Underage Sex" (Mature OR Explicit)</kbd></dt>
<dd>will return all works for this pairing that include an Underage Sex warning and are either rated Mature or Explicit</dd>
</dl>
2 changes: 1 addition & 1 deletion script/gift_exchange/tag_seed.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
"Graphic Depictions Of Violence",
"Major Character Death",
"Rape/Non-Con",
"Underage"
"Underage Sex"
]
}
2 changes: 1 addition & 1 deletion spec/controllers/api/api_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def valid_headers
# Values in API fake content
def content_fields
{
title: "Detected Title", summary: "Detected summary", fandoms: "Detected Fandom", warnings: "Underage",
title: "Detected Title", summary: "Detected summary", fandoms: "Detected Fandom", warnings: "Underage Sex",
characters: "Detected 1, Detected 2", rating: "Explicit", relationships: "Detected 1/Detected 2",
categories: "F/F", freeform: "Detected tag 1, Detected tag 2", external_author_name: "Detected Author",
external_author_email: "[email protected]", notes: "This is a <i>content note</i>.",
Expand Down
111 changes: 111 additions & 0 deletions spec/lib/tasks/after_tasks.rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,114 @@
end
end
end

describe "rake After:add_suffix_to_underage_sex_tag" do
let(:prompt) { "Tags can only be renamed by an admin, who will be listed as the tag's last wrangler. Enter the admin login we should use:\n" }

context "without a valid admin" do
it "puts an error without a valid admin" do
allow($stdin).to receive(:gets) { "no-admin" }

expect do
subject.invoke
end.to output("#{prompt}Admin not found.\n").to_stdout
end
end

context "with a valid admin" do
let!(:admin) { create(:admin, login: "admin") }

before do
allow($stdin).to receive(:gets) { "admin" }
tag = ArchiveWarning.find_by_name("Underage Sex")
tag.destroy!
end

it "puts an error if tag does not exist" do
expect do
subject.invoke
end.to output("#{prompt}No Underage Sex tag found.\n").to_stdout
end

it "puts an error if tag is an ArchiveWarning" do
tag = create(:archive_warning, name: "Underage Sex")

expect do
subject.invoke
end.to avoid_changing { tag.reload.name }
.and output("#{prompt}Underage Sex is already an Archive Warning.\n").to_stdout
end

it "puts a success message if tag exists and can be renamed" do
tag = create(:relationship, name: "Underage Sex")

expect do
subject.invoke
end.to change { tag.reload.name }
.from("Underage Sex")
.to("Underage Sex - Relationship")
.and output("#{prompt}Renamed Underage Sex tag to Underage Sex - Relationship.\n").to_stdout
end

it "puts an error if tag exists and cannot be renamed" do
tag = create(:freeform, name: "Underage Sex")
allow_any_instance_of(Tag).to receive(:save).and_return(false)

expect do
subject.invoke
end.to avoid_changing { tag.reload.name }
.and output("#{prompt}Failed to rename Underage Sex tag to Underage Sex - Freeform.\n").to_stdout
end
end
end

describe "rake After:rename_underage_warning" do
let(:prompt) { "Tags can only be renamed by an admin, who will be listed as the tag's last wrangler. Enter the admin login we should use:\n" }

context "without a valid admin" do
it "puts an error without a valid admin" do
allow($stdin).to receive(:gets) { "no-admin" }

expect do
subject.invoke
end.to output("#{prompt}Admin not found.\n").to_stdout
end
end

context "with a valid admin" do
let!(:admin) { create(:admin, login: "admin") }

before do
allow($stdin).to receive(:gets) { "admin" }
tag = ArchiveWarning.find_by_name("Underage Sex")
tag.destroy!
end

it "puts an error if tag does not exist" do
expect do
subject.invoke
end.to output("#{prompt}No Underage warning tag found.\n").to_stdout
end

it "puts a success message if tag exists and can be renamed" do
tag = create(:archive_warning, name: "Underage")

expect do
subject.invoke
end.to change { tag.reload.name }
.from("Underage")
.to("Underage Sex")
.and output("#{prompt}Renamed Underage warning tag to Underage Sex.\n").to_stdout
end

it "puts an error if tag exists and cannot be renamed" do
tag = create(:archive_warning, name: "Underage")
allow_any_instance_of(Tag).to receive(:save).and_return(false)

expect do
subject.invoke
end.to avoid_changing { tag.reload.name }
.and output("#{prompt}Failed to rename Underage warning tag to Underage Sex.\n").to_stdout
end
end
end
2 changes: 1 addition & 1 deletion test/fixtures/tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5629,7 +5629,7 @@ tag_1063754075:
id: 1063754075
type: Freeform
tag_1063753743:
name: Underage
name: Underage Sex
merger_id:
last_wrangler_type:
canonical: true
Expand Down

0 comments on commit 3bcead4

Please sign in to comment.