added specs for changing rates order

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@217 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
rkh 15 years ago
parent 1adf8f062e
commit a6e3bf046d
  1. 12
      spec/models/cost_entry_spec.rb
  2. 20
      spec/models/time_entry_spec.rb

@ -79,5 +79,17 @@ describe CostEntry do
@example.reload
@example.costs.should == rates("cheap_five").rate
end
it "should be able to change order of rates (sorted by valid_from)" do
cheap_one = rates("cheap_one")
cheap_three = rates("cheap_three")
@example.spent_on = cheap_one.valid_from
@example.save!
@example.rate.should == cheap_one
cheap_one.valid_from = cheap_three.valid_from - 1.day
cheap_one.save!
@example.reload
@example.rate.should == cheap_three
end
end

@ -42,7 +42,7 @@ describe TimeEntry do
@example.save!
@example.costs.should == rates("hourly_one").rate
hourly = HourlyRate.create! :valid_from => 1.day.ago, :rate => 1.0,
:user => User.current, :project => rates("hourly_one").project
:user => User.current, :project => rates("hourly_one").project
@example.reload
@example.rate.should_not == rates("hourly_one")
@example.costs.should == hourly.rate
@ -55,7 +55,7 @@ describe TimeEntry do
@example.save!
@example.costs.should == rates("hourly_three").rate
hourly = HourlyRate.create! :valid_from => 3.days.ago.to_date, :rate => 1.0,
:user => User.current, :project => rates("hourly_one").project
:user => User.current, :project => rates("hourly_one").project
@example.reload
@example.rate.should_not == rates("hourly_three")
@example.costs.should == hourly.rate
@ -84,6 +84,18 @@ describe TimeEntry do
@example.costs.should == rates("hourly_five").rate
end
it "should be able to change order of rates (sorted by valid_from)" do
hourly_one = rates("hourly_one")
hourly_three = rates("hourly_three")
@example.spent_on = hourly_one.valid_from
@example.save!
@example.rate.should == hourly_one
hourly_one.valid_from = hourly_three.valid_from - 1.day
hourly_one.save!
@example.reload
@example.rate.should == hourly_three
end
end
describe "default rate" do
@ -142,12 +154,12 @@ describe TimeEntry do
@default_example.reload
@default_example.costs.should == rates("default_hourly_five").rate
end
it "shoud be able to switch between default hourly rate and hourly rate" do
user = users("john")
@default_example.rate.should == rates("default_hourly_one")
rate = HourlyRate.create! :valid_from => 10.days.ago.to_date, :rate => 1337.0, :user => user,
:project => rates("hourly_one").project
:project => rates("hourly_one").project
@default_example.reload
@default_example.rate.should == rate
rate.destroy

Loading…
Cancel
Save