diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-04-17 00:06:11 +0200 |
---|---|---|
committer | Łukasz Strzałkowski <lukasz.strzalkowski@gmail.com> | 2013-06-20 17:23:16 +0200 |
commit | eb23754ebbfbf2d465cc0f900720704fb3703633 (patch) | |
tree | 5bd1764233b59075341611b1e857d418c794d812 /actionpack/test/activerecord | |
parent | 5bcdf4faa6da7acb762dab680372f8520a0533c2 (diff) | |
download | rails-eb23754ebbfbf2d465cc0f900720704fb3703633.tar.gz rails-eb23754ebbfbf2d465cc0f900720704fb3703633.tar.bz2 rails-eb23754ebbfbf2d465cc0f900720704fb3703633.zip |
Move template tests from actionpack to actionview
Diffstat (limited to 'actionpack/test/activerecord')
4 files changed, 0 insertions, 942 deletions
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb deleted file mode 100644 index 368bec1c70..0000000000 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'active_record_unit' -require 'active_record/railties/controller_runtime' -require 'fixtures/project' -require 'active_support/log_subscriber/test_helper' -require 'action_controller/log_subscriber' - -ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime - -class ControllerRuntimeLogSubscriberTest < ActionController::TestCase - class LogSubscriberController < ActionController::Base - respond_to :html - - def show - render :inline => "<%= Project.all %>" - end - - def zero - render :inline => "Zero DB runtime" - end - - def create - ActiveRecord::LogSubscriber.runtime += 100 - project = Project.last - respond_with(project, location: url_for(action: :show)) - end - - def redirect - Project.all - redirect_to :action => 'show' - end - - def db_after_render - render :inline => "Hello world" - Project.all - ActiveRecord::LogSubscriber.runtime += 100 - end - end - - include ActiveSupport::LogSubscriber::TestHelper - tests LogSubscriberController - - def setup - super - @old_logger = ActionController::Base.logger - ActionController::LogSubscriber.attach_to :action_controller - end - - def teardown - super - ActiveSupport::LogSubscriber.log_subscribers.clear - ActionController::Base.logger = @old_logger - end - - def set_logger(logger) - ActionController::Base.logger = logger - end - - def test_log_with_active_record - get :show - wait - - assert_equal 2, @logger.logged(:info).size - assert_match(/\(Views: [\d.]+ms \| ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[1]) - end - - def test_runtime_reset_before_requests - ActiveRecord::LogSubscriber.runtime += 12345 - get :zero - wait - - assert_equal 2, @logger.logged(:info).size - assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0.0ms\)/, @logger.logged(:info)[1]) - end - - def test_log_with_active_record_when_post - post :create - wait - assert_match(/ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[2]) - end - - def test_log_with_active_record_when_redirecting - get :redirect - wait - assert_equal 3, @logger.logged(:info).size - assert_match(/\(ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[2]) - end - - def test_include_time_query_time_after_rendering - get :db_after_render - wait - - assert_equal 2, @logger.logged(:info).size - assert_match(/\(Views: [\d.]+ms \| ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[1]) - end -end diff --git a/actionpack/test/activerecord/form_helper_activerecord_test.rb b/actionpack/test/activerecord/form_helper_activerecord_test.rb deleted file mode 100644 index 2e302c65a7..0000000000 --- a/actionpack/test/activerecord/form_helper_activerecord_test.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'active_record_unit' -require 'fixtures/project' -require 'fixtures/developer' - -class FormHelperActiveRecordTest < ActionView::TestCase - tests ActionView::Helpers::FormHelper - - def form_for(*) - @output_buffer = super - end - - def setup - @developer = Developer.new - @developer.id = 123 - @developer.name = "developer #123" - - @project = Project.new - @project.id = 321 - @project.name = "project #321" - @project.save - - @developer.projects << @project - @developer.save - end - - def teardown - Project.delete(321) - Developer.delete(123) - end - - Routes = ActionDispatch::Routing::RouteSet.new - Routes.draw do - resources :developers do - resources :projects - end - end - - def _routes - Routes - end - - include Routes.url_helpers - - def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association - form_for(@developer) do |f| - concat f.fields_for(:projects, @developer.projects.first, :child_index => 'abc') { |cf| - concat cf.text_field(:name) - } - end - - expected = whole_form('/developers/123', 'edit_developer_123', 'edit_developer', :method => 'patch') do - '<input id="developer_projects_attributes_abc_name" name="developer[projects_attributes][abc][name]" type="text" value="project #321" />' + - '<input id="developer_projects_attributes_abc_id" name="developer[projects_attributes][abc][id]" type="hidden" value="321" />' - end - - assert_dom_equal expected, output_buffer - end - - protected - - def hidden_fields(method = nil) - txt = %{<div style="margin:0;padding:0;display:inline">} - txt << %{<input name="utf8" type="hidden" value="✓" />} - if method && !%w(get post).include?(method.to_s) - txt << %{<input name="_method" type="hidden" value="#{method}" />} - end - txt << %{</div>} - end - - def form_text(action = "/", id = nil, html_class = nil, remote = nil, multipart = nil, method = nil) - txt = %{<form accept-charset="UTF-8" action="#{action}"} - txt << %{ enctype="multipart/form-data"} if multipart - txt << %{ data-remote="true"} if remote - txt << %{ class="#{html_class}"} if html_class - txt << %{ id="#{id}"} if id - method = method.to_s == "get" ? "get" : "post" - txt << %{ method="#{method}">} - end - - def whole_form(action = "/", id = nil, html_class = nil, options = nil) - contents = block_given? ? yield : "" - - if options.is_a?(Hash) - method, remote, multipart = options.values_at(:method, :remote, :multipart) - else - method = options - end - - form_text(action, id, html_class, remote, multipart, method) + hidden_fields(method) + contents + "</form>" - end -end
\ No newline at end of file diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb deleted file mode 100644 index afb714484b..0000000000 --- a/actionpack/test/activerecord/polymorphic_routes_test.rb +++ /dev/null @@ -1,546 +0,0 @@ -require 'active_record_unit' -require 'fixtures/project' - -class Task < ActiveRecord::Base - self.table_name = 'projects' -end - -class Step < ActiveRecord::Base - self.table_name = 'projects' -end - -class Bid < ActiveRecord::Base - self.table_name = 'projects' -end - -class Tax < ActiveRecord::Base - self.table_name = 'projects' -end - -class Fax < ActiveRecord::Base - self.table_name = 'projects' -end - -class Series < ActiveRecord::Base - self.table_name = 'projects' -end - -class ModelDelegator < ActiveRecord::Base - self.table_name = 'projects' - - def to_model - ModelDelegate.new - end -end - -class ModelDelegate - def self.model_name - ActiveModel::Name.new(self) - end - - def to_param - 'overridden' - end -end - -module Blog - class Post < ActiveRecord::Base - self.table_name = 'projects' - end - - class Blog < ActiveRecord::Base - self.table_name = 'projects' - end - - def self.use_relative_model_naming? - true - end -end - -class PolymorphicRoutesTest < ActionController::TestCase - include SharedTestRoutes.url_helpers - self.default_url_options[:host] = 'example.com' - - def setup - @project = Project.new - @task = Task.new - @step = Step.new - @bid = Bid.new - @tax = Tax.new - @fax = Fax.new - @delegator = ModelDelegator.new - @series = Series.new - @blog_post = Blog::Post.new - @blog_blog = Blog::Blog.new - end - - def test_passing_routes_proxy - with_namespaced_routes(:blog) do - proxy = ActionDispatch::Routing::RoutesProxy.new(_routes, self) - @blog_post.save - assert_equal "http://example.com/posts/#{@blog_post.id}", polymorphic_url([proxy, @blog_post]) - end - end - - def test_namespaced_model - with_namespaced_routes(:blog) do - @blog_post.save - assert_equal "http://example.com/posts/#{@blog_post.id}", polymorphic_url(@blog_post) - end - end - - def test_namespaced_model_with_name_the_same_as_namespace - with_namespaced_routes(:blog) do - @blog_blog.save - assert_equal "http://example.com/blogs/#{@blog_blog.id}", polymorphic_url(@blog_blog) - end - end - - def test_namespaced_model_with_nested_resources - with_namespaced_routes(:blog) do - @blog_post.save - @blog_blog.save - assert_equal "http://example.com/blogs/#{@blog_blog.id}/posts/#{@blog_post.id}", polymorphic_url([@blog_blog, @blog_post]) - end - end - - def test_with_nil - with_test_routes do - assert_raise ArgumentError, "Nil location provided. Can't build URI." do - polymorphic_url(nil) - end - end - end - - def test_with_record - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(@project) - end - end - - def test_with_class - with_test_routes do - assert_equal "http://example.com/projects", polymorphic_url(@project.class) - end - end - - def test_with_new_record - with_test_routes do - assert_equal "http://example.com/projects", polymorphic_url(@project) - end - end - - def test_with_destroyed_record - with_test_routes do - @project.destroy - assert_equal "http://example.com/projects", polymorphic_url(@project) - end - end - - def test_with_record_and_action - with_test_routes do - assert_equal "http://example.com/projects/new", polymorphic_url(@project, :action => 'new') - end - end - - def test_url_helper_prefixed_with_new - with_test_routes do - assert_equal "http://example.com/projects/new", new_polymorphic_url(@project) - end - end - - def test_url_helper_prefixed_with_edit - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}/edit", edit_polymorphic_url(@project) - end - end - - def test_url_helper_prefixed_with_edit_with_url_options - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}/edit?param1=10", edit_polymorphic_url(@project, :param1 => '10') - end - end - - def test_url_helper_with_url_options - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}?param1=10", polymorphic_url(@project, :param1 => '10') - end - end - - def test_format_option - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(@project, :format => :pdf) - end - end - - def test_format_option_with_url_options - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}.pdf?param1=10", polymorphic_url(@project, :format => :pdf, :param1 => '10') - end - end - - def test_id_and_format_option - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(:id => @project, :format => :pdf) - end - end - - def test_with_nested - with_test_routes do - @project.save - @task.save - assert_equal "http://example.com/projects/#{@project.id}/tasks/#{@task.id}", polymorphic_url([@project, @task]) - end - end - - def test_with_nested_unsaved - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}/tasks", polymorphic_url([@project, @task]) - end - end - - def test_with_nested_destroyed - with_test_routes do - @project.save - @task.destroy - assert_equal "http://example.com/projects/#{@project.id}/tasks", polymorphic_url([@project, @task]) - end - end - - def test_with_nested_class - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}/tasks", polymorphic_url([@project, @task.class]) - end - end - - def test_class_with_array_and_namespace - with_admin_test_routes do - assert_equal "http://example.com/admin/projects", polymorphic_url([:admin, @project.class]) - end - end - - def test_new_with_array_and_namespace - with_admin_test_routes do - assert_equal "http://example.com/admin/projects/new", polymorphic_url([:admin, @project], :action => 'new') - end - end - - def test_unsaved_with_array_and_namespace - with_admin_test_routes do - assert_equal "http://example.com/admin/projects", polymorphic_url([:admin, @project]) - end - end - - def test_nested_unsaved_with_array_and_namespace - with_admin_test_routes do - @project.save - assert_equal "http://example.com/admin/projects/#{@project.id}/tasks", polymorphic_url([:admin, @project, @task]) - end - end - - def test_nested_with_array_and_namespace - with_admin_test_routes do - @project.save - @task.save - assert_equal "http://example.com/admin/projects/#{@project.id}/tasks/#{@task.id}", polymorphic_url([:admin, @project, @task]) - end - end - - def test_ordering_of_nesting_and_namespace - with_admin_and_site_test_routes do - @project.save - @task.save - @step.save - assert_equal "http://example.com/admin/projects/#{@project.id}/site/tasks/#{@task.id}/steps/#{@step.id}", polymorphic_url([:admin, @project, :site, @task, @step]) - end - end - - def test_nesting_with_array_ending_in_singleton_resource - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}/bid", polymorphic_url([@project, :bid]) - end - end - - def test_nesting_with_array_containing_singleton_resource - with_test_routes do - @project.save - @task.save - assert_equal "http://example.com/projects/#{@project.id}/bid/tasks/#{@task.id}", polymorphic_url([@project, :bid, @task]) - end - end - - def test_nesting_with_array_containing_singleton_resource_and_format - with_test_routes do - @project.save - @task.save - assert_equal "http://example.com/projects/#{@project.id}/bid/tasks/#{@task.id}.pdf", polymorphic_url([@project, :bid, @task], :format => :pdf) - end - end - - def test_nesting_with_array_containing_namespace_and_singleton_resource - with_admin_test_routes do - @project.save - @task.save - assert_equal "http://example.com/admin/projects/#{@project.id}/bid/tasks/#{@task.id}", polymorphic_url([:admin, @project, :bid, @task]) - end - end - - def test_nesting_with_array_containing_nil - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}/bid", polymorphic_url([@project, nil, :bid]) - end - end - - def test_with_array_containing_single_object - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url([nil, @project]) - end - end - - def test_with_array_containing_single_name - with_test_routes do - @project.save - assert_equal "http://example.com/projects", polymorphic_url([:projects]) - end - end - - def test_with_array_containing_symbols - with_test_routes do - assert_equal "http://example.com/series/new", polymorphic_url([:new, :series]) - end - end - - def test_with_hash - with_test_routes do - @project.save - assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(:id => @project) - end - end - - def test_polymorphic_path_accepts_options - with_test_routes do - assert_equal "/projects/new", polymorphic_path(@project, :action => 'new') - end - end - - def test_polymorphic_path_does_not_modify_arguments - with_admin_test_routes do - @project.save - @task.save - - options = {} - object_array = [:admin, @project, @task] - original_args = [object_array.dup, options.dup] - - assert_no_difference('object_array.size') { polymorphic_path(object_array, options) } - assert_equal original_args, [object_array, options] - end - end - - # Tests for names where .plural.singular doesn't round-trip - def test_with_irregular_plural_record - with_test_routes do - @tax.save - assert_equal "http://example.com/taxes/#{@tax.id}", polymorphic_url(@tax) - end - end - - def test_with_irregular_plural_class - with_test_routes do - assert_equal "http://example.com/taxes", polymorphic_url(@tax.class) - end - end - - def test_with_irregular_plural_new_record - with_test_routes do - assert_equal "http://example.com/taxes", polymorphic_url(@tax) - end - end - - def test_with_irregular_plural_destroyed_record - with_test_routes do - @tax.destroy - assert_equal "http://example.com/taxes", polymorphic_url(@tax) - end - end - - def test_with_irregular_plural_record_and_action - with_test_routes do - assert_equal "http://example.com/taxes/new", polymorphic_url(@tax, :action => 'new') - end - end - - def test_irregular_plural_url_helper_prefixed_with_new - with_test_routes do - assert_equal "http://example.com/taxes/new", new_polymorphic_url(@tax) - end - end - - def test_irregular_plural_url_helper_prefixed_with_edit - with_test_routes do - @tax.save - assert_equal "http://example.com/taxes/#{@tax.id}/edit", edit_polymorphic_url(@tax) - end - end - - def test_with_nested_irregular_plurals - with_test_routes do - @tax.save - @fax.save - assert_equal "http://example.com/taxes/#{@tax.id}/faxes/#{@fax.id}", polymorphic_url([@tax, @fax]) - end - end - - def test_with_nested_unsaved_irregular_plurals - with_test_routes do - @tax.save - assert_equal "http://example.com/taxes/#{@tax.id}/faxes", polymorphic_url([@tax, @fax]) - end - end - - def test_new_with_irregular_plural_array_and_namespace - with_admin_test_routes do - assert_equal "http://example.com/admin/taxes/new", polymorphic_url([:admin, @tax], :action => 'new') - end - end - - def test_class_with_irregular_plural_array_and_namespace - with_admin_test_routes do - assert_equal "http://example.com/admin/taxes", polymorphic_url([:admin, @tax.class]) - end - end - - def test_unsaved_with_irregular_plural_array_and_namespace - with_admin_test_routes do - assert_equal "http://example.com/admin/taxes", polymorphic_url([:admin, @tax]) - end - end - - def test_nesting_with_irregular_plurals_and_array_ending_in_singleton_resource - with_test_routes do - @tax.save - assert_equal "http://example.com/taxes/#{@tax.id}/bid", polymorphic_url([@tax, :bid]) - end - end - - def test_with_array_containing_single_irregular_plural_object - with_test_routes do - @tax.save - assert_equal "http://example.com/taxes/#{@tax.id}", polymorphic_url([nil, @tax]) - end - end - - def test_with_array_containing_single_name_irregular_plural - with_test_routes do - @tax.save - assert_equal "http://example.com/taxes", polymorphic_url([:taxes]) - end - end - - # Tests for uncountable names - def test_uncountable_resource - with_test_routes do - @series.save - assert_equal "http://example.com/series/#{@series.id}", polymorphic_url(@series) - assert_equal "http://example.com/series", polymorphic_url(Series.new) - end - end - - def test_routing_a_to_model_delegate - with_test_routes do - @delegator.save - assert_equal "http://example.com/model_delegates/overridden", polymorphic_url(@delegator) - end - end - - def with_namespaced_routes(name) - with_routing do |set| - set.draw do - scope(:module => name) do - resources :blogs do - resources :posts - end - resources :posts - end - end - - self.class.send(:include, @routes.url_helpers) - yield - end - end - - def with_test_routes(options = {}) - with_routing do |set| - set.draw do - resources :projects do - resources :tasks - resource :bid do - resources :tasks - end - end - resources :taxes do - resources :faxes - resource :bid - end - resources :series - resources :model_delegates - end - - self.class.send(:include, @routes.url_helpers) - yield - end - end - - def with_admin_test_routes(options = {}) - with_routing do |set| - set.draw do - namespace :admin do - resources :projects do - resources :tasks - resource :bid do - resources :tasks - end - end - resources :taxes do - resources :faxes - end - resources :series - end - end - - self.class.send(:include, @routes.url_helpers) - yield - end - end - - def with_admin_and_site_test_routes(options = {}) - with_routing do |set| - set.draw do - namespace :admin do - resources :projects do - namespace :site do - resources :tasks do - resources :steps - end - end - end - end - end - - self.class.send(:include, @routes.url_helpers) - yield - end - end -end diff --git a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb deleted file mode 100644 index 409370104d..0000000000 --- a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb +++ /dev/null @@ -1,210 +0,0 @@ -require 'active_record_unit' - -class RenderPartialWithRecordIdentificationController < ActionController::Base - def render_with_has_many_and_belongs_to_association - @developer = Developer.find(1) - render :partial => @developer.projects - end - - def render_with_has_many_association - @topic = Topic.find(1) - render :partial => @topic.replies - end - - def render_with_scope - render :partial => Reply.base - end - - def render_with_has_many_through_association - @developer = Developer.first - 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 - end - - def render_with_record - @developer = Developer.first - render :partial => @developer - end - - def render_with_record_collection - @developers = Developer.all - render :partial => @developers - end - - def render_with_record_collection_and_spacer_template - @developer = Developer.find(1) - render :partial => @developer.projects, :spacer_template => 'test/partial_only' - end -end - -class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase - tests RenderPartialWithRecordIdentificationController - fixtures :developers, :projects, :developers_projects, :topics, :replies, :companies, :mascots - - def test_rendering_partial_with_has_many_and_belongs_to_association - get :render_with_has_many_and_belongs_to_association - assert_template 'projects/_project' - assert_equal assigns(:developer).projects.map(&:name).join, @response.body - end - - def test_rendering_partial_with_has_many_association - get :render_with_has_many_association - assert_template 'replies/_reply' - assert_equal 'Birdman is better!', @response.body - end - - def test_rendering_partial_with_scope - get :render_with_scope - assert_template 'replies/_reply' - assert_equal 'Birdman is better!Nuh uh!', @response.body - end - - def test_render_with_record - get :render_with_record - assert_template 'developers/_developer' - assert_equal 'David', @response.body - end - - def test_render_with_record_collection - get :render_with_record_collection - assert_template 'developers/_developer' - assert_equal 'DavidJamisfixture_3fixture_4fixture_5fixture_6fixture_7fixture_8fixture_9fixture_10Jamis', @response.body - end - - def test_render_with_record_collection_and_spacer_template - get :render_with_record_collection_and_spacer_template - assert_equal assigns(:developer).projects.map(&:name).join('only partial'), @response.body - 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 - -class Game < Struct.new(:name, :id) - extend ActiveModel::Naming - include ActiveModel::Conversion - def to_param - id.to_s - end -end - -module Fun - class NestedController < ActionController::Base - def render_with_record_in_nested_controller - render :partial => Game.new("Pong") - end - - def render_with_record_collection_in_nested_controller - render :partial => [ Game.new("Pong"), Game.new("Tank") ] - end - end - - module Serious - class NestedDeeperController < ActionController::Base - def render_with_record_in_deeper_nested_controller - render :partial => Game.new("Chess") - end - - def render_with_record_collection_in_deeper_nested_controller - render :partial => [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ] - end - end - end -end - -class RenderPartialWithRecordIdentificationAndNestedControllersTest < ActiveRecordTestCase - tests Fun::NestedController - - def test_render_with_record_in_nested_controller - get :render_with_record_in_nested_controller - assert_template %r{\Afun/games/_game\Z} - assert_equal "Fun Pong\n", @response.body - end - - def test_render_with_record_collection_in_nested_controller - get :render_with_record_collection_in_nested_controller - assert_template %r{\Afun/games/_game\Z} - assert_equal "Fun Pong\nFun Tank\n", @response.body - end -end - -class RenderPartialWithRecordIdentificationAndNestedControllersWithoutPrefixTest < ActiveRecordTestCase - tests Fun::NestedController - - def test_render_with_record_in_nested_controller - old_config = ActionView::Base.prefix_partial_path_with_controller_namespace - ActionView::Base.prefix_partial_path_with_controller_namespace = false - - get :render_with_record_in_nested_controller - assert_template %r{\Agames/_game\Z} - assert_equal "Just Pong\n", @response.body - ensure - ActionView::Base.prefix_partial_path_with_controller_namespace = old_config - end - - def test_render_with_record_collection_in_nested_controller - old_config = ActionView::Base.prefix_partial_path_with_controller_namespace - ActionView::Base.prefix_partial_path_with_controller_namespace = false - - get :render_with_record_collection_in_nested_controller - assert_template %r{\Agames/_game\Z} - assert_equal "Just Pong\nJust Tank\n", @response.body - ensure - ActionView::Base.prefix_partial_path_with_controller_namespace = old_config - end -end - -class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < ActiveRecordTestCase - tests Fun::Serious::NestedDeeperController - - def test_render_with_record_in_deeper_nested_controller - get :render_with_record_in_deeper_nested_controller - assert_template %r{\Afun/serious/games/_game\Z} - assert_equal "Serious Chess\n", @response.body - end - - def test_render_with_record_collection_in_deeper_nested_controller - get :render_with_record_collection_in_deeper_nested_controller - assert_template %r{\Afun/serious/games/_game\Z} - assert_equal "Serious Chess\nSerious Sudoku\nSerious Solitaire\n", @response.body - end -end - -class RenderPartialWithRecordIdentificationAndNestedDeeperControllersWithoutPrefixTest < ActiveRecordTestCase - tests Fun::Serious::NestedDeeperController - - def test_render_with_record_in_deeper_nested_controller - old_config = ActionView::Base.prefix_partial_path_with_controller_namespace - ActionView::Base.prefix_partial_path_with_controller_namespace = false - - get :render_with_record_in_deeper_nested_controller - assert_template %r{\Agames/_game\Z} - assert_equal "Just Chess\n", @response.body - ensure - ActionView::Base.prefix_partial_path_with_controller_namespace = old_config - end - - def test_render_with_record_collection_in_deeper_nested_controller - old_config = ActionView::Base.prefix_partial_path_with_controller_namespace - ActionView::Base.prefix_partial_path_with_controller_namespace = false - - get :render_with_record_collection_in_deeper_nested_controller - assert_template %r{\Agames/_game\Z} - assert_equal "Just Chess\nJust Sudoku\nJust Solitaire\n", @response.body - ensure - ActionView::Base.prefix_partial_path_with_controller_namespace = old_config - end -end |