summaryrefslogtreecommitdiff
path: root/spec/lib/banzai
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-03-30 19:27:03 +0200
committerJan Provaznik <jprovaznik@gitlab.com>2018-04-05 13:29:57 +0200
commitc1946364707947f56048cc00caa6d67fe635f3c7 (patch)
tree107096b44758bf8872bd60d41ed1ab8ab4e86c14 /spec/lib/banzai
parent166b4575a6353668c894fea0ba234d0b371dee03 (diff)
downloadgitlab-ce-c1946364707947f56048cc00caa6d67fe635f3c7.tar.gz
Better group support notes-related code
Updates notes-related services and rendering so this code can be easily used for group-scoped resources (specifically Epics). Related to gitlab-ee!5205
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r--spec/lib/banzai/cross_project_reference_spec.rb10
-rw-r--r--spec/lib/banzai/filter/label_reference_filter_spec.rb22
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/banzai/cross_project_reference_spec.rb b/spec/lib/banzai/cross_project_reference_spec.rb
index 68ca960caab..aadfe7637dd 100644
--- a/spec/lib/banzai/cross_project_reference_spec.rb
+++ b/spec/lib/banzai/cross_project_reference_spec.rb
@@ -14,6 +14,16 @@ describe Banzai::CrossProjectReference do
end
end
+ context 'when no project was referenced in group context' do
+ it 'returns the group from context' do
+ group = double
+
+ allow(self).to receive(:context).and_return({ group: group })
+
+ expect(parent_from_ref(nil)).to eq group
+ end
+ end
+
context 'when referenced project does not exist' do
it 'returns nil' do
expect(parent_from_ref('invalid/reference')).to be_nil
diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb
index 0c524a1551f..392905076dc 100644
--- a/spec/lib/banzai/filter/label_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb
@@ -596,6 +596,27 @@ describe Banzai::Filter::LabelReferenceFilter do
end
describe 'group context' do
+ it 'points to the page defined in label_url_method' do
+ group = create(:group)
+ label = create(:group_label, group: group)
+ reference = "~#{label.name}"
+
+ result = reference_filter("See #{reference}", { project: nil, group: group, label_url_method: :group_url } )
+
+ expect(result.css('a').first.attr('href')).to eq(urls.group_url(group, label_name: label.name))
+ end
+
+ it 'finds labels also in ancestor groups' do
+ group = create(:group)
+ label = create(:group_label, group: group)
+ subgroup = create(:group, parent: group)
+ reference = "~#{label.name}"
+
+ result = reference_filter("See #{reference}", { project: nil, group: subgroup, label_url_method: :group_url } )
+
+ expect(result.css('a').first.attr('href')).to eq(urls.group_url(subgroup, label_name: label.name))
+ end
+
it 'points to referenced project issues page' do
project = create(:project)
label = create(:label, project: project)
@@ -604,6 +625,7 @@ describe Banzai::Filter::LabelReferenceFilter do
result = reference_filter("See #{reference}", { project: nil, group: create(:group) } )
expect(result.css('a').first.attr('href')).to eq(urls.project_issues_url(project, label_name: label.name))
+ expect(result.css('a').first.text).to eq "#{label.name} in #{project.full_name}"
end
end
end