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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-15 00:13:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-15 00:13:08 +0300
commit30f908f6b9689ecda34474e68c55ce4dba1a9974 (patch)
tree980f904604222360eefcee2e01a7068539488713 /spec/experiments
parent0c6a209989efe28789e8580aedbac25677af9ca2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/experiments')
-rw-r--r--spec/experiments/application_experiment_spec.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/experiments/application_experiment_spec.rb b/spec/experiments/application_experiment_spec.rb
index e01c5522b51..5146fe3e752 100644
--- a/spec/experiments/application_experiment_spec.rb
+++ b/spec/experiments/application_experiment_spec.rb
@@ -233,6 +233,75 @@ RSpec.describe ApplicationExperiment, :experiment do
]
)
end
+
+ context "when using known context resources" do
+ let(:user) { build(:user, id: non_existing_record_id) }
+ let(:project) { build(:project, id: non_existing_record_id) }
+ let(:namespace) { build(:namespace, id: non_existing_record_id) }
+ let(:group) { build(:group, id: non_existing_record_id) }
+ let(:actor) { user }
+
+ let(:context) { { user: user, project: project, namespace: namespace } }
+
+ it "includes those using the gitlab standard context" do
+ subject.track(:action)
+
+ expect_snowplow_event(
+ category: 'namespaced/stub',
+ action: 'action',
+ user: user,
+ project: project,
+ namespace: namespace,
+ context: an_instance_of(Array)
+ )
+ end
+
+ it "falls back to using the group key" do
+ subject.context(namespace: nil, group: group)
+
+ subject.track(:action)
+
+ expect_snowplow_event(
+ category: 'namespaced/stub',
+ action: 'action',
+ user: user,
+ project: project,
+ namespace: group,
+ context: an_instance_of(Array)
+ )
+ end
+
+ context "with the actor key" do
+ it "provides it to the tracking call as the user" do
+ subject.context(user: nil, actor: actor)
+
+ subject.track(:action)
+
+ expect_snowplow_event(
+ category: 'namespaced/stub',
+ action: 'action',
+ user: actor,
+ project: project,
+ namespace: namespace,
+ context: an_instance_of(Array)
+ )
+ end
+
+ it "handles when it's not a user record" do
+ subject.context(user: nil, actor: nil)
+
+ subject.track(:action)
+
+ expect_snowplow_event(
+ category: 'namespaced/stub',
+ action: 'action',
+ project: project,
+ namespace: namespace,
+ context: an_instance_of(Array)
+ )
+ end
+ end
+ end
end
describe "#key_for" do