diff --git a/spec/factories/classifications.rb b/spec/factories/classifications.rb index bea7599ca..df2ba4456 100644 --- a/spec/factories/classifications.rb +++ b/spec/factories/classifications.rb @@ -9,6 +9,14 @@ FactoryBot.define do trait :milestone do kind { "milestone" } end + + transient { taggables { [] } } + + after(:create) do |tag, evaluator| + evaluator.taggables.each do |taggable| + create(:tagging, tag: tag, taggable: taggable) + end + end end factory :tagging, class: "ActsAsTaggableOn::Tagging" do diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 95dea8cb8..59dad7137 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -4,8 +4,7 @@ describe Tag do it "decreases tag_count when a debate is hidden" do debate = create(:debate) - tag = create(:tag) - tagging = create(:tagging, tag: tag, taggable: debate) + tag = create(:tag, taggables: [debate]) expect(tag.taggings_count).to eq(1) @@ -17,8 +16,7 @@ describe Tag do it "decreases tag_count when a proposal is hidden" do proposal = create(:proposal) - tag = create(:tag) - tagging = create(:tagging, tag: tag, taggable: proposal) + tag = create(:tag, taggables: [proposal]) expect(tag.taggings_count).to eq(1)