about summary refs log tree commit diff
path: root/spec/models/tag_spec.rb
diff options
context:
space:
mode:
authormasarakki <masaki182@gmail.com>2017-07-14 18:02:49 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-07-14 11:02:49 +0200
commita49be27145a858a51e1b9104b0ebc5f63a03b81b (patch)
tree8337aa515bdf3aea8124e6404eb4fb1177ba5c2c /spec/models/tag_spec.rb
parent27b2355738482a2e470281136bfe902ad6c78db8 (diff)
add validation to tag name (#4194)
Diffstat (limited to 'spec/models/tag_spec.rb')
-rw-r--r--spec/models/tag_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb
index 555474c44..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 }