diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2008-10-18 17:43:38 +1030 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2008-10-18 17:43:38 +1030 |
commit | 2139a1b6812be7ca86de2df52e9776a2be4a2bf7 (patch) | |
tree | 3131e29d3582b8aa1ba1c68710f327ce2f22aa1d /actionpack/test | |
parent | 09b7e351316cb87a815678241fc90af549327cf3 (diff) | |
parent | 095cafbcd7fbae3baa845b23b93c8dca93b442f8 (diff) | |
download | rails-2139a1b6812be7ca86de2df52e9776a2be4a2bf7.tar.gz rails-2139a1b6812be7ca86de2df52e9776a2be4a2bf7.tar.bz2 rails-2139a1b6812be7ca86de2df52e9776a2be4a2bf7.zip |
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/render_test.rb | 6 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 21 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 1 | ||||
-rw-r--r-- | actionpack/test/template/asset_tag_helper_test.rb | 13 | ||||
-rw-r--r-- | actionpack/test/template/atom_feed_helper_test.rb | 81 | ||||
-rw-r--r-- | actionpack/test/template/form_tag_helper_test.rb | 3 | ||||
-rw-r--r-- | actionpack/test/template/prototype_helper_test.rb | 6 |
7 files changed, 127 insertions, 4 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 5a6ca98b2e..7b8bb6856b 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -1441,6 +1441,12 @@ class LastModifiedRenderTest < Test::Unit::TestCase get :conditional_hello_with_bangs assert_response :not_modified end + + def test_last_modified_works_with_less_than_too + @request.if_modified_since = 5.years.ago.httpdate + get :conditional_hello_with_bangs + assert_response :not_modified + end end class RenderingLoggingTest < Test::Unit::TestCase diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 1eb26a7cfd..9699a04abb 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -924,6 +924,20 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do end + def test_named_route_with_name_prefix + rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :name_prefix => 'my_' + x = setup_for_named_route + assert_equal("http://named.route.test/page", + x.send(:my_page_url)) + end + + def test_named_route_with_path_prefix + rs.add_named_route :page, 'page', :controller => 'content', :action => 'show_page', :path_prefix => 'my' + x = setup_for_named_route + assert_equal("http://named.route.test/my/page", + x.send(:page_url)) + end + def test_named_route_with_nested_controller rs.add_named_route :users, 'admin/user', :controller => 'admin/user', :action => 'index' x = setup_for_named_route @@ -2147,6 +2161,13 @@ uses_mocha 'LegacyRouteSet, Route, RouteSet and RouteLoading' do assert_equal [:x], set.extra_keys(args) end + def test_generate_with_path_prefix + set.draw { |map| map.connect ':controller/:action/:id', :path_prefix => 'my' } + + args = { :controller => "foo", :action => "bar", :id => "7", :x => "y" } + assert_equal "/my/foo/bar/7?x=y", set.generate(args) + end + def test_named_routes_are_never_relative_to_modules set.draw do |map| map.connect "/connection/manage/:action", :controller => 'connection/manage' diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 9eff34a542..a23428804a 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -667,6 +667,7 @@ class NamedRoutesControllerTest < ActionController::TestCase with_routing do |set| set.draw { |map| map.resources :contents } assert_equal 'http://test.host/contents/new', new_content_url + assert_equal 'http://test.host/contents/1', content_url(:id => 1) end end end diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index aaf9fe2ebf..6dc1225035 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -230,6 +230,19 @@ class AssetTagHelperTest < ActionView::TestCase ImageLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) } end + uses_mocha 'test image tag with windows behaviour' do + def test_image_tag_windows_behaviour + old_asset_id, ENV["RAILS_ASSET_ID"] = ENV["RAILS_ASSET_ID"], "1" + # This simulates the behaviour of File#exist? on windows when testing a file ending in "." + # If the file "rails.png" exists, windows will return true when asked if "rails.png." exists (notice trailing ".") + # OS X, linux etc will return false in this case. + File.stubs(:exist?).with('template/../fixtures/public/images/rails.png.').returns(true) + assert_equal '<img alt="Rails" src="/images/rails.png?1" />', image_tag('rails.png') + ensure + ENV["RAILS_ASSET_ID"] = old_asset_id + end + end + def test_timebased_asset_id expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png") diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb index ef31ab2c76..9247a42d33 100644 --- a/actionpack/test/template/atom_feed_helper_test.rb +++ b/actionpack/test/template/atom_feed_helper_test.rb @@ -92,6 +92,64 @@ class ScrollsController < ActionController::Base end end EOT + FEEDS["feed_with_xml_processing_instructions"] = <<-EOT + atom_feed(:schema_date => '2008', + :instruct => {'xml-stylesheet' => { :href=> 't.css', :type => 'text/css' }}) do |feed| + feed.title("My great blog!") + feed.updated((@scrolls.first.created_at)) + + for scroll in @scrolls + feed.entry(scroll) do |entry| + entry.title(scroll.title) + entry.content(scroll.body, :type => 'html') + + entry.author do |author| + author.name("DHH") + end + end + end + end + EOT + FEEDS["feed_with_xml_processing_instructions_duplicate_targets"] = <<-EOT + atom_feed(:schema_date => '2008', + :instruct => {'target1' => [{ :a => '1', :b => '2' }, { :c => '3', :d => '4' }]}) do |feed| + feed.title("My great blog!") + feed.updated((@scrolls.first.created_at)) + + for scroll in @scrolls + feed.entry(scroll) do |entry| + entry.title(scroll.title) + entry.content(scroll.body, :type => 'html') + + entry.author do |author| + author.name("DHH") + end + end + end + end + EOT + FEEDS["feed_with_xhtml_content"] = <<-'EOT' + atom_feed do |feed| + feed.title("My great blog!") + feed.updated((@scrolls.first.created_at)) + + for scroll in @scrolls + feed.entry(scroll) do |entry| + entry.title(scroll.title) + entry.summary(:type => 'xhtml') do |xhtml| + xhtml.p "before #{scroll.id}" + xhtml.p {xhtml << scroll.body} + xhtml.p "after #{scroll.id}" + end + entry.tag!('app:edited', Time.now) + + entry.author do |author| + author.name("DHH") + end + end + end + end + EOT def index @scrolls = [ Scroll.new(1, "1", "Hello One", "Something <i>COOL!</i>", Time.utc(2007, 12, 12, 15), Time.utc(2007, 12, 12, 15)), @@ -194,6 +252,29 @@ class AtomFeedTest < Test::Unit::TestCase end end + def test_feed_xml_processing_instructions + with_restful_routing(:scrolls) do + get :index, :id => 'feed_with_xml_processing_instructions' + assert_match %r{<\?xml-stylesheet type="text/css" href="t.css"\?>}, @response.body + end + end + + def test_feed_xml_processing_instructions_duplicate_targets + with_restful_routing(:scrolls) do + get :index, :id => 'feed_with_xml_processing_instructions_duplicate_targets' + assert_match %r{<\?target1 (a="1" b="2"|b="2" a="1")\?>}, @response.body + assert_match %r{<\?target1 (c="3" d="4"|d="4" c="3")\?>}, @response.body + end + end + + def test_feed_xhtml + with_restful_routing(:scrolls) do + get :index, :id => "feed_with_xhtml_content" + assert_match %r{xmlns="http://www.w3.org/1999/xhtml"}, @response.body + assert_select "summary div p", :text => "Something Boring" + assert_select "summary div p", :text => "after 2" + end + end private def with_restful_routing(resources) with_routing do |set| diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index ad8baef5e4..1849a61f2f 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -211,7 +211,8 @@ class FormTagHelperTest < ActionView::TestCase def test_boolean_optios assert_dom_equal %(<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") assert_dom_equal %(<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) - assert_dom_equal %(<select id="people" multiple="multiple" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => true) + assert_dom_equal %(<select id="people" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => true) + assert_dom_equal %(<select id="people[]" multiple="multiple" name="people[]"><option>david</option></select>), select_tag("people[]", "<option>david</option>", :multiple => true) assert_dom_equal %(<select id="people" name="people"><option>david</option></select>), select_tag("people", "<option>david</option>", :multiple => nil) end diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index a1f541fd7b..d6b86a3964 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -218,9 +218,9 @@ class PrototypeHelperTest < PrototypeHelperBaseTest end - def test_button_to_remote - assert_dom_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)}); return false;\" type=\"button\" value=\"1000000\" />), - button_to_remote("More beer!", 1_000_000, :update => "empty_bottle") + def test_submit_to_remote + assert_dom_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)});\" type=\"button\" value=\"1000000\" />), + submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle") end def test_observe_field |