Commit 4a6a1c2ed3bef62e1a27227db41b63e1ba7a99c9

Authored by Rafael Manzo
Committed by Rafael Manzo
1 parent fa1013f0

Created ProjectOwnership model

Already associated it with User
app/models/project_ownership.rb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +class ProjectOwnership < ActiveRecord::Base
  2 + belongs_to :user
  3 +end
... ...
app/models/user.rb
... ... @@ -8,5 +8,6 @@ class User &lt; ActiveRecord::Base
8 8 validates :email, presence: true
9 9 validates :email, uniqueness: true
10 10  
  11 + has_many :project_ownerships
11 12 # Alert: when adding new parameters to this model, they should also be added to registrations_controller
12 13 end
... ...
db/migrate/20130826211404_create_project_ownerships.rb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +class CreateProjectOwnerships < ActiveRecord::Migration
  2 + def change
  3 + create_table :project_ownerships do |t|
  4 + t.integer :user_id
  5 + t.integer :project_id
  6 +
  7 + t.timestamps
  8 + end
  9 + end
  10 +end
... ...
db/schema.rb
... ... @@ -11,7 +11,14 @@
11 11 #
12 12 # It's strongly recommended that you check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(version: 20130627183652) do
  14 +ActiveRecord::Schema.define(version: 20130826211404) do
  15 +
  16 + create_table "project_ownerships", force: true do |t|
  17 + t.integer "user_id"
  18 + t.integer "project_id"
  19 + t.datetime "created_at"
  20 + t.datetime "updated_at"
  21 + end
15 22  
16 23 create_table "users", force: true do |t|
17 24 t.string "name", default: "", null: false
... ...
spec/factories/project_ownerships.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +# Read about factories at https://github.com/thoughtbot/factory_girl
  2 +
  3 +FactoryGirl.define do
  4 + factory :project_ownership do
  5 + user_id 1
  6 + project_id 1
  7 + end
  8 +end
... ...
spec/models/project_ownership_spec.rb 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +require 'spec_helper'
  2 +
  3 +describe ProjectOwnership do
  4 + describe 'associations' do
  5 + it { should belong_to(:user) }
  6 + end
  7 +end
... ...
spec/models/user_spec.rb
... ... @@ -8,4 +8,8 @@ describe User do
8 8 it { should validate_presence_of(:email) }
9 9 it { should validate_uniqueness_of(:email) }
10 10 end
  11 +
  12 + describe 'associations' do
  13 + it { should have_many(:project_ownerships) }
  14 + end
11 15 end
... ...