mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-27 11:14:31 -04:00
Showing plantings on crops page. Ugly for now, but works.
This commit is contained in:
@@ -3,6 +3,7 @@ class Crop < ActiveRecord::Base
|
||||
friendly_id :system_name, use: :slugged
|
||||
attr_accessible :en_wikipedia_url, :system_name
|
||||
has_many :scientific_names
|
||||
has_many :plantings
|
||||
|
||||
def Crop.random
|
||||
@crop = Crop.offset(rand(Crop.count)).first
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
=link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-large btn-primary'
|
||||
|
||||
%h2 Who's growing this?
|
||||
- (1..5).each do
|
||||
.well
|
||||
%h4 Some person
|
||||
%p These blocks would contain recent posts from members who are growing this crop.
|
||||
- @crop.plantings.each do |p|
|
||||
%p
|
||||
= p.quantity ? p.quantity : nil
|
||||
= link_to p.crop.system_name, p.crop
|
||||
in
|
||||
= link_to p.location, p.garden
|
||||
= p.planted_at ? "planted at #{p.planted_at}" : nil
|
||||
|
||||
.span3
|
||||
%h3 Scientific names:
|
||||
|
||||
@@ -5,6 +5,12 @@ describe "crops/show" do
|
||||
@crop = assign(:crop, FactoryGirl.create(:maize,
|
||||
:scientific_names => [ FactoryGirl.create(:zea_mays) ]
|
||||
))
|
||||
@owner = FactoryGirl.create(:member)
|
||||
@garden = FactoryGirl.create(:garden, :owner => @owner)
|
||||
@planting = FactoryGirl.create(:planting,
|
||||
:garden => @garden,
|
||||
:crop => @crop
|
||||
)
|
||||
end
|
||||
|
||||
it "shows the wikipedia URL" do
|
||||
@@ -28,6 +34,10 @@ describe "crops/show" do
|
||||
assert_select("a[href=#{new_planting_path}?crop_id=#{@crop.id}]")
|
||||
end
|
||||
|
||||
it "links to people who are growing this crop" do
|
||||
rendered.should contain "member1"
|
||||
end
|
||||
|
||||
context "logged out" do
|
||||
it "doesn't show the edit links if logged out" do
|
||||
render
|
||||
|
||||
Reference in New Issue
Block a user