adds more functionality to spending proposal importer
This commit is contained in:
@@ -1,16 +1,7 @@
|
|||||||
class SpendingProposalsImporter
|
class SpendingProposalsImporter
|
||||||
|
|
||||||
def import(sp)
|
def import(sp)
|
||||||
# feasibility
|
# votes
|
||||||
# unfeasibility_explanation
|
|
||||||
# heading_id
|
|
||||||
# valuator_assignments_count
|
|
||||||
# hidden_at
|
|
||||||
# comments_count
|
|
||||||
# group_id
|
|
||||||
# budget_id
|
|
||||||
# duration
|
|
||||||
|
|
||||||
# comments
|
# comments
|
||||||
|
|
||||||
budget = Budget.last || Budget.create!(name: Date.today.year.to_s, currency_symbol: "€")
|
budget = Budget.last || Budget.create!(name: Date.today.year.to_s, currency_symbol: "€")
|
||||||
@@ -35,7 +26,7 @@ class SpendingProposalsImporter
|
|||||||
'undecided'
|
'undecided'
|
||||||
end
|
end
|
||||||
|
|
||||||
Budget::Investment.create!(
|
investment = Budget::Investment.create!(
|
||||||
heading_id: heading.id,
|
heading_id: heading.id,
|
||||||
author_id: sp.author_id,
|
author_id: sp.author_id,
|
||||||
administrator_id: sp.administrator_id,
|
administrator_id: sp.administrator_id,
|
||||||
@@ -45,7 +36,9 @@ class SpendingProposalsImporter
|
|||||||
price: sp.price,
|
price: sp.price,
|
||||||
price_explanation: sp.price_explanation,
|
price_explanation: sp.price_explanation,
|
||||||
internal_comments: sp.internal_comments,
|
internal_comments: sp.internal_comments,
|
||||||
|
duration: sp.time_scope,
|
||||||
feasibility: feasibility,
|
feasibility: feasibility,
|
||||||
|
unfeasibility_explanation: sp.feasible_explanation,
|
||||||
valuation_finished: sp.valuation_finished,
|
valuation_finished: sp.valuation_finished,
|
||||||
price_first_year: sp.price_first_year,
|
price_first_year: sp.price_first_year,
|
||||||
cached_votes_up: sp.cached_votes_up,
|
cached_votes_up: sp.cached_votes_up,
|
||||||
@@ -55,6 +48,10 @@ class SpendingProposalsImporter
|
|||||||
responsible_name: sp.responsible_name,
|
responsible_name: sp.responsible_name,
|
||||||
terms_of_service: "1"
|
terms_of_service: "1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
investment.valuators = sp.valuation_assignments.map(&:valuator)
|
||||||
|
|
||||||
|
investment
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,5 +61,18 @@ describe SpendingProposalsImporter do
|
|||||||
expect(importer.import(feasible).feasibility).to eq('feasible')
|
expect(importer.import(feasible).feasibility).to eq('feasible')
|
||||||
expect(importer.import(unfeasible).feasibility).to eq('unfeasible')
|
expect(importer.import(unfeasible).feasibility).to eq('unfeasible')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "Imports valuation assignments" do
|
||||||
|
sp = create(:spending_proposal)
|
||||||
|
peter = create(:valuator)
|
||||||
|
john = create(:valuator)
|
||||||
|
sp.valuators << peter << john
|
||||||
|
|
||||||
|
inv = importer.import(sp)
|
||||||
|
|
||||||
|
expect(inv.valuator_assignments.count).to eq(2)
|
||||||
|
expect(inv.valuators).to include(peter)
|
||||||
|
expect(inv.valuators).to include(john)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user