summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-06 23:08:28 +0100
committerDouwe Maan <douwe@gitlab.com>2015-03-07 00:46:13 +0100
commit4dddaef8661c8bfb5127d5db12b91d18cfcf0b8f (patch)
tree565f40f93c24c8c188dabcc1470f7b7c6ceb40b9 /spec/helpers
parent0625d68f7510a2f2203bfe2c57f5927a0121c561 (diff)
downloadgitlab-ce-4dddaef8661c8bfb5127d5db12b91d18cfcf0b8f.tar.gz
Automatically link commit ranges to compare page.
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 76fcf888a6a..74a42932fe8 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -9,6 +9,7 @@ describe GitlabMarkdownHelper do
let(:user) { create(:user, username: 'gfm') }
let(:commit) { project.repository.commit }
+ let(:earlier_commit){ project.repository.commit("HEAD~2") }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:snippet) { create(:project_snippet, project: project) }
@@ -53,6 +54,53 @@ describe GitlabMarkdownHelper do
to have_selector('a.gfm.foo')
end
+ describe "referencing a commit range" do
+ let(:expected) { namespace_project_compare_path(project.namespace, project, from: earlier_commit.id, to: commit.id) }
+
+ it "should link using a full id" do
+ actual = "What happened in #{earlier_commit.id}...#{commit.id}"
+ expect(gfm(actual)).to match(expected)
+ end
+
+ it "should link using a short id" do
+ actual = "What happened in #{earlier_commit.short_id}...#{commit.short_id}"
+ expected = namespace_project_compare_path(project.namespace, project, from: earlier_commit.short_id, to: commit.short_id)
+ expect(gfm(actual)).to match(expected)
+ end
+
+ it "should link inclusively" do
+ actual = "What happened in #{earlier_commit.id}..#{commit.id}"
+ expected = namespace_project_compare_path(project.namespace, project, from: "#{earlier_commit.id}^", to: commit.id)
+ expect(gfm(actual)).to match(expected)
+ end
+
+ it "should link with adjacent text" do
+ actual = "(see #{earlier_commit.id}...#{commit.id})"
+ expect(gfm(actual)).to match(expected)
+ end
+
+ it "should keep whitespace intact" do
+ actual = "Changes #{earlier_commit.id}...#{commit.id} dramatically"
+ expected = /Changes <a.+>#{earlier_commit.id}...#{commit.id}<\/a> dramatically/
+ expect(gfm(actual)).to match(expected)
+ end
+
+ it "should not link with an invalid id" do
+ actual = expected = "What happened in #{earlier_commit.id.reverse}...#{commit.id.reverse}"
+ expect(gfm(actual)).to eq(expected)
+ end
+
+ it "should include a title attribute" do
+ actual = "What happened in #{earlier_commit.id}...#{commit.id}"
+ expect(gfm(actual)).to match(/title="Commits #{earlier_commit.id} through #{commit.id}"/)
+ end
+
+ it "should include standard gfm classes" do
+ actual = "What happened in #{earlier_commit.id}...#{commit.id}"
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-commit_range\s?"/)
+ end
+ end
+
describe "referencing a commit" do
let(:expected) { namespace_project_commit_path(project.namespace, project, commit) }