Compare commits

..

8 Commits

Author SHA1 Message Date
Skud
78ee229205 Merge pull request #321 from Growstuff/dev
Production push: order referral codes and some CSS fixes
2013-09-18 18:23:22 -07:00
Skud
065005395f Merge pull request #317 from Skud/crop-hierarchy-caching
Hotfix: Added caching of full crop hierarchy
2013-09-12 18:30:36 -07:00
Skud
22cb6d2ad5 Merge pull request #315 from Skud/one-more-places-fix
(hotfix) Removed deploy script reminders, as no longer necessary
2013-09-12 05:07:21 -07:00
Skud
b02091bc00 Merge pull request #313 from Growstuff/dev
Production push: places
2013-09-12 05:03:21 -07:00
Skud
b8cd4cc7cf Merge pull request #299 from Growstuff/dev
Production push: newsletter signup and some backend stuff
2013-08-29 16:37:58 -07:00
Skud
e8d91c6404 Merge pull request #296 from Growstuff/dev
Production push: member bio, wrangler homepage, bugfixes
2013-08-26 17:09:18 -07:00
Skud
83f99dd32e Merge pull request #289 from Growstuff/dev
Production push: redesigned homepage, JSON API cleanup, RSS improvements, recent activity bugfix
2013-08-21 18:13:03 -07:00
Skud
ec7ccd8500 Merge pull request #264 from Growstuff/dev
Production push: crop photos, rearranged navbars
2013-07-29 08:12:03 -07:00
106 changed files with 173 additions and 1921 deletions

View File

@@ -1,7 +1,5 @@
source 'https://rubygems.org'
ruby "1.9.3"
gem 'bundler', '>=1.1.5'
gem 'rails', '3.2.13'
@@ -16,8 +14,6 @@ gem 'cancan' # for checking member privileges
gem 'gibbon' # for Mailchimp newsletter subscriptions
gem 'csv_shaper' # CSV export
# vendored activemerchant for testing- needed for bogus paypal
# gateway monkeypatch
gem 'activemerchant', '1.33.0',
@@ -31,7 +27,6 @@ group :production, :staging do
gem 'newrelic_rpm'
gem 'dalli'
gem 'memcachier'
gem 'rails_12factor' # supresses heroku plugin injection
end
# Gems used only for assets and not required
@@ -76,8 +71,6 @@ group :development do
# Installation of the debugger gem fails on Travis CI,
# so we don't use it in the test environment
gem 'debugger'
gem 'better_errors'
gem 'binding_of_caller'
end
# Markdown formatting for updates etc

View File

@@ -60,18 +60,12 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.1.1)
better_errors (1.0.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bluecloth (2.2.0)
bootstrap-datepicker-rails (1.1.1.3)
railties (>= 3.0)
builder (3.0.4)
cancan (1.6.10)
chunky_png (1.2.8)
coderay (1.1.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -94,10 +88,7 @@ GEM
rest-client
simplecov (>= 0.7)
thor
csv_shaper (1.0.0)
activesupport (>= 3.0.0)
dalli (2.6.4)
debug_inspector (0.0.2)
debugger (1.6.1)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
@@ -194,11 +185,6 @@ GEM
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
rails_12factor (0.0.2)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.1)
rails_stdout_logging (0.0.3)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
@@ -267,8 +253,6 @@ PLATFORMS
DEPENDENCIES
active_utils (= 1.0.5)!
activemerchant (= 1.33.0)!
better_errors
binding_of_caller
bluecloth
bootstrap-datepicker-rails
bundler (>= 1.1.5)
@@ -276,7 +260,6 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
compass-rails (~> 1.0.3)
coveralls
csv_shaper
dalli
debugger
devise
@@ -301,7 +284,6 @@ DEPENDENCIES
pg
rack (~> 1.4.5)
rails (= 3.2.13)
rails_12factor
rake (>= 10.0.0)
rspec-rails (~> 2.12.1)
sass-rails (~> 3.2.3)

View File

@@ -1,3 +0,0 @@
# 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/

View File

@@ -155,15 +155,6 @@ p.stats {
height: 500px;
}
.member-location {
font-size: small;
font-style: italic;
}
.member-location a {
color: @brown;
}
// Overrides applying only to mobile view
@media only screen and (max-width: 767px) {

View File

@@ -10,17 +10,9 @@ class CropsController < ApplicationController
@crops = Crop.includes(:scientific_names, {:plantings => :photos}).paginate(:page => params[:page])
respond_to do |format|
format.html
format.json { render :json => @crops }
format.rss do
@crops = Crop.recent.includes(:scientific_names, :creator)
render :rss => @crops
end
format.csv do
@filename = "Growstuff-Crops-#{Time.zone.now.to_s(:number)}.csv"
@crops = Crop.includes(:scientific_names, :plantings, :seeds, :creator)
render :csv => @crops
end
format.html # index.html.haml
format.json { render json: @crops }
format.rss { render :layout => false }
end
end

View File

@@ -1,106 +0,0 @@
class HarvestsController < ApplicationController
load_and_authorize_resource
# GET /harvests
# GET /harvests.json
def index
@owner = Member.find_by_slug(params[:owner])
if @owner
@harvests = @owner.harvests.includes(:owner, :crop).paginate(:page => params[:page])
else
@harvests = Harvest.includes(:owner, :crop).paginate(:page => params[:page])
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @harvests }
format.csv do
if @owner
@filename = "Growstuff-#{@owner}-Harvests-#{Time.zone.now.to_s(:number)}.csv"
@harvests = @owner.harvests.includes(:owner, :crop)
else
@filename = "Growstuff-Harvests-#{Time.zone.now.to_s(:number)}.csv"
@harvests = Harvest.includes(:owner, :crop)
end
render :csv => @harvests
end
end
end
# GET /harvests/1
# GET /harvests/1.json
def show
@harvest = Harvest.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @harvest }
end
end
# GET /harvests/new
# GET /harvests/new.json
def new
@harvest = Harvest.new('harvested_at' => Date.today)
# using find_by_id here because it returns nil, unlike find
@crop = Crop.find_by_id(params[:crop_id]) || Crop.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @harvest }
end
end
# GET /harvests/1/edit
def edit
@harvest = Harvest.find(params[:id])
end
# POST /harvests
# POST /harvests.json
def create
params[:harvest][:owner_id] = current_member.id
params[:harvested_at] = parse_date(params[:harvested_at])
@harvest = Harvest.new(params[:harvest])
respond_to do |format|
if @harvest.save
format.html { redirect_to @harvest, notice: 'Harvest was successfully created.' }
format.json { render json: @harvest, status: :created, location: @harvest }
else
format.html { render action: "new" }
format.json { render json: @harvest.errors, status: :unprocessable_entity }
end
end
end
# PUT /harvests/1
# PUT /harvests/1.json
def update
@harvest = Harvest.find(params[:id])
respond_to do |format|
if @harvest.update_attributes(params[:harvest])
format.html { redirect_to @harvest, notice: 'Harvest was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @harvest.errors, status: :unprocessable_entity }
end
end
end
# DELETE /harvests/1
# DELETE /harvests/1.json
def destroy
@harvest = Harvest.find(params[:id])
@harvest.destroy
respond_to do |format|
format.html { redirect_to harvests_url }
format.json { head :no_content }
end
end
end

View File

@@ -17,16 +17,6 @@ class PlantingsController < ApplicationController
format.html # index.html.erb
format.json { render json: @plantings }
format.rss { render :layout => false } #index.rss.builder
format.csv do
if @owner
@filename = "Growstuff-#{@owner}-Plantings-#{Time.zone.now.to_s(:number)}.csv"
@plantings = @owner.plantings.includes(:owner, :crop, :garden)
else
@filename = "Growstuff-Plantings-#{Time.zone.now.to_s(:number)}.csv"
@plantings = Planting.includes(:owner, :crop, :garden)
end
render :csv => @plantings
end
end
end

View File

@@ -17,16 +17,6 @@ class SeedsController < ApplicationController
format.html # index.html.erb
format.json { render json: @seeds }
format.rss { render :layout => false } #index.rss.builder
format.csv do
if @owner
@filename = "Growstuff-#{@owner}-Seeds-#{Time.zone.now.to_s(:number)}.csv"
@seeds = @owner.seeds.includes(:owner, :crop)
else
@filename = "Growstuff-Seeds-#{Time.zone.now.to_s(:number)}.csv"
@seeds = Seed.includes(:owner, :crop)
end
render :csv => @seeds
end
end
end

View File

@@ -1,40 +0,0 @@
module HarvestsHelper
def display_quantity(harvest)
human_quantity = display_human_quantity(harvest)
weight = display_weight(harvest)
if human_quantity && weight
return "#{human_quantity}, weighing #{weight}"
elsif human_quantity
return human_quantity
elsif weight
return weight
else
return 'not specified'
end
end
def display_human_quantity(harvest)
if ! harvest.quantity.blank? && harvest.quantity > 0
if harvest.unit == 'individual' # just the number
number_to_human(harvest.quantity, :strip_insignificant_zeros => true)
elsif ! harvest.unit.blank? # pluralize anything else
return pluralize(number_to_human(harvest.quantity, :strip_insignificant_zeros => true), harvest.unit)
else
return "#{number_to_human(harvest.quantity, :strip_insignificant_zeros => true)} #{harvest.unit}"
end
else
return nil
end
end
def display_weight(harvest)
if ! harvest.weight_quantity.blank? && harvest.weight_quantity > 0
return "#{number_to_human(harvest.weight_quantity, :strip_insignificant_zeros => true)} #{harvest.weight_unit}"
else
return nil
end
end
end

View File

@@ -64,10 +64,6 @@ class Ability
can :update, Planting, :garden => { :owner_id => member.id }
can :destroy, Planting, :garden => { :owner_id => member.id }
can :create, Harvest
can :update, Harvest, :owner_id => member.id
can :destroy, Harvest, :owner_id => member.id
can :create, Photo
can :update, Photo, :owner_id => member.id
can :destroy, Photo, :owner_id => member.id

View File

@@ -1,19 +1,18 @@
class Crop < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
attr_accessible :en_wikipedia_url, :name, :parent_id, :creator_id
friendly_id :system_name, use: :slugged
attr_accessible :en_wikipedia_url, :system_name, :parent_id, :creator_id
has_many :scientific_names
has_many :plantings
has_many :photos, :through => :plantings
has_many :seeds
has_many :harvests
belongs_to :creator, :class_name => 'Member'
belongs_to :parent, :class_name => 'Crop'
has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id'
default_scope order("lower(name) asc")
default_scope order("lower(system_name) asc")
scope :recent, reorder("created_at desc")
scope :toplevel, where(:parent_id => nil)
scope :randomized, reorder('random()') # ok on sqlite and psql, but not on mysql
@@ -30,7 +29,7 @@ class Crop < ActiveRecord::Base
end
def to_s
return name
return system_name
end
def default_scientific_name
@@ -99,52 +98,4 @@ class Crop < ActiveRecord::Base
return interesting_crops
end
# Crop.create_from_csv(row)
# used by db/seeds.rb and rake growstuff:import_crops
# CSV fields:
# - name (required)
# - scientific name (optional, can be picked up from parent if it has one)
# - en_wikipedia_url (required)
# - parent (name, optional)
def Crop.create_from_csv(row)
name,scientific_name,en_wikipedia_url,parent = row
@cropbot = Member.find_by_login_name('cropbot')
raise "cropbot account not found: run rake db:seed" unless @cropbot
@crop = Crop.find_or_create_by_name(name)
@crop.update_attributes(
:en_wikipedia_url => en_wikipedia_url,
:creator_id => @cropbot.id
)
if parent
@parent = Crop.find_by_name(parent)
if @parent
@crop.update_attributes(:parent_id => @parent.id)
else
logger.warn("Warning: parent crop #{parent} not found")
end
end
unless @crop.scientific_names.exists?(:scientific_name => scientific_name)
@sn = ''
if scientific_name
@sn = scientific_name
elsif @crop.parent
@sn = @crop.parent.scientific_names.first.scientific_name
end
if @sn
@crop.scientific_names.create(
:scientific_name => @sn,
:creator_id => @cropbot.id
)
else
logger.warn("Warning: no scientific name (not even on parent crop) for #{@crop}")
end
end
end
end

View File

@@ -1,55 +1,21 @@
class Garden < ActiveRecord::Base
include Geocodable
extend FriendlyId
friendly_id :garden_slug, use: :slugged
attr_accessible :name, :slug, :owner_id, :description, :active,
:location, :latitude, :longitude, :area, :area_unit
attr_accessible :name, :slug, :owner_id, :description
belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id'
has_many :plantings, :order => 'created_at DESC', :dependent => :destroy
has_many :crops, :through => :plantings
# set up geocoding
geocoded_by :location
after_validation :geocode
after_validation :empty_unwanted_geocodes
# before_create :replace_blank_name
default_scope order("lower(name) asc")
scope :active, where(:active => true)
scope :inactive, where(:active => false)
validates :name,
:format => {
:with => /\S/
}
validates :area,
:numericality => { :only_integer => false },
:allow_nil => true
AREA_UNITS_VALUES = {
"square metres" => "square metre",
"square feet" => "square foot",
"hectares" => "hectare",
"acres" => "acre"
}
validates :area_unit, :inclusion => { :in => AREA_UNITS_VALUES.values,
:message => "%{value} is not a valid area unit" },
:allow_nil => true,
:allow_blank => true
after_validation :cleanup_area
def cleanup_area
if area == 0
self.area = nil
end
if area.blank?
self.area_unit = nil
end
end
def garden_slug
"#{owner.login_name}-#{name}".downcase.gsub(' ', '-')
end

View File

@@ -1,71 +0,0 @@
class Harvest < ActiveRecord::Base
extend FriendlyId
friendly_id :harvest_slug, use: :slugged
attr_accessible :crop_id, :harvested_at, :description, :owner_id,
:quantity, :unit, :weight_quantity, :weight_unit, :slug
belongs_to :crop
belongs_to :owner, :class_name => 'Member'
default_scope order('created_at DESC')
validates :quantity,
:numericality => { :only_integer => false },
:allow_nil => true
UNITS_VALUES = {
"individual" => "individual",
"bunches" => "bunch",
"sprigs" => "sprig",
"handfuls" => "handful",
"litres" => "litre",
"pints" => "ping",
"quarts" => "quart",
"buckets" => "bucket",
"baskets" => "basket",
"bushels" => "bushel"
}
validates :unit, :inclusion => { :in => UNITS_VALUES.values,
:message => "%{value} is not a valid unit" },
:allow_nil => true,
:allow_blank => true
validates :weight_quantity,
:numericality => { :only_integer => false },
:allow_nil => true
WEIGHT_UNITS_VALUES = {
"kg" => "kg",
"lb" => "lb"
}
validates :weight_unit, :inclusion => { :in => WEIGHT_UNITS_VALUES.values,
:message => "%{value} is not a valid unit" },
:allow_nil => true,
:allow_blank => true
after_validation :cleanup_quantities
def cleanup_quantities
if quantity == 0
self.quantity = nil
end
if quantity.blank?
self.unit = nil
end
if weight_quantity == 0
self.weight_quantity = nil
end
if weight_quantity.blank?
self.weight_unit = nil
end
end
def harvest_slug
"#{owner.login_name}-#{crop}".downcase.gsub(' ', '-')
end
end

View File

@@ -1,7 +1,5 @@
class Member < ActiveRecord::Base
include Geocodable
extend FriendlyId
friendly_id :login_name, use: :slugged
has_many :posts, :foreign_key => 'author_id'
@@ -12,7 +10,6 @@ class Member < ActiveRecord::Base
has_many :plantings, :foreign_key => 'owner_id'
has_many :seeds, :foreign_key => 'owner_id'
has_many :harvests, :foreign_key => 'owner_id'
has_and_belongs_to_many :roles
@@ -218,6 +215,22 @@ class Member < ActiveRecord::Base
return nearby_members
end
private
def geocode
unless self.location.blank?
self.latitude, self.longitude =
Geocoder.coordinates(location, params: {limit: 1})
end
end
def empty_unwanted_geocodes
if self.location.blank?
self.latitude = nil
self.longitude = nil
end
end
def update_newsletter_subscription
if confirmed_at_changed? and newsletter # just signed up
newsletter_subscribe

View File

@@ -14,7 +14,7 @@ class Planting < ActiveRecord::Base
default_scope order("created_at desc")
delegate :name,
delegate :system_name,
:en_wikipedia_url,
:default_scientific_name,
:plantings_count,
@@ -61,7 +61,7 @@ class Planting < ActiveRecord::Base
# stringify as "beet in Skud's backyard" or similar
def to_s
self.crop_name + " in " + self.location
self.crop_system_name + " in " + self.location
end
def default_photo

View File

@@ -55,6 +55,6 @@ class Seed < ActiveRecord::Base
end
def seed_slug
"#{owner.login_name}-#{crop.name}".downcase.gsub(' ', '-')
"#{owner.login_name}-#{crop.system_name}".downcase.gsub(' ', '-')
end
end

View File

@@ -13,8 +13,3 @@
%div.pagination
= page_entries_info @comments, :model => "comments"
= will_paginate @comments
%p
Subscribe to the #{Growstuff::Application.config.site_name}
= succeed "." do
= link_to "comments RSS feed", comments_path(:format => 'rss')

View File

@@ -6,8 +6,13 @@
%ul
- crop.seeds.tradable.each do |seed|
%li
= link_to "#{seed.owner} will trade #{seed.tradable_to}.", seed_path(seed)
= render :partial => 'members/location', :locals => { :member => seed.owner }
= link_to seed.owner, seed.owner
- if seed.owner.location
in #{seed.owner.location}
- else
(location unknown)
will trade #{seed.tradable_to}.
= link_to "View details.", seed_path(seed)
- if current_member
= link_to "List your seeds to trade.", new_seed_path()
- else

View File

@@ -13,9 +13,9 @@
on the Growstuff wiki.
.control-group
= f.label :name, :class => 'control-label'
= f.label :system_name, :class => 'control-label'
.controls
= f.text_field :name
= f.text_field :system_name
%span.help-inline Name in US English; singular; capitalize proper nouns only.
.control-group
= f.label :en_wikipedia_url, 'Wikipedia URL', :class => 'control-label'
@@ -25,7 +25,7 @@
.control-group
= f.label :parent_id, 'Parent crop', :class => 'control-label'
.controls
= collection_select(:crop, :parent_id, Crop.all, :id, :name, {:include_blank => true})
= collection_select(:crop, :parent_id, Crop.all, :id, :system_name, {:include_blank => true})
%span.help-inline Optional. For setting up crop hierarchies for varieties etc.
.form-actions
= f.submit 'Save', :class => 'btn btn-primary'

View File

@@ -1,19 +0,0 @@
%h4 Harvests
- if crop.harvests.empty?
%p
Nobody has harvested this crop yet.
- else
%ul
- crop.harvests.each do |harvest|
%li
= link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest)
= render :partial => 'members/location', :locals => { :member => harvest.owner }
%small
= distance_of_time_in_words(harvest.created_at, Time.zone.now)
ago.
- if current_member
= link_to "Track your #{crop.name} harvests.", new_harvest_path()
- else
= render :partial => 'shared/signin_signup', :locals => { :to => "track your #{crop.name} harvests" }

View File

@@ -2,11 +2,11 @@
= link_to |
image_tag( |
crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png', |
:alt => crop.name |
:alt => crop.system_name |
), |
crop, |
:rel => "popover", |
'data-trigger' => 'hover', |
'data-title' => crop.name, |
'data-title' => crop.system_name, |
'data-content' => "#{ render :partial => 'crops/popover', :locals => { :crop => crop } }", |
'data-html' => true

View File

@@ -1,8 +1,8 @@
.thumbnail(style='height: 220px')
- if crop
= link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => crop.name, :class => 'img-rounded'), crop
= link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => crop.system_name, :class => 'img-rounded'), crop
%p
= link_to crop.name, crop
= link_to crop.system_name, crop
- if crop.scientific_names.count > 0
%br/
%i

View File

@@ -1,6 +1,6 @@
- if crop.parent
%p
= crop.name
= crop.system_name
is a variety of
= succeed "." do
= link_to crop.parent, crop.parent

View File

@@ -1,83 +0,0 @@
csv.headers :id, :name,
:growstuff_url, :en_wikipedia_url,
:default_scientific_name,
:scientific_name_count,
:parent_crop_id, :parent_crop_name,
:plantings_count,
:seeds_count,
:recommended_sunniness,
:planted_in_sun,
:planted_in_semi_shade,
:planted_in_shade,
:plant_from_recommendation,
:planted_from_seed,
:planted_from_seedling,
:planted_from_cutting,
:planted_from_root_division,
:planted_from_runner,
:planted_from_bulb,
:planted_from_bare_root_plant,
:planted_from_advanced_plant,
:planted_from_graft,
:planted_from_layering,
:added_by_member_id,
:added_by_member_name,
:date_added,
:last_modified,
:license
@crops.each do |c|
csv.row c do |csv, crop|
csv.cells :id, :name, :en_wikipedia_url
csv.cell :growstuff_url, crop_url(c)
if c.scientific_names.any?
csv.cell :default_scientific_name, c.default_scientific_name
csv.cell :scientific_name_count, c.scientific_names.count
end
if c.parent
csv.cell :parent_crop_id, c.parent.id
csv.cell :parent_crop_name, c.parent.name
end
csv.cell :plantings_count || 0
csv.cell :seeds_count, c.seeds.count
sunniness = c.sunniness
sunniness_rec = sunniness.max_by{|k,v| v}
if sunniness_rec
csv.cell :recommended_sunniness, sunniness_rec[0]
end
csv.cell :planted_in_sun, sunniness['sun']
csv.cell :planted_in_semi_shade, sunniness['semi_shade']
csv.cell :planted_in_shade, sunniness['shade']
planted_from = c.planted_from
planted_from_rec = planted_from.max_by{|k,v| v}
if planted_from_rec
csv.cell :plant_from_recommendation, planted_from_rec[0]
end
csv.cell :planted_from_seed, planted_from['seed']
csv.cell :planted_from_seedling, planted_from['seedling']
csv.cell :planted_from_cutting, planted_from['cutting']
csv.cell :planted_from_root_division, planted_from['root division']
csv.cell :planted_from_runner, planted_from['runner']
csv.cell :planted_from_bulb, planted_from['bulb']
csv.cell :planted_from_bare_root_plant, planted_from['bare root plant']
csv.cell :planted_from_advanced_plant, planted_from['advanced plant']
csv.cell :planted_from_graft, planted_from['graft']
csv.cell :planted_from_layering, planted_from['layering']
csv.cell :added_by_member_id, c.creator.id
csv.cell :added_by_member_name, c.creator.to_s
csv.cell :date_added, c.created_at.to_s(:db)
csv.cell :last_modified, c.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"
end
end

View File

@@ -22,9 +22,3 @@
= page_entries_info @crops, :model => "crops"
= will_paginate @crops
%ul.inline
%li The data on this page is available in the following formats:
%li= link_to "CSV", crops_path(:format => 'csv')
%li= link_to "JSON", crops_path(:format => 'json')
%li= link_to "RSS", crops_path(:format => 'rss')

View File

@@ -5,7 +5,7 @@
%link= crops_url
- @crops.each do |crop|
%item
%title= crop.name
%title= crop.system_name
%pubDate= crop.created_at.to_s(:rfc822)
%link= post_url(crop)
%guid= post_url(crop)

View File

@@ -1,37 +1,29 @@
- content_for :title, @crop.name
- content_for :title, @crop.system_name
.row-fluid
.span9
%p
- if can? :create, Planting
= link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-primary'
- else
= render :partial => 'shared/signin_signup', :locals => { :to => 'plant this crop' }
- if can? :create, Harvest
= link_to "Harvest this", new_harvest_path(:crop_id => @crop.id), :class => 'btn btn-primary'
- if can? :create, Seed
= link_to 'Add seeds to stash', new_seed_path(:params => { :crop_id => @crop.id }), :class => 'btn btn-primary'
= render :partial => 'photos', :locals => { :crop => @crop }
= render :partial => 'varieties', :locals => { :crop => @crop }
= render :partial => 'planting_advice', :locals => { :crop => @crop }
%h2 Who's planted this crop?
%p
- if @crop.plantings.size > 0
= @crop.name.titleize
has been planted
Planted
= pluralize(@crop.plantings.size, "time")
by #{Growstuff::Application.config.site_name} members.
by #{Growstuff::Application.config.site_name} members
- else
Nobody is growing this yet. You could be the first!
%p
- if can? :create, Planting
= link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-primary'
- else
= render :partial => 'shared/signin_signup', :locals => { :to => 'plant this crop' }
- if can? :create, Seed
= link_to 'Add seeds to stash', new_seed_path(:params => { :crop_id => @crop.id }), :class => 'btn btn-primary'
- if @crop.plantings.size > 0
- @crop.plantings.each do |p|
@@ -67,5 +59,4 @@
%ul
%li= link_to 'Wikipedia (English)', @crop.en_wikipedia_url
= render :partial => 'harvests', :locals => { :crop => @crop }
= render :partial => 'find_seeds', :locals => { :crop => @crop }

View File

@@ -23,7 +23,7 @@
%th When
- @crops.each do |c|
%tr
%td= link_to c.name, c
%td= link_to c.system_name, c
%td= link_to c.en_wikipedia_url, c.en_wikipedia_url
%td
- c.scientific_names.each do |s|

View File

@@ -1,4 +1,4 @@
= form_for(@garden, :html => {:class => "form-horizontal"}) do |f|
= form_for @garden, :html => {} do |f|
- if @garden.errors.any?
#error_explanation
%h2= "#{pluralize(@garden.errors.count, "error")} prohibited this garden from being saved:"
@@ -6,41 +6,12 @@
- @garden.errors.full_messages.each do |msg|
%li= msg
.control_group
= f.label "Garden name: ", :class => 'control-label'
.controls= f.text_field :name
.control-group
= f.label :name, :class => 'control-label'
.controls
= f.text_field :name
.control-group
= f.label :description, :class => 'control-label'
.controls
= f.text_area :description, :rows => 6
.control-group
= f.label :location, :class => 'control-label'
.controls
= f.text_field :location, :value => @garden.location || current_member.location
%span.help-block
If you have a location set in your profile, it will be used when
you create a new garden.
- if current_member.location.blank?
=link_to "Set your location now.", edit_member_registration_path
- else
=link_to "Change your location.", edit_member_registration_path
.control-group
= f.label :area, :class => 'control-label'
.controls
= f.number_field :area, :class => 'input-small'
= f.select(:area_unit, Garden::AREA_UNITS_VALUES, {:include_blank => false}, :class => 'input-medium')
.control-group
= f.label 'Active? ', :class => 'control-label'
.controls
= f.check_box :active
%span.help-inline
You can mark a garden as inactive if you no longer use it.
= f.label 'Description: ', :class => 'control-label'
.controls= f.text_area :description, :rows => 6
.form-actions
= f.submit 'Save Garden', :class => 'btn btn-primary'

View File

@@ -26,9 +26,6 @@
%th Owner
%th Garden name
%th Description
%th Location
%th Area
%th Active?
%th Plantings
%th
@@ -38,13 +35,6 @@
%td= link_to garden.owner.login_name, garden.owner
%td= link_to garden.name, garden
%td= garden.description
%td
- if ! garden.location.blank?
= link_to garden.location, place_path(garden.location)
%td
- if garden.area
= pluralize(garden.area, garden.area_unit)
%td= garden.active ? "Yes" : "No"
%td
- if garden.plantings.empty?
None
@@ -53,7 +43,7 @@
- garden.plantings.each do |p|
%li
= p.quantity
= link_to p.crop.name, p
= link_to p.crop.system_name, p
- if p.planted_at
planted on
= p.planted_at

View File

@@ -1,25 +1,22 @@
=content_for :title, "#{@garden.owner}'s #{@garden}"
.row-fluid
.span9
- if ! @garden.active
.alert.alert-notice
NOTE: This garden is inactive.
- if can? :edit, @garden
= link_to 'Set it to active', edit_garden_path(@garden)
to plant something in this garden.
%p
%strong Owner:
= link_to @garden.owner, @garden.owner
- if ! @garden.location.blank?
%p
%strong Location:
= @garden.location
- if ! @garden.area.blank?
%p
%strong Area:
= pluralize(@garden.area, @garden.area_unit)
.span3
= render :partial => "members/avatar", :locals => { :member => @garden.owner }
%h4= "#{@garden.owner}'s gardens"
%ul
- @garden.owner.gardens.each do |othergarden|
%li
- if @garden == othergarden
= @garden
- else
= link_to "#{othergarden}", garden_path(othergarden)
- if can? :create, @garden
= link_to 'Add New Garden', new_garden_path, :class => 'btn btn-mini'
.span9
%div
:markdown
#{strip_tags @garden.description}
@@ -31,30 +28,9 @@
%h3
What's planted here?
- if can? :edit, @garden and @garden.active
- if can? :edit, @garden
= link_to "Plant something", new_planting_path(:garden_id => @garden.id), :class => 'btn btn-primary'
- @garden.plantings.each do |p|
= render :partial => "plantings/thumbnail", :locals => { :planting => p }
.span3
%h4= "#{@garden.owner}'s gardens"
%ul
- @garden.owner.gardens.active.each do |othergarden|
%li
- if @garden == othergarden
= @garden
- else
= link_to "#{othergarden}", garden_path(othergarden)
%h4= "Inactive gardens"
%ul
- @garden.owner.gardens.inactive.each do |othergarden|
%li
- if @garden == othergarden
= @garden
- else
= link_to "#{othergarden}", garden_path(othergarden)
- if can? :create, @garden
= link_to 'Add New Garden', new_garden_path, :class => 'btn btn-mini'

View File

@@ -1,39 +0,0 @@
= form_for(@harvest, :html => {:class => "form-horizontal"}) do |f|
- if @harvest.errors.any?
#error_explanation
%h2= "#{pluralize(@harvest.errors.count, "error")} prohibited this harvest from being saved:"
%ul
- @harvest.errors.full_messages.each do |msg|
%li= msg
.control-group
= f.label 'What did you harvest?', :class => 'control-label'
.controls
= collection_select(:harvest, :crop_id, Crop.all, :id, :name, :selected => @harvest.crop_id || @crop.id)
%span.help-inline
Can't find what you're looking for?
= link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link
.control-group
= f.label 'When?', :class => 'control-label'
.controls= f.text_field :harvested_at, :value => @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', :class => 'add-datepicker'
.control-group
= f.label 'How many?', :class => 'control-label'
.controls
= f.number_field :quantity, :class => 'input-small'
= f.select(:unit, Harvest::UNITS_VALUES, {:include_blank => false}, :class => 'input-medium')
.control-group
= f.label 'Weighing:', :class => 'control-label'
.controls
= f.number_field :weight_quantity, :class => 'input-small'
= f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, {:include_blank => false}, :class => 'input-medium')
in total
.control-group
= f.label 'Notes', :class => 'control-label'
.controls= f.text_area :description, :rows => 6
.form-actions
= f.submit 'Save', :class => 'btn btn-primary'

View File

@@ -1,7 +0,0 @@
- content_for :title, "Editing harvest"
= render 'form'
= link_to 'Show', @harvest
\|
= link_to 'Back', harvests_path

View File

@@ -1,41 +0,0 @@
csv.headers :id,
:growstuff_url,
:owner_id,
:owner_name,
:crop_id,
:crop_name,
:quantity,
:unit,
:weight_quantity,
:weight_unit,
:date_harvested,
:description,
:date_added,
:last_modified,
:license
@harvests.each do |h|
csv.row h do |csv, harvest|
csv.cell :id
csv.cell :growstuff_url, harvest_url(h)
csv.cell :owner_id, h.owner.id
csv.cell :owner_name, h.owner.to_s
csv.cell :crop_id, h.crop.id
csv.cell :crop_name, h.crop.to_s
csv.cells :quantity, :unit, :weight_quantity, :weight_unit
csv.cell :date_harvested, h.created_at.to_s(:db)
csv.cell :description
csv.cell :date_added, h.created_at.to_s(:db)
csv.cell :last_modified, h.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"
end
end

View File

@@ -1,58 +0,0 @@
- content_for :title, @owner ? "#{@owner}'s harvests" : "Everyone's harvests"
%p
#{Growstuff::Application.config.site_name} helps you track what you're
harvesting from your home garden and see how productive it is.
%p
- if can? :create, Harvest
- if @owner
%p
- if @owner == current_member
= link_to 'Add harvest', new_harvest_path, :class => 'btn btn-primary'
= link_to "View everyone's harvests", harvests_path, :class => 'btn'
- else # everyone's harvests
= link_to 'Add harvest', new_harvest_path, :class => 'btn btn-primary'
- if current_member
= link_to 'View your harvests', harvests_by_owner_path(:owner => current_member.slug), :class => 'btn'
- else
= render :partial => 'shared/signin_signup', :locals => { :to => 'track your harvests' }
%div.pagination
= page_entries_info @harvests, :model => "harvests"
= will_paginate @harvests
- if @harvests.length > 0
%table.table.table-striped
%tr
- unless @owner
%th Owner
%th Crop
%th Date
%th Quantity
%th Description
%th
- @harvests.each do |harvest|
%tr
- unless @owner
%td= link_to harvest.owner.login_name, harvest.owner
%td= link_to harvest.crop.name, harvest.crop
%td= harvest.harvested_at
%td= display_quantity(harvest)
%td= harvest.description
%td= link_to 'Details', harvest, :class => 'btn btn-mini'
%div.pagination
= page_entries_info @harvests, :model => "harvests"
= will_paginate @harvests
%ul.inline
%li The data on this page is available in the following formats:
- if @owner
%li= link_to "CSV", harvests_by_owner_path(@owner, :format => 'csv')
%li= link_to "JSON", harvests_by_owner_path(@owner, :format => 'json')
- else
%li= link_to "CSV", harvests_path(:format => 'csv')
%li= link_to "JSON", harvests_path(:format => 'json')

View File

@@ -1,3 +0,0 @@
- content_for :title, "New Harvest"
= render 'form'

View File

@@ -1,30 +0,0 @@
=content_for :title, "#{@harvest.crop} harvested by #{@harvest.owner}"
.row-fluid
.span6
%p
%b Owner:
= link_to @harvest.owner, @harvest.owner
&mdash;
= link_to "view all #{@harvest.owner}'s harvests", harvests_by_owner_path(:owner => @harvest.owner.slug)
%p
%b Harvested:
= @harvest.harvested_at ? @harvest.harvested_at : "not specified"
%p
%b Quantity:
= display_quantity(@harvest)
- if can? :edit, @harvest or can? :destroy, @harvest
%p
- if can? :edit, @harvest
=link_to 'Edit', edit_harvest_path(@harvest), :class => 'btn btn-mini'
- if can? :destroy, @harvest
=link_to 'Delete', @harvest, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-mini'
.span6
= render :partial => "crops/index_card", :locals => { :crop => @harvest.crop}
%h2 Notes
:markdown
#{ @harvest.description != "" ? @harvest.description : "No description given." }

View File

@@ -18,7 +18,7 @@
- seeds.each do |seed|
%tr
%td= link_to seed.owner.login_name, seed.owner
%td= link_to seed.crop.name, seed.crop
%td= link_to seed.crop.system_name, seed.crop
%td.hidden-phone.hidden-tablet= truncate(seed.description, :length => 40, :separator => ' ')
%td= seed.tradable? ? seed.tradable_to : ''
%td

View File

@@ -7,13 +7,13 @@
= Growstuff::Application.config.site_name
= current_member
= render :partial => 'stats'
%p
.btn-group
= link_to "Plant", new_planting_path, :class => 'btn'
= link_to "Harvest", new_harvest_path, :class => 'btn'
= link_to "Add seeds", new_seed_path, :class => 'btn'
= link_to "Post", new_post_path, :class => 'btn'
= link_to "Edit profile", edit_member_registration_path, :class => 'btn'
%ul.inline
%li{ :style => 'padding-left: 0px' }
%strong Quick links:
%li= link_to "Plant something", new_planting_path
%li= link_to "Add seeds", new_seed_path
%li= link_to "Post", new_post_path
%li= link_to "Edit profile", edit_member_registration_path
- else
.visible-desktop.visible-tablet

View File

@@ -34,7 +34,6 @@
%li= link_to "Profile", member_path(current_member)
%li= link_to "Gardens", gardens_by_owner_path(:owner => current_member.slug)
%li= link_to "Plantings", plantings_by_owner_path(:owner => current_member.slug)
%li= link_to "Harvests", harvests_by_owner_path(:owner => current_member.slug)
%li= link_to "Seeds", seeds_by_owner_path(:owner => current_member.slug)
%li= link_to "Posts", posts_by_author_path(:author => current_member.slug)
%li= link_to "Account", orders_path

View File

@@ -1,5 +0,0 @@
.member-location
- if member.location.blank?
unknown location
- else
= link_to member.location, place_path(:place => member.location)

View File

@@ -14,4 +14,4 @@
%small
%br/
Recently planted:
!= member.plantings.first(3).map{|p| link_to p.crop_name, p }.join(", ")
!= member.plantings.first(3).map{|p| link_to p.crop_system_name, p }.join(", ")

View File

@@ -9,14 +9,14 @@
.control-group
= f.label 'What did you plant?', :class => 'control-label'
.controls
= collection_select(:planting, :crop_id, Crop.all, :id, :name, :selected => @planting.crop_id || @crop.id)
= collection_select(:planting, :crop_id, Crop.all, :id, :system_name, :selected => @planting.crop_id || @crop.id)
%span.help-inline
Can't find what you're looking for?
= link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link
.control-group
= f.label 'Where did you plant it?', :class => 'control-label'
.controls
= collection_select(:planting, :garden_id, Garden.active.where(:owner_id => current_member), :id, :name, :selected => @planting.garden_id || @garden.id)
= collection_select(:planting, :garden_id, Garden.where(:owner_id => current_member), :id, :name, :selected => @planting.garden_id || @garden.id)
%span.help-inline
= link_to "Add a garden.", new_garden_path
.control-group

View File

@@ -8,7 +8,7 @@
- if defined?(title) && title == 'owner'
= link_to planting.owner, planting.owner
- else
= link_to planting.crop.name, planting
= link_to planting.crop.system_name, planting
%p
Planted

View File

@@ -1,45 +0,0 @@
csv.headers :id,
:growstuff_url,
:owner_id,
:owner_name,
:garden_id,
:garden_name,
:crop_id,
:crop_name,
:quantity,
:planted_from,
:sunniness,
:date_planted,
:description,
:date_added,
:last_modified,
:license
@plantings.each do |p|
csv.row p do |csv, planting|
csv.cell :id
csv.cell :growstuff_url, planting_url(p)
csv.cell :owner_id, p.owner.id
csv.cell :owner_name, p.owner.to_s
csv.cell :garden_id, p.garden.id
csv.cell :garden_name, p.garden.to_s
csv.cell :crop_id, p.crop.id
csv.cell :crop_name, p.crop.to_s
csv.cells :quantity, :planted_from, :sunniness
csv.cell :date_planted, p.planted_at ? p.planted_at.to_s(:db) : ''
csv.cell :description
csv.cell :date_added, p.created_at.to_s(:db)
csv.cell :last_modified, p.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"
end
end

View File

@@ -37,7 +37,7 @@
%tr
- unless @owner
%td= link_to planting.owner.login_name, planting.owner
%td= link_to planting.crop.name, planting.crop
%td= link_to planting.crop.system_name, planting.crop
%td= link_to planting.garden.name, planting.garden
%td
:markdown
@@ -51,14 +51,3 @@
%div.pagination
= page_entries_info @plantings, :model => "plantings"
= will_paginate @plantings
%ul.inline
%li The data on this page is available in the following formats:
- if @owner
%li= link_to "CSV", plantings_by_owner_path(@owner, :format => 'csv')
%li= link_to "JSON", plantings_by_owner_path(@owner, :format => 'json')
%li= link_to "RSS", plantings_by_owner_path(@owner, :format => 'rss')
- else
%li= link_to "CSV", plantings_path(:format => 'csv')
%li= link_to "JSON", plantings_path(:format => 'json')
%li= link_to "RSS", plantings_path(:format => 'rss')

View File

@@ -2,11 +2,6 @@
.row-fluid
.span6
%p
%b Owner:
= link_to @planting.owner, @planting.owner
&mdash;
= link_to "view all #{@planting.owner}'s plantings", plantings_by_owner_path(:owner => @planting.owner.slug)
%p
%b Planted:
= @planting.planted_at ? @planting.planted_at : "not specified"
@@ -46,6 +41,9 @@
:markdown
#{ @planting.description != "" ? @planting.description : "No description given." }
- if can? :edit, @planting
= link_to 'Edit', edit_planting_path(@planting), :class => 'btn btn-mini'
- if @planting.photos.count > 0 or (can? :edit, @planting and can? :create, Photo)
%h2 Pictures

View File

@@ -25,16 +25,3 @@
%div.pagination
= page_entries_info @posts, :model => "posts"
= will_paginate @posts
%p
- if @author
Subscribe to
= succeed "." do
= link_to "#{@author}'s posts RSS feed", posts_path(:format => 'rss')
- else
Subscribe to the #{Growstuff::Application.config.site_name}
= link_to "posts RSS feed", posts_path(:format => 'rss')
or
= succeed "." do
= link_to "comments RSS feed", comments_path(:format => 'rss')

View File

@@ -15,7 +15,7 @@
.control-group
= f.label :crop_id, :class => 'control-label'
.controls
= collection_select(:scientific_name, :crop_id, Crop.all, :id, :name, :selected => @scientific_name.crop_id || @crop.id)
= collection_select(:scientific_name, :crop_id, Crop.all, :id, :system_name, :selected => @scientific_name.crop_id || @crop.id)
.control-group
= f.label :scientific_name, :class => 'control-label'
.controls

View File

@@ -8,7 +8,7 @@
.control-group
= f.label 'Crop:', :class => 'control-label'
.controls= collection_select(:seed, :crop_id, Crop.all, :id, :name, :selected => @seed.crop_id || @crop.id)
.controls= collection_select(:seed, :crop_id, Crop.all, :id, :system_name, :selected => @seed.crop_id || @crop.id)
.control-group
= f.label 'Quantity:', :class => 'control-label'
.controls

View File

@@ -1,47 +0,0 @@
csv.headers :id,
:growstuff_url,
:owner_id,
:owner_name,
:crop_id,
:crop_name,
:quantity,
:plant_before,
:tradable_to,
:from_location,
:latitude,
:longitude,
:description,
:date_added,
:last_modified,
:license
@seeds.each do |s|
csv.row s do |csv, seed|
csv.cell :id
csv.cell :growstuff_url, seed_url(s)
csv.cell :owner_id, s.owner.id
csv.cell :owner_name, s.owner.to_s
csv.cell :crop_id, s.crop.id
csv.cell :crop_name, s.crop.to_s
csv.cell :quantity
csv.cell :plant_before, s.plant_before ? s.plant_before.to_s(:db) : ''
csv.cell :tradable_to
csv.cell :from_location, s.owner.location
csv.cell :latitude, s.owner.latitude
csv.cell :longitude, s.owner.longitude
csv.cell :description
csv.cell :date_added, s.created_at.to_s(:db)
csv.cell :last_modified, s.updated_at.to_s(:db)
csv.cell :license, "CC-BY-SA Growstuff http://growstuff.org/"
end
end

View File

@@ -40,7 +40,7 @@
%tr
- unless @owner
%td= link_to seed.owner.login_name, seed.owner
%td= link_to seed.crop.name, seed.crop
%td= link_to seed.crop.system_name, seed.crop
%td= seed.description
%td= seed.quantity
%td= seed.plant_before
@@ -56,14 +56,3 @@
%div.pagination
= page_entries_info @seeds, :model => "seeds"
= will_paginate @seeds
%ul.inline
%li The data on this page is available in the following formats:
- if @owner
%li= link_to "CSV", seeds_by_owner_path(@owner, :format => 'csv')
%li= link_to "JSON", seeds_by_owner_path(@owner, :format => 'json')
%li= link_to "RSS", seeds_by_owner_path(@owner, :format => 'rss')
- else
%li= link_to "CSV", seeds_path(:format => 'csv')
%li= link_to "JSON", seeds_path(:format => 'json')
%li= link_to "RSS", seeds_path(:format => 'rss')

View File

@@ -6,7 +6,7 @@
%b Owner:
= link_to @seed.owner, @seed.owner
&mdash;
= link_to "view all #{@seed.owner}'s seeds", seeds_by_owner_path(:owner => @seed.owner.slug)
= link_to "view all #{@seed.owner}'s seeds", seeds_path(:owner_id => @seed.owner.id)
%p
%b Quantity:
= @seed.quantity.blank? ? "not specified" : @seed.quantity

View File

@@ -1,5 +1,3 @@
require 'geocodable'
Geocoder.configure(
:units => :km,
:timeout => 10,

View File

@@ -13,7 +13,3 @@
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.acronym 'RESTful'
# end
ActiveSupport::Inflector.inflections do |inflect|
inflect.plural 'square foot', 'square feet'
end

View File

@@ -16,9 +16,6 @@ Growstuff::Application.routes.draw do
resources :seeds
match '/seeds/owner/:owner' => 'seeds#index', :as => 'seeds_by_owner'
resources :harvests
match '/harvests/owner/:owner' => 'harvests#index', :as => 'harvests_by_owner'
resources :posts
match '/posts/author/:author' => 'posts#index', :as => 'posts_by_author'

View File

@@ -1,14 +0,0 @@
class CreateHarvests < ActiveRecord::Migration
def change
create_table :harvests do |t|
t.integer :crop_id, :null => false
t.integer :owner_id, :null => false
t.date :harvested_at
t.decimal :quantity
t.string :units
t.text :notes
t.timestamps
end
end
end

View File

@@ -1,5 +0,0 @@
class ChangeHarvestNotesToDescription < ActiveRecord::Migration
def change
rename_column :harvests, :notes, :description
end
end

View File

@@ -1,5 +0,0 @@
class ChangeHarvestUnitsToUnit < ActiveRecord::Migration
def change
rename_column :harvests, :units, :unit
end
end

View File

@@ -1,5 +0,0 @@
class AddSlugToHarvests < ActiveRecord::Migration
def change
add_column :harvests, :slug, :string
end
end

View File

@@ -1,6 +0,0 @@
class AddWeightToHarvests < ActiveRecord::Migration
def change
add_column :harvests, :weight_quantity, :decimal
add_column :harvests, :weight_unit, :string
end
end

View File

@@ -1,15 +0,0 @@
class RenameSystemNameToName < ActiveRecord::Migration
def up
# Rails is smart enough to alter the column being indexed, but not the name
# of the index, and there's no rename_index command.
remove_index :crops, :system_name
rename_column :crops, :system_name, :name
add_index :crops, :name
end
def down
remove_index :crops, :name
rename_column :crops, :name, :system_name
add_index :crops, :system_name
end
end

View File

@@ -1,10 +0,0 @@
class AddFieldsToGardens < ActiveRecord::Migration
def change
add_column :gardens, :active, :boolean, :default => true
add_column :gardens, :location, :string
add_column :gardens, :latitude, :float
add_column :gardens, :longitude, :float
add_column :gardens, :area, :decimal
add_column :gardens, :area_unit, :string
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20131025104228) do
ActiveRecord::Schema.define(:version => 20130913015118) do
create_table "account_types", :force => true do |t|
t.string "name", :null => false
@@ -51,7 +51,7 @@ ActiveRecord::Schema.define(:version => 20131025104228) do
end
create_table "crops", :force => true do |t|
t.string "name", :null => false
t.string "system_name", :null => false
t.string "en_wikipedia_url"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
@@ -61,8 +61,8 @@ ActiveRecord::Schema.define(:version => 20131025104228) do
t.integer "creator_id"
end
add_index "crops", ["name"], :name => "index_crops_on_name"
add_index "crops", ["slug"], :name => "index_crops_on_slug", :unique => true
add_index "crops", ["system_name"], :name => "index_crops_on_system_name"
create_table "forums", :force => true do |t|
t.string "name", :null => false
@@ -76,37 +76,17 @@ ActiveRecord::Schema.define(:version => 20131025104228) do
add_index "forums", ["slug"], :name => "index_forums_on_slug", :unique => true
create_table "gardens", :force => true do |t|
t.string "name", :null => false
t.string "name", :null => false
t.integer "owner_id"
t.string "slug", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "slug", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "description"
t.boolean "active", :default => true
t.string "location"
t.float "latitude"
t.float "longitude"
t.decimal "area"
t.string "area_unit"
end
add_index "gardens", ["owner_id"], :name => "index_gardens_on_user_id"
add_index "gardens", ["slug"], :name => "index_gardens_on_slug", :unique => true
create_table "harvests", :force => true do |t|
t.integer "crop_id", :null => false
t.integer "owner_id", :null => false
t.date "harvested_at"
t.decimal "quantity"
t.string "unit"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "slug"
t.decimal "weight_quantity"
t.string "weight_unit"
end
create_table "members", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false

View File

@@ -1,5 +1,12 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# import crops from CSV
require 'csv'
@@ -22,12 +29,18 @@ def load_data
end
def load_crops
source_path = Rails.root.join('db', 'seeds')
Dir.glob("#{source_path}/crops*.csv").each do |crop_file|
puts "Loading crops from #{crop_file}..."
CSV.foreach(crop_file) do |row|
Crop.create_from_csv(row)
end
puts "Loading crops..."
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,
:creator_id => @cropbot_user.id
)
@crop.scientific_names.create(
:scientific_name => scientific_name,
:creator_id => @cropbot_user.id
)
end
puts "Finished loading crops"
end

View File

@@ -1,61 +0,0 @@
Capsicum,Capsicum,http://en.wikipedia.org/wiki/Capsicum,,This is the top parent variety -- the entire family of all kinds of peppers
Capsicum annuum,Capsicum annuum,http://en.wikipedia.org/wiki/Capsicum_annuum,Capsicum,
Capsicum baccatum,Capsicum baccatum,http://en.wikipedia.org/wiki/Capsicum_baccatum,Capsicum,
Capsicum chinense,Capsicum chinense,http://en.wikipedia.org/wiki/Capsicum_chinense,Capsicum,
rocoto,Capsicum pubescens,http://en.wikipedia.org/wiki/Capsicum_pubescens,Capsicum,AKA locoto
Capsicum frutescens,Capsicum frutescens,http://en.wikipedia.org/wiki/Capsicum_frutescens,Capsicum,
Aleppo pepper,,http://en.wikipedia.org/wiki/Aleppo_pepper,Capsicum annuum,"AKA pul biber, halaby pepper"
Anaheim pepper,,http://en.wikipedia.org/wiki/Anaheim_pepper,Capsicum annuum,"AKA New Mexico pepper, California chili, Magdalena chili"
banana pepper,,http://en.wikipedia.org/wiki/Banana_pepper,Capsicum annuum,"AKA yellow wax pepper, banana chili"
bell pepper,,http://en.wikipedia.org/wiki/Bell_pepper,Capsicum annuum,"AKA capsicum, sweet pepper, pepper, poivron, peperoni, piment"
bird's eye chili,,http://en.wikipedia.org/wiki/Bird%27s_eye_chili,Capsicum annuum,"AKA Thai chili pepper, bird's chili"
cascabel chili,,http://en.wikipedia.org/wiki/Cascabel_chili,Capsicum annuum,"AKA rattle chile, bola chile, chile bola"
cayenne pepper,,http://en.wikipedia.org/wiki/Cayenne_pepper,Capsicum annuum,"AKA Guinea spice, cow-horn pepper, aleva, bird pepper, red pepper"
pasilla pepper,,http://en.wikipedia.org/wiki/Pasilla,Capsicum annuum,"AKA chilaca pepper, chile negro"
chiltepin pepper,Capsicum annuum var. glabriusculum,http://en.wikipedia.org/wiki/Capsicum_annuum_var._glabriusculum,Capsicum annuum,"AKA wild chiltepin, chiltepe, chile tepin, turkey pepper, birds eye pepper, bird pepper"
Chungyang red pepper,,http://en.wikipedia.org/wiki/Chungyang_Red_Pepper,Capsicum annuum,
cubanelle pepper,,http://en.wikipedia.org/wiki/Cubanelle,Capsicum annuum,
chile de árbol pepper,,http://en.wikipedia.org/wiki/Chile_de_%C3%A1rbol,Capsicum annuum,"AKA bird's beak chile, rat's tail chile"
dundicut,,http://en.wikipedia.org/wiki/Dundicut,Capsicum annuum,AKA lal mirch
facing heaven pepper,Capsicum annuum var. conoides,http://en.wikipedia.org/wiki/Facing_heaven_pepper,Capsicum annuum,
Fresno pepper,,http://en.wikipedia.org/wiki/Fresno_pepper,Capsicum annuum,
guajillo pepper,,http://en.wikipedia.org/wiki/Guajillo_chili,Capsicum annuum,"AKA guajillo chili, guajillo chilli, chile guajillo"
Guntur Sannam chili,Capsicum Annuum var. Longhum,http://en.wikipedia.org/wiki/Guntur_Sannam,Capsicum annuum,
Hungarian wax pepper,,http://en.wikipedia.org/wiki/Hungarian_wax_pepper,Capsicum annuum,
Italian sweet pepper,,http://en.wikipedia.org/wiki/Italian_sweet_pepper,Capsicum annuum,
jalapeño pepper,,http://en.wikipedia.org/wiki/Jalape%C3%B1o,Capsicum annuum,
shishito pepper,,http://en.wikipedia.org/wiki/Shishito,Capsicum annuum,
medusa pepper,,http://en.wikipedia.org/wiki/Medusa_pepper,Capsicum annuum,
mulato pepper,,http://en.wikipedia.org/wiki/Mulato_pepper,Capsicum annuum,
peter pepper,Capsicum annuum var. annuum,http://en.wikipedia.org/wiki/Peter_pepper,Capsicum annuum,AKA chilli willy pepper
peperoncini pepper,,http://en.wikipedia.org/wiki/Peperoncini,Capsicum annuum,"AKA friggitello, peperone"
pequin pepper,"Capsicum annuum var. glabriusculum
",http://en.wikipedia.org/wiki/Pequin_pepper,Capsicum annuum,AKA piquin
pimento pepper,,http://en.wikipedia.org/wiki/Pimiento,Capsicum annuum,"AKA cherry pepper, pimiento pepper"
poblano pepper,,http://en.wikipedia.org/wiki/Poblano,Capsicum annuum,
Santa Fe Grande pepper,,http://en.wikipedia.org/wiki/Santa_Fe_Grande_pepper,Capsicum annuum,"AKA yellow hot chili pepper, guero chili pepper"
serrano pepper,,http://en.wikipedia.org/wiki/Serrano_pepper,Capsicum annuum,
bishop's crown pepper,Capsicum baccatum var. pendulum,http://en.wikipedia.org/wiki/Bishop%27s_Crown,Capsicum baccatum,AKA Christmas bell
lemon drop pepper,,http://en.wikipedia.org/wiki/Lemon_drop_%28pepper%29,Capsicum baccatum,"AKA ají limon, kellu uchu, hot lemon"
peppadew pepper,,http://en.wikipedia.org/wiki/Peppadew,Capsicum baccatum,
Brazilian starfish,,http://en.wikipedia.org/wiki/Capsicum_baccatum,Capsicum baccatum,
wild baccatum,,http://en.wikipedia.org/wiki/Capsicum_baccatum,Capsicum baccatum,
adjuma pepper,,http://en.wikipedia.org/wiki/Adjuma,Capsicum chinense,"AKA adjoema, aji umba, ojemma"
ají dulce pepper,,http://en.wikipedia.org/wiki/Aj%C3%AD_dulce,Capsicum chinense,"AKA ajicito, ajice, rubra, biquinho"
datil pepper,,http://en.wikipedia.org/wiki/Datil_pepper,Capsicum chinense,
fatalii pepper,,http://en.wikipedia.org/wiki/Fatalii,Capsicum chinense,
Madame Jeanette pepper,,http://en.wikipedia.org/wiki/Madame_Jeanette,Capsicum chinense,
habanero pepper,,http://en.wikipedia.org/wiki/Habanero,Capsicum chinense,AKA habañero
black habanero pepper,,http://en.wikipedia.org/wiki/Habanero,Capsicum chinense,
red savino pepper,,http://en.wikipedia.org/wiki/Red_Savina_pepper,Capsicum chinense,
bhut jolokia pepper,,http://en.wikipedia.org/wiki/Bhut_Jolokia,Capsicum chinense,"AKA ghost pepper, ghost chili pepper, red naga chilli, ghost chilli, naga jolokia"
Scotch bonnet pepper,,http://en.wikipedia.org/wiki/Scotch_bonnet_%28pepper%29,Capsicum chinense,"AKA boabs bonnet, Scotty bons, Bonney peppers, Caribbean red peppers, ball of fire"
cachucha pepper,,http://en.wikipedia.org/wiki/Scotch_bonnet_%28pepper%29,Capsicum chinense,
Trinidad scorpion butch T pepper,,http://en.wikipedia.org/wiki/Trinidad_Scorpion_Butch_T_pepper,Capsicum chinense,
Trinidad Moruga scorpion pepper,,http://en.wikipedia.org/wiki/Trinidad_Moruga_Scorpion,Capsicum chinense,
Hainan yellow lantern,,http://en.wikipedia.org/wiki/Hainan_Yellow_Lantern_Chili,Capsicum chinense,AKA yellow emperor chili
piri-piri pepper,,http://en.wikipedia.org/wiki/Piri_piri,Capsicum frutescens,"AKA African bird's eye pepper, peri peri, pili pili"
Tabasco pepper,,http://en.wikipedia.org/wiki/Tabasco_pepper,Capsicum frutescens,
malagueta pepper,,http://en.wikipedia.org/wiki/Malagueta_pepper,Capsicum frutescens,
siling labuyo pepper,,http://en.wikipedia.org/wiki/Siling_labuyo,Capsicum frutescens,"AKA chileng bundok, siling palay, pasitis, pasite, katumbal, kitikot, siling kolikot, silit-diablo, lada, rimorimo, paktin"
kambuzi,,http://en.wikipedia.org/wiki/Kambuzi,Capsicum frutescens,
1 Capsicum Capsicum http://en.wikipedia.org/wiki/Capsicum This is the top parent variety -- the entire family of all kinds of peppers
2 Capsicum annuum Capsicum annuum http://en.wikipedia.org/wiki/Capsicum_annuum Capsicum
3 Capsicum baccatum Capsicum baccatum http://en.wikipedia.org/wiki/Capsicum_baccatum Capsicum
4 Capsicum chinense Capsicum chinense http://en.wikipedia.org/wiki/Capsicum_chinense Capsicum
5 rocoto Capsicum pubescens http://en.wikipedia.org/wiki/Capsicum_pubescens Capsicum AKA locoto
6 Capsicum frutescens Capsicum frutescens http://en.wikipedia.org/wiki/Capsicum_frutescens Capsicum
7 Aleppo pepper http://en.wikipedia.org/wiki/Aleppo_pepper Capsicum annuum AKA pul biber, halaby pepper
8 Anaheim pepper http://en.wikipedia.org/wiki/Anaheim_pepper Capsicum annuum AKA New Mexico pepper, California chili, Magdalena chili
9 banana pepper http://en.wikipedia.org/wiki/Banana_pepper Capsicum annuum AKA yellow wax pepper, banana chili
10 bell pepper http://en.wikipedia.org/wiki/Bell_pepper Capsicum annuum AKA capsicum, sweet pepper, pepper, poivron, peperoni, piment
11 bird's eye chili http://en.wikipedia.org/wiki/Bird%27s_eye_chili Capsicum annuum AKA Thai chili pepper, bird's chili
12 cascabel chili http://en.wikipedia.org/wiki/Cascabel_chili Capsicum annuum AKA rattle chile, bola chile, chile bola
13 cayenne pepper http://en.wikipedia.org/wiki/Cayenne_pepper Capsicum annuum AKA Guinea spice, cow-horn pepper, aleva, bird pepper, red pepper
14 pasilla pepper http://en.wikipedia.org/wiki/Pasilla Capsicum annuum AKA chilaca pepper, chile negro
15 chiltepin pepper Capsicum annuum var. glabriusculum http://en.wikipedia.org/wiki/Capsicum_annuum_var._glabriusculum Capsicum annuum AKA wild chiltepin, chiltepe, chile tepin, turkey pepper, bird’s eye pepper, bird pepper
16 Chungyang red pepper http://en.wikipedia.org/wiki/Chungyang_Red_Pepper Capsicum annuum
17 cubanelle pepper http://en.wikipedia.org/wiki/Cubanelle Capsicum annuum
18 chile de árbol pepper http://en.wikipedia.org/wiki/Chile_de_%C3%A1rbol Capsicum annuum AKA bird's beak chile, rat's tail chile
19 dundicut http://en.wikipedia.org/wiki/Dundicut Capsicum annuum AKA lal mirch
20 facing heaven pepper Capsicum annuum var. conoides http://en.wikipedia.org/wiki/Facing_heaven_pepper Capsicum annuum
21 Fresno pepper http://en.wikipedia.org/wiki/Fresno_pepper Capsicum annuum
22 guajillo pepper http://en.wikipedia.org/wiki/Guajillo_chili Capsicum annuum AKA guajillo chili, guajillo chilli, chile guajillo
23 Guntur Sannam chili Capsicum Annuum var. Longhum http://en.wikipedia.org/wiki/Guntur_Sannam Capsicum annuum
24 Hungarian wax pepper http://en.wikipedia.org/wiki/Hungarian_wax_pepper Capsicum annuum
25 Italian sweet pepper http://en.wikipedia.org/wiki/Italian_sweet_pepper Capsicum annuum
26 jalapeño pepper http://en.wikipedia.org/wiki/Jalape%C3%B1o Capsicum annuum
27 shishito pepper http://en.wikipedia.org/wiki/Shishito Capsicum annuum
28 medusa pepper http://en.wikipedia.org/wiki/Medusa_pepper Capsicum annuum
29 mulato pepper http://en.wikipedia.org/wiki/Mulato_pepper Capsicum annuum
30 peter pepper Capsicum annuum var. annuum http://en.wikipedia.org/wiki/Peter_pepper Capsicum annuum AKA chilli willy pepper
31 peperoncini pepper http://en.wikipedia.org/wiki/Peperoncini Capsicum annuum AKA friggitello, peperone
32 pequin pepper Capsicum annuum var. glabriusculum http://en.wikipedia.org/wiki/Pequin_pepper Capsicum annuum AKA piquin
33 pimento pepper http://en.wikipedia.org/wiki/Pimiento Capsicum annuum AKA cherry pepper, pimiento pepper
34 poblano pepper http://en.wikipedia.org/wiki/Poblano Capsicum annuum
35 Santa Fe Grande pepper http://en.wikipedia.org/wiki/Santa_Fe_Grande_pepper Capsicum annuum AKA yellow hot chili pepper, guero chili pepper
36 serrano pepper http://en.wikipedia.org/wiki/Serrano_pepper Capsicum annuum
37 bishop's crown pepper Capsicum baccatum var. pendulum http://en.wikipedia.org/wiki/Bishop%27s_Crown Capsicum baccatum AKA Christmas bell
38 lemon drop pepper http://en.wikipedia.org/wiki/Lemon_drop_%28pepper%29 Capsicum baccatum AKA ají limon, kellu uchu, hot lemon
39 peppadew pepper http://en.wikipedia.org/wiki/Peppadew Capsicum baccatum
40 Brazilian starfish http://en.wikipedia.org/wiki/Capsicum_baccatum Capsicum baccatum
41 wild baccatum http://en.wikipedia.org/wiki/Capsicum_baccatum Capsicum baccatum
42 adjuma pepper http://en.wikipedia.org/wiki/Adjuma Capsicum chinense AKA adjoema, aji umba, ojemma
43 ají dulce pepper http://en.wikipedia.org/wiki/Aj%C3%AD_dulce Capsicum chinense AKA ajicito, ajice, rubra, biquinho
44 datil pepper http://en.wikipedia.org/wiki/Datil_pepper Capsicum chinense
45 fatalii pepper http://en.wikipedia.org/wiki/Fatalii Capsicum chinense
46 Madame Jeanette pepper http://en.wikipedia.org/wiki/Madame_Jeanette Capsicum chinense
47 habanero pepper http://en.wikipedia.org/wiki/Habanero Capsicum chinense AKA habañero
48 black habanero pepper http://en.wikipedia.org/wiki/Habanero Capsicum chinense
49 red savino pepper http://en.wikipedia.org/wiki/Red_Savina_pepper Capsicum chinense
50 bhut jolokia pepper http://en.wikipedia.org/wiki/Bhut_Jolokia Capsicum chinense AKA ghost pepper, ghost chili pepper, red naga chilli, ghost chilli, naga jolokia
51 Scotch bonnet pepper http://en.wikipedia.org/wiki/Scotch_bonnet_%28pepper%29 Capsicum chinense AKA boabs bonnet, Scotty bons, Bonney peppers, Caribbean red peppers, ball of fire
52 cachucha pepper http://en.wikipedia.org/wiki/Scotch_bonnet_%28pepper%29 Capsicum chinense
53 Trinidad scorpion butch T pepper http://en.wikipedia.org/wiki/Trinidad_Scorpion_Butch_T_pepper Capsicum chinense
54 Trinidad Moruga scorpion pepper http://en.wikipedia.org/wiki/Trinidad_Moruga_Scorpion Capsicum chinense
55 Hainan yellow lantern http://en.wikipedia.org/wiki/Hainan_Yellow_Lantern_Chili Capsicum chinense AKA yellow emperor chili
56 piri-piri pepper http://en.wikipedia.org/wiki/Piri_piri Capsicum frutescens AKA African bird's eye pepper, peri peri, pili pili
57 Tabasco pepper http://en.wikipedia.org/wiki/Tabasco_pepper Capsicum frutescens
58 malagueta pepper http://en.wikipedia.org/wiki/Malagueta_pepper Capsicum frutescens
59 siling labuyo pepper http://en.wikipedia.org/wiki/Siling_labuyo Capsicum frutescens AKA chileng bundok, siling palay, pasitis, pasite, katumbal, kitikot, siling kolikot, silit-diablo, lada, rimorimo, paktin
60 kambuzi http://en.wikipedia.org/wiki/Kambuzi Capsicum frutescens

View File

@@ -1,22 +0,0 @@
module Geocodable
def self.included(base)
base.extend(self)
end
private
def geocode
unless self.location.blank?
self.latitude, self.longitude =
Geocoder.coordinates(location, params: {limit: 1})
end
end
def empty_unwanted_geocodes
if self.location.blank?
self.latitude = nil
self.longitude = nil
end
end
end

View File

@@ -10,32 +10,6 @@ namespace :growstuff do
member.roles << admin
end
desc "Upload crops from a CSV file"
# usage: rake growstuff:import_crops file=filename.csv
task :import_crops => :environment do
require 'csv'
@file = ENV['file'] or raise "Usage: rake growstuff:import_crops file=file.csv"
puts "Loading crops from #{@file}..."
CSV.foreach(@file) do |row|
Crop.create_from_csv(row)
end
puts "Finished loading crops"
end
desc "Depopulate Null Island"
# this fixes up anyone who has erroneously wound up with a 0,0 lat/long
task :depopulate_null_island => :environment do
Member.find_each do |m|
if m.location and (m.latitude == nil and m.longitude == nil)
m.geocode
m.save
end
end
end
desc "One-off tasks needed at various times and kept for posterity"
namespace :oneoff do
@@ -193,21 +167,6 @@ namespace :growstuff do
end
end
desc "October 2013: set garden locations to member locations"
task :initialize_garden_locations => :environment do
Member.located.find_each do |m|
m.gardens.each do |g|
if g.location.blank?
g.location = m.location
g.latitude = m.latitude
g.longitude = m.longitude
g.save
end
end
end
end
end
end

View File

@@ -10,9 +10,8 @@
# echo "YYYY-MM-DD - do something or other"
# rake growstuff:oneoff:something
echo "2013-10-24 - fix zeroed geolocations"
rake growstuff:depopulate_null_island
echo "2013-10-24 - initialize garden locations"
rake growstuff:oneoff:initialize_garden_locations
echo "2013-08-26 - set planting owner"
rake growstuff:oneoff:set_planting_owner
echo "2013-08-26 - initialize member planting count"
rake growstuff:oneoff:initialize_member_planting_count

View File

@@ -6,7 +6,7 @@ describe CropsController do
def valid_attributes
{
:name => "Tomato",
:system_name => "Tomato",
:en_wikipedia_url => 'http://en.wikipedia.org/wiki/Tomato'
}
end

View File

@@ -1,141 +0,0 @@
require 'spec_helper'
describe HarvestsController do
login_member
def valid_attributes
{
:owner_id => subject.current_member.id,
:crop_id => FactoryGirl.create(:crop).id
}
end
describe "GET index" do
it "assigns all harvests as @harvests" do
harvest = Harvest.create! valid_attributes
get :index, {}
assigns(:harvests).should eq([harvest])
end
end
describe "GET show" do
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
get :show, {:id => harvest.to_param}
assigns(:harvest).should eq(harvest)
end
end
describe "GET new" do
it "assigns a new harvest as @harvest" do
get :new, {}
assigns(:harvest).should be_a_new(Harvest)
end
end
describe "GET edit" do
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
get :edit, {:id => harvest.to_param}
assigns(:harvest).should eq(harvest)
end
end
describe "POST create" do
describe "with valid params" do
it "creates a new Harvest" do
expect {
post :create, {:harvest => valid_attributes}
}.to change(Harvest, :count).by(1)
end
it "assigns a newly created harvest as @harvest" do
post :create, {:harvest => valid_attributes}
assigns(:harvest).should be_a(Harvest)
assigns(:harvest).should be_persisted
end
it "redirects to the created harvest" do
post :create, {:harvest => valid_attributes}
response.should redirect_to(Harvest.last)
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved harvest as @harvest" do
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
post :create, {:harvest => { "crop_id" => "invalid value" }}
assigns(:harvest).should be_a_new(Harvest)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
post :create, {:harvest => { "crop_id" => "invalid value" }}
response.should render_template("new")
end
end
end
describe "PUT update" do
describe "with valid params" do
it "updates the requested harvest" do
harvest = Harvest.create! valid_attributes
# Assuming there are no other harvests in the database, this
# specifies that the Harvest created on the previous line
# receives the :update_attributes message with whatever params are
# submitted in the request.
Harvest.any_instance.should_receive(:update_attributes).with({ "crop_id" => "1" })
put :update, {:id => harvest.to_param, :harvest => { "crop_id" => "1" }}
end
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
put :update, {:id => harvest.to_param, :harvest => valid_attributes}
assigns(:harvest).should eq(harvest)
end
it "redirects to the harvest" do
harvest = Harvest.create! valid_attributes
put :update, {:id => harvest.to_param, :harvest => valid_attributes}
response.should redirect_to(harvest)
end
end
describe "with invalid params" do
it "assigns the harvest as @harvest" do
harvest = Harvest.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
put :update, {:id => harvest.to_param, :harvest => { "crop_id" => "invalid value" }}
assigns(:harvest).should eq(harvest)
end
it "re-renders the 'edit' template" do
harvest = Harvest.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
put :update, {:id => harvest.to_param, :harvest => { "crop_id" => "invalid value" }}
response.should render_template("edit")
end
end
end
describe "DELETE destroy" do
it "destroys the requested harvest" do
harvest = Harvest.create! valid_attributes
expect {
delete :destroy, {:id => harvest.to_param}
}.to change(Harvest, :count).by(-1)
end
it "redirects to the harvests list" do
harvest = Harvest.create! valid_attributes
delete :destroy, {:id => harvest.to_param}
response.should redirect_to(harvests_url)
end
end
end

View File

@@ -1,54 +1,54 @@
FactoryGirl.define do
factory :crop do
name "Magic bean"
system_name "Magic bean"
en_wikipedia_url "http://en.wikipedia.org/wiki/Magic_bean"
creator
factory :tomato do
name "Tomato"
system_name "Tomato"
en_wikipedia_url "http://en.wikipedia.org/wiki/Tomato"
end
factory :maize do
name "Maize"
system_name "Maize"
en_wikipedia_url "http://en.wikipedia.org/wiki/Maize"
end
factory :chard do
name "Chard"
system_name "Chard"
end
factory :walnut do
name "Walnut"
system_name "Walnut"
end
factory :apple do
name "Apple"
system_name "Apple"
end
factory :pear do
name "Pear"
system_name "Pear"
end
# for testing varieties
factory :roma do
name "Roma tomato"
system_name "Roma tomato"
end
factory :popcorn do
name "popcorn"
system_name "popcorn"
end
# This should have a name that is alphabetically earlier than :uppercase
# crop to ensure that the ordering tests work.
factory :lowercasecrop do
name "ffrench bean"
system_name "ffrench bean"
end
factory :uppercasecrop do
name "Swiss chard"
system_name "Swiss chard"
end
end

View File

@@ -3,14 +3,6 @@ FactoryGirl.define do
name 'Springfield Community Garden'
description "This is a **totally** cool garden"
owner
active true
area 23
area_unit "acre"
location "Greenwich, UK"
factory :inactive_garden do
active false
end
# the following are used for testing alphabetical ordering
factory :garden_a do

View File

@@ -1,14 +0,0 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :harvest do
crop
owner
harvested_at "2013-09-17"
quantity "3"
unit "individual"
weight_quantity 6
weight_unit "kg"
description "A lovely harvest"
end
end

View File

@@ -1,79 +0,0 @@
require 'spec_helper'
describe HarvestsHelper do
describe "display_quantity" do
it "blank" do
harvest = FactoryGirl.create(:harvest,
:quantity => nil,
:weight_quantity => nil
)
result = helper.display_quantity(harvest)
result.should eq 'not specified'
end
it '3 individual' do
harvest = FactoryGirl.create(:harvest,
:quantity => 3,
:unit => 'individual',
:weight_quantity => nil
)
result = helper.display_quantity(harvest)
result.should eq '3'
end
it '1 bunch' do
harvest = FactoryGirl.create(:harvest,
:quantity => 1,
:unit => 'bunch',
:weight_quantity => nil
)
result = helper.display_quantity(harvest)
result.should eq '1 bunch'
end
it '3 bunches' do
harvest = FactoryGirl.create(:harvest,
:quantity => 3,
:unit => 'bunch',
:weight_quantity => nil
)
result = helper.display_quantity(harvest)
result.should eq '3 bunches'
end
it '3 kg' do
harvest = FactoryGirl.create(:harvest,
:quantity => nil,
:unit => nil,
:weight_quantity => 3,
:weight_unit => 'kg'
)
result = helper.display_quantity(harvest)
result.should eq '3 kg'
end
it '3 individual weighing 3 kg' do
harvest = FactoryGirl.create(:harvest,
:quantity => 3,
:unit => 'individual',
:weight_quantity => 3,
:weight_unit => 'kg'
)
result = helper.display_quantity(harvest)
result.should eq '3, weighing 3 kg'
end
it '3 bunches weighing 3 kg' do
harvest = FactoryGirl.create(:harvest,
:quantity => 3,
:unit => 'bunch',
:weight_quantity => 3,
:weight_unit => 'kg'
)
result = helper.display_quantity(harvest)
result.should eq '3 bunches, weighing 3 kg'
end
end
end

View File

@@ -13,7 +13,7 @@ describe Crop do
it 'should be fetchable from the database' do
@crop.save
@crop2 = Crop.find_by_name('Tomato')
@crop2 = Crop.find_by_system_name('Tomato')
@crop2.en_wikipedia_url.should == "http://en.wikipedia.org/wiki/Tomato"
@crop2.slug.should == "tomato"
end
@@ -32,7 +32,7 @@ describe Crop do
context 'invalid data' do
it 'should not save a crop without a system name' do
@crop = FactoryGirl.build(:crop, :name => nil)
@crop = FactoryGirl.build(:crop, :system_name => nil)
expect { @crop.save }.to raise_error ActiveRecord::StatementInvalid
end
end
@@ -235,12 +235,4 @@ describe Crop do
end
context "harvests" do
it "has harvests" do
crop = FactoryGirl.create(:crop)
harvest = FactoryGirl.create(:harvest, :crop => crop)
crop.harvests.should eq [harvest]
end
end
end

View File

@@ -23,7 +23,7 @@ describe Garden do
@garden = FactoryGirl.build(:garden, :name => "")
@garden.should_not be_valid
end
it "doesn't allow a name with only spaces" do
@garden = FactoryGirl.build(:garden, :name => " ")
@garden.should_not be_valid
@@ -96,73 +96,4 @@ describe Garden do
Planting.count.should == all - 2
end
context 'area' do
it 'allows numeric area' do
@garden = FactoryGirl.build(:garden, :area => 33)
@garden.should be_valid
end
it 'allows decimal quantities' do
@garden = FactoryGirl.build(:garden, :area => 3.3)
@garden.should be_valid
end
it 'allows blank quantities' do
@garden = FactoryGirl.build(:garden, :area => '')
@garden.should be_valid
end
it 'allows nil quantities' do
@garden = FactoryGirl.build(:garden, :area => nil)
@garden.should be_valid
end
it 'cleans up zero quantities' do
@garden = FactoryGirl.build(:garden, :area => 0)
@garden.area.should == 0
end
it "doesn't allow non-numeric quantities" do
@garden = FactoryGirl.build(:garden, :area => "99a")
@garden.should_not be_valid
end
end
context 'units' do
Garden::AREA_UNITS_VALUES.values.push(nil, '').each do |s|
it "#{s} should be a valid unit" do
@garden = FactoryGirl.build(:garden, :area_unit => s)
@garden.should be_valid
end
end
it 'should refuse invalid unit values' do
@garden = FactoryGirl.build(:garden, :area_unit => 'not valid')
@garden.should_not be_valid
@garden.errors[:area_unit].should include("not valid is not a valid area unit")
end
it 'sets area unit to blank if area is blank' do
@garden = FactoryGirl.build(:garden, :area => '', :area_unit => 'acre')
@garden.should be_valid
@garden.area_unit.should eq nil
end
end
context 'active scopes' do
before(:each) do
@active = FactoryGirl.create(:garden)
@inactive = FactoryGirl.create(:inactive_garden)
end
it 'includes active garden in active scope' do
Garden.active.should include @active
Garden.active.should_not include @inactive
end
it 'includes inactive garden in inactive scope' do
Garden.inactive.should include @inactive
Garden.inactive.should_not include @active
end
end
end

View File

@@ -1,128 +0,0 @@
require 'spec_helper'
describe Harvest do
it "has an owner" do
harvest = FactoryGirl.create(:harvest)
harvest.owner.should be_an_instance_of Member
end
it "has a crop" do
harvest = FactoryGirl.create(:harvest)
harvest.crop.should be_an_instance_of Crop
end
context 'quantity' do
it 'allows numeric quantities' do
@harvest = FactoryGirl.build(:harvest, :quantity => 33)
@harvest.should be_valid
end
it 'allows decimal quantities' do
@harvest = FactoryGirl.build(:harvest, :quantity => 3.3)
@harvest.should be_valid
end
it 'allows blank quantities' do
@harvest = FactoryGirl.build(:harvest, :quantity => '')
@harvest.should be_valid
end
it 'allows nil quantities' do
@harvest = FactoryGirl.build(:harvest, :quantity => nil)
@harvest.should be_valid
end
it 'cleans up zero quantities' do
@harvest = FactoryGirl.build(:harvest, :quantity => 0)
@harvest.quantity.should == 0
end
it "doesn't allow non-numeric quantities" do
@harvest = FactoryGirl.build(:harvest, :quantity => "99a")
@harvest.should_not be_valid
end
end
context 'units' do
Harvest::UNITS_VALUES.values.push(nil, '').each do |s|
it "#{s} should be a valid unit" do
@harvest = FactoryGirl.build(:harvest, :unit => s)
@harvest.should be_valid
end
end
it 'should refuse invalid unit values' do
@harvest = FactoryGirl.build(:harvest, :unit => 'not valid')
@harvest.should_not be_valid
@harvest.errors[:unit].should include("not valid is not a valid unit")
end
it 'sets unit to blank if quantity is blank' do
@harvest = FactoryGirl.build(:harvest, :quantity => '', :unit => 'individual')
@harvest.should be_valid
@harvest.unit.should eq nil
end
end
context 'weight quantity' do
it 'allows numeric weight quantities' do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => 33)
@harvest.should be_valid
end
it 'allows decimal weight quantities' do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => 3.3)
@harvest.should be_valid
end
it 'allows blank weight quantities' do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => '')
@harvest.should be_valid
end
it 'allows nil weight quantities' do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => nil)
@harvest.should be_valid
end
it 'cleans up zero quantities' do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => 0)
@harvest.weight_quantity.should == 0
end
it "doesn't allow non-numeric weight quantities" do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => "99a")
@harvest.should_not be_valid
end
end
context 'weight units' do
it 'all valid units should work' do
['kg', 'lb', nil, ''].each do |s|
@harvest = FactoryGirl.build(:harvest, :weight_unit => s)
@harvest.should be_valid
end
end
it 'should refuse invalid weight unit values' do
@harvest = FactoryGirl.build(:harvest, :weight_unit => 'not valid')
@harvest.should_not be_valid
@harvest.errors[:weight_unit].should include("not valid is not a valid unit")
end
it 'sets weight_unit to blank if quantity is blank' do
@harvest = FactoryGirl.build(:harvest, :weight_quantity => '', :weight_unit => 'kg')
@harvest.should be_valid
@harvest.weight_unit.should eq nil
end
end
context 'ordering' do
it 'lists most recent harvests first' do
@h1 = FactoryGirl.create(:harvest, :created_at => 1.day.ago)
@h2 = FactoryGirl.create(:harvest, :created_at => 1.hour.ago)
Harvest.all.should eq [@h2, @h1]
end
end
end

View File

@@ -373,12 +373,4 @@ describe 'member' do
end
end
context 'harvests' do
it 'has harvests' do
member = FactoryGirl.create(:member)
harvest = FactoryGirl.create(:harvest, :owner => member)
member.harvests.should eq [harvest]
end
end
end

View File

@@ -41,7 +41,7 @@ describe Planting do
context 'delegation' do
it 'system name' do
@planting.crop_name.should eq @planting.crop.name
@planting.crop_system_name.should eq @planting.crop.system_name
end
it 'wikipedia url' do
@planting.crop_en_wikipedia_url.should eq @planting.crop.en_wikipedia_url

View File

@@ -14,7 +14,7 @@ describe ScientificName do
it 'should be fetchable from the database' do
@sn.save
@sn2 = ScientificName.find_by_scientific_name('Zea mays')
@sn2.crop.name.should == "Maize"
@sn2.crop.system_name.should == "Maize"
end
it 'has a creator' do

View File

@@ -1,11 +0,0 @@
require 'spec_helper'
describe "Harvests" do
describe "GET /harvests" 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 harvests_path
response.status.should be(200)
end
end
end

View File

@@ -1,35 +0,0 @@
require "spec_helper"
describe HarvestsController do
describe "routing" do
it "routes to #index" do
get("/harvests").should route_to("harvests#index")
end
it "routes to #new" do
get("/harvests/new").should route_to("harvests#new")
end
it "routes to #show" do
get("/harvests/1").should route_to("harvests#show", :id => "1")
end
it "routes to #edit" do
get("/harvests/1/edit").should route_to("harvests#edit", :id => "1")
end
it "routes to #create" do
post("/harvests").should route_to("harvests#create")
end
it "routes to #update" do
put("/harvests/1").should route_to("harvests#update", :id => "1")
end
it "routes to #destroy" do
delete("/harvests/1").should route_to("harvests#destroy", :id => "1")
end
end
end

View File

@@ -21,8 +21,4 @@ describe "comments/index" do
rendered.should contain 'OMG LOL'
rendered.should contain 'ROFL'
end
it "contains an RSS feed link" do
assert_select "a", :href => comments_path(:format => 'rss')
end
end

View File

@@ -15,7 +15,7 @@ describe "crops/edit" do
it "renders the edit crop form" do
assert_select "form", :action => crops_path(@crop), :method => "post" do
assert_select "input#crop_name", :name => "crop[name]"
assert_select "input#crop_system_name", :name => "crop[system_name]"
assert_select "input#crop_en_wikipedia_url", :name => "crop[en_wikipedia_url]"
end
end

View File

@@ -4,12 +4,12 @@ describe "crops/hierarchy" do
before(:each) do
controller.stub(:current_user) { nil }
@tomato = FactoryGirl.create(:tomato)
@roma = FactoryGirl.create(:crop, :name => 'Roma tomato', :parent => @tomato)
@roma = FactoryGirl.create(:crop, :system_name => 'Roma tomato', :parent => @tomato)
assign(:crops, [@tomato, @roma])
render
end
it "shows crop hierarchy" do
assert_select "ul>li>ul>li", :text => @roma.name
assert_select "ul>li>ul>li", :text => @roma.system_name
end
end

View File

@@ -45,14 +45,4 @@ describe "crops/index" do
rendered.should contain "New Crop"
end
end
context "downloads" do
it "offers data downloads" do
render
rendered.should contain "The data on this page is available in the following formats:"
assert_select "a", :href => crops_path(:format => 'csv')
assert_select "a", :href => crops_path(:format => 'json')
assert_select "a", :href => crops_path(:format => 'rss')
end
end
end

View File

@@ -12,7 +12,7 @@ describe "crops/new" do
it "renders new crop form" do
# 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_name", :name => "crop[name]"
assert_select "input#crop_system_name", :name => "crop[system_name]"
assert_select "input#crop_en_wikipedia_url", :name => "crop[en_wikipedia_url]"
assert_select "select#crop_parent_id", :name => "crop[parent_id]"
end

View File

@@ -62,24 +62,13 @@ describe "crops/show" do
assert_select "a[href=#{seed_path(seed)}]"
end
end
end
context "harvests" do
before(:each) do
@owner1 = FactoryGirl.create(:london_member)
@h1 = FactoryGirl.create(:harvest, :owner => @owner1, :crop => @crop)
@h2 = FactoryGirl.create(:harvest, :owner => @owner1, :crop => @crop)
render
it "shows location if available" do
rendered.should contain "#{@owner1} in #{@owner1.location} will trade #{@seed1.tradable_to}"
end
it "shows a heading" do
rendered.should contain "Harvests"
end
it "shows a list of people who have harvested this crop" do
@crop.harvests.each do |harvest|
assert_select "a[href=#{harvest_path(harvest)}]"
end
it "shows grammatical text if seed trader has no location" do
rendered.should contain "#{@owner2} (location unknown) will trade #{@seed2.tradable_to}"
end
end
@@ -165,18 +154,18 @@ describe "crops/show" do
context 'varieties' do
before(:each) do
@popcorn = FactoryGirl.create(:popcorn, :parent_id => @crop.id)
@ubercrop = FactoryGirl.create(:crop, :name => 'ubercrop')
@ubercrop = FactoryGirl.create(:crop, :system_name => 'ubercrop')
@crop.parent_id = @ubercrop.id
@crop.save
render
end
it 'shows popcorn as a child variety' do
rendered.should contain @popcorn.name
rendered.should contain @popcorn.system_name
end
it 'shows parent crop' do
rendered.should contain @ubercrop.name
rendered.should contain @ubercrop.system_name
end
end
@@ -198,10 +187,6 @@ describe "crops/show" do
rendered.should contain "Plant this"
end
it "shows a harvest this button" do
rendered.should contain "Harvest this"
end
it "links to the right crop in the planting link" do
assert_select("a[href=#{new_planting_path}?crop_id=#{@crop.id}]")
end

View File

@@ -18,10 +18,6 @@ describe "gardens/edit" do
assert_select "form", :action => gardens_path(@garden), :method => "post" do
assert_select "input#garden_name", :name => "garden[name]"
assert_select "textarea#garden_description", :name => "garden[description]"
assert_select "input#garden_location", :name => "garden[location]"
assert_select "input#garden_area", :name => "garden[area]"
assert_select "select#garden_area_unit", :name => "garden[area_unit]"
assert_select "input#garden_active", :name => "garden[active]"
end
end
end

View File

@@ -4,12 +4,14 @@ describe "gardens/index" do
before(:each) do
controller.stub(:current_user) { nil }
@owner = FactoryGirl.create(:member)
@garden = FactoryGirl.create(:garden, :owner => @owner)
page = 1
per_page = 2
total_entries = 2
gardens = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([@garden, @garden])
pager.replace([
FactoryGirl.create(:garden, :owner => @owner),
FactoryGirl.create(:garden, :owner => @owner)
])
end
assign(:gardens, gardens)
end
@@ -17,9 +19,7 @@ describe "gardens/index" do
it "renders a list of gardens" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => @garden.name, :count => 2
assert_select "tr>td>a", :text => @garden.location, :count => 2
assert_select "tr>td", :text => pluralize(@garden.area, @garden.area_unit), :count => 2
assert_select "tr>td", :text => "Springfield Community Garden".to_s, :count => 2
end
end

View File

@@ -2,22 +2,17 @@ require 'spec_helper'
describe "gardens/new" do
before(:each) do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_user) { @member }
@garden = FactoryGirl.create(:garden, :owner => @member)
assign(:garden, @garden)
render
controller.stub(:current_user) { Member.new }
assign(:garden, FactoryGirl.create(:garden))
end
it "renders new garden form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => gardens_path, :method => "post" do
assert_select "input#garden_name", :name => "garden[name]"
assert_select "textarea#garden_description", :name => "garden[description]"
assert_select "input#garden_location", :name => "garden[location]"
assert_select "input#garden_area", :name => "garden[area]"
assert_select "select#garden_area_unit", :name => "garden[area_unit]"
assert_select "input#garden_active", :name => "garden[active]"
end
end
end

View File

@@ -10,14 +10,6 @@ describe "gardens/show" do
render
end
it 'should show the location' do
rendered.should contain @garden.location
end
it 'should show the area' do
rendered.should contain pluralize(@garden.area, @garden.area_unit)
end
it 'should show the description' do
rendered.should contain "totally cool garden"
end
@@ -27,7 +19,7 @@ describe "gardens/show" do
end
it 'should show plantings on the garden page' do
rendered.should contain @planting.crop.name
rendered.should contain @planting.crop.system_name
end
it "doesn't show the note about random plantings" do

View File

@@ -1,19 +0,0 @@
require 'spec_helper'
describe "harvests/edit" do
before(:each) do
assign(:harvest, FactoryGirl.create(:harvest))
render
end
it "renders new harvest form" do
assert_select "form", :action => harvests_path, :method => "post" do
assert_select "select#harvest_crop_id", :name => "harvest[crop_id]"
assert_select "input#harvest_quantity", :name => "harvest[quantity]"
assert_select "input#harvest_weight_quantity", :name => "harvest[quantity]"
assert_select "select#harvest_unit", :name => "harvest[unit]"
assert_select "select#harvest_weight_unit", :name => "harvest[unit]"
assert_select "textarea#harvest_description", :name => "harvest[description]"
end
end
end

View File

@@ -1,41 +0,0 @@
require 'spec_helper'
describe "harvests/index" do
before(:each) do
controller.stub(:current_user) { nil }
@member = FactoryGirl.create(:member)
@tomato = FactoryGirl.create(:tomato)
@maize = FactoryGirl.create(:maize)
page = 1
per_page = 2
total_entries = 2
harvests = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
FactoryGirl.create(:harvest,
:crop => @tomato,
:owner => @member
),
FactoryGirl.create(:harvest,
:crop => @maize,
:owner => @member
)
])
end
assign(:harvests, harvests)
render
end
it "renders a list of harvests" do
render
assert_select "tr>td", :text => @member.login_name
assert_select "tr>td", :text => @tomato.name
assert_select "tr>td", :text => @maize.name
end
it "provides data links" do
render
rendered.should contain "The data on this page is available in the following formats:"
assert_select "a", :href => harvests_path(:format => 'csv')
assert_select "a", :href => harvests_path(:format => 'json')
end
end

View File

@@ -1,19 +0,0 @@
require 'spec_helper'
describe "harvests/new" do
before(:each) do
assign(:harvest, FactoryGirl.create(:harvest))
render
end
it "renders new harvest form" do
assert_select "form", :action => harvests_path, :method => "post" do
assert_select "select#harvest_crop_id", :name => "harvest[crop_id]"
assert_select "input#harvest_quantity", :name => "harvest[quantity]"
assert_select "input#harvest_weight_quantity", :name => "harvest[quantity]"
assert_select "select#harvest_unit", :name => "harvest[unit]"
assert_select "select#harvest_weight_unit", :name => "harvest[unit]"
assert_select "textarea#harvest_description", :name => "harvest[description]"
end
end
end

View File

@@ -1,16 +0,0 @@
require 'spec_helper'
describe "harvests/show" do
before(:each) do
controller.stub(:current_user) { nil }
@crop = FactoryGirl.create(:tomato)
@harvest = assign(:harvest, FactoryGirl.create(:harvest, :crop => @crop))
render
end
it "renders attributes" do
rendered.should contain @crop.name
rendered.should contain @harvest.harvested_at.to_s
end
end

View File

@@ -17,7 +17,7 @@ describe 'home/_members.html.haml', :type => "view" do
it 'Shows members' do
rendered.should contain @member.login_name
rendered.should contain @member.location
rendered.should contain @planting.crop_name
rendered.should contain @planting.crop_system_name
end
end

View File

@@ -1,35 +0,0 @@
require 'spec_helper'
describe "members/_location" do
context "member with location" do
before(:each) do
@member = FactoryGirl.create(:london_member)
render :partial => 'members/location', :locals => { :member => @member }
end
it 'shows location if available' do
rendered.should contain @member.location
end
it "links to the places page" do
assert_select "a", :href => place_path(@member.location)
end
end
context "member with no location" do
before(:each) do
@member = FactoryGirl.create(:member)
render :partial => 'members/location', :locals => { :member => @member }
end
it 'shows unknown location' do
rendered.should contain "unknown location"
end
it "doesn't link anywhere" do
assert_select "a", false
end
end
end

Some files were not shown because too many files have changed in this diff Show More