diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-10 21:09:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-10 21:09:11 +0000 |
commit | 696b36294520f8a311586f99e838b6a61b1b3f32 (patch) | |
tree | aa043fc07393643a80453a579c590fe437d02ead /spec/controllers/oauth | |
parent | c57e10faab0abb213e7a18274fd5a98ba87a5c09 (diff) | |
download | gitlab-ce-696b36294520f8a311586f99e838b6a61b1b3f32.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/oauth')
-rw-r--r-- | spec/controllers/oauth/applications_controller_spec.rb | 75 |
1 files changed, 64 insertions, 11 deletions
diff --git a/spec/controllers/oauth/applications_controller_spec.rb b/spec/controllers/oauth/applications_controller_spec.rb index 5f1f6af3999..09f8ad4332d 100644 --- a/spec/controllers/oauth/applications_controller_spec.rb +++ b/spec/controllers/oauth/applications_controller_spec.rb @@ -4,31 +4,82 @@ require 'spec_helper' describe Oauth::ApplicationsController do let(:user) { create(:user) } + let(:application) { create(:oauth_application, owner: user) } context 'project members' do before do sign_in(user) end - describe 'GET #index' do - it 'shows list of applications' do - get :index - - expect(response).to have_gitlab_http_status(:ok) + shared_examples 'redirects to login page when the user is not signed in' do + before do + sign_out(user) end - it 'redirects back to profile page if OAuth applications are disabled' do - disable_user_oauth + it { is_expected.to redirect_to(new_user_session_path) } + end + + describe 'GET #new' do + subject { get :new } + + it { is_expected.to have_gitlab_http_status(:ok) } + + it_behaves_like 'redirects to login page when the user is not signed in' + end + + describe 'DELETE #destroy' do + subject { delete :destroy, params: { id: application.id } } + + it { is_expected.to redirect_to(oauth_applications_url) } + + it_behaves_like 'redirects to login page when the user is not signed in' + end + + describe 'GET #edit' do + subject { get :edit, params: { id: application.id } } + + it { is_expected.to have_gitlab_http_status(:ok) } + + it_behaves_like 'redirects to login page when the user is not signed in' + end + + describe 'PUT #update' do + subject { put :update, params: { id: application.id, doorkeeper_application: { name: 'application' } } } + + it { is_expected.to redirect_to(oauth_application_url(application)) } + + it_behaves_like 'redirects to login page when the user is not signed in' + end + + describe 'GET #show' do + subject { get :show, params: { id: application.id } } + + it { is_expected.to have_gitlab_http_status(:ok) } + + it_behaves_like 'redirects to login page when the user is not signed in' + end + + describe 'GET #index' do + subject { get :index } + + it { is_expected.to have_gitlab_http_status(:ok) } - get :index + context 'when OAuth applications are disabled' do + before do + disable_user_oauth + end - expect(response).to have_gitlab_http_status(:ok) + it { is_expected.to have_gitlab_http_status(:ok) } end + + it_behaves_like 'redirects to login page when the user is not signed in' end describe 'POST #create' do + subject { post :create, params: oauth_params } + it 'creates an application' do - post :create, params: oauth_params + subject expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(oauth_application_path(Doorkeeper::Application.last)) @@ -37,7 +88,7 @@ describe Oauth::ApplicationsController do it 'redirects back to profile page if OAuth applications are disabled' do disable_user_oauth - post :create, params: oauth_params + subject expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(profile_path) @@ -59,6 +110,8 @@ describe Oauth::ApplicationsController do expect(response.body).to include 'Redirect URI is forbidden by the server' end end + + it_behaves_like 'redirects to login page when the user is not signed in' end end |