Use traits instead of methods to create headings

This commit is contained in:
Javi Martín
2019-09-27 20:23:50 +02:00
parent 1973c61552
commit c15b58f927
2 changed files with 10 additions and 11 deletions

View File

@@ -79,6 +79,13 @@ FactoryBot.define do
trait :drafting_budget do
association :group, factory: [:budget_group, :drafting_budget]
end
trait :with_investment_with_milestone do
after(:create) do |heading|
investment = create(:budget_investment, :winner, heading: heading)
create(:milestone, milestoneable: investment)
end
end
end
factory :budget_investment, class: "Budget::Investment" do

View File

@@ -276,19 +276,11 @@ describe "Executions" do
end
context "Heading Order" do
def create_heading_with_investment_with_milestone(group:, name:)
heading = create(:budget_heading, group: group, name: name)
investment = create(:budget_investment, :winner, heading: heading)
milestone = create(:milestone, milestoneable: investment)
heading
end
scenario "Non-city headings are displayed in alphabetical order" do
heading.destroy!
z_heading = create_heading_with_investment_with_milestone(group: group, name: "Zzz")
a_heading = create_heading_with_investment_with_milestone(group: group, name: "Aaa")
m_heading = create_heading_with_investment_with_milestone(group: group, name: "Mmm")
z_heading = create(:budget_heading, :with_investment_with_milestone, group: group, name: "Zzz")
a_heading = create(:budget_heading, :with_investment_with_milestone, group: group, name: "Aaa")
m_heading = create(:budget_heading, :with_investment_with_milestone, group: group, name: "Mmm")
visit budget_executions_path(budget)