Skip to content

Commit

Permalink
AO3-6626 test all forbidden characters
Browse files Browse the repository at this point in the history
  • Loading branch information
nikobee committed Nov 20, 2023
1 parent 250b48f commit 2243127
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions spec/models/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
expect(@fandom_tag.taggings_count).to eq 1
end

it 'will start caching a when tag when that tag is used significantly' do
it 'will start caching a tag when that tag is used significantly' do

Check warning on line 52 in spec/models/tag_spec.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. Raw Output: spec/models/tag_spec.rb:52:10: C: Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
(1..ArchiveConfig.TAGGINGS_COUNT_MIN_CACHE_COUNT).each do |try|
FactoryBot.create(:work, fandom_string: @fandom_tag.name)
RedisJobSpawner.perform_now("TagCountUpdateJob")
Expand Down Expand Up @@ -168,11 +168,15 @@ def expect_tag_update_flag_in_redis_to_be(flag)
expect(tag.errors[:name].join).to match(/too long/)
end

it "should not be valid with disallowed characters" do
tag = Tag.new
tag.name = "bad<tag"
expect(tag.save).to be_falsey
expect(tag.errors[:name].join).to match(/restricted characters/)
context "tags using restricted characters should not be saved" do
BAD_TAGS.each do |tag|
forbidden_tag = Tag.new
forbidden_tag.name = tag
it "is not saved and receives an error message about restricted characters" do
expect(forbidden_tag.save).to be_falsey
expect(forbidden_tag.errors[:name].join).to match(/restricted characters/)
end
end
end

context "unwrangleable" do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
config.use_transactional_fixtures = true

BAD_EMAILS = ["Abc.example.com", "A@b@c@example.com", 'a\"b(c)d,e:f;g<h>i[j\k]l@example.com', 'this is"not\allowed@example.com', 'this\ still\"not/\/\allowed@example.com', "nodomain", "foo@oops", "ast*risk@example.com", "asterisk@ex*ample.com"].freeze
BAD_TAGS = [ "bad, tag", "also, bad", "no、good", "wild*card", "lesser<tag", "greater>tag", "^tag", "{open", "close}", "not=allowed", "suspicious`character", "no%maths" ]

Check warning on line 140 in spec/spec_helper.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Do not define constants this way within a block. Raw Output: spec/spec_helper.rb:140:3: W: Lint/ConstantDefinitionInBlock: Do not define constants this way within a block.

Check warning on line 140 in spec/spec_helper.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Freeze mutable objects assigned to constants. Raw Output: spec/spec_helper.rb:140:14: C: Style/MutableConstant: Freeze mutable objects assigned to constants.

Check warning on line 140 in spec/spec_helper.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Do not use space inside array brackets. Raw Output: spec/spec_helper.rb:140:15: C: Layout/SpaceInsideArrayLiteralBrackets: Do not use space inside array brackets.

Check warning on line 140 in spec/spec_helper.rb

View workflow job for this annotation

GitHub Actions / Rubocop

[rubocop] reported by reviewdog 🐶 Do not use space inside array brackets. Raw Output: spec/spec_helper.rb:140:170: C: Layout/SpaceInsideArrayLiteralBrackets: Do not use space inside array brackets.
INVALID_URLS = %w[no_scheme.com ftp://ftp.address.com http://www.b@d!35.com https://www.b@d!35.com http://b@d!35.com https://www.b@d!35.com].freeze
VALID_URLS = %w[http://rocksalt-recs.livejournal.com/196316.html https://rocksalt-recs.livejournal.com/196316.html].freeze
INACTIVE_URLS = %w[https://www.iaminactive.com http://www.iaminactive.com https://iaminactive.com http://iaminactive.com].freeze
Expand Down

0 comments on commit 2243127

Please sign in to comment.