From 22431272c142d629bb84cee57ff4df1bb9507c65 Mon Sep 17 00:00:00 2001 From: nikobee Date: Mon, 20 Nov 2023 08:32:36 +0000 Subject: [PATCH] AO3-6626 test all forbidden characters --- spec/models/tag_spec.rb | 16 ++++++++++------ spec/spec_helper.rb | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 16daf57b9bb..fd186cab2ec 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -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 (1..ArchiveConfig.TAGGINGS_COUNT_MIN_CACHE_COUNT).each do |try| FactoryBot.create(:work, fandom_string: @fandom_tag.name) RedisJobSpawner.perform_now("TagCountUpdateJob") @@ -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 = "badi[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", "lessertag", "^tag", "{open", "close}", "not=allowed", "suspicious`character", "no%maths" ] 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