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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-21 06:08:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-21 06:08:34 +0300
commit9c1df7bcf10e362442057b1df43a753b621d85ee (patch)
tree593887914bd382186b016387d6dbde6c21c03d08 /spec
parent92ea86691a2a6b3df4b36c7ff00001410303a701 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/search_controller_spec.rb11
-rw-r--r--spec/features/projects/blobs/blame_spec.rb6
-rw-r--r--spec/lib/gitlab/diff/formatters/image_formatter_spec.rb1
-rw-r--r--spec/lib/gitlab/diff/formatters/text_formatter_spec.rb1
-rw-r--r--spec/lib/gitlab/diff/position_spec.rb80
-rw-r--r--spec/lib/gitlab/diff/position_tracer/image_strategy_spec.rb113
-rw-r--r--spec/lib/gitlab/diff/position_tracer/line_strategy_spec.rb138
-rw-r--r--spec/models/diff_note_spec.rb30
-rw-r--r--spec/models/integrations/base_chat_notification_spec.rb18
-rw-r--r--spec/presenters/gitlab/blame_presenter_spec.rb3
-rw-r--r--spec/requests/api/integrations_spec.rb15
-rw-r--r--spec/services/draft_notes/publish_service_spec.rb2
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb37
-rw-r--r--spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb16
15 files changed, 85 insertions, 390 deletions
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index 4abcd414e51..c664b2269d7 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe SearchController do
end
end
- describe 'GET #show' do
+ describe 'GET #show', :snowplow do
it_behaves_like 'when the user cannot read cross project', :show, { search: 'hello' } do
it 'still allows accessing the search page' do
get :show
@@ -257,6 +257,15 @@ RSpec.describe SearchController do
end
end
+ it_behaves_like 'Snowplow event tracking' do
+ let(:category) { described_class.to_s }
+ let(:action) { 'i_search_total' }
+ let(:namespace) { create(:group) }
+ let(:feature_flag_name) { :route_hll_to_snowplow_phase2 }
+
+ subject { get :show, params: { group_id: namespace.id, scope: 'blobs', search: 'term' } }
+ end
+
context 'on restricted projects' do
context 'when signed out' do
before do
diff --git a/spec/features/projects/blobs/blame_spec.rb b/spec/features/projects/blobs/blame_spec.rb
index bb3b5cd931c..4e422786f36 100644
--- a/spec/features/projects/blobs/blame_spec.rb
+++ b/spec/features/projects/blobs/blame_spec.rb
@@ -49,6 +49,12 @@ RSpec.describe 'File blame', :js do
expect(page).to have_css('#L3')
expect(find('.page-link.active')).to have_text('2')
end
+
+ it 'correctly redirects to the prior blame page' do
+ find('.version-link').click
+
+ expect(find('.page-link.active')).to have_text('2')
+ end
end
context 'when feature flag disabled' do
diff --git a/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb b/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
index 579776d44aa..73c0d0dba88 100644
--- a/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
+++ b/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
@@ -10,7 +10,6 @@ RSpec.describe Gitlab::Diff::Formatters::ImageFormatter do
head_sha: 789,
old_path: 'old_image.png',
new_path: 'new_image.png',
- file_identifier_hash: '777',
position_type: 'image'
}
end
diff --git a/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb b/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
index b6bdc5ff493..290585d0991 100644
--- a/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
+++ b/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
@@ -10,7 +10,6 @@ RSpec.describe Gitlab::Diff::Formatters::TextFormatter do
head_sha: 789,
old_path: 'old_path.txt',
new_path: 'new_path.txt',
- file_identifier_hash: '777',
line_range: nil
}
end
diff --git a/spec/lib/gitlab/diff/position_spec.rb b/spec/lib/gitlab/diff/position_spec.rb
index c9a20f40462..bb3522eb579 100644
--- a/spec/lib/gitlab/diff/position_spec.rb
+++ b/spec/lib/gitlab/diff/position_spec.rb
@@ -574,86 +574,6 @@ RSpec.describe Gitlab::Diff::Position do
end
end
- describe '#find_diff_file_from' do
- context "position for a diff file that has changed from symlink to regular file" do
- let(:commit) { project.commit("81e6355ce4e1544a3524b230952c12455de0777b") }
-
- let(:old_symlink_file_identifier_hash) { "bfa430463f33619872d52a6b85ced59c973e42dc" }
- let(:new_regular_file_identifier_hash) { "e25b60c2e5ffb977d2b1431b96c6f7800c3c3529" }
- let(:file_identifier_hash) { new_regular_file_identifier_hash }
-
- let(:args) do
- {
- file_identifier_hash: file_identifier_hash,
- old_path: "symlink",
- new_path: "symlink",
- old_line: nil,
- new_line: 1,
- diff_refs: commit.diff_refs
- }
- end
-
- let(:diffable) { commit.diff_refs.compare_in(project) }
-
- subject(:diff_file) { described_class.new(args).find_diff_file_from(diffable) }
-
- context 'when file_identifier_hash is disabled' do
- before do
- stub_feature_flags(file_identifier_hash: false)
- end
-
- it "returns the first diff file" do
- expect(diff_file.file_identifier_hash).to eq(old_symlink_file_identifier_hash)
- end
- end
-
- context 'when file_identifier_hash is enabled' do
- before do
- stub_feature_flags(file_identifier_hash: true)
- end
-
- context 'for new regular file' do
- it "returns the correct diff file" do
- expect(diff_file.file_identifier_hash).to eq(new_regular_file_identifier_hash)
- end
- end
-
- context 'for old symlink file' do
- let(:args) do
- {
- file_identifier_hash: old_symlink_file_identifier_hash,
- old_path: "symlink",
- new_path: "symlink",
- old_line: 1,
- new_line: nil,
- diff_refs: commit.diff_refs
- }
- end
-
- it "returns the correct diff file" do
- expect(diff_file.file_identifier_hash).to eq(old_symlink_file_identifier_hash)
- end
- end
-
- context 'when file_identifier_hash is missing' do
- let(:file_identifier_hash) { nil }
-
- it "returns the first diff file" do
- expect(diff_file.file_identifier_hash).to eq(old_symlink_file_identifier_hash)
- end
- end
-
- context 'when file_identifier_hash cannot be found' do
- let(:file_identifier_hash) { "missingidentifier" }
-
- it "returns nil" do
- expect(diff_file).to be_nil
- end
- end
- end
- end
- end
-
describe '#==' do
let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
diff --git a/spec/lib/gitlab/diff/position_tracer/image_strategy_spec.rb b/spec/lib/gitlab/diff/position_tracer/image_strategy_spec.rb
index 1414056ad6a..563480d214b 100644
--- a/spec/lib/gitlab/diff/position_tracer/image_strategy_spec.rb
+++ b/spec/lib/gitlab/diff/position_tracer/image_strategy_spec.rb
@@ -234,118 +234,5 @@ RSpec.describe Gitlab::Diff::PositionTracer::ImageStrategy do
end
end
end
-
- describe 'symlink scenarios' do
- let(:new_file) { old_file_status == :new }
- let(:deleted_file) { old_file_status == :deleted }
- let(:renamed_file) { old_file_status == :renamed }
-
- let(:file_identifier) { "#{file_name}-#{new_file}-#{deleted_file}-#{renamed_file}" }
- let(:file_identifier_hash) { Digest::SHA1.hexdigest(file_identifier) }
- let(:old_position) { position(old_path: file_name, new_path: file_name, position_type: 'image', file_identifier_hash: file_identifier_hash) }
-
- let(:update_file_commit) do
- initial_commit
-
- update_file(
- branch_name,
- file_name,
- Base64.encode64('morecontent')
- )
- end
-
- let(:delete_file_commit) do
- initial_commit
-
- delete_file(branch_name, file_name)
- end
-
- let(:create_second_file_commit) do
- initial_commit
-
- create_file(
- branch_name,
- second_file_name,
- Base64.encode64('morecontent')
- )
- end
-
- before do
- stub_feature_flags(file_identifier_hash: true)
- end
-
- describe 'from symlink to image' do
- let(:initial_commit) { project.commit('a19c7f9a147e35e535c797cf148d29c24dac5544') }
- let(:symlink_to_image_commit) { project.commit('8cfca8420812e5bd7479aa32cf33e0c95a3ca576') }
- let(:branch_name) { 'diff-files-symlink-to-image' }
- let(:file_name) { 'symlink-to-image.png' }
-
- context "when the old position is on the new image file" do
- let(:old_file_status) { :new }
-
- context "when the image file's content was unchanged between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_image_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, create_second_file_commit) }
-
- it "returns the new position" do
- expect_new_position(
- old_path: file_name,
- new_path: file_name
- )
- end
- end
-
- context "when the image file's content was changed between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_image_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, update_file_commit) }
- let(:change_diff_refs) { diff_refs(symlink_to_image_commit, update_file_commit) }
-
- it "returns the position of the change" do
- expect_change_position(
- old_path: file_name,
- new_path: file_name
- )
- end
- end
-
- context "when the image file was removed between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_image_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, delete_file_commit) }
- let(:change_diff_refs) { diff_refs(symlink_to_image_commit, delete_file_commit) }
-
- it "returns the position of the change" do
- expect_change_position(
- old_path: file_name,
- new_path: file_name
- )
- end
- end
- end
- end
-
- describe 'from image to symlink' do
- let(:initial_commit) { project.commit('d10dcdfbbb2b59a959a5f5d66a4adf28f0ea4008') }
- let(:image_to_symlink_commit) { project.commit('3e94fdaa60da8aed38401b91bc56be70d54ca424') }
- let(:branch_name) { 'diff-files-image-to-symlink' }
- let(:file_name) { 'image-to-symlink.png' }
-
- context "when the old position is on the added image file" do
- let(:old_file_status) { :new }
-
- context "when the image file gets changed to a symlink between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit.parent, initial_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit.parent, image_to_symlink_commit) }
- let(:change_diff_refs) { diff_refs(initial_commit, image_to_symlink_commit) }
-
- it "returns the position of the change" do
- expect_change_position(
- old_path: file_name,
- new_path: file_name
- )
- end
- end
- end
- end
- end
end
end
diff --git a/spec/lib/gitlab/diff/position_tracer/line_strategy_spec.rb b/spec/lib/gitlab/diff/position_tracer/line_strategy_spec.rb
index ea56a87dec2..2b21084d8e5 100644
--- a/spec/lib/gitlab/diff/position_tracer/line_strategy_spec.rb
+++ b/spec/lib/gitlab/diff/position_tracer/line_strategy_spec.rb
@@ -1860,143 +1860,5 @@ RSpec.describe Gitlab::Diff::PositionTracer::LineStrategy, :clean_gitlab_redis_c
end
end
end
-
- describe 'symlink scenarios' do
- let(:new_file) { old_file_status == :new }
- let(:deleted_file) { old_file_status == :deleted }
- let(:renamed_file) { old_file_status == :renamed }
-
- let(:file_identifier) { "#{file_name}-#{new_file}-#{deleted_file}-#{renamed_file}" }
- let(:file_identifier_hash) { Digest::SHA1.hexdigest(file_identifier) }
-
- let(:update_line_commit) do
- update_file(
- branch_name,
- file_name,
- <<-CONTENT.strip_heredoc
- A
- BB
- C
- CONTENT
- )
- end
-
- let(:delete_file_commit) do
- delete_file(branch_name, file_name)
- end
-
- let(:create_second_file_commit) do
- create_file(
- branch_name,
- second_file_name,
- <<-CONTENT.strip_heredoc
- D
- E
- CONTENT
- )
- end
-
- before do
- stub_feature_flags(file_identifier_hash: true)
- end
-
- describe 'from symlink to text' do
- let(:initial_commit) { project.commit('0e5b363105e9176a77bac94d7ff6d8c4fb35c3eb') }
- let(:symlink_to_text_commit) { project.commit('689815e617abc6889f1fded4834d2dd7d942a58e') }
- let(:branch_name) { 'diff-files-symlink-to-text' }
- let(:file_name) { 'symlink-to-text.txt' }
- let(:old_position) { position(old_path: file_name, new_path: file_name, new_line: 3, file_identifier_hash: file_identifier_hash) }
-
- before do
- create_branch('diff-files-symlink-to-text-test', branch_name)
- end
-
- context "when the old position is on the new text file" do
- let(:old_file_status) { :new }
-
- context "when the text file's content was unchanged between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_text_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, create_second_file_commit) }
-
- it "returns the new position" do
- expect_new_position(
- new_path: old_position.new_path,
- new_line: old_position.new_line
- )
- end
- end
-
- context "when the text file's content has change, but the line was unchanged between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_text_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, update_line_commit) }
-
- it "returns the new position" do
- expect_new_position(
- new_path: old_position.new_path,
- new_line: old_position.new_line
- )
- end
- end
-
- context "when the text file's line was changed between the old and the new diff" do
- let(:old_position) { position(old_path: file_name, new_path: file_name, new_line: 2, file_identifier_hash: file_identifier_hash) }
-
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_text_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, update_line_commit) }
- let(:change_diff_refs) { diff_refs(symlink_to_text_commit, update_line_commit) }
-
- it "returns the position of the change" do
- expect_change_position(
- old_path: file_name,
- new_path: file_name,
- old_line: 2,
- new_line: nil
- )
- end
- end
-
- context "when the text file was removed between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit, symlink_to_text_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit, delete_file_commit) }
- let(:change_diff_refs) { diff_refs(symlink_to_text_commit, delete_file_commit) }
-
- it "returns the position of the change" do
- expect_change_position(
- old_path: file_name,
- new_path: file_name,
- old_line: 3,
- new_line: nil
- )
- end
- end
- end
-
- describe 'from text to symlink' do
- let(:initial_commit) { project.commit('3db7bd90bab8ce8f02c9818590b84739a2e97230') }
- let(:text_to_symlink_commit) { project.commit('5e2c2708c2e403dece5dd25759369150aac51644') }
- let(:branch_name) { 'diff-files-text-to-symlink' }
- let(:file_name) { 'text-to-symlink.txt' }
-
- context "when the position is on the added text file" do
- let(:old_file_status) { :new }
-
- context "when the text file gets changed to a symlink between the old and the new diff" do
- let(:old_diff_refs) { diff_refs(initial_commit.parent, initial_commit) }
- let(:new_diff_refs) { diff_refs(initial_commit.parent, text_to_symlink_commit) }
- let(:change_diff_refs) { diff_refs(initial_commit, text_to_symlink_commit) }
-
- it "returns the position of the change" do
- expect_change_position(
- old_path: file_name,
- new_path: file_name,
- old_line: 3,
- new_line: nil
- )
- end
- end
- end
- end
- end
- end
end
end
diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb
index f377b34679c..d379ffeee02 100644
--- a/spec/models/diff_note_spec.rb
+++ b/spec/models/diff_note_spec.rb
@@ -260,32 +260,12 @@ RSpec.describe DiffNote do
end
context 'when the discussion was created in the diff' do
- context 'when file_identifier_hash is disabled' do
- before do
- stub_feature_flags(file_identifier_hash: false)
- end
-
- it 'returns correct diff file' do
- diff_file = subject.diff_file
-
- expect(diff_file.old_path).to eq(position.old_path)
- expect(diff_file.new_path).to eq(position.new_path)
- expect(diff_file.diff_refs).to eq(position.diff_refs)
- end
- end
-
- context 'when file_identifier_hash is enabled' do
- before do
- stub_feature_flags(file_identifier_hash: true)
- end
-
- it 'returns correct diff file' do
- diff_file = subject.diff_file
+ it 'returns correct diff file' do
+ diff_file = subject.diff_file
- expect(diff_file.old_path).to eq(position.old_path)
- expect(diff_file.new_path).to eq(position.new_path)
- expect(diff_file.diff_refs).to eq(position.diff_refs)
- end
+ expect(diff_file.old_path).to eq(position.old_path)
+ expect(diff_file.new_path).to eq(position.new_path)
+ expect(diff_file.diff_refs).to eq(position.diff_refs)
end
end
diff --git a/spec/models/integrations/base_chat_notification_spec.rb b/spec/models/integrations/base_chat_notification_spec.rb
index 672d8de1e14..8cbefbb9b47 100644
--- a/spec/models/integrations/base_chat_notification_spec.rb
+++ b/spec/models/integrations/base_chat_notification_spec.rb
@@ -285,4 +285,22 @@ RSpec.describe Integrations::BaseChatNotification do
expect { subject.webhook_placeholder }.to raise_error(NotImplementedError)
end
end
+
+ describe '#event_channel_name' do
+ it 'returns the channel field name for the given event' do
+ expect(subject.event_channel_name(:event)).to eq('event_channel')
+ end
+ end
+
+ describe '#get_channel_field' do
+ it 'returns the channel field value for the given event' do
+ subject.push_channel = '#pushes'
+
+ expect(subject.get_channel_field(:push)).to eq('#pushes')
+ end
+
+ it 'raises an error for unsupported events' do
+ expect { subject.get_channel_field(:foo) }.to raise_error(NoMethodError)
+ end
+ end
end
diff --git a/spec/presenters/gitlab/blame_presenter_spec.rb b/spec/presenters/gitlab/blame_presenter_spec.rb
index ff128416692..b3b9e133a73 100644
--- a/spec/presenters/gitlab/blame_presenter_spec.rb
+++ b/spec/presenters/gitlab/blame_presenter_spec.rb
@@ -8,8 +8,9 @@ RSpec.describe Gitlab::BlamePresenter do
let(:commit) { project.commit('master') }
let(:blob) { project.repository.blob_at(commit.id, path) }
let(:blame) { Gitlab::Blame.new(blob, commit) }
+ let(:page) { 1 }
- subject { described_class.new(blame, project: project, path: path) }
+ subject { described_class.new(blame, project: project, path: path, page: page) }
it 'precalculates necessary data on init' do
expect_any_instance_of(described_class)
diff --git a/spec/requests/api/integrations_spec.rb b/spec/requests/api/integrations_spec.rb
index cd9a0746581..a23c9b9f2ba 100644
--- a/spec/requests/api/integrations_spec.rb
+++ b/spec/requests/api/integrations_spec.rb
@@ -55,25 +55,20 @@ RSpec.describe API::Integrations do
describe "PUT /projects/:id/#{endpoint}/#{integration.dasherize}" do
include_context integration
- # NOTE: Some attributes are not supported for PUT requests, even though in most cases they should be.
- # For some of them the problem is somewhere else, i.e. most chat integrations don't support the `*_channel`
- # fields but they're incorrectly included in `#fields`.
- #
+ # NOTE: Some attributes are not supported for PUT requests, even though they probably should be.
# We can fix these manually, or with a generic approach like https://gitlab.com/gitlab-org/gitlab/-/issues/348208
- let(:missing_channel_attributes) { %i[push_channel issue_channel confidential_issue_channel merge_request_channel note_channel confidential_note_channel tag_push_channel pipeline_channel wiki_page_channel] }
let(:missing_attributes) do
{
datadog: %i[archive_trace_events],
- discord: missing_channel_attributes + %i[branches_to_be_notified notify_only_broken_pipelines],
- hangouts_chat: missing_channel_attributes + %i[notify_only_broken_pipelines],
+ discord: %i[branches_to_be_notified notify_only_broken_pipelines],
+ hangouts_chat: %i[notify_only_broken_pipelines],
jira: %i[issues_enabled project_key vulnerabilities_enabled vulnerabilities_issuetype],
mattermost: %i[deployment_channel labels_to_be_notified],
- microsoft_teams: missing_channel_attributes,
mock_ci: %i[enable_ssl_verification],
prometheus: %i[manual_configuration],
slack: %i[alert_events alert_channel deployment_channel labels_to_be_notified],
- unify_circuit: missing_channel_attributes + %i[branches_to_be_notified notify_only_broken_pipelines],
- webex_teams: missing_channel_attributes + %i[branches_to_be_notified notify_only_broken_pipelines]
+ unify_circuit: %i[branches_to_be_notified notify_only_broken_pipelines],
+ webex_teams: %i[branches_to_be_notified notify_only_broken_pipelines]
}
end
diff --git a/spec/services/draft_notes/publish_service_spec.rb b/spec/services/draft_notes/publish_service_spec.rb
index 51ef30c91c0..81443eed7d3 100644
--- a/spec/services/draft_notes/publish_service_spec.rb
+++ b/spec/services/draft_notes/publish_service_spec.rb
@@ -168,7 +168,7 @@ RSpec.describe DraftNotes::PublishService do
# NOTE: This should be reduced as we work on reducing Gitaly calls.
# Gitaly requests shouldn't go above this threshold as much as possible
# as it may add more to the Gitaly N+1 issue we are experiencing.
- expect { publish }.to change { Gitlab::GitalyClient.get_request_count }.by(21)
+ expect { publish }.to change { Gitlab::GitalyClient.get_request_count }.by(20)
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index b39153e79fc..6bd16edcb72 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -296,10 +296,6 @@ RSpec.configure do |config|
stub_feature_flags(flag => enable_rugged)
end
- # Disable the usage of file_identifier_hash by default until it is ready
- # See https://gitlab.com/gitlab-org/gitlab/-/issues/33867
- stub_feature_flags(file_identifier_hash: false)
-
# Disable `main_branch_over_master` as we migrate
# from `master` to `main` accross our codebase.
# It's done in order to preserve the concistency in tests
diff --git a/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb
new file mode 100644
index 00000000000..2f908c4b428
--- /dev/null
+++ b/spec/support/shared_examples/controllers/snowplow_event_tracking_examples.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+#
+# Requires a context containing:
+# - subject
+# - feature_flag_name
+# - category
+# - action
+# - namespace
+# - user
+
+shared_examples 'Snowplow event tracking' do
+ let(:label) { nil }
+ let(:project) { nil }
+
+ it 'is not emitted if FF is disabled' do
+ stub_feature_flags(feature_flag_name => false)
+
+ subject
+
+ expect_no_snowplow_event
+ end
+
+ it 'is emitted' do
+ params = {
+ category: category,
+ action: action,
+ namespace: namespace,
+ user: user,
+ project: project,
+ label: label
+ }.compact
+
+ subject
+
+ expect_snowplow_event(**params)
+ end
+end
diff --git a/spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb
index 326800e6dc2..c9300aff3e6 100644
--- a/spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/position_formatters_shared_examples.rb
@@ -32,21 +32,7 @@ RSpec.shared_examples "position formatter" do
subject { formatter.to_h }
- context 'when file_identifier_hash is disabled' do
- before do
- stub_feature_flags(file_identifier_hash: false)
- end
-
- it { is_expected.to eq(formatter_hash.except(:file_identifier_hash)) }
- end
-
- context 'when file_identifier_hash is enabled' do
- before do
- stub_feature_flags(file_identifier_hash: true)
- end
-
- it { is_expected.to eq(formatter_hash) }
- end
+ it { is_expected.to eq(formatter_hash) }
end
describe '#==' do