Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
efb70f0f
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
efb70f0f
编写于
10月 07, 2009
作者:
B
Bob Remeika
提交者:
Stefan Penner
1月 27, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed data-remote='true' to data-js-type='remote'
上级
29811533
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
18 deletion
+29
-18
actionpack/lib/action_view/helpers/ajax_helper.rb
actionpack/lib/action_view/helpers/ajax_helper.rb
+1
-1
actionpack/test/javascript/ajax_test.rb
actionpack/test/javascript/ajax_test.rb
+28
-17
未找到文件。
actionpack/lib/action_view/helpers/ajax_helper.rb
浏览文件 @
efb70f0f
...
...
@@ -25,7 +25,7 @@ def extract_remote_attributes!(options)
attributes
[
"data-update-position"
]
=
options
.
delete
(
:position
)
attributes
[
"data-method"
]
=
options
.
delete
(
:method
)
attributes
[
"data-
remote"
]
=
true
attributes
[
"data-
js-type"
]
=
"remote"
attributes
end
...
...
actionpack/test/javascript/ajax_test.rb
浏览文件 @
efb70f0f
...
...
@@ -74,17 +74,21 @@ def link(options = {})
test
"using a url hash"
do
link
=
link_to_remote
(
"Delete this post"
,
{
:controller
=>
:blog
},
:update
=>
"#posts"
)
assert_html
link
,
%w(href="/blog/destroy/4" data-update-success="#posts")
assert_html
link
,
%w(href="/url/hash" data-update-success="#posts")
end
test
"with no update"
do
assert_html
link
,
%w(href="/blog/destroy/4" Delete\ this\ post data-js-type="remote")
end
test
"with :html options"
do
expected
=
%{<a href="/blog/destroy/4" data-custom="me" data-
remote="tru
e" data-update-success="#posts">Delete this post</a>}
expected
=
%{<a href="/blog/destroy/4" data-custom="me" data-
js-type="remot
e" data-update-success="#posts">Delete this post</a>}
assert_equal
expected
,
link
(
:update
=>
"#posts"
,
:html
=>
{
"data-custom"
=>
"me"
})
end
test
"with a hash for :update"
do
link
=
link
(
:update
=>
{
:success
=>
"#posts"
,
:failure
=>
"#error"
})
assert_html
link
,
%w(data-
remote="tru
e" data-update-success="#posts" data-update-failure="#error")
assert_html
link
,
%w(data-
js-type="remot
e" data-update-success="#posts" data-update-failure="#error")
end
test
"with positional parameters"
do
...
...
@@ -105,7 +109,7 @@ def link(options)
end
test
"basic link_to_remote with :url =>"
do
expected
=
%{<a href="/blog/destroy/4" data-
remote="tru
e" data-update-success="#posts">Delete this post</a>}
expected
=
%{<a href="/blog/destroy/4" data-
js-type="remot
e" data-update-success="#posts">Delete this post</a>}
assert_equal
expected
,
link_to_remote
(
"Delete this post"
,
:url
=>
"/blog/destroy/4"
,
:update
=>
"#posts"
)
end
...
...
@@ -137,7 +141,7 @@ def authenticity_input_attributes
# TODO: Play with using assert_dom_equal
test
"basic"
do
assert_html
form_remote_tag
(
:update
=>
"#glass_of_beer"
,
:url
=>
{
:action
=>
:fast
}),
%w(form action="/url/hash" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer")
%w(form action="/url/hash" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer")
end
test
"when protect_against_forgery? is true"
do
...
...
@@ -145,7 +149,7 @@ def protect_against_forgery?
true
end
expected_form_attributes
=
%w(form action="/url/hash" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer")
expected_form_attributes
=
%w(form action="/url/hash" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer")
expected_patterns
=
expected_form_attributes
+
authenticity_input_attributes
assert_equal
true
,
protect_against_forgery?
...
...
@@ -155,14 +159,14 @@ def protect_against_forgery?
test
":action is used when it is present"
do
html
=
form_remote_tag
(
:update
=>
"#glass_of_beer"
,
:action
=>
"foo"
)
assert_html
html
,
%w(form action="foo" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer")
assert_html
html
,
%w(form action="foo" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer")
assert_no_match
/url="foo"/
,
html
end
test
":url is used when :action is not present"
do
html
=
form_remote_tag
(
:update
=>
"#glass_of_beer"
,
:url
=>
"bar"
)
assert_html
html
,
%w(form action="bar" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer")
assert_html
html
,
%w(form action="bar" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer")
assert_no_match
/url="bar"/
,
html
end
...
...
@@ -174,18 +178,25 @@ def protect_against_forgery?
test
"update callbacks"
do
assert_html
form_remote_tag
(
:update
=>
{
:success
=>
"#glass_of_beer"
},
:url
=>
{
:action
=>
:fast
}),
%w(form action="/url/hash" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer")
%w(form action="/url/hash" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer")
assert_html
form_remote_tag
(
:update
=>
{
:failure
=>
"#glass_of_water"
},
:url
=>
{
:action
=>
:fast
}),
%w(form action="/url/hash" method="post" data-
remote="tru
e" data-update-failure="#glass_of_water")
%w(form action="/url/hash" method="post" data-
js-type="remot
e" data-update-failure="#glass_of_water")
assert_html
form_remote_tag
(
:update
=>
{
:success
=>
"#glass_of_beer"
,
:failure
=>
"#glass_of_water"
},
:url
=>
{
:action
=>
:fast
}),
%w(form action="/url/hash" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer" data-update-failure="#glass_of_water")
%w(form action="/url/hash" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer" data-update-failure="#glass_of_water")
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.
>>>>>>>
6
af9c2f
...
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
}),
...
...
@@ -207,7 +218,7 @@ def concat(str)
@buffer
<<
str
end
expected_form_attributes
=
%w(form action="/url/hash" method="post" data-
remote="tru
e" data-update-success="#glass_of_beer" /form)
expected_form_attributes
=
%w(form action="/url/hash" method="post" data-
js-type="remot
e" data-update-success="#glass_of_beer" /form)
expected_inner_html
=
%w(w00t!)
form_remote_tag
(
:update
=>
"#glass_of_beer"
,
:url
=>
{
:action
=>
:fast
})
{
concat
expected_inner_html
}
...
...
@@ -251,14 +262,14 @@ def setup
test
"remote_form_for with record identification with new record"
do
remote_form_for
(
@record
,
{
:html
=>
{
:id
=>
'create-author'
}})
{}
expected
=
%(<form action="/authors" data-
remote="tru
e" class="new_author" id="create-author" method="post"></form>)
expected
=
%(<form action="/authors" data-
js-type="remot
e" class="new_author" id="create-author" method="post"></form>)
assert_dom_equal
expected
,
output_buffer
end
test
"remote_form_for with record identification without html options"
do
remote_form_for
(
@record
)
{}
expected
=
%(<form action="/authors" data-
remote="tru
e" class="new_author" id="new_author" method="post"></form>)
expected
=
%(<form action="/authors" data-
js-type="remot
e" class="new_author" id="new_author" method="post"></form>)
assert_dom_equal
expected
,
output_buffer
end
...
...
@@ -266,14 +277,14 @@ def setup
@record
.
save
remote_form_for
(
@record
)
{}
expected
=
%(<form action="/authors/1" data-
remote="tru
e" class="edit_author" id="edit_author_1" method="post"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /></div></form>)
expected
=
%(<form action="/authors/1" data-
js-type="remot
e" class="edit_author" id="edit_author_1" method="post"><div style="margin:0;padding:0;display:inline"><input name="_method" type="hidden" value="put" /></div></form>)
assert_dom_equal
expected
,
output_buffer
end
test
"remote_form_for with new object in list"
do
remote_form_for
([
@author
,
@article
])
{}
expected
=
%(<form action="#{author_articles_path(@author)}" class="new_article" method="post" id="new_article" data-
remote="tru
e"></form>)
expected
=
%(<form action="#{author_articles_path(@author)}" class="new_article" method="post" id="new_article" data-
js-type="remot
e"></form>)
assert_dom_equal
expected
,
output_buffer
end
...
...
@@ -282,7 +293,7 @@ def setup
@article
.
save
remote_form_for
([
@author
,
@article
])
{}
expected
=
%(<form action='#{author_article_path(@author, @article)}' id='edit_article_1' method='post' class='edit_article' data-
remote="tru
e"><div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div></form>)
expected
=
%(<form action='#{author_article_path(@author, @article)}' id='edit_article_1' method='post' class='edit_article' data-
js-type="remot
e"><div style='margin:0;padding:0;display:inline'><input name='_method' type='hidden' value='put' /></div></form>)
assert_dom_equal
expected
,
output_buffer
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录