Add act_as_taggable_on milestoneable concern
This commit is contained in:
@@ -8,6 +8,8 @@ module Milestoneable
|
||||
|
||||
has_many :progress_bars, as: :progressable
|
||||
|
||||
acts_as_taggable_on :milestone_tags
|
||||
|
||||
def primary_progress_bar
|
||||
progress_bars.primary.first
|
||||
end
|
||||
|
||||
@@ -166,6 +166,10 @@ FactoryBot.define do
|
||||
trait :with_confirmed_hide do
|
||||
confirmed_hide_at { Time.current }
|
||||
end
|
||||
|
||||
trait :with_milestone_tags do
|
||||
after(:create) { |investment| investment.milestone_tags << create(:tag, :milestone) }
|
||||
end
|
||||
end
|
||||
|
||||
factory :budget_phase, class: "Budget::Phase" do
|
||||
|
||||
@@ -5,6 +5,10 @@ FactoryBot.define do
|
||||
trait :category do
|
||||
kind "category"
|
||||
end
|
||||
|
||||
trait :milestone do
|
||||
kind "milestone"
|
||||
end
|
||||
end
|
||||
|
||||
factory :tagging, class: "ActsAsTaggableOn::Tagging" do
|
||||
|
||||
@@ -112,6 +112,10 @@ FactoryBot.define do
|
||||
result_publication_enabled false
|
||||
published true
|
||||
end
|
||||
|
||||
trait :with_milestone_tags do
|
||||
after(:create) { |legislation| legislation.milestone_tags << create(:tag, :milestone) }
|
||||
end
|
||||
end
|
||||
|
||||
factory :legislation_draft_version, class: "Legislation::DraftVersion" do
|
||||
|
||||
@@ -66,6 +66,9 @@ FactoryBot.define do
|
||||
|
||||
trait :published do
|
||||
published_at { Time.current }
|
||||
|
||||
trait :with_milestone_tags do
|
||||
after(:create) { |proposal| proposal.milestone_tags << create(:tag, :milestone) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1267,6 +1267,27 @@ describe Budget::Investment do
|
||||
investment.valuators << valuator
|
||||
investment.administrator = administrator
|
||||
expect(investment.admin_and_valuator_users_associated).to eq([valuator, administrator])
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe "milestone_tags" do
|
||||
context "without milestone_tags" do
|
||||
let(:investment) {create(:budget_investment)}
|
||||
it "do not have milestone_tags" do
|
||||
expect(investment.milestone_tag_list).to eq([])
|
||||
expect(investment.milestone_tags).to eq([])
|
||||
end
|
||||
it "add a new milestone_tag" do
|
||||
investment.milestone_tag_list = "tag1,tag2"
|
||||
expect(investment.milestone_tag_list).to eq(["tag1", "tag2"])
|
||||
end
|
||||
end
|
||||
context "with milestone_tags" do
|
||||
let(:investment) {create(:budget_investment, :with_milestone_tags)}
|
||||
it "has milestone_tags" do
|
||||
expect(investment.milestone_tag_list.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -194,4 +194,24 @@ describe Legislation::Process do
|
||||
end
|
||||
end
|
||||
|
||||
describe "milestone_tags" do
|
||||
context "without milestone_tags" do
|
||||
let(:process) {create(:legislation_process)}
|
||||
it "do not have milestone_tags" do
|
||||
expect(process.milestone_tag_list).to eq([])
|
||||
expect(process.milestone_tags).to eq([])
|
||||
end
|
||||
it "add a new milestone_tag" do
|
||||
process.milestone_tag_list = "tag1,tag2"
|
||||
expect(process.milestone_tag_list).to eq(["tag1", "tag2"])
|
||||
end
|
||||
end
|
||||
context "with milestone_tags" do
|
||||
let(:process) {create(:legislation_process, :with_milestone_tags)}
|
||||
it "has milestone_tags" do
|
||||
expect(process.milestone_tag_list.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1084,4 +1084,32 @@ describe Proposal do
|
||||
|
||||
end
|
||||
|
||||
describe "milestone_tags" do
|
||||
|
||||
context "without milestone_tags" do
|
||||
|
||||
let(:proposal) {create(:proposal)}
|
||||
|
||||
it "do not have milestone_tags" do
|
||||
expect(proposal.milestone_tag_list).to eq([])
|
||||
expect(proposal.milestone_tags).to eq([])
|
||||
end
|
||||
|
||||
it "add a new milestone_tag" do
|
||||
proposal.milestone_tag_list = "tag1,tag2"
|
||||
|
||||
expect(proposal.milestone_tag_list).to eq(["tag1", "tag2"])
|
||||
end
|
||||
end
|
||||
|
||||
context "with milestone_tags" do
|
||||
|
||||
let(:proposal) {create(:proposal, :with_milestone_tags)}
|
||||
|
||||
it "has milestone_tags" do
|
||||
expect(proposal.milestone_tag_list.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user