diff options
author | Rémy Coutable <remy@rymai.me> | 2017-04-28 15:05:06 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-28 15:05:06 +0000 |
commit | 93e83afb39aa83d498fee1ebcab422b517ae6ba7 (patch) | |
tree | 80e9adb916f908317fc3fd80827c2ea3c6510958 /spec/controllers | |
parent | 2bd552041661ad1f2e5364a643a21d1419a9e6b3 (diff) | |
parent | c277b2c34d4ce03ad60511982fa16a22afbade06 (diff) | |
download | gitlab-ce-93e83afb39aa83d498fee1ebcab422b517ae6ba7.tar.gz |
Merge branch 'dz-add-oauth-controller-spec' into 'master'
Add tests for Oauth::AuthorizationsController
See merge request !10982
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/oauth/authorizations_controller_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb new file mode 100644 index 00000000000..d321bfcea9d --- /dev/null +++ b/spec/controllers/oauth/authorizations_controller_spec.rb @@ -0,0 +1,55 @@ +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 + + expect(response).to have_http_status(200) + expect(response).to render_template('doorkeeper/authorizations/error') + end + end + + context 'with valid params' do + it 'returns 200 code and renders view' do + get :new, params + + expect(response).to have_http_status(200) + expect(response).to render_template('doorkeeper/authorizations/new') + end + + it 'deletes session.user_return_to and redirects when skip authorization' do + request.session['user_return_to'] = 'http://example.com' + allow(controller).to receive(:skip_authorization?).and_return(true) + + get :new, params + + expect(request.session['user_return_to']).to be_nil + expect(response).to have_http_status(302) + end + end + end +end |