Skip to content

Commit

Permalink
Cleaned up deprecation notices
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Nov 20, 2008
1 parent 56220ab commit 8be7d96
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 18 deletions.
15 changes: 12 additions & 3 deletions actionpack/test/controller/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,10 @@ def test_render_vanilla_js
end

def test_render_xml
get :render_xml_hello
assert_deprecated do
get :render_xml_hello
end

assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
assert_equal "application/xml", @response.content_type
end
Expand Down Expand Up @@ -903,7 +906,10 @@ def test_layout_rendering
end

def test_render_xml_with_layouts
get :builder_layout_test
assert_deprecated do
get :builder_layout_test
end

assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
end

Expand Down Expand Up @@ -1427,7 +1433,10 @@ def test_etag_should_not_be_changed_when_already_set
end

def test_etag_should_govern_renders_with_layouts_too
get :builder_layout_test
assert_deprecated do
get :builder_layout_test
end

assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
assert_equal etag_for("<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n"), @response.headers['ETag']
end
Expand Down
28 changes: 20 additions & 8 deletions actionpack/test/template/compiled_templates_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,42 @@ def setup

def test_template_gets_compiled
assert_equal 0, @compiled_templates.instance_methods.size
assert_equal "Hello world!", render("test/hello_world.erb")
assert_deprecated do
assert_equal "Hello world!", render("test/hello_world.erb")
end
assert_equal 1, @compiled_templates.instance_methods.size
end

def test_template_gets_recompiled_when_using_different_keys_in_local_assigns
assert_equal 0, @compiled_templates.instance_methods.size
assert_equal "Hello world!", render("test/hello_world.erb")
assert_equal "Hello world!", render("test/hello_world.erb", {:foo => "bar"})
assert_deprecated do
assert_equal "Hello world!", render("test/hello_world.erb")
assert_equal "Hello world!", render("test/hello_world.erb", {:foo => "bar"})
end
assert_equal 2, @compiled_templates.instance_methods.size
end

def test_compiled_template_will_not_be_recompiled_when_rendered_with_identical_local_assigns
assert_equal 0, @compiled_templates.instance_methods.size
assert_equal "Hello world!", render("test/hello_world.erb")
ActionView::Template.any_instance.expects(:compile!).never
assert_equal "Hello world!", render("test/hello_world.erb")
assert_deprecated do
assert_equal "Hello world!", render("test/hello_world.erb")
ActionView::Template.any_instance.expects(:compile!).never
assert_equal "Hello world!", render("test/hello_world.erb")
end
end

def test_compiled_template_will_always_be_recompiled_when_eager_loaded_templates_is_off
ActionView::PathSet::Path.expects(:eager_load_templates?).times(4).returns(false)
assert_equal 0, @compiled_templates.instance_methods.size
assert_equal "Hello world!", render("#{FIXTURE_LOAD_PATH}/test/hello_world.erb")

assert_deprecated do
assert_equal "Hello world!", render("#{FIXTURE_LOAD_PATH}/test/hello_world.erb")
end

ActionView::Template.any_instance.expects(:compile!).times(3)
3.times { assert_equal "Hello world!", render("#{FIXTURE_LOAD_PATH}/test/hello_world.erb") }
assert_deprecated do
3.times { assert_equal "Hello world!", render("#{FIXTURE_LOAD_PATH}/test/hello_world.erb") }
end
assert_equal 1, @compiled_templates.instance_methods.size
end

Expand Down
28 changes: 21 additions & 7 deletions actionpack/test/template/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@ def setup
end

def test_render_file
assert_equal "Hello world!", @view.render("test/hello_world.erb")
assert_deprecated do
assert_equal "Hello world!", @view.render("test/hello_world.erb")
end
end

def test_render_file_not_using_full_path
assert_equal "Hello world!", @view.render(:file => "test/hello_world.erb")
end

def test_render_file_without_specific_extension
assert_equal "Hello world!", @view.render("test/hello_world")
assert_deprecated do
assert_equal "Hello world!", @view.render("test/hello_world")
end
end

def test_render_file_at_top_level
assert_equal 'Elastica', @view.render('/shared')
assert_deprecated do
assert_equal 'Elastica', @view.render('/shared')
end
end

def test_render_file_with_full_path
Expand All @@ -29,20 +35,28 @@ def test_render_file_with_full_path
end

def test_render_file_with_instance_variables
assert_equal "The secret is in the sauce\n", @view.render("test/render_file_with_ivar.erb")
assert_deprecated do
assert_equal "The secret is in the sauce\n", @view.render("test/render_file_with_ivar.erb")
end
end

def test_render_file_with_locals
locals = { :secret => 'in the sauce' }
assert_equal "The secret is in the sauce\n", @view.render("test/render_file_with_locals.erb", locals)
assert_deprecated do
assert_equal "The secret is in the sauce\n", @view.render("test/render_file_with_locals.erb", locals)
end
end

def test_render_file_not_using_full_path_with_dot_in_path
assert_equal "The secret is in the sauce\n", @view.render("test/dot.directory/render_file_with_ivar")
assert_deprecated do
assert_equal "The secret is in the sauce\n", @view.render("test/dot.directory/render_file_with_ivar")
end
end

def test_render_has_access_current_template
assert_equal "test/template.erb", @view.render("test/template.erb")
assert_deprecated do
assert_equal "test/template.erb", @view.render("test/template.erb")
end
end

def test_render_update
Expand Down

0 comments on commit 8be7d96

Please sign in to comment.