aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorrick <rick@spacemonkey.local>2008-05-05 23:19:21 -0700
committerrick <rick@spacemonkey.local>2008-05-05 23:19:21 -0700
commit0052938ac5b8894b27fdb9f27b1ed39f0a9ea176 (patch)
treef714643a4043d9fb73b39ec2a114d18f5deeffdd /activerecord/test/models
parenteacb5cf0cab6447db78085c8bda6c94dd329ce6b (diff)
parent3cffe92ff066c2b35eef409547db93652c5cccfc (diff)
downloadrails-0052938ac5b8894b27fdb9f27b1ed39f0a9ea176.tar.gz
rails-0052938ac5b8894b27fdb9f27b1ed39f0a9ea176.tar.bz2
rails-0052938ac5b8894b27fdb9f27b1ed39f0a9ea176.zip
Merge commit 'core/master'
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/job.rb5
-rw-r--r--activerecord/test/models/person.rb5
-rw-r--r--activerecord/test/models/reference.rb4
-rwxr-xr-xactiverecord/test/models/reply.rb2
-rw-r--r--activerecord/test/models/subscriber.rb2
-rw-r--r--activerecord/test/models/subscription.rb4
-rwxr-xr-xactiverecord/test/models/topic.rb1
7 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/test/models/job.rb b/activerecord/test/models/job.rb
new file mode 100644
index 0000000000..3333a02e27
--- /dev/null
+++ b/activerecord/test/models/job.rb
@@ -0,0 +1,5 @@
+class Job < ActiveRecord::Base
+ has_many :references
+ has_many :people, :through => :references
+ belongs_to :ideal_reference, :class_name => 'Reference'
+end
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
index 366f9fb708..4f4d695b24 100644
--- a/activerecord/test/models/person.rb
+++ b/activerecord/test/models/person.rb
@@ -2,4 +2,9 @@ class Person < ActiveRecord::Base
has_many :readers
has_many :posts, :through => :readers
has_many :posts_with_no_comments, :through => :readers, :source => :post, :include => :comments, :conditions => 'comments.id is null'
+
+ has_many :references
+ has_many :jobs, :through => :references
+ has_one :favourite_reference, :class_name => 'Reference', :conditions => ['favourite=?', true]
+
end
diff --git a/activerecord/test/models/reference.rb b/activerecord/test/models/reference.rb
new file mode 100644
index 0000000000..479e8b72c6
--- /dev/null
+++ b/activerecord/test/models/reference.rb
@@ -0,0 +1,4 @@
+class Reference < ActiveRecord::Base
+ belongs_to :person
+ belongs_to :job
+end
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb
index 27621bd703..812bc1f535 100755
--- a/activerecord/test/models/reply.rb
+++ b/activerecord/test/models/reply.rb
@@ -1,6 +1,8 @@
require 'models/topic'
class Reply < Topic
+ named_scope :base
+
belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
has_many :replies, :class_name => "SillyReply", :dependent => :destroy, :foreign_key => "parent_id"
diff --git a/activerecord/test/models/subscriber.rb b/activerecord/test/models/subscriber.rb
index 51335a8f20..5b78014e6f 100644
--- a/activerecord/test/models/subscriber.rb
+++ b/activerecord/test/models/subscriber.rb
@@ -1,5 +1,7 @@
class Subscriber < ActiveRecord::Base
set_primary_key 'nick'
+ has_many :subscriptions
+ has_many :books, :through => :subscriptions
end
class SpecialSubscriber < Subscriber
diff --git a/activerecord/test/models/subscription.rb b/activerecord/test/models/subscription.rb
new file mode 100644
index 0000000000..4bdb36ea46
--- /dev/null
+++ b/activerecord/test/models/subscription.rb
@@ -0,0 +1,4 @@
+class Subscription < ActiveRecord::Base
+ belongs_to :subscriber
+ belongs_to :book
+end
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index d2503b78df..f63e862cfd 100755
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -1,4 +1,5 @@
class Topic < ActiveRecord::Base
+ named_scope :base
named_scope :written_before, lambda { |time|
{ :conditions => ['written_on < ?', time] }
}