Files
onemdm-server/spec/controllers/apps_controller_spec.rb
leenasn 879a0f49e1 Add API for App Index
- Add tests for unauthorised response for APIs which require authentication
2015-11-23 12:05:45 +05:30

27 lines
638 B
Ruby

require 'rails_helper'
RSpec.describe AppsController, type: :controller do
context "With Authentication" do
let(:device){create(:device)}
before(:each) do
request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(device.access_token)
end
it "#index" do
expect(App).to receive(:all)
get :index, format: :json
expect(response).to have_http_status(:ok)
end
end
context "Without Authentication" do
it "#index" do
get :index, format: :json
expect(response).to have_http_status(:unauthorized)
end
end
end