diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/views/shared/_label_row.html.haml_spec.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) | |
download | gitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/views/shared/_label_row.html.haml_spec.rb')
-rw-r--r-- | spec/views/shared/_label_row.html.haml_spec.rb | 139 |
1 files changed, 111 insertions, 28 deletions
diff --git a/spec/views/shared/_label_row.html.haml_spec.rb b/spec/views/shared/_label_row.html.haml_spec.rb index 8f8aa3072e2..e9a0bfdcd4e 100644 --- a/spec/views/shared/_label_row.html.haml_spec.rb +++ b/spec/views/shared/_label_row.html.haml_spec.rb @@ -2,43 +2,126 @@ require 'spec_helper' RSpec.describe 'shared/_label_row.html.haml' do - label_types = { - 'project label': :label, - 'group label': :group_label - } + let_it_be(:group) { create(:group) } + let(:label) { build_stubbed(:group_label, group: group).present(issuable_subject: group) } - label_types.each do |label_type, label_factory| - let!(:label) do - label_record = create(label_factory) # rubocop: disable Rails/SaveBang - label_record.present(issuable_subject: label_record.subject) + before do + allow(view).to receive(:label) { label } + end + + context 'with a project context' do + let_it_be(:project) { create(:project, group: group) } + let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) } + + before do + assign(:project, label.project) + + render + end + + it 'has label title' do + expect(rendered).to have_text(label.title) + end + + it 'has a non-linked label title' do + expect(rendered).not_to have_link(label.title) + end + + it 'has Issues link' do + expect(rendered).to have_link('Issues') + end + + it 'has Merge request link' do + expect(rendered).to have_link('Merge requests') + end + + it 'shows the path from where the label was created' do + expect(rendered).to have_css('.label-badge', text: project.full_name) + end + end + + context 'with a subgroup context' do + let_it_be(:subgroup) { create(:group, parent: group) } + let(:label) { build_stubbed(:group_label, group: subgroup).present(issuable_subject: subgroup) } + + before do + assign(:group, label.group) + + render + end + + it 'has label title' do + expect(rendered).to have_text(label.title) + end + + it 'has a non-linked label title' do + expect(rendered).not_to have_link(label.title) + end + + it 'has Issues link' do + expect(rendered).to have_link('Issues') + end + + it 'has Merge request link' do + expect(rendered).to have_link('Merge requests') + end + + it 'shows the path from where the label was created' do + expect(rendered).to have_css('.label-badge', text: subgroup.full_name) + end + end + + context 'with a group context' do + before do + assign(:group, label.group) + + render + end + + it 'has label title' do + expect(rendered).to have_text(label.title) + end + + it 'has a non-linked label title' do + expect(rendered).not_to have_link(label.title) + end + + it 'has Issues link' do + expect(rendered).to have_link('Issues') end - context "for a #{label_type}" do - before do - if label.project_label? - @project = label.project - else - @group = label.group - end - end + it 'has Merge request link' do + expect(rendered).to have_link('Merge requests') + end + + it 'does not show a path from where the label was created' do + expect(rendered).not_to have_css('.label-badge') + end + end - it 'has a non-linked label title' do - render 'shared/label_row', label: label + context 'with an admin context' do + before do + render + end - expect(rendered).not_to have_css('a', text: label.title) - end + it 'has label title' do + expect(rendered).to have_text(label.title) + end - it "has Issues link for #{label_type}" do - render 'shared/label_row', label: label + it 'has a non-linked label title' do + expect(rendered).not_to have_link(label.title) + end - expect(rendered).to have_css('a', text: 'Issues') - end + it 'does not show Issues link' do + expect(rendered).not_to have_link('Issues') + end - it "has Merge request link for #{label_type}" do - render 'shared/label_row', label: label + it 'does not show Merge request link' do + expect(rendered).not_to have_link('Merge requests') + end - expect(rendered).to have_css('a', text: 'Merge requests') - end + it 'does not show a path from where the label was created' do + expect(rendered).not_to have_css('.label-badge') end end end |