aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-03-28 23:51:34 -0700
committerJosé Valim <jose.valim@gmail.com>2012-03-28 23:51:34 -0700
commite51322a34b740a4ad3b651345e2420912fe2a15f (patch)
treec9d93d3933893f04534b5810a806b1dcf7e9663e /actionpack/test
parente83e76eca4e134c91c4c2c1092b41f4483592172 (diff)
parent18d275ada1b23bf07cc51a815385afac6bb2b8cb (diff)
downloadrails-e51322a34b740a4ad3b651345e2420912fe2a15f.tar.gz
rails-e51322a34b740a4ad3b651345e2420912fe2a15f.tar.bz2
rails-e51322a34b740a4ad3b651345e2420912fe2a15f.zip
Merge pull request #5625 from nertzy/prefix_partial_path_with_controller_namespace
Add config option to turn off prefixing partial path with controller namespace
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/activerecord/render_partial_with_record_identification_test.rb68
-rw-r--r--actionpack/test/fixtures/fun/games/_game.erb2
-rw-r--r--actionpack/test/fixtures/fun/serious/games/_game.erb2
-rw-r--r--actionpack/test/fixtures/games/_game.erb1
4 files changed, 63 insertions, 10 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 97be5a5bb0..8187eb72d5 100644
--- a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
+++ b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
@@ -130,14 +130,40 @@ class RenderPartialWithRecordIdentificationAndNestedControllersTest < ActiveReco
def test_render_with_record_in_nested_controller
get :render_with_record_in_nested_controller
- assert_template 'fun/games/_game'
- assert_equal 'Pong', @response.body
+ 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 'fun/games/_game'
- assert_equal 'PongTank', @response.body
+ 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
@@ -146,13 +172,39 @@ class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < Acti
def test_render_with_record_in_deeper_nested_controller
get :render_with_record_in_deeper_nested_controller
- assert_template 'fun/serious/games/_game'
- assert_equal 'Chess', @response.body
+ 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 'fun/serious/games/_game'
- assert_equal 'ChessSudokuSolitaire', @response.body
+ 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
diff --git a/actionpack/test/fixtures/fun/games/_game.erb b/actionpack/test/fixtures/fun/games/_game.erb
index d51b7b3ebc..f0f542ff92 100644
--- a/actionpack/test/fixtures/fun/games/_game.erb
+++ b/actionpack/test/fixtures/fun/games/_game.erb
@@ -1 +1 @@
-<%= game.name %> \ No newline at end of file
+Fun <%= game.name %>
diff --git a/actionpack/test/fixtures/fun/serious/games/_game.erb b/actionpack/test/fixtures/fun/serious/games/_game.erb
index d51b7b3ebc..523bc55bd7 100644
--- a/actionpack/test/fixtures/fun/serious/games/_game.erb
+++ b/actionpack/test/fixtures/fun/serious/games/_game.erb
@@ -1 +1 @@
-<%= game.name %> \ No newline at end of file
+Serious <%= game.name %>
diff --git a/actionpack/test/fixtures/games/_game.erb b/actionpack/test/fixtures/games/_game.erb
new file mode 100644
index 0000000000..1aeb81fcba
--- /dev/null
+++ b/actionpack/test/fixtures/games/_game.erb
@@ -0,0 +1 @@
+Just <%= game.name %>