mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-27 09:18:26 -04:00
Added finished fields for plantings
This commit is contained in:
1 parent
40c7124769
commit
b07d9d8db0
5 files changed
+26
-6
No files matched your search
@@ -3,7 +3,8 @@ class Planting < ActiveRecord::Base
|
||||
friendly_id :planting_slug, use: :slugged
|
||||
|
||||
attr_accessible :crop_id, :description, :garden_id, :planted_at,
|
||||
:quantity, :sunniness, :planted_from, :owner_id
|
||||
:quantity, :sunniness, :planted_from, :owner_id, :finished,
|
||||
:finished_at
|
||||
|
||||
belongs_to :garden
|
||||
belongs_to :owner, :class_name => 'Member', :counter_cache => true
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddFinishedToPlanting < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :plantings, :finished, :boolean, :default => false
|
||||
add_column :plantings, :finished_at, :date
|
||||
end
|
||||
end
|
||||
+7
-5
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140718075753) do
|
||||
ActiveRecord::Schema.define(:version => 20140829230600) do
|
||||
|
||||
create_table "account_types", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
@@ -213,17 +213,19 @@ ActiveRecord::Schema.define(:version => 20140718075753) do
|
||||
end
|
||||
|
||||
create_table "plantings", :force => true do |t|
|
||||
t.integer "garden_id", :null => false
|
||||
t.integer "crop_id", :null => false
|
||||
t.integer "garden_id", :null => false
|
||||
t.integer "crop_id", :null => false
|
||||
t.date "planted_at"
|
||||
t.integer "quantity"
|
||||
t.text "description"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "slug"
|
||||
t.string "sunniness"
|
||||
t.string "planted_from"
|
||||
t.integer "owner_id"
|
||||
t.boolean "finished", :default => false
|
||||
t.date "finished_at"
|
||||
end
|
||||
|
||||
add_index "plantings", ["slug"], :name => "index_plantings_on_slug", :unique => true
|
||||
|
||||
@@ -30,5 +30,10 @@ FactoryGirl.define do
|
||||
factory :shady_planting do
|
||||
sunniness 'shade'
|
||||
end
|
||||
|
||||
factory :finished_planting do
|
||||
finished true
|
||||
finished_at '2014-08-30'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -209,6 +209,12 @@ describe Planting do
|
||||
Planting.interesting.should_not include @planting1
|
||||
end
|
||||
|
||||
it 'has finished fields' do
|
||||
@planting = FactoryGirl.create(:finished_planting)
|
||||
@planting.finished.should be true
|
||||
@planting.finished_at.should be_an_instance_of Date
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user