aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/javascript/ajax_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/javascript/ajax_test.rb')
-rw-r--r--actionpack/test/javascript/ajax_test.rb50
1 files changed, 31 insertions, 19 deletions
diff --git a/actionpack/test/javascript/ajax_test.rb b/actionpack/test/javascript/ajax_test.rb
index 41bfdbd9b9..5e62677a92 100644
--- a/actionpack/test/javascript/ajax_test.rb
+++ b/actionpack/test/javascript/ajax_test.rb
@@ -188,15 +188,10 @@ class FormRemoteTagTest < AjaxTestCase
end
test "using a :method option" do
-<<<<<<< HEAD
- expected_form_attributes = %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer")
- # TODO: Ask Katz: Why does rails do this? Some web servers don't allow PUT or DELETE from what I remember... - BR
-=======
expected_form_attributes = %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer")
# TODO: Experiment with not using this _method param. Apparently this is done to address browser incompatibilities, but since
# we have a layer between the HTML and the JS libs now, we can probably get away with letting JS the JS libs handle the requirement
# for an extra field if needed.
->>>>>>> 6af9c2f... Changed data-remote='true' to data-js-type='remote'
expected_input_attributes = %w(input name="_method" type="hidden" value="put")
assert_html form_remote_tag(:update => "#glass_of_beer", :url => { :action => :fast }, :html => { :method => :put }),
@@ -341,6 +336,20 @@ class ButtonToRemoteTest < AjaxTestCase
button(callback => "undoRequestCompleted(request)")
end
end
+<<<<<<< HEAD
+=======
+end
+
+class ScriptDecoratorTest < AjaxTestCase
+ def decorator()
+ script_decorator("foo_type", :foo => "bar", :baz => "bang")
+ end
+
+ test "basic" do
+ expected = %(<script type="application/json" data-js-type="foo_type" data-foo="bar" data-baz="bang"></script>)
+ assert_dom_equal expected, decorator
+ end
+>>>>>>> bd54253... Applied Yehuda's patch; Sharing extract_object_name_for_form! between form_helper and ajax_helper; Added script_decorator helper
end
class ObserveFieldTest < AjaxTestCase
@@ -358,18 +367,18 @@ class ObserveFieldTest < AjaxTestCase
end
test "using a url string" do
- assert_data_element_json field(:url => "/some/other/url"),
- "url" => "/some/other/url", "name" => "title"
+ assert_html field(:url => "/some/other/url"),
+ %w(script data-url="/some/other/url" data-name="title")
end
test "using a url hash" do
- assert_data_element_json field(:url => {:controller => :blog, :action => :update}),
- "url" => "/url/hash", "name" => "title"
+ assert_html field(:url => {:controller => :blog, :action => :update}),
+ %w(script data-url="/url/hash" data-name="title")
end
test "using a :frequency option" do
- assert_data_element_json field(:url => { :controller => :blog }, :frequency => 5.minutes),
- "url" => "/url/hash", "name" => "title", "frequency" => 300
+ assert_html field(:url => { :controller => :blog }, :frequency => 5.minutes),
+ %w(script data-url="/url/hash" data-name="title" data-frequency="300")
end
test "using a :frequency option of 0" do
@@ -384,19 +393,22 @@ class ObserveFieldTest < AjaxTestCase
# TODO: Consider using JSON instead of strings. Is using 'value' as a magical reference to the value of the observed field weird? (Rails2 does this) - BR
test "using a :with option" do
- assert_data_element_json field(:with => "foo"),
- "name" => "title", "with" => "'foo=' + encodeURIComponent(value)"
- assert_data_element_json field(:with => "'foo=' + encodeURIComponent(value)"),
- "name" => "title", "with" => "'foo=' + encodeURIComponent(value)"
+ assert_html field(:with => "foo"),
+ %w(script data-name="title" data-with="'foo=' + encodeURIComponent(value)")
+
+ assert_html field(:with => "'foo=' + encodeURIComponent(value)"),
+ %w(script data-name="title" data-with="'foo=' + encodeURIComponent(value)")
+
end
test "using json in a :with option" do
- assert_data_element_json field(:with => "{'id':value}"),
- "name" => "title", "with" => "{'id':value}"
+ assert_html field(:with => "{'id':value}"),
+ %w(script data-name="title" data-with="{'id':value}")
end
test "using :function for callback" do
- assert_data_element_json field(:function => "alert('Element changed')"),
- "name" => "title", "function" => "function(element, value) {alert('Element changed')}"
+ assert_html field(:function => "alert('Element changed')"),
+ %w(script data-function="function(element, value) {alert('Element changed')}")
+
end
end