Skip to content

Commit

Permalink
specs laufen
Browse files Browse the repository at this point in the history
  • Loading branch information
Widu Wittekindt committed Mar 15, 2012
1 parent b7cdefb commit b1f03b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/booking.rb
Expand Up @@ -190,7 +190,7 @@ def not_to_long
end

def not_to_short
if machine && machine.min_duration
if machine && ends_at && starts_at
duration = ends_at - starts_at
text = I18n.t('human_time_units.' + machine.min_booking_time_unit, :count => machine.min_booking_time)
errors.add(:ends_at, :to_short, :min => text) if duration < machine.min_duration
Expand Down
6 changes: 3 additions & 3 deletions spec/models/booking_spec.rb
Expand Up @@ -89,8 +89,8 @@

describe "next and previous booking" do
before :each do
@booking1 = FactoryGirl.create(:booking, :starts_at => "2011-12-01 00:00:00", :ends_at => "2011-12-01 00:02:00")
@booking2 = FactoryGirl.create(:booking, :starts_at => "2011-12-01 00:02:00", :ends_at => "2011-12-01 00:05:00")
@booking1 = FactoryGirl.create(:booking, :starts_at => "2011-12-01 00:00:00", :ends_at => "2011-12-02 00:03:00")
@booking2 = FactoryGirl.create(:booking, :starts_at => "2011-12-01 00:02:00", :ends_at => "2011-12-02 00:05:00")
@booking3 = FactoryGirl.create(:booking, :starts_at => "2011-12-03 00:02:02", :ends_at => "2011-12-04 00:03:00", :machine => @booking1.machine)
end

Expand Down Expand Up @@ -335,7 +335,7 @@
it "is valid if a neede accessory is available n times, but not booked n times during the same period" do
@machine3 = FactoryGirl.create(:machine, :options => [@option1, @option2])
@booking3 = FactoryGirl.create(:booking, machine: @machine3, options: [@option2], starts_at: Time.now - 1.hour, ends_at: Time.now + 1.minute)
@booking2 = FactoryGirl.create(:booking, machine: @machine2, options: [@option2], starts_at: Time.now + 2.minutes, ends_at: Time.now + 1.hour)
@booking2 = FactoryGirl.create(:booking, machine: @machine2, options: [@option2], starts_at: Time.now + 2.minutes, ends_at: Time.now + 2.hour)
@booking = FactoryGirl.build(:booking, machine: @machine1, options: [@option2], starts_at: Time.now, ends_at: Time.now + 1.hour)
@booking.should be_valid
end
Expand Down

0 comments on commit b1f03b0

Please sign in to comment.