Commit 271061a1 authored by alinamihaila's avatar alinamihaila

Add check for calling add in tests

parent f6f964a4
......@@ -14,7 +14,7 @@ module API
end
params do
requires :event, type: String, desc: 'The event name it should be tracked'
requires :event, type: String, desc: 'The event name that should be tracked'
end
post 'increment_unique_users' do
......
......@@ -11,7 +11,7 @@ RSpec.describe API::UsageData do
let(:unknown_event) { 'unknown' }
context 'usage_data_api feature not enabled' do
it 'retruns not_found' do
it 'returns not_found' do
stub_feature_flags(usage_data_api: false)
post api(endpoint, user), params: { event: known_event }
......@@ -31,6 +31,8 @@ RSpec.describe API::UsageData do
context 'with authentication' do
before do
stub_feature_flags(usage_data_api: true)
stub_feature_flags("usage_data_#{known_event}" => true)
stub_application_setting(usage_ping_enabled: true)
end
context 'when event is missing from params' do
......@@ -43,6 +45,8 @@ RSpec.describe API::UsageData do
context 'with correct params' do
it 'returns status ok' do
expect(Gitlab::Redis::HLL).to receive(:add)
post api(endpoint, user), params: { event: known_event }
expect(response).to have_gitlab_http_status(:ok)
......@@ -51,6 +55,8 @@ RSpec.describe API::UsageData do
context 'with unknown event' do
it 'returns status ok' do
expect(Gitlab::Redis::HLL).not_to receive(:add)
post api(endpoint, user), params: { event: unknown_event }
expect(response).to have_gitlab_http_status(:ok)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment