OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/spec/models/variable_cost_object_spec.rb

49 lines
1.3 KiB

require File.dirname(__FILE__) + '/../spec_helper'
describe VariableCostObject do
let(:cost_object) { FactoryGirl.build(:variable_cost_object) }
let(:tracker) { FactoryGirl.create(:tracker_feature) }
let(:project) { FactoryGirl.create(:project_with_trackers) }
let(:user) { FactoryGirl.create(:user) }
describe 'recreate initial journal' do
before do
User.current = user
@variable_cost_object = FactoryGirl.create(:variable_cost_object , :project => project,
:author => user)
@initial_journal = @variable_cost_object.journals.first
@recreated_journal = @variable_cost_object.recreate_initial_journal!
end
it { @initial_journal.should be_identical(@recreated_journal) }
end
describe "initialization" do
let(:cost_object) { VariableCostObject.new }
before do
User.current = user
end
it { cost_object.author.should == user }
end
describe "destroy" do
let(:issue) { FactoryGirl.create(:issue) }
before do
cost_object.author = user
cost_object.issues = [issue]
cost_object.save!
cost_object.destroy
end
it { VariableCostObject.find_by_id(cost_object.id).should be_nil }
it { Issue.find_by_id(issue.id).should == issue }
it { issue.reload.cost_object.should be_nil }
end
end