From 56861af7339559dd66a9cf38150fc2a2d0c9931c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 30 Apr 2008 14:59:24 -0500 Subject: Added test for has_one partial rendering (keeran) [#43 state:resolved] --- .../render_partial_with_record_identification_test.rb | 14 +++++++++++++- actionpack/test/fixtures/company.rb | 1 + actionpack/test/fixtures/db_definitions/sqlite.sql | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'actionpack/test') 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 94070f5523..32b26206c3 100644 --- a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb +++ b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb @@ -1,7 +1,7 @@ require 'active_record_unit' class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase - fixtures :developers, :projects, :developers_projects, :topics, :replies + fixtures :developers, :projects, :developers_projects, :topics, :replies, :companies, :mascots class RenderPartialWithRecordIdentificationController < ActionController::Base def render_with_has_many_and_belongs_to_association @@ -23,6 +23,11 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase render :partial => @developer.topics end + def render_with_has_one_association + @company = Company.find(1) + render :partial => @company.mascot + end + def render_with_belongs_to_association @reply = Reply.find(1) render :partial => @reply.topic @@ -71,4 +76,11 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase get :render_with_record_collection assert_template 'developers/_developer' end + + def test_rendering_partial_with_has_one_association + mascot = Company.find(1).mascot + get :render_with_has_one_association + assert_template 'mascots/_mascot' + assert_equal mascot.name, @response.body + end end diff --git a/actionpack/test/fixtures/company.rb b/actionpack/test/fixtures/company.rb index 0d1c29b906..cbbd0edb14 100644 --- a/actionpack/test/fixtures/company.rb +++ b/actionpack/test/fixtures/company.rb @@ -1,4 +1,5 @@ class Company < ActiveRecord::Base + has_one :mascot attr_protected :rating set_sequence_name :companies_nonstd_seq diff --git a/actionpack/test/fixtures/db_definitions/sqlite.sql b/actionpack/test/fixtures/db_definitions/sqlite.sql index 358c2bbb04..8e1947d14a 100644 --- a/actionpack/test/fixtures/db_definitions/sqlite.sql +++ b/actionpack/test/fixtures/db_definitions/sqlite.sql @@ -41,3 +41,9 @@ CREATE TABLE 'developers_projects' ( 'joined_on' DATE DEFAULT NULL, 'access_level' INTEGER DEFAULT 1 ); + +CREATE TABLE 'mascots' ( + 'id' INTEGER PRIMARY KEY NOT NULL, + 'company_id' INTEGER NOT NULL, + 'name' TEXT DEFAULT NULL +); \ No newline at end of file -- cgit v1.2.3