summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-08-10 00:07:56 +0000
committerRobert Speicher <robert@gitlab.com>2015-08-10 00:07:56 +0000
commitfb6f8d9198a7dbbd2dabf731ad0c9c8010a3f9f4 (patch)
tree138bb9dfd4d0718e1f908c2d1d5068a1cbf45a41 /spec
parent1a3283d4e871c518d131eb3c9a82dce33f4609f8 (diff)
parent32e63ba7a1a554a9b1ea38a3f6f4c846ebe0e785 (diff)
downloadgitlab-ce-fb6f8d9198a7dbbd2dabf731ad0c9c8010a3f9f4.tar.gz
Merge branch 'rs-reference-data-attrs' into 'master'
Add `data-[type]-id` attribute to reference links This is to let us redact them later in another filter. See merge request !1110
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown/commit_reference_filter_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown/issue_reference_filter_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown/label_reference_filter_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb8
-rw-r--r--spec/lib/gitlab/markdown/user_reference_filter_spec.rb16
7 files changed, 64 insertions, 0 deletions
diff --git a/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb b/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
index e8391cc7aca..58155284486 100644
--- a/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
@@ -80,6 +80,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('class')).to include 'custom'
end
+ it 'includes a data-project-id attribute' do
+ doc = filter("See #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-project-id')
+ expect(link.attr('data-project-id')).to eq project.id.to_s
+ end
+
it 'supports an :only_path option' do
doc = filter("See #{reference}", only_path: true)
link = doc.css('a').first.attr('href')
diff --git a/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb b/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
index a10d43c9a02..05a02de4669 100644
--- a/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/commit_reference_filter_spec.rb
@@ -76,6 +76,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('class')).to include 'custom'
end
+ it 'includes a data-project-id attribute' do
+ doc = filter("See #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-project-id')
+ expect(link.attr('data-project-id')).to eq project.id.to_s
+ end
+
it 'supports an :only_path context' do
doc = filter("See #{reference}", only_path: true)
link = doc.css('a').first.attr('href')
diff --git a/spec/lib/gitlab/markdown/issue_reference_filter_spec.rb b/spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
index fa43d33794d..35b1ba5f132 100644
--- a/spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
@@ -73,6 +73,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('class')).to include 'custom'
end
+ it 'includes a data-project-id attribute' do
+ doc = filter("Issue #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-project-id')
+ expect(link.attr('data-project-id')).to eq project.id.to_s
+ end
+
it 'supports an :only_path context' do
doc = filter("Issue #{reference}", only_path: true)
link = doc.css('a').first.attr('href')
diff --git a/spec/lib/gitlab/markdown/label_reference_filter_spec.rb b/spec/lib/gitlab/markdown/label_reference_filter_spec.rb
index e9f8ed277a5..fabe0411e46 100644
--- a/spec/lib/gitlab/markdown/label_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/label_reference_filter_spec.rb
@@ -30,6 +30,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('class')).to include 'custom'
end
+ it 'includes a data-project-id attribute' do
+ doc = filter("Label #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-project-id')
+ expect(link.attr('data-project-id')).to eq project.id.to_s
+ end
+
it 'supports an :only_path context' do
doc = filter("Label #{reference}", only_path: true)
link = doc.css('a').first.attr('href')
diff --git a/spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb b/spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
index 5945302a2da..5cef52b1916 100644
--- a/spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/merge_request_reference_filter_spec.rb
@@ -61,6 +61,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('class')).to include 'custom'
end
+ it 'includes a data-project-id attribute' do
+ doc = filter("Merge #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-project-id')
+ expect(link.attr('data-project-id')).to eq project.id.to_s
+ end
+
it 'supports an :only_path context' do
doc = filter("Merge #{reference}", only_path: true)
link = doc.css('a').first.attr('href')
diff --git a/spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb b/spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb
index 38619a3c07f..678b171e99e 100644
--- a/spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/snippet_reference_filter_spec.rb
@@ -60,6 +60,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('class')).to include 'custom'
end
+ it 'includes a data-project-id attribute' do
+ doc = filter("Snippet #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-project-id')
+ expect(link.attr('data-project-id')).to eq project.id.to_s
+ end
+
it 'supports an :only_path context' do
doc = filter("Snippet #{reference}", only_path: true)
link = doc.css('a').first.attr('href')
diff --git a/spec/lib/gitlab/markdown/user_reference_filter_spec.rb b/spec/lib/gitlab/markdown/user_reference_filter_spec.rb
index 9c55b4ff38f..a5405e14a73 100644
--- a/spec/lib/gitlab/markdown/user_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/user_reference_filter_spec.rb
@@ -64,6 +64,14 @@ module Gitlab::Markdown
expect(doc.css('a').length).to eq 1
end
+ it 'includes a data-user-id attribute' do
+ doc = filter("Hey #{reference}")
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-user-id')
+ expect(link.attr('data-user-id')).to eq user.namespace.owner_id.to_s
+ end
+
it 'adds to the results hash' do
result = pipeline_result("Hey #{reference}")
expect(result[:references][:user]).to eq [user]
@@ -85,6 +93,14 @@ module Gitlab::Markdown
expect(doc.css('a').first.attr('href')).to eq urls.group_url(group)
end
+ it 'includes a data-group-id attribute' do
+ doc = filter("Hey #{reference}", current_user: user)
+ link = doc.css('a').first
+
+ expect(link).to have_attribute('data-group-id')
+ expect(link.attr('data-group-id')).to eq group.id.to_s
+ end
+
it 'adds to the results hash' do
result = pipeline_result("Hey #{reference}", current_user: user)
expect(result[:references][:user]).to eq group.users