Commit ccb740c5 authored by Kamil Trzciński's avatar Kamil Trzciński

Fix `tracking_label` usage

This ensures that `tracking_label`
can be called without a subject.

Additionally, ensures that code using this method
properly calls experimentation framework.
parent cbeb9f70
...@@ -140,7 +140,7 @@ module Gitlab ...@@ -140,7 +140,7 @@ module Gitlab
cookies[:force_experiment].to_s.split(',').any? { |experiment| experiment.strip == experiment_key.to_s } cookies[:force_experiment].to_s.split(',').any? { |experiment| experiment.strip == experiment_key.to_s }
end end
def tracking_label(subject) def tracking_label(subject = nil)
return experimentation_subject_id if subject.blank? return experimentation_subject_id if subject.blank?
if subject.respond_to?(:to_global_id) if subject.respond_to?(:to_global_id)
......
...@@ -7,6 +7,10 @@ RSpec.describe InviteMembersHelper do ...@@ -7,6 +7,10 @@ RSpec.describe InviteMembersHelper do
let_it_be(:developer) { create(:user, developer_projects: [project]) } let_it_be(:developer) { create(:user, developer_projects: [project]) }
let(:owner) { project.owner } let(:owner) { project.owner }
before do
helper.extend(Gitlab::Experimentation::ControllerConcern)
end
context 'with project' do context 'with project' do
before do before do
assign(:project, project) assign(:project, project)
...@@ -202,7 +206,6 @@ RSpec.describe InviteMembersHelper do ...@@ -202,7 +206,6 @@ RSpec.describe InviteMembersHelper do
before do before do
allow(helper).to receive(:experiment_tracking_category_and_group) { '_track_property_' } allow(helper).to receive(:experiment_tracking_category_and_group) { '_track_property_' }
allow(helper).to receive(:tracking_label)
allow(helper).to receive(:current_user) { owner } allow(helper).to receive(:current_user) { owner }
end end
......
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