Files
nairobi/spec/lib/tasks/budgets_spec.rb
voodoorai2000 71e6c5713a Add rake task to set the original_heading_id value
By default we want this attribute to be the current heading id for existing investments. If there have been reclassifications, this field should be updated accordingly.
2019-09-12 16:49:01 +02:00

23 lines
537 B
Ruby

require "rails_helper"
describe Budget do
let(:run_rake_task) do
Rake.application.invoke_task("budgets:set_original_heading_id")
end
it "sets attribute original_heading_id for existing investments" do
heading = create(:budget_heading)
investment = create(:budget_investment, heading: heading)
investment.update(original_heading_id: nil)
expect(investment.original_heading_id).to equal(nil)
run_rake_task
investment.reload
expect(investment.original_heading_id).to equal(heading.id)
end
end