mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-21 22:44:23 -04:00
Add alternate name model.
This commit is contained in:
1 parent
694bc56f68
commit
e85cb4598d
5 files changed
+51
-1
No files matched your search
@@ -0,0 +1,5 @@
|
||||
class AlternateName < ActiveRecord::Base
|
||||
attr_accessible :crop_id, :name, :creator_id
|
||||
belongs_to :crop
|
||||
belongs_to :creator, :class_name => 'Member'
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class CreateAlternateNames < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :alternate_names do |t|
|
||||
t.string :name, :null => false
|
||||
t.integer :crop_id, :null => false
|
||||
t.integer :creator_id, :null => false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
+10
-1
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20141002022459) do
|
||||
ActiveRecord::Schema.define(:version => 20141018111015) do
|
||||
|
||||
create_table "account_types", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
@@ -29,6 +29,14 @@ ActiveRecord::Schema.define(:version => 20141002022459) do
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "alternate_names", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.integer "crop_id", :null => false
|
||||
t.integer "creator_id", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "authentications", :force => true do |t|
|
||||
t.integer "member_id", :null => false
|
||||
t.string "provider", :null => false
|
||||
@@ -154,6 +162,7 @@ ActiveRecord::Schema.define(:version => 20141002022459) do
|
||||
t.text "bio"
|
||||
t.integer "plantings_count"
|
||||
t.boolean "newsletter"
|
||||
t.boolean "send_planting_reminder", :default => true
|
||||
end
|
||||
|
||||
add_index "members", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :alternate_name do
|
||||
association :crop, factory: :crop
|
||||
name "alternate name"
|
||||
creator
|
||||
|
||||
factory :alternate_tomato do
|
||||
association :crop, factory: :tomato
|
||||
name "alternative tomato"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe AlternateName do
|
||||
before (:each) do
|
||||
@an = FactoryGirl.create(:alternate_tomato)
|
||||
end
|
||||
|
||||
it 'should save a basic alternate name' do
|
||||
@an.save.should be_true
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user