Merge pull request #162 from phazel/sorted_plantings

sort plantings
This commit is contained in:
Skud
2013-03-31 22:07:31 -07:00
3 changed files with 8 additions and 9 deletions

View File

@@ -13,6 +13,8 @@ class Planting < ActiveRecord::Base
:to => :crop,
:prefix => true
default_scope order("created_at desc")
SUNNINESS_VALUES = %w(sun semi-shade shade)
validates :sunniness, :inclusion => { :in => SUNNINESS_VALUES,
:message => "%{value} is not a valid sunniness value" },

View File

@@ -112,15 +112,6 @@ ActiveRecord::Schema.define(:version => 20130329045744) do
t.datetime "updated_at", :null => false
end
create_table "payments", :force => true do |t|
t.integer "payer_id"
t.decimal "amount"
t.date "paid_period_begins"
t.date "paid_period_ends"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "plantings", :force => true do |t|
t.integer "garden_id", :null => false
t.integer "crop_id", :null => false

View File

@@ -19,6 +19,12 @@ describe Planting do
@planting.location.should match /^member\d+'s Springfield Community Garden$/
end
it "sorts plantings in descending order of creation" do
@planting1 = FactoryGirl.create(:planting)
@planting2 = FactoryGirl.create(:planting)
Planting.first.should eq @planting2
end
it "should have a slug" do
@planting.slug.should match /^member\d+-springfield-community-garden-tomato$/
end