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/helpers/analytics/cycle_analytics_helper_spec.rb')
-rw-r--r--spec/helpers/analytics/cycle_analytics_helper_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/helpers/analytics/cycle_analytics_helper_spec.rb b/spec/helpers/analytics/cycle_analytics_helper_spec.rb
new file mode 100644
index 00000000000..d906646e25c
--- /dev/null
+++ b/spec/helpers/analytics/cycle_analytics_helper_spec.rb
@@ -0,0 +1,61 @@
+# frozen_string_literal: true
+require "spec_helper"
+
+RSpec.describe Analytics::CycleAnalyticsHelper do
+ describe '#cycle_analytics_initial_data' do
+ let(:user) { create(:user, name: 'fake user', username: 'fake_user') }
+ let(:image_path_keys) { [:empty_state_svg_path, :no_data_svg_path, :no_access_svg_path] }
+ let(:api_path_keys) { [:milestones_path, :labels_path] }
+ let(:additional_data_keys) { [:full_path, :group_id, :group_path, :project_id, :request_path] }
+ let(:group) { create(:group) }
+
+ subject(:cycle_analytics_data) { helper.cycle_analytics_initial_data(project, group) }
+
+ before do
+ project.add_maintainer(user)
+ end
+
+ context 'when a group is present' do
+ let(:project) { create(:project, group: group) }
+
+ it "sets the correct data keys" do
+ expect(cycle_analytics_data.keys)
+ .to match_array(api_path_keys + image_path_keys + additional_data_keys)
+ end
+
+ it "sets group paths" do
+ expect(cycle_analytics_data)
+ .to include({
+ full_path: project.full_path,
+ group_path: "/#{project.namespace.name}",
+ group_id: project.namespace.id,
+ request_path: "/#{project.full_path}/-/value_stream_analytics",
+ milestones_path: "/groups/#{group.name}/-/milestones.json",
+ labels_path: "/groups/#{group.name}/-/labels.json"
+ })
+ end
+ end
+
+ context 'when a group is not present' do
+ let(:group) { nil }
+ let(:project) { create(:project) }
+
+ it "sets the correct data keys" do
+ expect(cycle_analytics_data.keys)
+ .to match_array(image_path_keys + api_path_keys + additional_data_keys)
+ end
+
+ it "sets project name space paths" do
+ expect(cycle_analytics_data)
+ .to include({
+ full_path: project.full_path,
+ group_path: project.namespace.path,
+ group_id: project.namespace.id,
+ request_path: "/#{project.full_path}/-/value_stream_analytics",
+ milestones_path: "/#{project.full_path}/-/milestones.json",
+ labels_path: "/#{project.full_path}/-/labels.json"
+ })
+ end
+ end
+ end
+end