Showing scientific names on the crop page

This commit is contained in:
Skud
2012-11-07 13:19:59 +11:00
parent 876a74cee8
commit 4e3c47a82f
4 changed files with 43 additions and 10 deletions

View File

@@ -32,7 +32,7 @@ GEM
bcrypt-ruby (3.0.1)
builder (3.0.4)
cape (1.5.0)
capistrano (2.13.4)
capistrano (2.13.5)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
@@ -54,7 +54,7 @@ GEM
sass (~> 3.1)
compass-rails (1.0.3)
compass (>= 0.12.2, < 0.14)
daemon_controller (1.0.0)
daemon_controller (1.1.0)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
@@ -65,7 +65,7 @@ GEM
execjs (1.4.0)
multi_json (~> 1.0)
fastthread (1.0.7)
friendly_id (4.0.8)
friendly_id (4.0.9)
fssm (0.2.9)
haml (3.1.7)
haml-rails (0.3.5)
@@ -90,7 +90,7 @@ GEM
modular-scale (1.0.2)
compass (>= 0.11.5)
sassy-math (>= 1.2)
multi_json (1.3.6)
multi_json (1.3.7)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
@@ -100,7 +100,7 @@ GEM
net-ssh (>= 1.99.1)
nokogiri (1.5.5)
orm_adapter (0.4.0)
passenger (3.0.17)
passenger (3.0.18)
daemon_controller (>= 1.0.0)
fastthread (>= 1.0.1)
rack
@@ -147,7 +147,7 @@ GEM
rspec (~> 2.11.0)
rvm-capistrano (1.2.7)
capistrano (>= 2.0.0)
sass (3.2.1)
sass (3.2.2)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
@@ -164,10 +164,10 @@ GEM
libv8 (~> 3.3.10)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.11)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
tzinfo (0.3.35)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)

View File

@@ -1,5 +1,12 @@
- content_for :title, @crop.system_name
%p
%b Scientific names:
%ul
- @crop.scientific_names.each do |sn|
%li= sn.scientific_name
%p
%b More information:
= link_to @crop.en_wikipedia_url, @crop.en_wikipedia_url

View File

@@ -5,3 +5,13 @@
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# import crops from CSV
require 'csv'
CSV.foreach(Rails.root.join('db', 'seeds', 'crops.csv')) do |row|
system_name,scientific_name,en_wikipedia_url = row
@crop = Crop.create(:system_name => system_name, :en_wikipedia_url => en_wikipedia_url)
@crop.scientific_names.create(:scientific_name => scientific_name)
end

View File

@@ -3,9 +3,25 @@ require 'spec_helper'
describe "crops/show" do
before(:each) do
@crop = assign(:crop, stub_model(Crop,
:system_name => "System Name",
:en_wikipedia_url => "En Wikipedia Url"
:id => 1,
:system_name => "Corn",
:en_wikipedia_url => "http://en.wikipedia.org/Maize"
))
@crop.scientific_names.create(
:scientific_name => "Zea mays",
:crop_id => 1
)
end
it "shows the wikipedia URL" do
render
rendered.should contain "en.wikipedia.org"
end
it "shows the scientific name" do
render
rendered.should contain "Scientific names"
rendered.should contain "Zea mays"
end
context "logged out" do