diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-13 09:09:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-13 09:09:09 +0300 |
commit | 8f71e69fdbb65d2cf95cf16ef5a0add0919edb45 (patch) | |
tree | 0c282e1224b9ff50ba272b698b92919b72973af9 /spec/views/shared | |
parent | f645d7e060e85cbf442b4e86009bc776688e4661 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views/shared')
-rw-r--r-- | spec/views/shared/_label_row.html.haml_spec.rb | 96 |
1 files changed, 68 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..1d21574a0c4 100644 --- a/spec/views/shared/_label_row.html.haml_spec.rb +++ b/spec/views/shared/_label_row.html.haml_spec.rb @@ -2,43 +2,83 @@ 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 a non-linked label title' do + expect(rendered).not_to have_css('a', text: label.title) + end + + it "has Issues link" do + expect(rendered).to have_css('a', text: '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_css('a', text: 'Merge requests') + end - it 'has a non-linked label title' do - render 'shared/label_row', label: label + it "shows the path from where the label was created" do + expect(rendered).to have_css('.label-badge', text: project.full_name) + end + end - expect(rendered).not_to have_css('a', text: label.title) - end + context 'with a group context' do + before do + assign(:group, label.group) - it "has Issues link for #{label_type}" do - render 'shared/label_row', label: label + render + end - expect(rendered).to have_css('a', text: 'Issues') - end + it 'has a non-linked label title' do + expect(rendered).not_to have_css('a', text: label.title) + end - it "has Merge request link for #{label_type}" do - render 'shared/label_row', label: label + it "has Issues link" do + expect(rendered).to have_css('a', text: 'Issues') + end + + it "has Merge request link" do + 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 + + context 'with an admin context' do + before do + render + end + + it 'has a non-linked label title' do + expect(rendered).not_to have_css('a', text: label.title) + end + + it "does not show Issues link" do + expect(rendered).not_to have_css('a', text: 'Issues') + end + + it "does not show Merge request link" do + expect(rendered).not_to have_css('a', text: '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 |