summaryrefslogtreecommitdiff
path: root/spec/helpers/gitlab_markdown_helper_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-04 18:36:22 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-04 18:36:22 +0300
commitbcc4e4dc7ed0740e92a61fc82c3c669f8f2d8d30 (patch)
tree1df3e2d68cd524af4dce107b2e4227778bb3945d /spec/helpers/gitlab_markdown_helper_spec.rb
parent211e435ade337c968fab11c52427c172adcec99a (diff)
parente0af7cefb4c92b474d14116b40927d70c13e78cc (diff)
downloadgitlab-ce-bcc4e4dc7ed0740e92a61fc82c3c669f8f2d8d30.tar.gz
Merge branch 'gist' of https://github.com/Andrew8xx8/gitlabhq into Andrew8xx8-gist
Conflicts: Gemfile.lock app/models/ability.rb app/models/project.rb app/views/snippets/_form.html.haml db/schema.rb features/steps/shared/paths.rb spec/factories.rb spec/models/project_spec.rb
Diffstat (limited to 'spec/helpers/gitlab_markdown_helper_spec.rb')
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb39
1 files changed, 37 insertions, 2 deletions
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 23b18fbf0eb..0f206f47234 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -10,7 +10,7 @@ describe GitlabMarkdownHelper do
let(:commit) { project.repository.commit }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, project: project) }
- let(:snippet) { create(:snippet, project: project) }
+ let(:snippet) { create(:project_snippet, project: project) }
let(:member) { project.users_projects.where(user_id: user).first }
before do
@@ -190,8 +190,43 @@ describe GitlabMarkdownHelper do
describe "referencing a snippet" do
let(:object) { snippet }
let(:reference) { "$#{snippet.id}" }
+ let(:actual) { "Reference to #{reference}" }
+ let(:expected) { project_snippet_path(project, object) }
+
+ it "should link using a valid id" do
+ gfm(actual).should match(expected)
+ end
+
+ it "should link with adjacent text" do
+ # Wrap the reference in parenthesis
+ gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+
+ # Append some text to the end of the reference
+ gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ end
+
+ it "should keep whitespace intact" do
+ actual = "Referenced #{reference} already."
+ expected = /Referenced <a.+>[^\s]+<\/a> already/
+ gfm(actual).should match(expected)
+ end
+
+ it "should not link with an invalid id" do
+ # Modify the reference string so it's still parsed, but is invalid
+ reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
+ gfm(actual).should == actual
+ end
+
+ it "should include a title attribute" do
+ title = "Snippet: #{object.title}"
+ gfm(actual).should match(/title="#{title}"/)
+ end
+
+ it "should include standard gfm classes" do
+ css = object.class.to_s.underscore
+ gfm(actual).should match(/class="\s?gfm gfm-snippet\s?"/)
+ end
- include_examples 'referenced object'
end
describe "referencing multiple objects" do