From eb169ca4350813c06845c5ab5d1cd1d4e93f5d9f Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 5 Feb 2019 16:19:54 +0100 Subject: [PATCH] Add models tag spec with 160 chars --- app/models/tag.rb | 2 ++ spec/factories/classifications.rb | 8 +++++++- spec/models/tag_spec.rb | 10 ++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 app/models/tag.rb diff --git a/app/models/tag.rb b/app/models/tag.rb new file mode 100644 index 000000000..ef3d4af06 --- /dev/null +++ b/app/models/tag.rb @@ -0,0 +1,2 @@ +class Tag < ActsAsTaggableOn::Tag +end diff --git a/spec/factories/classifications.rb b/spec/factories/classifications.rb index ecb608b99..e905ea3d4 100644 --- a/spec/factories/classifications.rb +++ b/spec/factories/classifications.rb @@ -1,5 +1,5 @@ FactoryBot.define do - factory :tag, class: 'ActsAsTaggableOn::Tag' do + factory :tag, class: "ActsAsTaggableOn::Tag" do sequence(:name) { |n| "Tag #{n} name" } trait :category do @@ -7,6 +7,12 @@ FactoryBot.define do end end + factory :tagging, class: "ActsAsTaggableOn::Tagging" do + context "tags" + association :taggable, factory: :proposal + tag + end + factory :topic do sequence(:title) { |n| "Topic title #{n}" } sequence(:description) { |n| "Description as comment #{n}" } diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 91897fd4e..3346ff7d8 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Tag do @@ -28,4 +28,10 @@ describe Tag do expect(tag.taggings_count).to eq(0) end -end \ No newline at end of file + describe "name validation" do + it "160 char name should be valid" do + tag = build(:tag, name: Faker::Lorem.characters(160)) + expect(tag).to be_valid + end + end +end