diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 15:40:28 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 15:40:28 +0000 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/controllers/profiles | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) | |
download | gitlab-ce-b595cb0c1dec83de5bdee18284abe86614bed33b.tar.gz |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/controllers/profiles')
-rw-r--r-- | spec/controllers/profiles/emails_controller_spec.rb | 6 | ||||
-rw-r--r-- | spec/controllers/profiles/personal_access_tokens_controller_spec.rb | 37 |
2 files changed, 40 insertions, 3 deletions
diff --git a/spec/controllers/profiles/emails_controller_spec.rb b/spec/controllers/profiles/emails_controller_spec.rb index b63db831462..818aba77354 100644 --- a/spec/controllers/profiles/emails_controller_spec.rb +++ b/spec/controllers/profiles/emails_controller_spec.rb @@ -20,9 +20,9 @@ RSpec.describe Profiles::EmailsController do before do allowed_threshold = Gitlab::ApplicationRateLimiter.rate_limits[action][:threshold] - allow(Gitlab::ApplicationRateLimiter) - .to receive(:increment) - .and_return(allowed_threshold + 1) + allow_next_instance_of(Gitlab::ApplicationRateLimiter::BaseStrategy) do |strategy| + allow(strategy).to receive(:increment).and_return(allowed_threshold + 1) + end end it 'does not send any email' do diff --git a/spec/controllers/profiles/personal_access_tokens_controller_spec.rb b/spec/controllers/profiles/personal_access_tokens_controller_spec.rb index 48c747bf074..aafea0050d3 100644 --- a/spec/controllers/profiles/personal_access_tokens_controller_spec.rb +++ b/spec/controllers/profiles/personal_access_tokens_controller_spec.rb @@ -65,5 +65,42 @@ RSpec.describe Profiles::PersonalAccessTokensController do scopes: contain_exactly(:api, :read_user) ) end + + context "access_token_pagination feature flag is enabled" do + before do + stub_feature_flags(access_token_pagination: true) + allow(Kaminari.config).to receive(:default_per_page).and_return(1) + create(:personal_access_token, user: user) + end + + it "returns paginated response" do + get :index, params: { page: 1 } + expect(assigns(:active_personal_access_tokens).count).to eq(1) + end + + it 'adds appropriate headers' do + get :index, params: { page: 1 } + expect_header('X-Per-Page', '1') + expect_header('X-Page', '1') + expect_header('X-Next-Page', '2') + expect_header('X-Total', '2') + end + end + + context "access_token_pagination feature flag is disabled" do + before do + stub_feature_flags(access_token_pagination: false) + create(:personal_access_token, user: user) + end + + it "returns all tokens in system" do + get :index, params: { page: 1 } + expect(assigns(:active_personal_access_tokens).count).to eq(2) + end + end + end + + def expect_header(header_name, header_val) + expect(response.headers[header_name]).to eq(header_val) end end |