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-6867 Increase tag name limit to 150 #4999

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TITLE_MIN: 1
SUMMARY_MAX: 1250
NOTES_MAX: 5000
COMMENT_MAX: 10000
TAG_MAX: 100
TAG_MAX: 150
CONTENT_MIN: 10
CONTENT_MAX: 510000
CONTENT_MAX_DISPLAYED: 500000
Expand Down
15 changes: 15 additions & 0 deletions db/migrate/20241221141135_increase_tag_name_limit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

class IncreaseTagNameLimit < ActiveRecord::Migration[7.0]
uses_departure! if Rails.env.staging? || Rails.env.production?

def up
change_column :tags, :name, :string, limit: 150
end

def down
# This is only safe to run if no users have created tags with names > 100 characters.
# Otherwise, tags wil need to be renamed first and _then_ this migration torn down.
change_column :tags, :name, :string, limit: 100
end
end
4 changes: 2 additions & 2 deletions features/works/work_create.feature
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ Feature: Create Works
And I press "Preview"
Then I should see "badcoauthor cannot be listed as a co-creator"
When I fill in "pseud_byline" with "coauthor"
And I fill in "Additional Tags" with "this is a very long tag more than one hundred characters in length how would this normally even be created"
And I fill in "Additional Tags" with "this is a very long tag more than one hundred fifty characters in length how would this normally even be created plus some extra words to pad this out 1"
And I press "Preview"
Then I should see "try using less than 100 characters or using commas to separate your tags"
Then I should see "try using less than 150 characters or using commas to separate your tags"
When I fill in "Additional Tags" with "this is a shorter tag"
And I press "Preview"
Then I should see "Draft was successfully created"
Expand Down
2 changes: 1 addition & 1 deletion public/help/relationships-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ <h4>Relationships Tags</h4>

<p>(For more information, see the <a href="/faq/tags">Tags on the Archive FAQ</a>.)</p>

<p>The relationships in your work. Full names are preferred (for example, "Mickey Mouse/Minnie Mouse" or "Rodney McKay & John Sheppard"). You may list more than one relationship, separated by commas. Please note that all user-created tags must be 100 characters or less; if your work contains a threesome (or a larger poly group) you may want to use first names only to avoid going over the character limit.</p>
<p>The relationships in your work. Full names are preferred (for example, "Mickey Mouse/Minnie Mouse" or "Rodney McKay & John Sheppard"). You may list more than one relationship, separated by commas. Please note that all user-created tags must be 150 characters or less; if your work contains a threesome (or a larger poly group) you may want to use first names only to avoid going over the character limit.</p>

14 changes: 4 additions & 10 deletions spec/models/tag_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# encoding: UTF-8
require 'spec_helper'
require "spec_helper"

describe Tag do
after(:each) do
User.current_user = nil
end

it { is_expected.not_to allow_values("", "a" * 151).for(:name) }

context "checking count caching" do
before(:each) do
# Set the minimal amount of time a tag can be cached for.
Expand Down Expand Up @@ -66,7 +67,7 @@
end

it "Writes to the database do not happen immediately" do
(1..40 * ArchiveConfig.TAGGINGS_COUNT_CACHE_DIVISOR - 1).each do |try|
(1..(40 * ArchiveConfig.TAGGINGS_COUNT_CACHE_DIVISOR) - 1).each do |try|
@fandom_tag.taggings_count = try
@fandom_tag.reload
expect(@fandom_tag.taggings_count_cache).to eq 0
Expand Down Expand Up @@ -161,13 +162,6 @@ def expect_tag_update_flag_in_redis_to_be(flag)
expect(tag.save).to be_truthy
end

it "should not be valid if too long" do
tag = Tag.new
tag.name = "a" * 101
expect(tag.save).not_to be_truthy
expect(tag.errors[:name].join).to match(/too long/)
end

context "tags using restricted characters should not be saved" do
[
"bad, tag",
Expand Down
Loading