<commit_before># -*- encoding: utf-8 -*-
require 'spec_helper'

describe Item do
  #pending "add some examples to (or delete) #{__FILE__}"
  fixtures :all

  it "should be rent" do
    items(:item_00001).rent?.should be_truthy
  end

  it "should not be rent" do
    items(:item_00010).rent?.should be_falsy
  end

  it "should be checked out" do
    items(:item_00010).checkout!(users(:admin)).should be_truthy
    items(:item_00010).circulation_status.name.should eq 'On Loan'
  end

  it "should be checked in" do
    items(:item_00001).checkin!.should be_truthy
    items(:item_00001).circulation_status.name.should eq 'Available On Shelf'
  end

  it "should be retained" do
    old_count = MessageRequest.count
    items(:item_00013).retain(users(:librarian1)).should be_truthy
    items(:item_00013).reserves.first.state.should eq 'retained'
    MessageRequest.count.should eq old_count + 4
  end

  it "should not be checked out when it is reserved" do
    items(:item_00012).available_for_checkout?.should be_falsy
  end

  it "should have library_url" do
    items(:item_00001).library_url.should eq "#{LibraryGroup.site_config.url}libraries/web"
  end

  it "should not be able to checkout a removed item" do
    Item.for_checkout.include?(items(:item_00023)).should be_falsy
  end

  it "should update lending policies" do
    item = items(:item_00001)
    item.checkout_type = CheckoutType.where(:name => 'serial').first
    item.save
    item.reload
    item.lending_policies.where(:user_group_id => 1).first.loan_period.should eq 10
  end
end

# == Schema Information
#
# Table name: items
#
#  id                      :integer          not null, primary key
#  call_number             :string(255)
#  item_identifier         :string(255)
#  created_at              :datetime         not null
#  updated_at              :datetime         not null
#  deleted_at              :datetime
#  shelf_id                :integer          default(1), not null
#  include_supplements     :boolean          default(FALSE), not null
#  note                    :text
#  url                     :string(255)
#  price                   :integer
#  lock_version            :integer          default(0), not null
#  required_role_id        :integer          default(1), not null
#  required_score          :integer          default(0), not null
#  acquired_at             :datetime
#  bookstore_id            :integer
#  budget_type_id          :integer
#  circulation_status_id   :integer          default(5), not null
#  checkout_type_id        :integer          default(1), not null
#  binding_item_identifier :string(255)
#  binding_call_number     :string(255)
#  binded_at               :datetime
#  manifestation_id        :integer
#
<commit_msg>updated spec file<commit_after># -*- encoding: utf-8 -*-
require 'spec_helper'

describe Item do
  #pending "add some examples to (or delete) #{__FILE__}"
  fixtures :all

  it "should be rent" do
    items(:item_00001).rent?.should be_truthy
  end

  it "should not be rent" do
    items(:item_00010).rent?.should be_falsy
  end

  it "should be checked out" do
    items(:item_00010).checkout!(users(:admin)).should be_truthy
    items(:item_00010).circulation_status.name.should eq 'On Loan'
  end

  it "should be checked in" do
    items(:item_00001).checkin!.should be_truthy
    items(:item_00001).circulation_status.name.should eq 'Available On Shelf'
  end

  it "should be retained" do
    old_count = MessageRequest.count
    items(:item_00013).retain(users(:librarian1)).should be_truthy
    items(:item_00013).reserves.first.state.should eq 'retained'
    MessageRequest.count.should eq old_count + 4
  end

  it "should not be checked out when it is reserved" do
    items(:item_00012).available_for_checkout?.should be_falsy
  end

  it "should have library_url" do
    items(:item_00001).library_url.should eq "#{LibraryGroup.site_config.url}libraries/web"
  end

  it "should not be able to checkout a removed item" do
    Item.for_checkout.include?(items(:item_00023)).should be_falsy
  end

  it "should update lending policies" do
    item = items(:item_00001)
    item.checkout_type = CheckoutType.where(:name => 'serial').first
    item.save
    item.reload
    item.lending_policies.where(:user_group_id => 1).first.loan_period.should eq 10
  end

  it "should not create item without manifestation_id" do
    item = items(:item_00001)
    item.manifestation_id = nil
    item.valid?.should be_falsy
  end
end

# == Schema Information
#
# Table name: items
#
#  id                      :integer          not null, primary key
#  call_number             :string(255)
#  item_identifier         :string(255)
#  created_at              :datetime         not null
#  updated_at              :datetime         not null
#  deleted_at              :datetime
#  shelf_id                :integer          default(1), not null
#  include_supplements     :boolean          default(FALSE), not null
#  note                    :text
#  url                     :string(255)
#  price                   :integer
#  lock_version            :integer          default(0), not null
#  required_role_id        :integer          default(1), not null
#  required_score          :integer          default(0), not null
#  acquired_at             :datetime
#  bookstore_id            :integer
#  budget_type_id          :integer
#  circulation_status_id   :integer          default(5), not null
#  checkout_type_id        :integer          default(1), not null
#  binding_item_identifier :string(255)
#  binding_call_number     :string(255)
#  binded_at               :datetime
#  manifestation_id        :integer
#

{'fraction_non_alphanumeric': 0.09058802754723645, 'fraction_numerical': 0.03160868797457178, 'mean_word_length': 2.526774595267746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3481792', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1713, 'n_words': 447}