From 3eb97531b8650db5cc7b9558cc3828c56a526b6a Mon Sep 17 00:00:00 2001 From: wycats Date: Sat, 3 Apr 2010 02:30:06 -0700 Subject: Refactored url_for in AV to have its own instances of the helpers instead of proxying back to the controller. This potentially allows for more standalone usage of AV. It also kicked up a lot of dust in the tests, which were mocking out controllers to get this behavior. By moving it to the view, it made a lot of the tests more standalone (a win) --- .../test/template/scriptaculous_helper_test.rb | 33 +++++++++------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'actionpack/test/template/scriptaculous_helper_test.rb') diff --git a/actionpack/test/template/scriptaculous_helper_test.rb b/actionpack/test/template/scriptaculous_helper_test.rb index bebc3cb9f4..233012bfdd 100644 --- a/actionpack/test/template/scriptaculous_helper_test.rb +++ b/actionpack/test/template/scriptaculous_helper_test.rb @@ -3,21 +3,16 @@ require 'abstract_unit' class ScriptaculousHelperTest < ActionView::TestCase tests ActionView::Helpers::ScriptaculousHelper - def setup - super - @controller = Class.new do - def url_for(options) - url = "http://www.example.com/" - url << options[:action].to_s if options and options[:action] - url - end - end.new + def url_for(options) + url = "http://www.example.com/" + url << options[:action].to_s if options and options[:action] + url end - + def test_effect assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, "posts") assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect("highlight", :posts) - assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, :posts) + assert_equal "new Effect.Highlight(\"posts\",{});", visual_effect(:highlight, :posts) assert_equal "new Effect.Fade(\"fademe\",{duration:4.0});", visual_effect(:fade, "fademe", :duration => 4.0) assert_equal "new Effect.Shake(element,{});", visual_effect(:shake) assert_equal "new Effect.DropOut(\"dropme\",{queue:'end'});", visual_effect(:drop_out, 'dropme', :queue => :end) @@ -43,7 +38,7 @@ class ScriptaculousHelperTest < ActionView::TestCase assert ve[2].include?("scope:'test'") assert ve[2].include?("position:'end'") end - + def test_toggle_effects assert_equal "Effect.toggle(\"posts\",'appear',{});", visual_effect(:toggle_appear, "posts") assert_equal "Effect.toggle(\"posts\",'slide',{});", visual_effect(:toggle_slide, "posts") @@ -52,26 +47,26 @@ class ScriptaculousHelperTest < ActionView::TestCase assert_equal "Effect.toggle(\"posts\",'slide',{});", visual_effect("toggle_slide", "posts") assert_equal "Effect.toggle(\"posts\",'blind',{});", visual_effect("toggle_blind", "posts") end - + def test_sortable_element - assert_dom_equal %(), + assert_dom_equal %(), sortable_element("mylist", :url => { :action => "order" }) - assert_equal %(), + assert_equal %(), sortable_element("mylist", :tag => "div", :constraint => "horizontal", :url => { :action => "order" }) - assert_dom_equal %||, + assert_dom_equal %||, sortable_element("mylist", :containment => ['list1','list2'], :constraint => "horizontal", :url => { :action => "order" }) - assert_dom_equal %(), + assert_dom_equal %(), sortable_element("mylist", :containment => 'list1', :constraint => "horizontal", :url => { :action => "order" }) end - + def test_draggable_element assert_dom_equal %(), draggable_element("product_13") assert_equal %(), draggable_element("product_13", :revert => true) end - + def test_drop_receiving_element assert_dom_equal %(), drop_receiving_element("droptarget1") -- cgit v1.2.3