Sha256: 81e24a6e4608f7317a722881128f31e9665b13328919e34c35c5ca26e3af088d

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'rails_helper'

describe ItemsController do
  fixtures :all

  def valid_attributes
    FactoryBot.attributes_for(:item)
  end

  describe 'GET index', solr: true do
    before do
      Item.reindex
    end

    describe 'When logged in as Librarian' do
      login_fixture_librarian

      it 'should not get index with inventory_file_id' do
        get :index, params: { inventory_file_id: 1 }
        expect(response).to be_successful
        assigns(:inventory_file).should eq InventoryFile.find(1)
        expect(assigns(:items)).to eq Item.inventory_items(assigns(:inventory_file), 'not_on_shelf').order('items.id').page(1)
      end
    end

    describe 'When logged in as User' do
      login_fixture_user

      it 'should not get index with inventory_file_id' do
        get :index, params: { inventory_file_id: 1 }
        expect(response).to be_forbidden
      end
    end

    describe 'When not logged in' do

      it 'should not get index with inventory_file_id' do
        get :index, params: { inventory_file_id: 1 }
        expect(response).to redirect_to new_user_session_url
        assigns(:inventory_file).should_not be_nil
      end
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
enju_inventory-0.3.1 spec/controllers/items_controller_spec.rb
enju_inventory-0.4.0.rc.1 spec/controllers/items_controller_spec.rb