mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-27 11:14:31 -04:00
16
Gemfile.lock
16
Gemfile.lock
@@ -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)
|
||||
|
||||
3
app/assets/javascripts/scientific_names.js.coffee
Normal file
3
app/assets/javascripts/scientific_names.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
83
app/controllers/scientific_names_controller.rb
Normal file
83
app/controllers/scientific_names_controller.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
class ScientificNamesController < ApplicationController
|
||||
# GET /scientific_names
|
||||
# GET /scientific_names.json
|
||||
def index
|
||||
@scientific_names = ScientificName.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @scientific_names }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /scientific_names/1
|
||||
# GET /scientific_names/1.json
|
||||
def show
|
||||
@scientific_name = ScientificName.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @scientific_name }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /scientific_names/new
|
||||
# GET /scientific_names/new.json
|
||||
def new
|
||||
@scientific_name = ScientificName.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.json { render json: @scientific_name }
|
||||
end
|
||||
end
|
||||
|
||||
# GET /scientific_names/1/edit
|
||||
def edit
|
||||
@scientific_name = ScientificName.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /scientific_names
|
||||
# POST /scientific_names.json
|
||||
def create
|
||||
@scientific_name = ScientificName.new(params[:scientific_name])
|
||||
|
||||
respond_to do |format|
|
||||
if @scientific_name.save
|
||||
format.html { redirect_to @scientific_name, notice: 'Scientific name was successfully created.' }
|
||||
format.json { render json: @scientific_name, status: :created, location: @scientific_name }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.json { render json: @scientific_name.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /scientific_names/1
|
||||
# PUT /scientific_names/1.json
|
||||
def update
|
||||
@scientific_name = ScientificName.find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
if @scientific_name.update_attributes(params[:scientific_name])
|
||||
format.html { redirect_to @scientific_name, notice: 'Scientific name was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.json { render json: @scientific_name.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /scientific_names/1
|
||||
# DELETE /scientific_names/1.json
|
||||
def destroy
|
||||
@scientific_name = ScientificName.find(params[:id])
|
||||
@scientific_name.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to scientific_names_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
end
|
||||
2
app/helpers/scientific_names_helper.rb
Normal file
2
app/helpers/scientific_names_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ScientificNamesHelper
|
||||
end
|
||||
@@ -2,4 +2,5 @@ class Crop < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
friendly_id :system_name, use: :slugged
|
||||
attr_accessible :en_wikipedia_url, :system_name
|
||||
has_many :scientific_names
|
||||
end
|
||||
|
||||
4
app/models/scientific_name.rb
Normal file
4
app/models/scientific_name.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ScientificName < ActiveRecord::Base
|
||||
attr_accessible :crop_id, :scientific_name
|
||||
belongs_to :crop
|
||||
end
|
||||
@@ -1,5 +1,13 @@
|
||||
- content_for :title, "New crop"
|
||||
|
||||
= render 'form'
|
||||
- if user_signed_in?
|
||||
= render 'form'
|
||||
%ul.link-list
|
||||
%li
|
||||
= link_to 'Show', @crop, { :class => 'button' }
|
||||
%li
|
||||
= link_to 'Back', crops_path, { :class => 'button' }
|
||||
- else
|
||||
%div.alert-box.alert You're not logged in. Only logged in users can do this.
|
||||
|
||||
= link_to 'Back', crops_path
|
||||
|
||||
@@ -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
|
||||
|
||||
16
app/views/scientific_names/_form.html.haml
Normal file
16
app/views/scientific_names/_form.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
= form_for @scientific_name do |f|
|
||||
- if @scientific_name.errors.any?
|
||||
#error_explanation
|
||||
%h2= "#{pluralize(@scientific_name.errors.count, "error")} prohibited this scientific_name from being saved:"
|
||||
%ul
|
||||
- @scientific_name.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
.field
|
||||
= f.label :scientific_name
|
||||
= f.text_field :scientific_name
|
||||
.field
|
||||
= f.label :crop_id
|
||||
= f.number_field :crop_id
|
||||
.actions
|
||||
= f.submit 'Save'
|
||||
11
app/views/scientific_names/edit.html.haml
Normal file
11
app/views/scientific_names/edit.html.haml
Normal file
@@ -0,0 +1,11 @@
|
||||
%h1 Editing scientific_name
|
||||
|
||||
- if user_signed_in?
|
||||
= render 'form'
|
||||
%ul.link-list
|
||||
%li
|
||||
= link_to 'Show', @scientific_name, { :class => 'button' }
|
||||
%li
|
||||
= link_to 'Back', scientific_names_path, { :class => 'button' }
|
||||
- else
|
||||
%div.alert-box.alert You're not logged in. Only logged in users can do this.
|
||||
21
app/views/scientific_names/index.html.haml
Normal file
21
app/views/scientific_names/index.html.haml
Normal file
@@ -0,0 +1,21 @@
|
||||
%h1 Listing scientific_names
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th Scientific name
|
||||
%th Crop
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
|
||||
- @scientific_names.each do |scientific_name|
|
||||
%tr
|
||||
%td= scientific_name.scientific_name
|
||||
%td= scientific_name.crop_id
|
||||
%td= link_to 'Show', scientific_name
|
||||
%td= link_to 'Edit', edit_scientific_name_path(scientific_name)
|
||||
%td= link_to 'Destroy', scientific_name, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
|
||||
%br
|
||||
|
||||
= link_to 'New Scientific name', new_scientific_name_path
|
||||
11
app/views/scientific_names/new.html.haml
Normal file
11
app/views/scientific_names/new.html.haml
Normal file
@@ -0,0 +1,11 @@
|
||||
%h1 New scientific_name
|
||||
|
||||
- if user_signed_in?
|
||||
= render 'form'
|
||||
%ul.link-list
|
||||
%li
|
||||
= link_to 'Show', @scientific_name, { :class => 'button' }
|
||||
%li
|
||||
= link_to 'Back', scientific_names_path, { :class => 'button' }
|
||||
- else
|
||||
%div.alert-box.alert You're not logged in. Only logged in users can do this.
|
||||
12
app/views/scientific_names/show.html.haml
Normal file
12
app/views/scientific_names/show.html.haml
Normal file
@@ -0,0 +1,12 @@
|
||||
%p#notice= notice
|
||||
|
||||
%p
|
||||
%b Scientific name:
|
||||
= @scientific_name.scientific_name
|
||||
%p
|
||||
%b Crop:
|
||||
= @scientific_name.crop_id
|
||||
|
||||
= link_to 'Edit', edit_scientific_name_path(@scientific_name)
|
||||
\|
|
||||
= link_to 'Back', scientific_names_path
|
||||
@@ -1,4 +1,6 @@
|
||||
Growstuff::Application.routes.draw do
|
||||
resources :scientific_names
|
||||
|
||||
resources :crops, :members
|
||||
|
||||
devise_for :users
|
||||
|
||||
@@ -3,7 +3,6 @@ class CreateCrops < ActiveRecord::Migration
|
||||
create_table :crops do |t|
|
||||
t.string :system_name
|
||||
t.string :en_wikipedia_url
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
10
db/migrate/20121107012827_create_scientific_names.rb
Normal file
10
db/migrate/20121107012827_create_scientific_names.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateScientificNames < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :scientific_names do |t|
|
||||
t.string :scientific_name, :null => false
|
||||
t.integer :crop_id, :null => false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20121106101936) do
|
||||
ActiveRecord::Schema.define(:version => 20121107012827) do
|
||||
|
||||
create_table "crops", :force => true do |t|
|
||||
t.string "system_name", :null => false
|
||||
@@ -24,6 +24,13 @@ ActiveRecord::Schema.define(:version => 20121106101936) do
|
||||
add_index "crops", ["slug"], :name => "index_crops_on_slug", :unique => true
|
||||
add_index "crops", ["system_name"], :name => "index_crops_on_system_name"
|
||||
|
||||
create_table "scientific_names", :force => true do |t|
|
||||
t.string "scientific_name", :null => false
|
||||
t.integer "crop_id", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :default => "", :null => false
|
||||
|
||||
10
db/seeds.rb
10
db/seeds.rb
@@ -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
|
||||
|
||||
233
db/seeds/crops.csv
Normal file
233
db/seeds/crops.csv
Normal file
@@ -0,0 +1,233 @@
|
||||
achiote,Bixa orellana,https://en.wikipedia.org/wiki/Bixa_orellana
|
||||
ackee,Blighia sapida,https://en.wikipedia.org/wiki/Ackee
|
||||
acuyo,Piper auritum,https://en.wikipedia.org/wiki/Piper_auritum
|
||||
alexanders,Smyrnium olusatrum,https://en.wikipedia.org/wiki/Alexanders
|
||||
alfalfa,Medicago sativa,https://en.wikipedia.org/wiki/Alfalfa
|
||||
allspice,Pimenta dioica,https://en.wikipedia.org/wiki/Allspice
|
||||
almond,Prunus dulcis,https://en.wikipedia.org/wiki/Almond
|
||||
amaranth,Amaranthus spp.,https://en.wikipedia.org/wiki/Amaranth
|
||||
anise,Pimpinella anisum,https://en.wikipedia.org/wiki/Anise
|
||||
apple,Malus domestica,https://en.wikipedia.org/wiki/Apple
|
||||
apple mint,Mentha suaveolens,https://en.wikipedia.org/wiki/Apple_mint
|
||||
apricot,Prunus armeniaca,https://en.wikipedia.org/wiki/Apricot
|
||||
arrowroot,Maranta arundinacea,https://en.wikipedia.org/wiki/Maranta_arundinacea
|
||||
artichoke,Cynara cardunculus,https://en.wikipedia.org/wiki/Artichoke
|
||||
arugula,Eruca sativa,https://en.wikipedia.org/wiki/Arugula
|
||||
asparagus,Asparagus officinalis,https://en.wikipedia.org/wiki/Asparagus
|
||||
avocado,Persea americana,https://en.wikipedia.org/wiki/Avocado
|
||||
banana,Musa spp.,https://en.wikipedia.org/wiki/Banana
|
||||
barley,Hordeum vulgare,https://en.wikipedia.org/wiki/Barley
|
||||
basil,Ocimum basilicum,https://en.wikipedia.org/wiki/Basil
|
||||
bay,Laurus nobilis,https://en.wikipedia.org/wiki/Bay_Laurel
|
||||
bean,Phaseolus vulgaris,https://en.wikipedia.org/wiki/Common_bean
|
||||
beet,Beta vulgaris,https://en.wikipedia.org/wiki/Beet
|
||||
bell pepper,Capsicum annuum,https://en.wikipedia.org/wiki/Bell_pepper
|
||||
bitter melon,Momordica charantia,https://en.wikipedia.org/wiki/Bitter_melon
|
||||
blackberry,Rubus fruticosus,https://en.wikipedia.org/wiki/Blackberry
|
||||
blackcurrant,Ribes spp.,https://en.wikipedia.org/wiki/Ribes
|
||||
borage,Borago officinalis,https://en.wikipedia.org/wiki/Borage
|
||||
breadfruit,Artocarpus altilis,https://en.wikipedia.org/wiki/Breadfruit
|
||||
broccoli,Brassica oleracea,https://en.wikipedia.org/wiki/Broccoli
|
||||
Brussels sprout,Brassica oleracea,https://en.wikipedia.org/wiki/Brussels_sprout
|
||||
buckwheat,Fagopyrum esculentum,https://en.wikipedia.org/wiki/Buckwheat
|
||||
cabbage,Brassica oleracea,https://en.wikipedia.org/wiki/Cabbage
|
||||
cape gooseberry,Physalis peruviana,https://en.wikipedia.org/wiki/Physalis_peruviana
|
||||
caper,Capparis spinosa,https://en.wikipedia.org/wiki/Caper
|
||||
cardoon,Cynara cardunculus,https://en.wikipedia.org/wiki/Cardoon
|
||||
carrot,Daucus carota,https://en.wikipedia.org/wiki/Carrot
|
||||
cassava,Manihot esculenta,https://en.wikipedia.org/wiki/Cassava
|
||||
catnip,Nepeta cataria,https://en.wikipedia.org/wiki/Nepeta_cataria
|
||||
cauliflower,Brassica oleracea,https://en.wikipedia.org/wiki/Cauliflower
|
||||
cayenne pepper,Capsicum annuum,https://en.wikipedia.org/wiki/Cayenne_pepper
|
||||
celeriac,Apium graveolens var. rapaceum,https://en.wikipedia.org/wiki/Celeriac
|
||||
celery,Apium graveolens,https://en.wikipedia.org/wiki/Celery
|
||||
chamomile,Matricaria chamomila,https://en.wikipedia.org/wiki/Matricaria_recutita
|
||||
chaya,Cnidoscolus aconitifolius,https://en.wikipedia.org/wiki/Cnidoscolus_aconitifolius
|
||||
chayote,Sechium edule,https://en.wikipedia.org/wiki/Chayote
|
||||
cherry,Prunus avium,https://en.wikipedia.org/wiki/Cherry
|
||||
chervil,Anthriscus cerefolium,https://en.wikipedia.org/wiki/Chervil
|
||||
chestnut,Castanea spp.,https://en.wikipedia.org/wiki/Chestnut
|
||||
chickpeas,Cicer arietinum,https://en.wikipedia.org/wiki/Chickpea
|
||||
chickweed,Stellaria,https://en.wikipedia.org/wiki/Stellaria
|
||||
chicory,Cichorium intybus,https://en.wikipedia.org/wiki/Chicory
|
||||
chinese cabbage,Brassica rapa (pekinensis),https://en.wikipedia.org/wiki/Chinese_cabbage
|
||||
chives,Allium schoenoprasum,https://en.wikipedia.org/wiki/Chives
|
||||
cicely,Myrrhis odorata,https://en.wikipedia.org/wiki/Cicely
|
||||
citron,Citrus medica,https://en.wikipedia.org/wiki/Citron
|
||||
coconut,Cocos nucifera,https://en.wikipedia.org/wiki/Coconut
|
||||
collard greens,Brassica oleracea (acephala),https://en.wikipedia.org/wiki/Collard_greens
|
||||
comfrey,Symphytum officinale,https://en.wikipedia.org/wiki/Comfrey
|
||||
coriander,Coriandrum sativum,https://en.wikipedia.org/wiki/Coriander
|
||||
corn,Zea mays,https://en.wikipedia.org/wiki/Corn
|
||||
corn salad,Valerianella locusta,https://en.wikipedia.org/wiki/Corn_salad
|
||||
cress,Lepidium sativum,https://en.wikipedia.org/wiki/Garden_cress
|
||||
cucumber,Cucumis sativus,https://en.wikipedia.org/wiki/Cucumbers
|
||||
cumin,Cuminum cyminum,https://en.wikipedia.org/wiki/Cumin
|
||||
cumquat,Citrus japonica,https://en.wikipedia.org/wiki/Kumquat
|
||||
curry leaf,Murraya koenigii,https://en.wikipedia.org/wiki/Curry-leaf_Tree
|
||||
curry plant,Helichrysum italicum,https://en.wikipedia.org/wiki/Helichrysum_italicum
|
||||
daikon,Raphanus sativus Longipinnatus group,https://en.wikipedia.org/wiki/Daikon
|
||||
dandelion,Taraxacum officinale,https://en.wikipedia.org/wiki/Dandelion
|
||||
dates,Phoenix dactylifera,https://en.wikipedia.org/wiki/Date_%28fruit%29
|
||||
desert lime,Citrus glauca,https://en.wikipedia.org/wiki/Citrus_glauca
|
||||
dill,Anethum graveolens,https://en.wikipedia.org/wiki/Dill
|
||||
dog rose,Rosa canina,https://en.wikipedia.org/wiki/Rosa_canina
|
||||
durian,Durio,https://en.wikipedia.org/wiki/Durian
|
||||
eggplant,Solanum melongena,https://en.wikipedia.org/wiki/Eggplant
|
||||
elderberry,Sambucus nigra,https://en.wikipedia.org/wiki/Sambucus_nigra
|
||||
endive,Cichorium endivia,https://en.wikipedia.org/wiki/Endive
|
||||
epazote,Dysphania ambrosioides,https://en.wikipedia.org/wiki/Epazote
|
||||
fava bean,Vicia faba,https://en.wikipedia.org/wiki/Vicia_faba
|
||||
feijoa,Acca sellowiana,https://en.wikipedia.org/wiki/Acca_sellowiana
|
||||
fennel,Foeniculum vulgare,https://en.wikipedia.org/wiki/Fennel
|
||||
fenugreek,Trigonella foenum-graecum,https://en.wikipedia.org/wiki/Fenugreek
|
||||
fiddlehead,Pteridium aquilinum,https://en.wikipedia.org/wiki/Fiddlehead
|
||||
fig,Ficus carica,https://en.wikipedia.org/wiki/Common_fig
|
||||
flax,Linum usitatissimum,https://en.wikipedia.org/wiki/Flax
|
||||
garlic,Allium sativum,https://en.wikipedia.org/wiki/Garlic
|
||||
garlic chives,Allium tuberosum,https://en.wikipedia.org/wiki/Garlic_chives
|
||||
ginger,Zingiber officinale,https://en.wikipedia.org/wiki/Ginger
|
||||
gooseberry,Ribes uva-crispa,https://en.wikipedia.org/wiki/Gooseberry
|
||||
grapefruit,Citrus paradisi,https://en.wikipedia.org/wiki/Grapefruit
|
||||
grapes,Vitis spp.,https://en.wikipedia.org/wiki/Grape
|
||||
guava,Psidium spp.,https://en.wikipedia.org/wiki/Guava
|
||||
habanero,Capsicum chinense,https://en.wikipedia.org/wiki/Habanero
|
||||
hibiscus,Hibiscus,https://en.wikipedia.org/wiki/Hibiscus
|
||||
horseradish,Armoracia rusticana,https://en.wikipedia.org/wiki/Horseradish
|
||||
jasmine,Jasminum officinale,https://en.wikipedia.org/wiki/Jasmine
|
||||
Jerusalem artichoke,Helianthus tuberosus,https://en.wikipedia.org/wiki/Jerusalem_artichoke
|
||||
jicama,Pachyrhizus erosus,https://en.wikipedia.org/wiki/Jicama
|
||||
juniper berry,Juniperus communis,https://en.wikipedia.org/wiki/Juniper_berry
|
||||
kaffir lime,Citrus x hystrix,https://en.wikipedia.org/wiki/Kaffir_lime
|
||||
kale,Brassica oleracea (acephala),https://en.wikipedia.org/wiki/Kale
|
||||
kava,Piper methysticum,https://en.wikipedia.org/wiki/Kava
|
||||
kohlrabi,Brassica oleracea (gongylodes),https://en.wikipedia.org/wiki/Kohlrabi
|
||||
lavender,Lavandula spp.,https://en.wikipedia.org/wiki/Lavender
|
||||
leek,Allium ampeloprasum var. porrum,https://en.wikipedia.org/wiki/Leeks
|
||||
lemon,Citrus limon,https://en.wikipedia.org/wiki/Lemon
|
||||
lemon balm,Melissa officinalis,https://en.wikipedia.org/wiki/Lemon_balm
|
||||
lemon myrtle,Backhousia citriodora,https://en.wikipedia.org/wiki/Backhousia_citriodora
|
||||
lemon verbena,Aloysia citrodora,https://en.wikipedia.org/wiki/Aloysia_citrodora
|
||||
lemongrass,Cymbopogon spp.,https://en.wikipedia.org/wiki/Lemongrass
|
||||
lentils,Lens culinaris,https://en.wikipedia.org/wiki/Lentil
|
||||
lettuce,Lactuca sativa,https://en.wikipedia.org/wiki/Lettuce
|
||||
licorice,Glycyrrhiza glabra,https://en.wikipedia.org/wiki/Licorice
|
||||
lillipilli,Syzygium luehmannii,https://en.wikipedia.org/wiki/Syzygium_luehmannii
|
||||
lima bean,Phaseolus lunatus,https://en.wikipedia.org/wiki/Phaseolus_lunatus
|
||||
lime,Citrus spp.,https://en.wikipedia.org/wiki/Lime_%28fruit%29
|
||||
lovage,Levisticum officinale,https://en.wikipedia.org/wiki/Lovage
|
||||
luffa,Luffa cylindrica,https://en.wikipedia.org/wiki/Luffa
|
||||
lupin bean,Lupinus luteus,https://en.wikipedia.org/wiki/Lupin_bean
|
||||
macadamia,Macadamia,https://en.wikipedia.org/wiki/Macadamia
|
||||
Malabar spinach,Basella alba,https://en.wikipedia.org/wiki/Basella_alba
|
||||
mandarin,Citrus reticulata,https://en.wikipedia.org/wiki/Mandarin_orange
|
||||
mango,Mangifera spp.,https://en.wikipedia.org/wiki/Mango
|
||||
maracuja,Passiflora edulis,https://en.wikipedia.org/wiki/Maracuja
|
||||
marjoram,Origanum majorana,https://en.wikipedia.org/wiki/Marjoram
|
||||
marshmallow,Althaea officinalis,https://en.wikipedia.org/wiki/Althaea_officinalis
|
||||
medlar,Mespilus germanica,https://en.wikipedia.org/wiki/Mespilus_germanica
|
||||
melon,Cucumis melo,https://en.wikipedia.org/wiki/Melon
|
||||
miner's lettuce,Claytonia perfoliata,https://en.wikipedia.org/wiki/Claytonia_perfoliata
|
||||
mint,Mentha spicata,https://en.wikipedia.org/wiki/Mentha_spicata
|
||||
mung bean,Vigna radiata,https://en.wikipedia.org/wiki/Mung_bean
|
||||
mustard,Brassica juncea,https://en.wikipedia.org/wiki/Mustard_plant
|
||||
nasturtium,Tropaeloum spp.,https://en.wikipedia.org/wiki/Tropaeolum
|
||||
New Zealand spinach,Tetragonia tetragonioides,https://en.wikipedia.org/wiki/Tetragonia
|
||||
nigella,Nigella sativa,https://en.wikipedia.org/wiki/Nigella_sativa
|
||||
oats,Avena sativa,https://en.wikipedia.org/wiki/Oats
|
||||
okra,Abelmoschus esculentus,https://en.wikipedia.org/wiki/Okra
|
||||
olive,Olea europaea,https://en.wikipedia.org/wiki/Olive
|
||||
onion,Allium cepa,https://en.wikipedia.org/wiki/Onions
|
||||
orange,Citrus sinensis,https://en.wikipedia.org/wiki/Orange_%28fruit%29
|
||||
oregano,Origanum vulgare,https://en.wikipedia.org/wiki/Oregano
|
||||
parsley,Petroselinum hortense,https://en.wikipedia.org/wiki/Parsley
|
||||
parsnip,Pastinaca sativa,https://en.wikipedia.org/wiki/Parsnip
|
||||
passion fruit,Passiflora edulis,https://en.wikipedia.org/wiki/Passionfruit
|
||||
pea,Pisum sativum,https://en.wikipedia.org/wiki/Pea
|
||||
peach,Prunus persica,https://en.wikipedia.org/wiki/Peach
|
||||
peach,Prunus persica,https://en.wikipedia.org/wiki/Peach
|
||||
peanut,Arachis hypogaea,https://en.wikipedia.org/wiki/Peanut
|
||||
pear,Pyrus spp.,https://en.wikipedia.org/wiki/Pear
|
||||
pearl millet,Pennisetum glaucum,https://en.wikipedia.org/wiki/Pearl_millet
|
||||
pecan,Carya illinoinensis,https://en.wikipedia.org/wiki/Pecan
|
||||
peppermint,Mentha x piperita,https://en.wikipedia.org/wiki/Peppermint
|
||||
Persian lime,Citrus latifolia,https://en.wikipedia.org/wiki/Persian_lime
|
||||
persimmon,Diospyros spp.,https://en.wikipedia.org/wiki/Persimmon
|
||||
pigeon pea,Cajanus cajan,https://en.wikipedia.org/wiki/Pigeon_pea
|
||||
pigface,Carpobrotus glaucescens,https://en.wikipedia.org/wiki/Carpobrotus_glaucescens
|
||||
pineapple,Ananas comosus,https://en.wikipedia.org/wiki/Pineapple
|
||||
pistachio,Pistacia vera,https://en.wikipedia.org/wiki/Pistachio
|
||||
plantain,Musa spp.,https://en.wikipedia.org/wiki/Plantain
|
||||
plum,Prunus spp.,https://en.wikipedia.org/wiki/Plum
|
||||
pomegranate,Punica granatum,https://en.wikipedia.org/wiki/Pomegranate
|
||||
pomelo,Citrus maxima,https://en.wikipedia.org/wiki/Pomelo
|
||||
potato,Solanum tuberosum,https://en.wikipedia.org/wiki/Potatoes
|
||||
prickly pear,Opuntia,https://en.wikipedia.org/wiki/Opuntia
|
||||
pumpkin,Cucurbita spp.,https://en.wikipedia.org/wiki/Pumpkin
|
||||
purslane,Portulaca oleracea,https://en.wikipedia.org/wiki/Portulaca_oleracea
|
||||
quandong,Santalum acuminatum,https://en.wikipedia.org/wiki/Santalum_acuminatum
|
||||
quince,Cydonia oblonga,https://en.wikipedia.org/wiki/Quince
|
||||
quinoa,Chenopodium quinoa,https://en.wikipedia.org/wiki/Quinoa
|
||||
radicchio,Cichorium intybus,https://en.wikipedia.org/wiki/Radicchio
|
||||
radish,Raphanus sativus,https://en.wikipedia.org/wiki/Radish
|
||||
rapeseed,Brassica napus,https://en.wikipedia.org/wiki/Rapeseed
|
||||
raspberry,Rubus idaeus,https://en.wikipedia.org/wiki/Rubus_idaeus
|
||||
rhubarb,Rheum rhabarbarum,https://en.wikipedia.org/wiki/Rhubarb
|
||||
rice,Oryza sativa,https://en.wikipedia.org/wiki/Rice
|
||||
rice bean,Vigna umbellata,https://en.wikipedia.org/wiki/Ricebean
|
||||
rose,Rosa,https://en.wikipedia.org/wiki/Rose
|
||||
roselle,Hibiscus sabdariffa,https://en.wikipedia.org/wiki/Roselle_%28plant%29
|
||||
rosemary,Rosmarinus officinalis,https://en.wikipedia.org/wiki/Rosemary
|
||||
rue,Ruta graveolens,https://en.wikipedia.org/wiki/Common_Rue
|
||||
runner bean,Phaseolus coccineus,https://en.wikipedia.org/wiki/Runner_bean
|
||||
rutabaga,Brassica napus Napobrassica group,https://en.wikipedia.org/wiki/Rutabaga
|
||||
rye,Secale cereale,https://en.wikipedia.org/wiki/Rye
|
||||
safflower,Carthamus tinctorius,https://en.wikipedia.org/wiki/Safflower
|
||||
saffron,Crocus sativus,https://en.wikipedia.org/wiki/Saffron
|
||||
sage,Salvia officinalis,https://en.wikipedia.org/wiki/Salvia_officinalis
|
||||
salad burnet,Sanguisorba minor,https://en.wikipedia.org/wiki/Salad_burnet
|
||||
salsify,Tragopogon porrifolius,https://en.wikipedia.org/wiki/Salsify
|
||||
samphire,Crithmum maritimum,https://en.wikipedia.org/wiki/Rock_samphire
|
||||
sassafras,Sassafras albidum,https://en.wikipedia.org/wiki/Sassafras_albidum
|
||||
sesame,Sesamum indicum,https://en.wikipedia.org/wiki/Sesame
|
||||
shallot,Allium cepa var. aggregatum,https://en.wikipedia.org/wiki/Shallot
|
||||
sorghum,Sorghum spp.,https://en.wikipedia.org/wiki/Sorghum
|
||||
sorrel,Rumex acetosa,https://en.wikipedia.org/wiki/Sorrel
|
||||
soursop,Annona muricata,https://en.wikipedia.org/wiki/Soursop
|
||||
soybean,Glycine max,https://en.wikipedia.org/wiki/Soybean
|
||||
spearmint,Mentha spicata,https://en.wikipedia.org/wiki/Mentha_spicata
|
||||
spinach,Spinacia oleracea,https://en.wikipedia.org/wiki/Spinach
|
||||
star anise,Illicium verum,https://en.wikipedia.org/wiki/Star_anise
|
||||
starfruit,Averrhoa carambola,https://en.wikipedia.org/wiki/Starfruit
|
||||
stevia,Stevia rebaudiana,https://en.wikipedia.org/wiki/Stevia
|
||||
strawberry,Fragaria ananassa,https://en.wikipedia.org/wiki/Strawberry
|
||||
summer savory,Satureja hortensis,https://en.wikipedia.org/wiki/Summer_savory
|
||||
sunflowers,Helianthus annuus,https://en.wikipedia.org/wiki/Sunflower
|
||||
sweet potato,Ipomoea batatas,https://en.wikipedia.org/wiki/Sweet_potato
|
||||
Swiss chard,Beta vulgaris var. cicla,https://en.wikipedia.org/wiki/Swiss_chard
|
||||
tamarillo,Solanum betaceum ,https://en.wikipedia.org/wiki/Tamarillo
|
||||
tamarind,Tamarindus indica,https://en.wikipedia.org/wiki/Tamarind
|
||||
tangerine,Citrus tangerina,https://en.wikipedia.org/wiki/Tangerine
|
||||
tansy,Tanacetum vulgare,https://en.wikipedia.org/wiki/Tansy
|
||||
taro,Colocasia esculenta,https://en.wikipedia.org/wiki/Taro
|
||||
tarragon,Artemisia dracunculus,https://en.wikipedia.org/wiki/Tarragon
|
||||
thyme,Thymus mongolicus,https://en.wikipedia.org/wiki/Thyme
|
||||
tomatillo,Physalis philadelphica,https://en.wikipedia.org/wiki/Tomatillo
|
||||
tomato,Solanum lycopersicum,https://en.wikipedia.org/wiki/Tomato
|
||||
turmeric,Curcuma longa,https://en.wikipedia.org/wiki/Turmeric
|
||||
turnip,Brassica rapa var. rapa,https://en.wikipedia.org/wiki/Turnip
|
||||
urad bean,Vigna mungo,https://en.wikipedia.org/wiki/Urad_(bean)
|
||||
valerian,Valeriana officinalis,https://en.wikipedia.org/wiki/Valerian_%28plant%29
|
||||
vanilla,Vanilla planifolia,https://en.wikipedia.org/wiki/Vanilla
|
||||
walnut,Juglans spp.,https://en.wikipedia.org/wiki/Walnut
|
||||
wasabi,Wasabia japonica,https://en.wikipedia.org/wiki/Wasabi
|
||||
watermelon,Citrullus lanatus,https://en.wikipedia.org/wiki/Watermelon
|
||||
wheat,Triticum spp.,https://en.wikipedia.org/wiki/Wheat
|
||||
winter savory,Satureja montana,https://en.wikipedia.org/wiki/Winter_savory
|
||||
wormwood,Artemisia absinthium,https://en.wikipedia.org/wiki/Artemisia_absinthium
|
||||
yam,Dioscorea spp.,https://en.wikipedia.org/wiki/Yam_(vegetable)
|
||||
yardlong bean,Vigna unguiculata (sesquipedalis),https://en.wikipedia.org/wiki/Yardlong_bean
|
||||
yarrow,Achillea millefolium,https://en.wikipedia.org/wiki/Achillea_millefolium
|
||||
zucchini,Cucurbita pepo.,https://en.wikipedia.org/wiki/Zucchini
|
||||
coffee,Coffea,https://en.wikipedia.org/wiki/Coffee
|
||||
tea,Camellia sinensis,https://en.wikipedia.org/wiki/Tea
|
||||
|
164
spec/controllers/scientific_names_controller_spec.rb
Normal file
164
spec/controllers/scientific_names_controller_spec.rb
Normal file
@@ -0,0 +1,164 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
describe ScientificNamesController do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# ScientificName. As you add validations to ScientificName, be sure to
|
||||
# update the return value of this method accordingly.
|
||||
def valid_attributes
|
||||
{ :scientific_name => 'Solanum lycopersicum', :crop_id => 1 }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# ScientificNamesController. Be sure to keep this updated too.
|
||||
def valid_session
|
||||
{}
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all scientific_names as @scientific_names" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
assigns(:scientific_names).should eq([scientific_name])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
it "assigns the requested scientific_name as @scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
get :show, {:id => scientific_name.to_param}, valid_session
|
||||
assigns(:scientific_name).should eq(scientific_name)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "assigns a new scientific_name as @scientific_name" do
|
||||
get :new, {}, valid_session
|
||||
assigns(:scientific_name).should be_a_new(ScientificName)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET edit" do
|
||||
it "assigns the requested scientific_name as @scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
get :edit, {:id => scientific_name.to_param}, valid_session
|
||||
assigns(:scientific_name).should eq(scientific_name)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
describe "with valid params" do
|
||||
it "creates a new ScientificName" do
|
||||
expect {
|
||||
post :create, {:scientific_name => valid_attributes}, valid_session
|
||||
}.to change(ScientificName, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created scientific_name as @scientific_name" do
|
||||
post :create, {:scientific_name => valid_attributes}, valid_session
|
||||
assigns(:scientific_name).should be_a(ScientificName)
|
||||
assigns(:scientific_name).should be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created scientific_name" do
|
||||
post :create, {:scientific_name => valid_attributes}, valid_session
|
||||
response.should redirect_to(ScientificName.last)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns a newly created but unsaved scientific_name as @scientific_name" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ScientificName.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:scientific_name => {}}, valid_session
|
||||
assigns(:scientific_name).should be_a_new(ScientificName)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ScientificName.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:scientific_name => {}}, valid_session
|
||||
response.should render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT update" do
|
||||
describe "with valid params" do
|
||||
it "updates the requested scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
# Assuming there are no other scientific_names in the database, this
|
||||
# specifies that the ScientificName created on the previous line
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
ScientificName.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
|
||||
put :update, {:id => scientific_name.to_param, :scientific_name => {'these' => 'params'}}, valid_session
|
||||
end
|
||||
|
||||
it "assigns the requested scientific_name as @scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
put :update, {:id => scientific_name.to_param, :scientific_name => valid_attributes}, valid_session
|
||||
assigns(:scientific_name).should eq(scientific_name)
|
||||
end
|
||||
|
||||
it "redirects to the scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
put :update, {:id => scientific_name.to_param, :scientific_name => valid_attributes}, valid_session
|
||||
response.should redirect_to(scientific_name)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns the scientific_name as @scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ScientificName.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => scientific_name.to_param, :scientific_name => {}}, valid_session
|
||||
assigns(:scientific_name).should eq(scientific_name)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
ScientificName.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => scientific_name.to_param, :scientific_name => {}}, valid_session
|
||||
response.should render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE destroy" do
|
||||
it "destroys the requested scientific_name" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => scientific_name.to_param}, valid_session
|
||||
}.to change(ScientificName, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the scientific_names list" do
|
||||
scientific_name = ScientificName.create! valid_attributes
|
||||
delete :destroy, {:id => scientific_name.to_param}, valid_session
|
||||
response.should redirect_to(scientific_names_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/scientific_names_helper_spec.rb
Normal file
15
spec/helpers/scientific_names_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the ScientificNamesHelper. For example:
|
||||
#
|
||||
# describe ScientificNamesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# helper.concat_strings("this","that").should == "this that"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe ScientificNamesHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/scientific_name_spec.rb
Normal file
5
spec/models/scientific_name_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe ScientificName do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
11
spec/requests/scientific_names_spec.rb
Normal file
11
spec/requests/scientific_names_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "ScientificNames" do
|
||||
describe "GET /scientific_names" do
|
||||
it "works! (now write some real specs)" do
|
||||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
|
||||
get scientific_names_path
|
||||
response.status.should be(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
35
spec/routing/scientific_names_routing_spec.rb
Normal file
35
spec/routing/scientific_names_routing_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe ScientificNamesController do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
get("/scientific_names").should route_to("scientific_names#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
get("/scientific_names/new").should route_to("scientific_names#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
get("/scientific_names/1").should route_to("scientific_names#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
get("/scientific_names/1/edit").should route_to("scientific_names#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
post("/scientific_names").should route_to("scientific_names#create")
|
||||
end
|
||||
|
||||
it "routes to #update" do
|
||||
put("/scientific_names/1").should route_to("scientific_names#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
delete("/scientific_names/1").should route_to("scientific_names#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -16,7 +16,6 @@ describe "crops/edit" do
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
|
||||
before(:each) do
|
||||
@user = User.create(:email => "growstuff@example.com", :password => "irrelevant")
|
||||
@user.confirm!
|
||||
@@ -26,7 +25,6 @@ describe "crops/edit" do
|
||||
|
||||
it "renders the edit crop form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => crops_path(@crop), :method => "post" do
|
||||
assert_select "input#crop_system_name", :name => "crop[system_name]"
|
||||
@@ -34,5 +32,4 @@ describe "crops/edit" do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,13 +8,30 @@ describe "crops/new" do
|
||||
).as_new_record)
|
||||
end
|
||||
|
||||
it "renders new crop form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => crops_path, :method => "post" do
|
||||
assert_select "input#crop_system_name", :name => "crop[system_name]"
|
||||
assert_select "input#crop_en_wikipedia_url", :name => "crop[en_wikipedia_url]"
|
||||
context "logged out" do
|
||||
it "doesn't show the crop form if logged out" do
|
||||
render
|
||||
rendered.should contain "Only logged in users can do this"
|
||||
end
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
|
||||
before(:each) do
|
||||
@user = User.create(:email => "growstuff@example.com", :password => "irrelevant")
|
||||
@user.confirm!
|
||||
sign_in @user
|
||||
render
|
||||
end
|
||||
|
||||
it "renders new crop form" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => crops_path, :method => "post" do
|
||||
assert_select "input#crop_system_name", :name => "crop[system_name]"
|
||||
assert_select "input#crop_en_wikipedia_url", :name => "crop[en_wikipedia_url]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
36
spec/views/scientific_names/edit.html.haml_spec.rb
Normal file
36
spec/views/scientific_names/edit.html.haml_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "scientific_names/edit" do
|
||||
before(:each) do
|
||||
@scientific_name = assign(:scientific_name, stub_model(ScientificName,
|
||||
:scientific_name => "MyString",
|
||||
:crop_id => 1
|
||||
))
|
||||
end
|
||||
|
||||
context "logged out" do
|
||||
it "doesn't show the SN form if logged out" do
|
||||
render
|
||||
rendered.should contain "Only logged in users can do this"
|
||||
end
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
@user = User.create(:email => "growstuff@example.com", :password => "irrelevant")
|
||||
@user.confirm!
|
||||
sign_in @user
|
||||
render
|
||||
end
|
||||
|
||||
it "renders the edit scientific_name form" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => scientific_names_path(@scientific_name), :method => "post" do
|
||||
assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]"
|
||||
assert_select "input#scientific_name_crop_id", :name => "scientific_name[crop_id]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
23
spec/views/scientific_names/index.html.haml_spec.rb
Normal file
23
spec/views/scientific_names/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "scientific_names/index" do
|
||||
before(:each) do
|
||||
assign(:scientific_names, [
|
||||
stub_model(ScientificName,
|
||||
:scientific_name => "Scientific Name",
|
||||
:crop_id => 1
|
||||
),
|
||||
stub_model(ScientificName,
|
||||
:scientific_name => "Scientific Name",
|
||||
:crop_id => 1
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of scientific_names" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "tr>td", :text => "Scientific Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => 1.to_s, :count => 2
|
||||
end
|
||||
end
|
||||
37
spec/views/scientific_names/new.html.haml_spec.rb
Normal file
37
spec/views/scientific_names/new.html.haml_spec.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "scientific_names/new" do
|
||||
before(:each) do
|
||||
assign(:scientific_name, stub_model(ScientificName,
|
||||
:scientific_name => "MyString",
|
||||
:crop_id => 1
|
||||
).as_new_record)
|
||||
end
|
||||
|
||||
context "logged out" do
|
||||
it "doesn't show the SN form if logged out" do
|
||||
render
|
||||
rendered.should contain "Only logged in users can do this"
|
||||
end
|
||||
end
|
||||
|
||||
context "logged in" do
|
||||
before(:each) do
|
||||
@user = User.create(:email => "growstuff@example.com", :password => "irrelevant")
|
||||
@user.confirm!
|
||||
sign_in @user
|
||||
render
|
||||
end
|
||||
|
||||
it "renders new scientific_name form" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => scientific_names_path, :method => "post" do
|
||||
assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]"
|
||||
assert_select "input#scientific_name_crop_id", :name => "scientific_name[crop_id]"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
17
spec/views/scientific_names/show.html.haml_spec.rb
Normal file
17
spec/views/scientific_names/show.html.haml_spec.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "scientific_names/show" do
|
||||
before(:each) do
|
||||
@scientific_name = assign(:scientific_name, stub_model(ScientificName,
|
||||
:scientific_name => "Scientific Name",
|
||||
:crop_id => 1
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
rendered.should match(/Scientific Name/)
|
||||
rendered.should match(/1/)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user