2015-12-21 17:51:49 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe APIController, type: :controller do
|
|
|
|
controller(APIController) do
|
|
|
|
def show
|
|
|
|
render json: {}, satus: 200
|
|
|
|
end
|
2016-11-15 04:24:09 +01:00
|
|
|
|
2015-12-21 17:51:49 +01:00
|
|
|
def index
|
|
|
|
render json: {}, satus: 200
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET index' do
|
|
|
|
context 'when token is missing' do
|
|
|
|
subject { get :index }
|
2016-11-15 04:24:09 +01:00
|
|
|
it { expect(subject.status).to eq(401) }
|
2015-12-21 17:51:49 +01:00
|
|
|
end
|
|
|
|
context 'when token does not exist' do
|
|
|
|
let(:token) { 'invalid_token' }
|
2016-11-15 04:24:09 +01:00
|
|
|
subject { get :index, params: {token: token} }
|
|
|
|
it { expect(subject.status).to eq(401) }
|
2015-12-21 17:51:49 +01:00
|
|
|
end
|
|
|
|
context 'when token exist' do
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
2016-11-15 04:24:09 +01:00
|
|
|
subject { get :index, params: {token: administrateur.api_token} }
|
|
|
|
it { expect(subject.status).to eq(200) }
|
2015-12-21 17:51:49 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|