From 6f9428b1cd66d9f4ded1f1b1ef38e258e2b97c50 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Mon, 6 Aug 2012 02:32:17 +0200 Subject: [PATCH] Fix GFM helper to raise an exception when @project is not set --- app/helpers/application_helper.rb | 1 + spec/helpers/gitlab_flavored_markdown_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5e7cddb3..06cfa5b6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -44,6 +44,7 @@ module ApplicationHelper def gfm(text, html_options = {}) return text if text.nil? + raise "@project is not set" if @project.nil? # Extract pre blocks # from http://github.github.com/github-flavored-markdown/ diff --git a/spec/helpers/gitlab_flavored_markdown_spec.rb b/spec/helpers/gitlab_flavored_markdown_spec.rb index c1d95b82..9ba2e911 100644 --- a/spec/helpers/gitlab_flavored_markdown_spec.rb +++ b/spec/helpers/gitlab_flavored_markdown_spec.rb @@ -10,6 +10,12 @@ describe ApplicationHelper do end describe "#gfm" do + it "should raiase an error if @project is not set" do + @project = nil + + expect { gfm("foo") }.to raise_error + end + describe "referencing a commit" do it "should link using a full id" do gfm("Reverts changes from #{@commit.id}").should == "Reverts changes from #{link_to @commit.id, project_commit_path(@project, :id => @commit.id), :title => "Commit: #{@commit.author_name} - #{@commit.title}", :class => "gfm gfm-commit "}"