gitlab-org--gitlab-foss/spec/requests/api/doorkeeper_access_spec.rb
Jeroen van Baarsen 0c4a70a306 Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-12 19:17:35 +01:00

31 lines
904 B
Ruby

require 'spec_helper'
describe API::API, api: true do
include ApiHelpers
let!(:user) { create(:user) }
let!(:application) { Doorkeeper::Application.create!(:name => "MyApp", :redirect_uri => "https://app.com", :owner => user) }
let!(:token) { Doorkeeper::AccessToken.create! :application_id => application.id, :resource_owner_id => user.id }
describe "when unauthenticated" do
it "returns authentication success" do
get api("/user"), :access_token => token.token
expect(response.status).to eq(200)
end
end
describe "when token invalid" do
it "returns authentication error" do
get api("/user"), :access_token => "123a"
expect(response.status).to eq(401)
end
end
describe "authorization by private token" do
it "returns authentication success" do
get api("/user", user)
expect(response.status).to eq(200)
end
end
end