mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-04-23 16:28:05 -04:00
Added creator field to crops
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
class Crop < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
friendly_id :system_name, use: :slugged
|
||||
attr_accessible :en_wikipedia_url, :system_name, :parent_id
|
||||
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
|
||||
belongs_to :creator, :class_name => 'Member'
|
||||
|
||||
belongs_to :parent, :class_name => 'Crop'
|
||||
has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id'
|
||||
|
||||
5
db/migrate/20130821011352_add_creator_to_crops.rb
Normal file
5
db/migrate/20130821011352_add_creator_to_crops.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddCreatorToCrops < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :crops, :creator_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130819004549) do
|
||||
ActiveRecord::Schema.define(:version => 20130821011352) do
|
||||
|
||||
create_table "account_types", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
@@ -58,6 +58,7 @@ ActiveRecord::Schema.define(:version => 20130819004549) do
|
||||
t.string "slug"
|
||||
t.integer "parent_id"
|
||||
t.integer "plantings_count"
|
||||
t.integer "creator_id"
|
||||
end
|
||||
|
||||
add_index "crops", ["slug"], :name => "index_crops_on_slug", :unique => true
|
||||
@@ -114,6 +115,7 @@ ActiveRecord::Schema.define(:version => 20130819004549) do
|
||||
t.float "latitude"
|
||||
t.float "longitude"
|
||||
t.boolean "send_notification_email", :default => true
|
||||
t.text "bio"
|
||||
end
|
||||
|
||||
add_index "members", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
||||
|
||||
@@ -3,6 +3,7 @@ FactoryGirl.define do
|
||||
factory :crop do
|
||||
system_name "Magic bean"
|
||||
en_wikipedia_url "http://en.wikipedia.org/wiki/Magic_bean"
|
||||
creator
|
||||
|
||||
factory :tomato do
|
||||
system_name "Tomato"
|
||||
|
||||
@@ -2,7 +2,7 @@ FactoryGirl.define do
|
||||
sequence(:email) { |n| "member#{n}@example.com" }
|
||||
sequence(:login_name) { |n| "member#{n}" }
|
||||
|
||||
factory :member, aliases: [:author, :owner, :sender, :recipient] do
|
||||
factory :member, aliases: [:author, :owner, :sender, :recipient, :creator] do
|
||||
login_name { generate(:login_name) }
|
||||
password 'password1'
|
||||
email { generate(:email) }
|
||||
|
||||
@@ -23,6 +23,11 @@ describe Crop do
|
||||
@crop.to_s.should == 'Tomato'
|
||||
"#{@crop}".should == 'Tomato'
|
||||
end
|
||||
|
||||
it 'has a creator' do
|
||||
@crop.save
|
||||
@crop.creator.should be_an_instance_of Member
|
||||
end
|
||||
end
|
||||
|
||||
context 'invalid data' do
|
||||
|
||||
Reference in New Issue
Block a user