From 1c4d28ba314c8cdd0039becf3bc9e678219b8f46 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 17 Jun 2009 10:37:39 -0500 Subject: Move model naming into ActiveModel --- actionpack/test/template/atom_feed_helper_test.rb | 1 + actionpack/test/template/prototype_helper_test.rb | 3 +++ actionpack/test/template/record_tag_helper_test.rb | 1 + actionpack/test/template/test_test.rb | 1 + actionpack/test/template/url_helper_test.rb | 2 ++ 5 files changed, 8 insertions(+) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb index bd97caf5d7..6f1179f359 100644 --- a/actionpack/test/template/atom_feed_helper_test.rb +++ b/actionpack/test/template/atom_feed_helper_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' Scroll = Struct.new(:id, :to_param, :title, :body, :updated_at, :created_at) +Scroll.extend ActiveModel::Naming class ScrollsController < ActionController::Base FEEDS = {} diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index f9f418aec9..02b1d137f5 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -1,8 +1,10 @@ require 'abstract_unit' Bunny = Struct.new(:Bunny, :id) +Bunny.extend ActiveModel::Naming class Author + extend ActiveModel::Naming attr_reader :id def save; @id = 1 end def new_record?; @id.nil? end @@ -12,6 +14,7 @@ class Author end class Article + extend ActiveModel::Naming attr_reader :id attr_reader :author_id def save; @id = 1; @author_id = 1 end diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 809ed6d6af..5b840d123b 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' class Post + extend ActiveModel::Naming def id 45 end diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index dd07a6d438..f32d0b3d42 100644 --- a/actionpack/test/template/test_test.rb +++ b/actionpack/test/template/test_test.rb @@ -41,6 +41,7 @@ class PeopleHelperTest < ActionView::TestCase def test_link_to_person person = mock(:name => "David") + person.class.extend ActiveModel::Naming expects(:mocha_mock_path).with(person).returns("/people/1") assert_equal 'David', link_to_person(person) end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index f3d2f87b4a..f0364fd660 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -494,6 +494,7 @@ class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase end class Workshop + extend ActiveModel::Naming attr_accessor :id, :new_record def initialize(id, new_record) @@ -510,6 +511,7 @@ class Workshop end class Session + extend ActiveModel::Naming attr_accessor :id, :workshop_id, :new_record def initialize(id, new_record) -- cgit v1.2.3 From 4fad953f90f82e860a69d67745887b40d5b15475 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 12:00:23 -0700 Subject: Fixing pending tests and fixed some formats / partial rendering semantics --- actionpack/test/template/render_test.rb | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 2ed11aa3c0..45e3dc6f15 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -46,29 +46,6 @@ module RenderTestCases I18n.locale = old_locale end - def test_render_implicit_html_template_from_xhr_request - old_format = @view.formats - pending do - @view.formats = [:js] - assert_equal "Hello HTML!", @view.render(:file => "test/render_implicit_html_template_from_xhr_request") - end - ensure - @view.formats = old_format - end - - def test_render_implicit_html_template_from_xhr_request_with_localization - old_locale = I18n.locale - old_format = @view.formats - pending do - I18n.locale = :da - @view.formats = [:js] - assert_equal "Hey HTML!\n", @view.render(:file => "test/render_implicit_html_template_from_xhr_request") - end - ensure - I18n.locale = old_locale - @view.formats = old_format - end - def test_render_file_at_top_level assert_equal 'Elastica', @view.render(:file => '/shared') end -- cgit v1.2.3 From d8f352e970ec86e8b791f9994465a3678a44281f Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 15:32:55 -0700 Subject: Rename ActionView::Template::Path ActionView::Resolver --- actionpack/test/template/compiled_templates_test.rb | 2 +- actionpack/test/template/render_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index b29b03f99d..9c268aef27 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -41,7 +41,7 @@ class CompiledTemplatesTest < Test::Unit::TestCase end def render_without_cache(*args) - path = ActionView::Template::FileSystemPathWithFallback.new(FIXTURE_LOAD_PATH) + path = ActionView::FileSystemResolverWithFallback.new(FIXTURE_LOAD_PATH) view_paths = ActionView::Base.process_view_paths(path) ActionView::Base.new(view_paths, {}).render(*args) end diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 45e3dc6f15..7f30ae88a1 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -255,7 +255,7 @@ class CachedViewRenderTest < ActiveSupport::TestCase # Ensure view path cache is primed def setup view_paths = ActionController::Base.view_paths - assert_equal ActionView::Template::FileSystemPathWithFallback, view_paths.first.class + assert_equal ActionView::FileSystemResolverWithFallback, view_paths.first.class setup_view(view_paths) end end @@ -266,9 +266,9 @@ class LazyViewRenderTest < ActiveSupport::TestCase # Test the same thing as above, but make sure the view path # is not eager loaded def setup - path = ActionView::Template::FileSystemPathWithFallback.new(FIXTURE_LOAD_PATH) + path = ActionView::FileSystemResolverWithFallback.new(FIXTURE_LOAD_PATH) view_paths = ActionView::Base.process_view_paths(path) - assert_equal ActionView::Template::FileSystemPathWithFallback, view_paths.first.class + assert_equal ActionView::FileSystemResolverWithFallback, view_paths.first.class setup_view(view_paths) end end -- cgit v1.2.3 From 65102c8f1a55c8d73e44b62eed5e689017ace7cd Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 17 Jun 2009 16:51:51 -0700 Subject: Cleaning up more tests and code that needed to work in both old and new base --- actionpack/test/template/body_parts_test.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/body_parts_test.rb b/actionpack/test/template/body_parts_test.rb index 4e7aa63f96..bac67c1a7d 100644 --- a/actionpack/test/template/body_parts_test.rb +++ b/actionpack/test/template/body_parts_test.rb @@ -4,9 +4,8 @@ class BodyPartsTest < ActionController::TestCase RENDERINGS = [Object.new, Object.new, Object.new] class TestController < ActionController::Base - def performed? - defined?(ActionController::Http) ? true : super - end + def performed?() true end + def index RENDERINGS.each do |rendering| @template.punctuate_body! rendering @@ -19,11 +18,9 @@ class BodyPartsTest < ActionController::TestCase def test_body_parts get :index - pending(:old_base) do - # TestProcess buffers body_parts into body - # TODO: Rewrite test w/o going through process - assert_equal RENDERINGS, @response.body_parts - end + # TestProcess buffers body_parts into body + # TODO: Rewrite test w/o going through process + assert_equal RENDERINGS, @response.body_parts assert_equal RENDERINGS.join, @response.body end end -- cgit v1.2.3 From 5267addd4f986c89df3d31f35e046abc3b1fbe26 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 17 Jun 2009 19:37:08 -0700 Subject: Use errors[field] instead of errors.on(field) --- actionpack/test/template/active_record_helper_test.rb | 14 +++++++------- actionpack/test/template/form_helper_test.rb | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb index b4b8cbe074..4691049a41 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -33,8 +33,8 @@ class ActiveRecordHelperTest < ActionView::TestCase ["Author name can't be empty"] end - def on(field) - "can't be empty" + def [](field) + ["can't be empty"] end end @@ -47,14 +47,14 @@ class ActiveRecordHelperTest < ActionView::TestCase @post = Post.new def @post.errors Class.new { - def on(field) + def [](field) case field.to_s when "author_name" - "can't be empty" + ["can't be empty"] when "body" - true + ['foo'] else - false + [] end end def empty?() false end @@ -85,7 +85,7 @@ class ActiveRecordHelperTest < ActionView::TestCase @user = User.new def @user.errors Class.new { - def on(field) field == "email" end + def [](field) field == "email" ? ['nonempty'] : [] end def empty?() false end def count() 1 end def full_messages() [ "User email can't be empty" ] end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 947668ccc6..f8215132e3 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -50,7 +50,7 @@ class FormHelperTest < ActionView::TestCase @comment = Comment.new def @post.errors() Class.new{ - def on(field); "can't be empty" if field == "author_name"; end + def [](field); field == "author_name" ? ["can't be empty"] : [] end def empty?() false end def count() 1 end def full_messages() [ "Author name can't be empty" ] end @@ -1193,4 +1193,4 @@ class FormHelperTest < ActionView::TestCase def protect_against_forgery? false end -end \ No newline at end of file +end -- cgit v1.2.3 From 9cb8c812f2a23ab5653a7888740a014a02c97c18 Mon Sep 17 00:00:00 2001 From: Darragh Curran Date: Sun, 21 Jun 2009 17:05:43 +0100 Subject: Add content_for?(:name) helper to check if content_for(:name) is present [#1311 state:resolved] Signed-off-by: Pratik Naik --- actionpack/test/template/capture_helper_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 actionpack/test/template/capture_helper_test.rb (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb new file mode 100644 index 0000000000..2017a18806 --- /dev/null +++ b/actionpack/test/template/capture_helper_test.rb @@ -0,0 +1,15 @@ +require 'abstract_unit' + +class CaptureHelperTest < ActionView::TestCase + def setup + super + @_content_for = Hash.new {|h,k| h[k] = "" } + end + + def test_content_for + assert ! content_for?(:title) + content_for :title, 'title' + assert content_for?(:title) + assert ! content_for?(:something_else) + end +end -- cgit v1.2.3