Merge branch 'dev' into payments-new

Conflicts:
	db/schema.rb
This commit is contained in:
Skud committed 2013-05-22 10:21:43 +10:00
commit f138c99846
16 files changed
+72 -6

No files matched your search

-1
View File
@@ -79,7 +79,6 @@ gem 'bootstrap-datepicker-rails'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-flickr'
gem 'authbuttons-rails'
# for phusion passenger (i.e. mod_rails) on the server
gem 'passenger'
-2
View File
@@ -29,7 +29,6 @@ GEM
i18n (= 0.6.1)
multi_json (~> 1.0)
arel (3.0.2)
authbuttons-rails (0.1.2)
bcrypt-ruby (3.0.1)
bluecloth (2.2.0)
bootstrap-datepicker-rails (1.0.0)
@@ -233,7 +232,6 @@ PLATFORMS
ruby
DEPENDENCIES
authbuttons-rails
bluecloth
bootstrap-datepicker-rails
bundler (>= 1.1.5)
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

+6 -1
View File
@@ -1,9 +1,14 @@
class Crop < ActiveRecord::Base
extend FriendlyId
friendly_id :system_name, use: :slugged
attr_accessible :en_wikipedia_url, :system_name
attr_accessible :en_wikipedia_url, :system_name, :parent_id
has_many :scientific_names
has_many :plantings
belongs_to :parent, :class_name => 'Crop'
has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id'
default_scope order("lower(system_name) asc")
validates :en_wikipedia_url,
+5
View File
@@ -22,5 +22,10 @@
.controls
= f.text_field :en_wikipedia_url
%span.help-inline Link to this crop's page on the English language Wikipedia.
.control-group
= f.label :parent_id, 'Parent crop', :class => 'control-label'
.controls
= 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'
+13
View File
@@ -2,6 +2,19 @@
.row
.span9
- if @crop.parent
%p
= @crop.system_name
is a variety of
= succeed "." do
= link_to @crop.parent, @crop.parent
- if @crop.varieties.count > 0
%p
Varieties of
= succeed ":" do
= @crop.system_name
!= @crop.varieties.map{ |c| link_to c, c }.join(", ")
- if @crop.plantings_count > 0
%p
Planted
@@ -53,6 +53,7 @@
- else
=link_to 'Connect to Twitter', '/auth/twitter'
%p
= image_tag "flickr_32.png", :size => "32x32", :alt => 'Flickr logo'
- if @flickr_auth
You are connected to Flickr as
= succeed "." do
+1 -1
View File
@@ -7,7 +7,7 @@
= label_tag :distance, "Find members within", :class => 'control-label'
= text_field_tag :distance, @distance, :class => 'input-mini'
= select_tag :units, options_for_select({"miles" => :mi, "km" => :km}, @units), :class => 'input-small'
= label_tag :location, "miles of", :class => 'control-label'
= label_tag :location, "of", :class => 'control-label'
= text_field_tag :location, @location
= submit_tag "Search", :class => 'btn btn-primary'
+1 -1
View File
@@ -33,7 +33,7 @@
- if @flickr_auth
%p
Flickr:
= image_tag "flickr_32.png", :size => "32x32", :alt => 'Flickr logo'
=link_to @flickr_auth.name, "http://flickr.com/photos/#{@flickr_auth.uid}"
- if @member.show_email
@@ -0,0 +1,5 @@
class AddParentToCrop < ActiveRecord::Migration
def change
add_column :crops, :parent_id, :integer
end
end
+1
View File
@@ -56,6 +56,7 @@ ActiveRecord::Schema.define(:version => 20130518002942) do
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "slug"
t.integer "parent_id"
end
add_index "crops", ["slug"], :name => "index_crops_on_slug", :unique => true
+10
View File
@@ -30,6 +30,16 @@ FactoryGirl.define do
system_name "Pear"
end
# for testing varieties
factory :roma do
system_name "Roma tomato"
end
factory :popcorn do
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
+9
View File
@@ -60,4 +60,13 @@ describe Crop do
@crop = FactoryGirl.build(:tomato, :en_wikipedia_url => 'http://en.wikipedia.org/wiki/SomePage')
@crop.should be_valid
end
context 'varieties' do
it 'has a crop hierarchy' do
@tomato = FactoryGirl.create(:tomato)
@roma = FactoryGirl.create(:roma, :parent_id => @tomato.id)
@roma.parent.should eq @tomato
@tomato.varieties.should eq [@roma]
end
end
end
+1
View File
@@ -14,6 +14,7 @@ describe "crops/new" do
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]"
assert_select "select#crop_parent_id", :name => "crop[parent_id]"
end
end
+19
View File
@@ -44,6 +44,25 @@ describe "crops/show" do
rendered.should contain "Springfield Community Garden"
end
context 'varieties' do
before(:each) do
@popcorn = FactoryGirl.create(:popcorn, :parent_id => @crop.id)
@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.system_name
end
it 'shows parent crop' do
rendered.should contain @ubercrop.system_name
end
end
context "logged in and crop wrangler" do
before(:each) do