debian-mirror-gitlab/spec/controllers/oauth/authorizations_controller_spec.rb

58 lines
1.3 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe Oauth::AuthorizationsController do
let(:user) { create(:user) }
let(:doorkeeper) do
Doorkeeper::Application.create(
name: "MyApp",
redirect_uri: 'http://example.com',
scopes: "")
end
let(:params) do
{
response_type: "code",
client_id: doorkeeper.uid,
redirect_uri: doorkeeper.redirect_uri,
state: 'state'
}
end
before do
sign_in(user)
end
describe 'GET #new' do
context 'without valid params' do
it 'returns 200 code and renders error view' do
get :new
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(200)
2017-08-17 22:00:37 +05:30
expect(response).to render_template('doorkeeper/authorizations/error')
end
end
context 'with valid params' do
2018-03-27 19:54:05 +05:30
render_views
2017-08-17 22:00:37 +05:30
it 'returns 200 code and renders view' do
get :new, params
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(200)
2017-08-17 22:00:37 +05:30
expect(response).to render_template('doorkeeper/authorizations/new')
end
it 'deletes session.user_return_to and redirects when skip authorization' do
2017-09-10 17:25:29 +05:30
doorkeeper.update(trusted: true)
2017-08-17 22:00:37 +05:30
request.session['user_return_to'] = 'http://example.com'
get :new, params
expect(request.session['user_return_to']).to be_nil
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(302)
2017-08-17 22:00:37 +05:30
end
end
end
end