From 626fc55f37bf200007e1b3346937ff0b82dd0605 Mon Sep 17 00:00:00 2001 From: Skud Date: Fri, 21 Dec 2012 13:45:22 +1100 Subject: [PATCH] render markdown in planting descriptions --- app/views/plantings/index.html.haml | 3 ++- app/views/plantings/show.html.haml | 3 ++- spec/views/plantings/index.html.haml_spec.rb | 6 +++++- spec/views/plantings/show.html.haml_spec.rb | 6 +++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml index 3e1bbd79b..9114df850 100644 --- a/app/views/plantings/index.html.haml +++ b/app/views/plantings/index.html.haml @@ -15,7 +15,8 @@ = p.planted_at %div - = p.description != "" ? p.description : "No description given" + :markdown + #{ p.description != "" ? p.description : "No description given." } %p = link_to 'More...', p diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml index 9b4b39fa9..94080d181 100644 --- a/app/views/plantings/show.html.haml +++ b/app/views/plantings/show.html.haml @@ -10,7 +10,8 @@ = @planting.quantity != 0 ? @planting.quantity : "not specified" %p %b Description: - = @planting.description != "" ? @planting.description : "No description." + :markdown + #{ @planting.description != "" ? @planting.description : "No description." } - if user_signed_in? && current_user == @planting.owner = link_to 'Edit', edit_planting_path(@planting), :class => 'btn' diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index d345fae4e..a56770400 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -26,7 +26,7 @@ describe "plantings/index" do :crop => @crop, :planted_at => '2008-01-05 12:34:56', :quantity => 3, - :description => "MyText", + :description => "MyText *ITALIC*", :created_at => Time.now ), stub_model(Planting, @@ -57,4 +57,8 @@ describe "plantings/index" do rendered.should contain '2008-01-05 12:34:56' end + it "renders markdown in the description" do + assert_select "em", "ITALIC" + end + end diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index 5913b8da7..13640d4f9 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -21,7 +21,7 @@ describe "plantings/show" do :garden => @garden, :crop => @crop, :quantity => 333, - :description => "MyText" + :description => "MyText *ITALIC*" )) render end @@ -33,4 +33,8 @@ describe "plantings/show" do it "renders the description" do rendered.should match(/MyText/) end + + it "renders markdown in the description" do + assert_select "em", "ITALIC" + end end