diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml
index a05981d55..5273d26fb 100644
--- a/app/views/crops/show.html.haml
+++ b/app/views/crops/show.html.haml
@@ -5,7 +5,7 @@
.span9
%h2 Who's growing this?
- @crop.plantings.each do |p|
- = render :partial => "plantings/thumbnail", :locals => { :planting => p, :title => 'owner'}
+ = render :partial => "plantings/thumbnail", :locals => { :planting => p, :title => 'owner' }
.span3
%h4 Scientific names:
diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml
index 78be21dd6..f0dbc2601 100644
--- a/app/views/members/show.html.haml
+++ b/app/views/members/show.html.haml
@@ -28,7 +28,7 @@
%h3 What's planted here?
- g.featured_plantings.each do |p|
- = render :partial => "plantings/thumbnail", :locals => { :planting => p }
+ = render :partial => "plantings/thumbnail", :locals => { :planting => p, :hide_description => true }
%p
= link_to "More about this garden...", url_for(g)
diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml
index 2baa37fe7..607fb133b 100644
--- a/app/views/plantings/_thumbnail.html.haml
+++ b/app/views/plantings/_thumbnail.html.haml
@@ -1,19 +1,25 @@
-%h4
- - if defined?(title) && title == 'owner'
- = link_to planting.owner, planting.owner
- - else
- = link_to planting.crop.system_name, planting.crop
+.well
+ %h4
+ - if defined?(title) && title == 'owner'
+ = link_to planting.owner, planting.owner
+ - else
+ = link_to planting.crop.system_name, planting.crop
-%p
- Planted
- - if planting.planted_at
- = planting.planted_at.to_s(:date)
- in
- = link_to planting.location, planting.garden
+ %p
+ Planted
+ - if planting.planted_at
+ = planting.planted_at.to_s(:date)
+ in
+ = link_to planting.location, planting.garden
-%p
- - if planting.quantity
- Quantity:
- = planting.quantity
- - else
-
+ %p
+ - if planting.quantity
+ Quantity:
+ = planting.quantity
+ - else
+
+
+ - if planting.description && ! defined?(hide_description)
+ %div
+ :markdown
+ #{ planting.description }
diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml
index a1e833b9c..2913ca7e5 100644
--- a/app/views/plantings/index.html.haml
+++ b/app/views/plantings/index.html.haml
@@ -3,26 +3,10 @@
%p Here are the latest things planted by Growstuff members.
- @recent_plantings.each do |p|
- .well
- %h2
- = p.crop
- %small
- = "in #{p.location}"
-
- - if p.planted_at
- %p
- Planted at
- = p.planted_at
-
- %div
- :markdown
- #{ p.description != "" ? p.description : "No description given." }
+ = render :partial => "plantings/thumbnail", :locals => { :planting => p }
+ - if member_signed_in? && current_member == p.owner
%p
- = link_to 'More...', p
-
- - if member_signed_in? && current_member == p.owner
- %p
- =link_to 'Edit', edit_planting_path(p), :class => 'btn'
- =link_to 'Destroy', p, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn'
+ =link_to 'Edit', edit_planting_path(p), :class => 'btn'
+ =link_to 'Destroy', p, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn'
diff --git a/spec/views/plantings/_thumbnail.html.haml_spec.rb b/spec/views/plantings/_thumbnail.html.haml_spec.rb
index 405bdf5f8..a558bc201 100644
--- a/spec/views/plantings/_thumbnail.html.haml_spec.rb
+++ b/spec/views/plantings/_thumbnail.html.haml_spec.rb
@@ -10,24 +10,43 @@ describe "plantings/_thumbnail" do
:garden => @garden,
:crop => @crop
)
-
- render :partial => "thumbnail", :locals => {
- :planting => @planting,
- :show_crop => true,
- :show_location => true
- }
end
- it "renders the quantity planted" do
- rendered.should contain "33"
+ context "simple view" do
+ before(:each) do
+ render :partial => "thumbnail", :locals => {
+ :planting => @planting,
+ }
+ end
+
+ it "renders the quantity planted" do
+ rendered.should contain "33"
+ end
+
+ it "renders the date planted" do
+ rendered.should contain @planting.planted_at.to_s(:date)
+ end
+
+ it "shows the name of the crop" do
+ rendered.should contain "Tomato"
+ end
+
+ it "shows the description by default" do
+ rendered.should contain "This is a"
+ end
end
- it "renders the date planted" do
- rendered.should contain @planting.planted_at.to_s(:date)
- end
+ context "with complicated args" do
+ before(:each) do
+ render :partial => "thumbnail", :locals => {
+ :planting => @planting,
+ :hide_description => true
+ }
+ end
- it "shows the name of the crop" do
- rendered.should contain "Tomato"
+ it "hides the description if asked" do
+ rendered.should_not contain "This is a"
+ end
end
end
diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb
index cfb6508f0..68fb6df9d 100644
--- a/spec/views/plantings/index.html.haml_spec.rb
+++ b/spec/views/plantings/index.html.haml_spec.rb
@@ -31,12 +31,8 @@ describe "plantings/index" do
rendered.should contain "This is a"
end
- it "shows filler when there is no description" do
- rendered.should contain "No description given"
- end
-
it "displays planting time" do
- rendered.should contain '2013-01-13 01:25:34'
+ rendered.should contain 'January 13, 2013'
end
it "renders markdown in the description" do