Skip to content

Commit bb65cf8

Browse files
committed
[WIP] Initial specs
1 parent 35a44cc commit bb65cf8

File tree

12 files changed

+78
-9
lines changed

12 files changed

+78
-9
lines changed

app/models/pg_team.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#Rename to Team when Mongodb is dropped
22
class PgTeam < ActiveRecord::Base
33
self.table_name = 'teams'
4-
has_one :account, class_name: 'Teams::Account'
4+
#TODO add inverse_of
5+
has_one :account, class_name: 'Teams::Account' , foreign_key: 'team_id'
56

6-
has_many :members, class_name: 'Teams::Member'
7-
has_many :links, class_name: 'Teams::Link'
8-
has_many :locations, class_name: 'Teams::Location'
7+
has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id'
8+
has_many :links, class_name: 'Teams::Link', foreign_key: 'team_id'
9+
has_many :locations, class_name: 'Teams::Location' , foreign_key: 'team_id'
910
end

app/models/teams/account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Teams::Account < ActiveRecord::Base
2-
belongs_to :team, class_name: 'PgTeam'
2+
belongs_to :team, class_name: 'PgTeam', foreign_key: 'team_id'
33
end

app/models/teams/link.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Teams::Link < ActiveRecord::Base
2-
belongs_to :team, class_name: 'PgTeam'
2+
belongs_to :team, class_name: 'PgTeam', foreign_key: 'team_id'
33
end

app/models/teams/location.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class Teams::Location < ActiveRecord::Base
2-
belongs_to :team, class_name: 'PgTeam'
2+
#Rails 3 is stupid
3+
belongs_to :team, class_name: 'PgTeam', foreign_key: 'team_id'
34
end

app/models/teams/member.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class Teams::Member < ActiveRecord::Base
2-
belongs_to :team, class_name: 'PgTeam'
2+
belongs_to :team, class_name: 'PgTeam', foreign_key: 'team_id'
33
belongs_to :user
44
end

db/migrate/20140718084025_create_pg_teams.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class CreatePgTeams < ActiveRecord::Migration
22
def change
3-
create_table :pg_teams do |t|
3+
create_table :teams do |t|
44

55
t.timestamps
66
end

db/schema.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,44 @@
356356
t.string "name"
357357
end
358358

359+
create_table "teams", :force => true do |t|
360+
t.datetime "created_at", :null => false
361+
t.datetime "updated_at", :null => false
362+
end
363+
364+
create_table "teams_accounts", :force => true do |t|
365+
t.integer "team_id", :null => false
366+
t.datetime "created_at", :null => false
367+
t.datetime "updated_at", :null => false
368+
end
369+
370+
create_table "teams_links", :force => true do |t|
371+
t.string "name"
372+
t.string "url"
373+
t.integer "team_id", :null => false
374+
t.datetime "created_at", :null => false
375+
t.datetime "updated_at", :null => false
376+
end
377+
378+
create_table "teams_locations", :force => true do |t|
379+
t.string "name"
380+
t.string "description"
381+
t.string "address"
382+
t.string "city"
383+
t.string "state_code"
384+
t.string "country"
385+
t.integer "team_id", :null => false
386+
t.datetime "created_at", :null => false
387+
t.datetime "updated_at", :null => false
388+
end
389+
390+
create_table "teams_members", :force => true do |t|
391+
t.integer "team_id", :null => false
392+
t.integer "user_id", :null => false
393+
t.datetime "created_at", :null => false
394+
t.datetime "updated_at", :null => false
395+
end
396+
359397
create_table "tokens", :force => true do |t|
360398
t.string "token"
361399
t.string "secret"

spec/models/pg_team_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe PgTeam, :type => :model do
4+
it {is_expected.to have_one :account}
5+
6+
it {is_expected.to have_many :locations}
7+
it {is_expected.to have_many :links}
8+
it {is_expected.to have_many :members}
9+
end

spec/models/teams/account_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe Teams::Account, :type => :model do
4+
it {is_expected.to belong_to(:team)}
5+
end

spec/models/teams/link_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe Teams::Link, :type => :model do
4+
it {is_expected.to belong_to(:team)}
5+
end

spec/models/teams/location_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe Teams::Location, :type => :model do
4+
it {is_expected.to belong_to(:team)}
5+
end

spec/models/teams/member_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe Teams::Member, :type => :model do
4+
it {is_expected.to belong_to(:team)}
5+
end

0 commit comments

Comments
 (0)