Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/concerns')
-rw-r--r--spec/controllers/concerns/boards_responses_spec.rb23
-rw-r--r--spec/controllers/concerns/product_analytics_tracking_spec.rb44
-rw-r--r--spec/controllers/concerns/send_file_upload_spec.rb7
3 files changed, 32 insertions, 42 deletions
diff --git a/spec/controllers/concerns/boards_responses_spec.rb b/spec/controllers/concerns/boards_responses_spec.rb
deleted file mode 100644
index 553a547d42c..00000000000
--- a/spec/controllers/concerns/boards_responses_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe BoardsResponses do
- let(:controller_class) do
- Class.new do
- include BoardsResponses
- end
- end
-
- subject(:controller) { controller_class.new }
-
- describe '#serialize_as_json' do
- let!(:board) { create(:board) }
-
- it 'serializes properly' do
- expected = { "id" => board.id }
-
- expect(subject.serialize_as_json(board)).to include(expected)
- end
- end
-end
diff --git a/spec/controllers/concerns/product_analytics_tracking_spec.rb b/spec/controllers/concerns/product_analytics_tracking_spec.rb
index 2e734d81ea0..28b79a10624 100644
--- a/spec/controllers/concerns/product_analytics_tracking_spec.rb
+++ b/spec/controllers/concerns/product_analytics_tracking_spec.rb
@@ -51,15 +51,21 @@ RSpec.describe ProductAnalyticsTracking, :snowplow do
end
end
- def expect_tracking(user: self.user)
+ def expect_redis_hll_tracking
expect(Gitlab::UsageDataCounters::HLLRedisCounter).to have_received(:track_event)
.with('g_analytics_valuestream', values: instance_of(String))
+ end
+
+ def expect_snowplow_tracking(user)
+ context = Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: 'g_analytics_valuestream')
+ .to_context.to_json
expect_snowplow_event(
category: anything,
action: 'g_analytics_valuestream',
namespace: group,
- user: user
+ user: user,
+ context: [context]
)
end
@@ -77,7 +83,8 @@ RSpec.describe ProductAnalyticsTracking, :snowplow do
it 'tracks the event' do
get :index
- expect_tracking
+ expect_redis_hll_tracking
+ expect_snowplow_tracking(user)
end
context 'when FF is disabled' do
@@ -97,7 +104,8 @@ RSpec.describe ProductAnalyticsTracking, :snowplow do
get :index
- expect_tracking
+ expect_redis_hll_tracking
+ expect_snowplow_tracking(user)
end
it 'does not track the event if DNT is enabled' do
@@ -137,7 +145,8 @@ RSpec.describe ProductAnalyticsTracking, :snowplow do
get :show, params: { id: 1 }
- expect_tracking(user: nil)
+ expect_redis_hll_tracking
+ expect_snowplow_tracking(nil)
end
end
@@ -151,21 +160,24 @@ RSpec.describe ProductAnalyticsTracking, :snowplow do
it 'tracks the event when there is custom id' do
get :show, params: { id: 1 }
- expect_tracking(user: nil)
+ expect_redis_hll_tracking
+ expect_snowplow_tracking(nil)
end
- it 'does not track the HLL event when there is no custom id' do
- allow(controller).to receive(:get_custom_id).and_return(nil)
+ context 'when there is no custom_id set' do
+ before do
+ allow(controller).to receive(:get_custom_id).and_return(nil)
- get :show, params: { id: 2 }
+ get :show, params: { id: 2 }
+ end
- expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
- expect_snowplow_event(
- category: anything,
- action: 'g_analytics_valuestream',
- namespace: group,
- user: nil
- )
+ it 'does not track the HLL event' do
+ expect(Gitlab::UsageDataCounters::HLLRedisCounter).not_to receive(:track_event)
+ end
+
+ it 'tracks Snowplow event' do
+ expect_snowplow_tracking(nil)
+ end
end
end
end
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb
index f9a6afb95ea..32304815bbb 100644
--- a/spec/controllers/concerns/send_file_upload_spec.rb
+++ b/spec/controllers/concerns/send_file_upload_spec.rb
@@ -96,9 +96,10 @@ RSpec.describe SendFileUpload do
expect(controller).to receive(:params).at_least(:once).and_return(width: '64')
expect(controller).to receive(:head).with(:ok)
- expect(Gitlab::Workhorse).to receive(:send_scaled_image).with(a_string_matching('^(/.+|https://.+)'), 64, 'image/png').and_return([
- Gitlab::Workhorse::SEND_DATA_HEADER, "send-scaled-img:faux"
- ])
+ expect(Gitlab::Workhorse).to receive(:send_scaled_image)
+ .with(a_string_matching('^(/.+|https://.+)'), 64, 'image/png')
+ .and_return([Gitlab::Workhorse::SEND_DATA_HEADER, "send-scaled-img:faux"])
+
expect(headers).to receive(:store).with(Gitlab::Workhorse::SEND_DATA_HEADER, "send-scaled-img:faux")
subject