Skip to content
Browse files

Revert "Merge pull request #7659 from HugoLnx/template_error_no_match…

…es_rebased"

This reverts commit 7d17cd2.

Conflicts:
	actionpack/CHANGELOG.md

Reason: This added a regression since people were relying on this buggy behavior.
This will introduce back #3849 but we will be backward compatible in
stable release.

Fixes #8068.
  • Loading branch information...
1 parent 6b7cd20 commit d5b275db5c20669a7a9e598a70decf1316b39e03 @rafaelfranca rafaelfranca committed Oct 31, 2012
View
9 actionpack/CHANGELOG.md
@@ -1,10 +1,17 @@
## Rails 3.2.9 (unreleased) ##
+* Revert the `assert_template` fix to not pass with ever string that matches the template name.
+ This added a regression since people were relying on this buggy behavior.
+ This will introduce back #3849 but this stable release will be backward compatible.
+ Fixes #8068.
+
+ *Rafael Mendonça França*
+
* Revert the rename of internal variable on ActionController::TemplateAssertions to prevent
naming collisions. This added a regression related with shoulda-matchers, since it is
expecting the [instance variable @layouts](https://github.com/thoughtbot/shoulda-matchers/blob/9e1188eea68c47d9a56ce6280e45027da6187ab1/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb#L74).
This will introduce back #7459 but this stable release will be backward compatible.
- Fixes #8068
+ Fixes #8068.
*Rafael Mendonça França*
View
19 actionpack/lib/action_controller/test_case.rb
@@ -72,26 +72,19 @@ def assert_template(options = {}, message = nil)
validate_request!
case options
- when NilClass, Regexp, String, Symbol
+ when NilClass, String, Symbol
options = options.to_s if Symbol === options
rendered = @templates
msg = build_message(message,
"expecting <?> but rendering with <?>",
options, rendered.keys.join(', '))
- matches_template =
- case options
- when String
- rendered.any? do |t, num|
- options_splited = options.split(File::SEPARATOR)
- t_splited = t.split(File::SEPARATOR)
- t_splited.last(options_splited.size) == options_splited
- end
- when Regexp
+ assert_block(msg) do
+ if options
rendered.any? { |t,num| t.match(options) }
- when NilClass
- rendered.blank?
+ else
+ @templates.blank?
end
- assert matches_template, msg
+ end
when Hash
if expected_layout = options[:layout]
msg = build_message(message,
View
22 actionpack/test/controller/action_pack_assertions_test.rb
@@ -7,7 +7,6 @@ class ActionPackAssertionsController < ActionController::Base
def nothing() head :ok end
def hello_world() render :template => "test/hello_world"; end
- def hello_repeating_in_path() render :template => "test/hello/hello"; end
def hello_xml_world() render :template => "test/hello_xml_world"; end
@@ -470,34 +469,13 @@ def test_fails_with_incorrect_string
end
end
- def test_fails_with_incorrect_string_that_matches
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template 'est/he'
- end
- end
-
- def test_fails_with_repeated_name_in_path
- get :hello_repeating_in_path
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template 'test/hello'
- end
- end
-
def test_fails_with_incorrect_symbol
get :hello_world
assert_raise(ActiveSupport::TestCase::Assertion) do
assert_template :hello_planet
end
end
- def test_fails_with_incorrect_symbol_that_matches
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template :"est/he"
- end
- end
-
def test_fails_with_wrong_layout
get :render_with_layout
assert_raise(ActiveSupport::TestCase::Assertion) do
View
1 actionpack/test/fixtures/test/hello/hello.erb
@@ -1 +0,0 @@
-Hello world!

0 comments on commit d5b275d

Please sign in to comment.
Something went wrong with that request. Please try again.