-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elad Meidar
committed
Nov 11, 2009
1 parent
584ad9d
commit 07f5d43
Showing
8 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Address < ActiveRecord::Base | ||
belongs_to :addressable, :polymorphic => true | ||
belongs_to :user | ||
belongs_to :company | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Company < ActiveRecord::Base | ||
|
||
belongs_to :owner, :foreign_key => 'owner_id', :class_name => 'User' | ||
|
||
has_one :address, :as => :addressable | ||
|
||
has_many :users | ||
|
||
has_and_belongs_to_many :freelancers | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Freelancer < ActiveRecord::Base | ||
has_and_belongs_to_many :companies | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class User < ActiveRecord::Base | ||
belongs_to :company | ||
|
||
has_one :company, :foreign_key => 'owner_id' | ||
has_one :address, :as => :addressable | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ActiveRecord::Schema.define do | ||
create_table "users", :force => true do |t| | ||
t.column "company_id", :integer | ||
t.column "name", :text | ||
t.column "email", :text | ||
end | ||
|
||
create_table "companies", :force => true do |t| | ||
t.column "name", :text | ||
t.column "owned_id", :integer | ||
end | ||
|
||
create_table "addresses", :force => true do |t| | ||
t.column "addressable_type", :string | ||
t.column "addressable_id", :integer | ||
t.column "address", :text | ||
end | ||
|
||
create_table "freelancers", :force => true do |t| | ||
t.column "name", :string | ||
t.column "price_per_hour", :integer | ||
end | ||
|
||
create_table "companies_freelancers", :force => true do |t| | ||
t.column "freelancer_id", :integer | ||
t.column "company_id", :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
require 'test_helper' | ||
|
||
class RailsIndexesTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
|
||
test "fail dammit" do | ||
assert_equal 1,4 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
require 'rubygems' | ||
require 'activerecord' | ||
require 'active_record/fixtures' | ||
require 'active_support' | ||
require 'active_support/test_case' | ||
require 'active_support/test_case' | ||
require 'action_controller' | ||
|
||
require 'indexer' | ||
|
||
ActiveRecord::Base.establish_connection( | ||
:adapter => "sqlite3", | ||
:database => ":memory:" | ||
) | ||
|
||
load 'test/fixtures/schema.rb' | ||
|
||
# Load models | ||
Dir['test/fixtures/app/models/**/*.rb'].each { |f| require f } | ||
|
||
# load controllers | ||
Dir['test/fixtures/app/controllers/**/*.rb'].each { |f| require f } | ||
|
||
puts "Done!" |