Simplify taggings creation in specs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user