Skip to content

Commit

Permalink
add spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Sep 22, 2018
1 parent bb27524 commit 9672e97
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions spec/controllers/items_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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_success
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

0 comments on commit 9672e97

Please sign in to comment.