aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/activerecord/render_partial_with_record_identification_test.rb10
-rw-r--r--actionpack/test/fixtures/db_definitions/sqlite.sql3
-rw-r--r--actionpack/test/fixtures/developer.rb2
-rw-r--r--actionpack/test/fixtures/replies.yml2
-rw-r--r--actionpack/test/fixtures/reply.rb3
5 files changed, 18 insertions, 2 deletions
diff --git a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
index 7aeb1192f1..ccebbefead 100644
--- a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
+++ b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
@@ -14,6 +14,11 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
render :partial => @topic.replies
end
+ def render_with_has_many_through_association
+ @developer = Developer.find(:first)
+ render :partial => @developer.topics
+ end
+
def render_with_belongs_to_association
@reply = Reply.find(1)
render :partial => @reply.topic
@@ -47,6 +52,11 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
assert_template 'replies/_reply'
end
+ def test_rendering_partial_with_has_many_association
+ get :render_with_has_many_through_association
+ assert_template 'topics/_topic'
+ end
+
def test_rendering_partial_with_belongs_to_association
get :render_with_belongs_to_association
assert_template 'topics/_topic'
diff --git a/actionpack/test/fixtures/db_definitions/sqlite.sql b/actionpack/test/fixtures/db_definitions/sqlite.sql
index b4e7539d16..358c2bbb04 100644
--- a/actionpack/test/fixtures/db_definitions/sqlite.sql
+++ b/actionpack/test/fixtures/db_definitions/sqlite.sql
@@ -9,7 +9,8 @@ CREATE TABLE 'replies' (
'content' text,
'created_at' datetime,
'updated_at' datetime,
- 'topic_id' integer
+ 'topic_id' integer,
+ 'developer_id' integer
);
CREATE TABLE 'topics' (
diff --git a/actionpack/test/fixtures/developer.rb b/actionpack/test/fixtures/developer.rb
index f5e5b901fd..c70eda34c6 100644
--- a/actionpack/test/fixtures/developer.rb
+++ b/actionpack/test/fixtures/developer.rb
@@ -1,5 +1,7 @@
class Developer < ActiveRecord::Base
has_and_belongs_to_many :projects
+ has_many :replies
+ has_many :topics, :through => :replies
end
class DeVeLoPeR < ActiveRecord::Base
diff --git a/actionpack/test/fixtures/replies.yml b/actionpack/test/fixtures/replies.yml
index 284c9c0796..a17d2fc42b 100644
--- a/actionpack/test/fixtures/replies.yml
+++ b/actionpack/test/fixtures/replies.yml
@@ -1,6 +1,7 @@
witty_retort:
id: 1
topic_id: 1
+ developer_id: 1
content: Birdman is better!
created_at: <%= 6.hours.ago.to_s(:db) %>
updated_at: nil
@@ -8,6 +9,7 @@ witty_retort:
another:
id: 2
topic_id: 2
+ developer_id: 1
content: Nuh uh!
created_at: <%= 1.hour.ago.to_s(:db) %>
updated_at: nil \ No newline at end of file
diff --git a/actionpack/test/fixtures/reply.rb b/actionpack/test/fixtures/reply.rb
index ea84042b9a..588713de1e 100644
--- a/actionpack/test/fixtures/reply.rb
+++ b/actionpack/test/fixtures/reply.rb
@@ -1,5 +1,6 @@
class Reply < ActiveRecord::Base
belongs_to :topic, :include => [:replies]
-
+ belongs_to :developer
+
validates_presence_of :content
end