Sha256: c5aa066b1374c58a1abd952a06056902d535a4a037bc4243cffab4cf552f905b

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

require 'rails_helper'

class MyAccept < Accept
  include EnjuCirculation::EnjuAccept
end

describe EnjuCirculation::EnjuAccept do
  fixtures :all

  it "should successfully accept" do
    accept = MyAccept.new(FactoryBot.attributes_for(:accept))
    expect(accept.item).to be_truthy
    expect(accept.item.circulation_status.name).to eq "In Process"
    accept.save!
    expect(accept.item.circulation_status.name).to eq "Available On Shelf"
    expect(accept.item.use_restriction.name).to eq "Limited Circulation, Normal Loan Period"
  end

  it "should reflect to items list", solr: true do
    FactoryBot.create(:item)
    FactoryBot.create(:item)
    FactoryBot.create(:item)
    result = Item.search.build { facet :circulation_status }.execute
    inprocess_count = result.facet(:circulation_status).rows.find{|e| e.value == "In Process" }.count
    onshelf_count = result.facet(:circulation_status).rows.find{|e| e.value == "Available On Shelf" }.try(:count) || 0
    accept = MyAccept.new(FactoryBot.attributes_for(:accept))
    accept.save!
    result = Item.search.build { facet :circulation_status }.execute
    expect(result.facet(:circulation_status).rows.find{|e| e.value == "In Process" }.count).to eq inprocess_count
    expect(result.facet(:circulation_status).rows.find{|e| e.value == "Available On Shelf" }.try(:count)).to eq onshelf_count + 1
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
enju_circulation-0.3.3 spec/concerns/enju_accept_spec.rb
enju_circulation-0.3.2 spec/concerns/enju_accept_spec.rb