diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-29 15:09:30 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-29 15:09:30 +0000 |
commit | 09ff71d425b83646eed07d52078111ccbd4b84a9 (patch) | |
tree | 836e655ab4bd9fc680a35ab9e4a176134a2c9221 /spec/helpers | |
parent | 1838e244070041ed8ebb6344c628b580d78b578f (diff) | |
download | gitlab-ce-09ff71d425b83646eed07d52078111ccbd4b84a9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/sidebars_helper_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/helpers/sidebars_helper_spec.rb b/spec/helpers/sidebars_helper_spec.rb new file mode 100644 index 00000000000..e329968e6c0 --- /dev/null +++ b/spec/helpers/sidebars_helper_spec.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe SidebarsHelper do + describe '#sidebar_tracking_attributes_by_object' do + subject { helper.sidebar_tracking_attributes_by_object(object) } + + before do + allow(helper).to receive(:tracking_enabled?).and_return(true) + end + + context 'when object is a project' do + let(:object) { build(:project) } + + it 'returns tracking attrs for project' do + expect(subject[:data]).to eq({ track_label: 'projects_side_navigation', track_property: 'projects_side_navigation', track_action: 'render' }) + end + end + + context 'when object is a group' do + let(:object) { build(:group) } + + it 'returns tracking attrs for group' do + expect(subject[:data]).to eq({ track_label: 'groups_side_navigation', track_property: 'groups_side_navigation', track_action: 'render' }) + end + end + + context 'when object is a user' do + let(:object) { build(:user) } + + it 'returns tracking attrs for user' do + expect(subject[:data]).to eq({ track_label: 'user_side_navigation', track_property: 'user_side_navigation', track_action: 'render' }) + end + end + + context 'when object is something else' do + let(:object) { build(:ci_pipeline) } + + it 'returns no attributes' do + expect(subject).to eq({}) + end + end + end +end |