rosa-build/spec/controllers/api/v1/search_controller_spec.rb

34 lines
818 B
Ruby
Raw Normal View History

2012-11-21 12:32:59 +00:00
require 'spec_helper'
shared_examples_for 'able search with api' do
it 'should be able to search' do
2014-01-21 04:51:49 +00:00
get :index, format: :json
expect(response).to be_success
expect(response).to render_template(:index)
2012-11-21 12:32:59 +00:00
end
end
shared_examples_for 'not able search with api' do
it 'should not be able to search' do
2014-01-21 04:51:49 +00:00
get :index, format: :json
expect(response.code).to eq('401')
2012-11-21 12:32:59 +00:00
end
end
2015-02-19 01:12:08 +00:00
describe Api::V1::SearchController, type: :controller do
2012-11-21 12:32:59 +00:00
before { stub_symlink_methods }
context 'as guest' do
if APP_CONFIG['anonymous_access']
it_should_behave_like 'able search with api'
else
it_should_behave_like 'not able search with api'
end
end
context 'as user' do
before {set_session_for FactoryGirl.create(:user)}
it_should_behave_like 'able search with api'
end
end