diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/requests/api/commits_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/requests/api/commits_spec.rb')
-rw-r--r-- | spec/requests/api/commits_spec.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 21ff0a94db9..d34244771ad 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -367,10 +367,31 @@ RSpec.describe API::Commits do end end - it 'does not increment the usage counters using access token authentication' do - expect(::Gitlab::UsageDataCounters::WebIdeCounter).not_to receive(:increment_commits_count) + context 'when using access token authentication' do + it 'does not increment the usage counters' do + expect(::Gitlab::UsageDataCounters::WebIdeCounter).not_to receive(:increment_commits_count) + expect(::Gitlab::UsageDataCounters::EditorUniqueCounter).not_to receive(:track_web_ide_edit_action) - post api(url, user), params: valid_c_params + post api(url, user), params: valid_c_params + end + end + + context 'when using warden' do + it 'increments usage counters', :clean_gitlab_redis_shared_state do + session_id = Rack::Session::SessionId.new('6919a6f1bb119dd7396fadc38fd18d0d') + session_hash = { 'warden.user.user.key' => [[user.id], user.encrypted_password[0, 29]] } + + Gitlab::Redis::SharedState.with do |redis| + redis.set("session:gitlab:#{session_id.private_id}", Marshal.dump(session_hash)) + end + + cookies[Gitlab::Application.config.session_options[:key]] = session_id.public_id + + expect(::Gitlab::UsageDataCounters::WebIdeCounter).to receive(:increment_commits_count) + expect(::Gitlab::UsageDataCounters::EditorUniqueCounter).to receive(:track_web_ide_edit_action) + + post api(url), params: valid_c_params + end end context 'a new file in project repo' do |