Display thumbnail inside a .well, optionally hide description

This commit is contained in:
Skud
2013-01-18 14:04:45 +11:00
parent 54965654bd
commit 46dd7ed346
6 changed files with 62 additions and 57 deletions

View File

@@ -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:

View File

@@ -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)

View File

@@ -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 }

View File

@@ -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'

View File

@@ -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

View File

@@ -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