Sha256: 60a6838d0921455e0a552ac403df4aa1e59a1b3b81c0a03dff3c77c4dc68f58c

Contents?: true

Size: 1.22 KB

Versions: 33

Compression:

Stored size: 1.22 KB

Contents

# -*- encoding: utf-8 -*-
require 'spec_helper'

describe Basket do
  fixtures :all

  it "should not create basket when user is not active" do
    Basket.create(:user => users(:user4)).id.should be_nil
  end

  it "should not check out items that are already checked out" do
    items(:item_00021).checkouts.count.should eq 0
    basket_1 = Basket.new
    basket_1.user = users(:admin)
    basket_1.save
    checked_item_1 = basket_1.checked_items.new
    checked_item_1.item = items(:item_00011)
    checked_item_1.save
    basket_2 = Basket.new
    basket_2.user = users(:user1)
    basket_2.save
    checked_item_2 = basket_2.checked_items.new
    checked_item_2.item = items(:item_00011)
    checked_item_2.save
    basket_1.basket_checkout(users(:librarian1))
    lambda{basket_2.basket_checkout(users(:librarian1))}.should raise_exception ActiveRecord::RecordInvalid
    items(:item_00011).checkouts.first.user.should eq users(:admin)
  end
end

# == Schema Information
#
# Table name: baskets
#
#  id           :integer          not null, primary key
#  user_id      :integer
#  note         :text
#  lock_version :integer          default(0), not null
#  created_at   :datetime         not null
#  updated_at   :datetime         not null
#

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
enju_circulation-0.1.0.pre40 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre39 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre38 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre37 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre36 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre35 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre34 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre33 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre32 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre31 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre30 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre29 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre28 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre27 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre26 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre25 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre24 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre23 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre22 spec/models/basket_spec.rb
enju_circulation-0.1.0.pre21 spec/models/basket_spec.rb