diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2016-11-25 23:42:29 -0500 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2016-11-26 01:23:07 -0500 |
commit | 02568801e6e34ee1ccbb825c6a10dfab83d1663e (patch) | |
tree | 89e472b2f5dcb151f90dd39fe11cc1ad2a97dfeb /actionview/test/ujs/views | |
parent | ad3a47759e67a411f3534309cdd704f12f6930a7 (diff) | |
download | rails-02568801e6e34ee1ccbb825c6a10dfab83d1663e.tar.gz rails-02568801e6e34ee1ccbb825c6a10dfab83d1663e.tar.bz2 rails-02568801e6e34ee1ccbb825c6a10dfab83d1663e.zip |
Add UJS tests
Diffstat (limited to 'actionview/test/ujs/views')
-rw-r--r-- | actionview/test/ujs/views/layouts/application.html.erb | 40 | ||||
-rw-r--r-- | actionview/test/ujs/views/tests/index.html.erb | 25 |
2 files changed, 65 insertions, 0 deletions
diff --git a/actionview/test/ujs/views/layouts/application.html.erb b/actionview/test/ujs/views/layouts/application.html.erb new file mode 100644 index 0000000000..74fa3bd06d --- /dev/null +++ b/actionview/test/ujs/views/layouts/application.html.erb @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html id="html"> + <head> + <title><%= @title %></title> + <link href="/vendor/qunit.css" media="screen" rel="stylesheet" type="text/css" media="screen, projection" /> + <style> + #jquery-cdn, #jquery-version { + padding: 0 2em .8em 0; + text-align: right; + font-family: sans-serif; + line-height: 1; + color: #8699A4; + background-color: #0d3349; + } + #jquery-cdn a, #jquery-version a { + color: white; + text-decoration: underline; + } + </style> + + <%= script_tag jquery_src %> + <script> + // This is for test in override.js. + // Must go after jQuery is loaded, but before jquery-ujs. + $(document).bind('rails:attachBindings', function() { + $.rails.linkClickSelector += ', a[data-custom-remote-link]'; + // Hijacks link click before ujs binds any handlers + // This is only used for ctrl-clicking test on remote links + $.rails.delegate(document, '#qunit-fixture a', 'click', function(e) { + e.preventDefault(); + }); + }); + </script> + <%= script_tag "/rails-ujs.js" %> + </head> + + <body id="body"> + <%= yield %> + </body> +</html> diff --git a/actionview/test/ujs/views/tests/index.html.erb b/actionview/test/ujs/views/tests/index.html.erb new file mode 100644 index 0000000000..393a5ee235 --- /dev/null +++ b/actionview/test/ujs/views/tests/index.html.erb @@ -0,0 +1,25 @@ +<% @title = "jquery-ujs test" %> + +<%= test_to 'data-confirm', 'data-remote', 'data-disable', 'data-disable-with', 'call-remote', 'call-remote-callbacks', 'data-method', 'override', 'csrf-refresh', 'csrf-token' %> + +<h1 id="qunit-header"><%= @title %></h1> +<div id="jquery-cdn"> + CDN: + <%= cdn_link 'jquery' %> • + <%= cdn_link 'googleapis' %> +</div> +<div id="jquery-version"> + jQuery version: + + <% jquery_versions.each do |v| %> + <%= ' • ' if v != jquery_versions.first %> + <%= jquery_link v %> + <% end %> + <%= (' • ' + jquery_link('edge')) if File.exist?(Rails.root + '/public/vendor/jquery.js') %> +</div> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> + +<div id="qunit-fixture"></div> |