about summary refs log tree commit diff
path: root/spec/models/tag_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/tag_spec.rb')
-rw-r--r--spec/models/tag_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb
index 7c574eabe..f727fa1dd 100644
--- a/spec/models/tag_spec.rb
+++ b/spec/models/tag_spec.rb
@@ -1,6 +1,24 @@
 require 'rails_helper'
 
 RSpec.describe Tag, type: :model do
+  describe 'validations' do
+    it 'invalid with #' do
+      expect(Tag.new(name: '#hello_world')).to_not be_valid
+    end
+
+    it 'invalid with .' do
+      expect(Tag.new(name: '.abcdef123')).to_not be_valid
+    end
+
+    it 'invalid with spaces' do
+      expect(Tag.new(name: 'hello world')).to_not be_valid
+    end
+
+    it 'valid with aesthetic' do
+      expect(Tag.new(name: 'aesthetic')).to be_valid
+    end
+  end
+
   describe 'HASHTAG_RE' do
     subject { Tag::HASHTAG_RE }
 
@@ -27,6 +45,15 @@ RSpec.describe Tag, type: :model do
       expect(results).to eq [tag]
     end
 
+    it 'finds tag records in case insensitive' do
+      tag = Fabricate(:tag, name: "MATCH")
+      _miss_tag = Fabricate(:tag, name: "miss")
+
+      results = Tag.search_for("match")
+
+      expect(results).to eq [tag]
+    end
+
     it 'finds the exact matching tag as the first item' do
       similar_tag = Fabricate(:tag, name: "matchlater")
       tag = Fabricate(:tag, name: "match")