diff options
author | Rémy Coutable <remy@rymai.me> | 2019-09-11 08:19:02 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-09-11 08:19:02 +0000 |
commit | bfaa96d586668678893e295062495f2c35b73c2a (patch) | |
tree | 9b598b46a8e802ccc162f08b310c4ef1261442e2 /spec | |
parent | b88728e7b13fb193bc3a359e18f23b371bc93d16 (diff) | |
parent | 08c3e59aeed34ad71e74afb674ddda7327fdc3a7 (diff) | |
download | gitlab-ce-bfaa96d586668678893e295062495f2c35b73c2a.tar.gz |
Merge branch 'sh-fix-oauth-application-page' into 'master'
Optimize /admin/applications so that it does not timeout
Closes #67228
See merge request gitlab-org/gitlab-ce!32852
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin/applications_controller_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/oauth_access_token_spec.rb | 28 |
2 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/admin/applications_controller_spec.rb b/spec/controllers/admin/applications_controller_spec.rb index 9c9f658a0bd..2f3c7da484b 100644 --- a/spec/controllers/admin/applications_controller_spec.rb +++ b/spec/controllers/admin/applications_controller_spec.rb @@ -10,6 +10,16 @@ describe Admin::ApplicationsController do sign_in(admin) end + describe 'GET #index' do + render_views + + it 'renders the application form' do + get :index + + expect(response).to have_http_status(200) + end + end + describe 'GET #new' do it 'renders the application form' do get :new diff --git a/spec/models/oauth_access_token_spec.rb b/spec/models/oauth_access_token_spec.rb new file mode 100644 index 00000000000..0a1c576a5e7 --- /dev/null +++ b/spec/models/oauth_access_token_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe OauthAccessToken do + let(:user) { create(:user) } + let(:app_one) { create(:oauth_application) } + let(:app_two) { create(:oauth_application) } + let(:app_three) { create(:oauth_application) } + let(:tokens) { described_class.all } + + before do + create(:oauth_access_token, application_id: app_one.id) + create_list(:oauth_access_token, 2, resource_owner: user, application_id: app_two.id) + end + + it 'returns unique owners' do + expect(tokens.count).to eq(3) + expect(tokens.distinct_resource_owner_counts([app_one])).to eq({ app_one.id => 1 }) + expect(tokens.distinct_resource_owner_counts([app_two])).to eq({ app_two.id => 1 }) + expect(tokens.distinct_resource_owner_counts([app_three])).to eq({}) + expect(tokens.distinct_resource_owner_counts([app_one, app_two])) + .to eq({ + app_one.id => 1, + app_two.id => 1 + }) + end +end |