From 47873fb32341c307c49b74cf0bbc693be3c7fdb5 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Mon, 7 Sep 2009 16:12:15 -0400 Subject: [PATCH] Get rid of UJS plugin (finally)! --- config/routes.rb | 2 - .../plugins/unobtrusive_javascript/CHANGELOG | 72 ---- vendor/plugins/unobtrusive_javascript/README | 73 ----- .../plugins/unobtrusive_javascript/Rakefile | 33 -- .../plugins/unobtrusive_javascript/about.yml | 6 - .../assets/javascripts/lowpro.js | 307 ------------------ vendor/plugins/unobtrusive_javascript/init.rb | 21 -- .../plugins/unobtrusive_javascript/install.rb | 1 - .../lib/actionview_helpers_patches.rb | 25 -- .../lib/asset_tag_helper_patches.rb | 34 -- .../lib/behaviour_caching.rb | 70 ---- .../unobtrusive_javascript_controller.rb | 52 --- .../lib/prototype_helper_patches.rb | 72 ---- .../lib/scriptaculous_helper_patches.rb | 62 ---- .../lib/tag_helper_patches.rb | 37 --- .../plugins/unobtrusive_javascript/lib/ujs.rb | 32 -- .../lib/ujs/behaviour_helper.rb | 62 ---- .../lib/ujs/behaviour_script.rb | 58 ---- .../lib/ujs/behaviour_script_converter.rb | 23 -- .../lib/ujs/controller_methods.rb | 55 ---- .../unobtrusive_javascript/lib/ujs/helpers.rb | 152 --------- .../lib/ujs/javascript_proxies.rb | 57 ---- .../tasks/unobtrusive_javascript_tasks.rake | 15 - .../test/asset_tag_helper_patches_test.rb | 32 -- .../test/behaviour_helper_test.rb | 180 ---------- .../test/behaviour_script_converter_test.rb | 72 ---- .../test/behaviour_script_test.rb | 98 ------ .../test/config/database.yml | 19 -- .../test/config/environment.rb | 8 - .../test/config/routes.rb | 4 - .../test/config/schema.rb | 3 - .../test/controller_methods_test.rb | 48 --- .../test/helpers_test.rb | 186 ----------- .../test/javascript_proxies_test.rb | 3 - .../test/lib/ptk/boot.rb | 26 -- .../test/lib/ptk/gem/action_controller.rb | 11 - .../test/lib/ptk/gem/action_mailer.rb | 4 - .../test/lib/ptk/gem/active_record.rb | 27 -- .../test/lib/ptk/gem/rails.rb | 31 -- .../test/lib/ptk/ptk.rb | 148 --------- .../test/lib/ptk/suite/difference.rb | 23 -- .../test/lib/stubs/controller_stub.rb | 10 - .../unobtrusive_javascript/test/ptk_helper.rb | 29 -- .../test/tag_helper_patches_test.rb | 59 ---- .../test/test_helper.rb | 25 -- .../unobtrusive_javascript_controller_test.rb | 95 ------ .../unobtrusive_javascript/uninstall.rb | 1 - 47 files changed, 2463 deletions(-) delete mode 100644 vendor/plugins/unobtrusive_javascript/CHANGELOG delete mode 100644 vendor/plugins/unobtrusive_javascript/README delete mode 100644 vendor/plugins/unobtrusive_javascript/Rakefile delete mode 100644 vendor/plugins/unobtrusive_javascript/about.yml delete mode 100644 vendor/plugins/unobtrusive_javascript/assets/javascripts/lowpro.js delete mode 100644 vendor/plugins/unobtrusive_javascript/init.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/install.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/actionview_helpers_patches.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/asset_tag_helper_patches.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/behaviour_caching.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/controllers/unobtrusive_javascript_controller.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/prototype_helper_patches.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/scriptaculous_helper_patches.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/tag_helper_patches.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_helper.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_script.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_script_converter.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs/controller_methods.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs/helpers.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/lib/ujs/javascript_proxies.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/tasks/unobtrusive_javascript_tasks.rake delete mode 100644 vendor/plugins/unobtrusive_javascript/test/asset_tag_helper_patches_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/behaviour_helper_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/behaviour_script_converter_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/behaviour_script_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/config/database.yml delete mode 100644 vendor/plugins/unobtrusive_javascript/test/config/environment.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/config/routes.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/config/schema.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/controller_methods_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/helpers_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/javascript_proxies_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/boot.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/action_controller.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/action_mailer.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/active_record.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/rails.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/ptk.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/ptk/suite/difference.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/lib/stubs/controller_stub.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/ptk_helper.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/tag_helper_patches_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/test_helper.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/test/unobtrusive_javascript_controller_test.rb delete mode 100644 vendor/plugins/unobtrusive_javascript/uninstall.rb diff --git a/config/routes.rb b/config/routes.rb index c420a0e5..aa44b788 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,4 @@ ActionController::Routing::Routes.draw do |map| - UJS::routes - map.with_options :controller => 'login' do |login| login.login 'login', :action => 'login' login.formatted_login 'login.:format', :action => 'login' diff --git a/vendor/plugins/unobtrusive_javascript/CHANGELOG b/vendor/plugins/unobtrusive_javascript/CHANGELOG deleted file mode 100644 index e5e784cd..00000000 --- a/vendor/plugins/unobtrusive_javascript/CHANGELOG +++ /dev/null @@ -1,72 +0,0 @@ -== rel-0.3.2 -* FIXED: Error when trying to convert nil from hash (ticket #8) - -* FIXED: Got tests running inside a Rails app - -* UPDATED: Refactored BehaviourScriptConverter - -== rel-0.3.1 -* FIXED: Issues with Rails edge have now been resolved. Have changed the UnobtrusiveJavascript module to UJS. This has one API change - use UJS::Routes in routes.rb - -* FIXED: Major issue when restarting server (server just hangs) due to serializing of behaviour scripts to the session. Objects are now converted to and from a hash before serializing to the session. All reports suggest that this has fixed the issue. Please raise a ticket if you get any more weird errors. - -* FIXED: remote_function was incorrectly quoting JS (ticket #3) - -* FIXED: :external => false now works for apply_behaviours (ticket #5) - -* FIXED: element.replace_html inside Ruby behaviour block wasn't working, this is now fixed (ticket #4) - -* FIXED: behaviours_url now works correctly when using mongrel url-prefix (ticket #6) - -* FIXED: Resolved some documentation issues - -== rel-0.3 -* FIXED: Problems with rake:unobtrusive_javascript:install (ticket #12 on old trac) - -* FIXED: Problems with back button (result of caching feature) (ticket #10 on old trac) - -* Refactored a lot of the code and increased test coverage significantly - -* NEW: Out-of-the box caching using HTTP ETags and advanced behaviour caching - -* NEW: Apply multiple behaviours at once with apply_behaviours - -* NEW: Behaviour helpers to easily and unobtrusively apply scriptaculous effects - -* UPDATED: Updated lowpro.js library - -* UPDATED: Added :external option support to tag_options - -* NEW: :prevent_default option to cancel original event behaviour such as link following and form submission - -== rel-0.2.2 -* FIXED: Change the way tag_options detects javascript events, using blank? instead of include? as some Rails helpers insert an empty onclick handler. - -== rel-0.2.1 -* FIXED: Added an about.yml file - bad Luke - practice what you preach! - -* FIXED: Fixed the plugin in edge rails by explicitly requiring the controller file - -== rel-0.2 - -* UPDATED: register_js_behaviour has been renamed to apply_behaviour and now takes an optional options hash and a block, which allows you to write your behaviours in pure Ruby. register_js_behaviour remains as an alias for backwards compatibility but is officially deprecated; it will probably be removed in the next release. There are also aliases for the American spelling of behaviour for our friends on the other side of the pond. - -* NEW: You can now attach behaviours directly to elements using content_tag and tag by passing in javascript event handlers in the HTML options hash (:onclick, :onmousedown etc.) - they'll be extracted to the external behaviours file automatically. - -* UPDATED: The core Rails AJAX/Javascript helpers (link_to_remote, button_to_function, link_to_function, form_remote_tag etc.) now work out of the box. - -* NEW: There is no need to explicitly specify an HTML ID for the elements you want to attach behaviour to - if you don't, one will be generated automatically for you. - -* NEW: Options to render behaviour rules directly in your page inside script blocks instead of in the external behaviour file. - -* FIXED: Behaviours inside AJAX-loaded partials will now work. - -* UPDATED: event:Selectors and domReady javascript libraries are replaced with the lowPro.js library by Dan Webb - -* UPDATED: Javascript behaviours now have access to a single variable - event. To access the element the event was applied to, use this. - -* UPDATED: Behaviours can now cancel the default action by returning false as well as using Event.stop(event) - -* FIXED: The required javascript files will be copied to your public folder automatically on installation. There is also a rake task for copying files across when upgrading the plugin. - -* NEW: Lots more documentation! \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/README b/vendor/plugins/unobtrusive_javascript/README deleted file mode 100644 index 11951219..00000000 --- a/vendor/plugins/unobtrusive_javascript/README +++ /dev/null @@ -1,73 +0,0 @@ -= Unobtrusive Javascript for Rails Version 0.3.2 - -Please see www.ujs4rails.com for full documentation, articles and updates. - -The Unobtrusive Javascript plugin for Rails allows you to attach Javascript behaviour and events to your page elements using pure Ruby, from within your controller or view, without clogging up your rendered HTML with Javascript - either inline or in the head of your document. - -== Installation - -The recommended way of installing the plugin is to take advantage of Subversion's svn:externals feature. From within your Rails app root, enter the following on the command line: - - $ ./script/plugin install -x http://opensource.agileevolved.com/svn/root/rails_plugins/unobtrusive_javascript/tags/rel-0.2 unobtrusive_javascript - -If you are upgrading from a previous version remember to update your applications javascripts with: - - rake unobtrusive_javascript:install - -Finally, add the necessary routes to config/routes.rb by adding: - - UJS.routes - -To the Routes.draw block. - -== Including the necessary libraries and behaviours file - -The only modification you need to make to your app is to add the following line somewhere in the head of your app's layout: - - <%= javascript_include_tag 'prototype', :unobtrusive %> - -You're now up and running with unobtrusive javascript functionality. - -== Registering javascript behaviours - -The plugin offers a simple, low-level function for attaching behaviours to elements of your page using the +register_js_behaviour+ function. - - <%= apply_behaviour "#coolink:click", "alert('Hello world!')" %> - -You can also pass a block to the function that lets you write your javascript behaviours using ruby: - - <%= apply_behaviour "#sayhellothenfade:click" do |page, element, event| - page.alert "Hello, I'm gonna fade..." - element.visual_effect :fade - end %> - -See the API documentation for more usage examples. - -=== Rendering behaviours inside script blocks instead of an external file - -By default, all unobtrusive behaviours will be rendered in an external javascript file, generated at runtime. Sometimes, you may want to embed the behaviours directly in a page, inside script tags. You can do this by passing the option :external => false to register_js_behaviour. - - <%= apply_behaviour "#coolink:click", "alert('Hello world!')", :external => false %> - -One of the main reasons to render javascript inside javascript tags instead of the external file is when you are embedding behaviours inside partials that are loaded into your page using AJAX. Because the external javascript file will already have been generated, any subsequent behaviours inside your AJAX-loaded partials will not register. For this reason the behaviours need to be rendered inside normal script tags. The unobtrusive_javascript plugin takes care of this for you automatically - any behaviours registered inside an AJAX-loaded partial will be rendered inside a script element without having to specify :external => false manually. - -== Attaching behaviours directly to elements using Rails' tag generators - -Rails comes with two built-in tag generator helpers - tag and content_tag. You can use these helpers to generate HTML elements and attach behaviour to them by directly specifying the events as part of the helpers' html options hash. The behaviours will be extracted and moved into the external behaviours file instead of being rendered inline. - - <%= content_tag "div", "Click Me", :onclick => "alert('You clicked me')" %> - -The full range of javascript events are available through this method. - -The above functionality is achieved with a patch to Rails' tag_options function. Because of this patch, most of Rails' javascript/ajax helpers (or any helper that generates HTML using the tag_options function and that accepts an HTML options hash) will work in an unobtrusive fashion out of the box. The list of helpers that currently work unobtrusively include: - -* link_to_remote -* link_to_function -* button_to_function -* form_remote_tag -* submit_to_remote - -== Credits - -The unobtrusive_javascript plugin is by Luke Redpath (http://www.lukeredpath.co.uk) and Dan Webb (http://www.vivabit.com/bollocks). The plugin also makes use of the Low Pro JavaScript library also by -Dan Webb, parts of which were heavily inspired by Justin Palmer's excellent event:Selectors (http://encytemedia.com/eventselectors/). \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/Rakefile b/vendor/plugins/unobtrusive_javascript/Rakefile deleted file mode 100644 index e1a7326f..00000000 --- a/vendor/plugins/unobtrusive_javascript/Rakefile +++ /dev/null @@ -1,33 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'fileutils' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the unobtrusive_javascript plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the unobtrusive_javascript plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'UJS' - rdoc.options << '--line-numbers' << '--inline-source' << '--accessor=cattr_accessor' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -desc 'Updates application with the necessary javascripts for unobtrusive_javascript.' -task :update_scripts do - FileUtils.cp Dir['assets/javascripts/*.js'], '../../../public/javascripts' -end - -desc 'Removes the javascripts for the plugin.' -task :remove_scripts do - FileUtils.rm %{lowpro.js}.collect { |f| "../../../public/javascripts/" + f } -end diff --git a/vendor/plugins/unobtrusive_javascript/about.yml b/vendor/plugins/unobtrusive_javascript/about.yml deleted file mode 100644 index 80d8a995..00000000 --- a/vendor/plugins/unobtrusive_javascript/about.yml +++ /dev/null @@ -1,6 +0,0 @@ -author: Luke Redpath & Dan Webb -summary: Makes adding javascript behaviour easy and enhances existing Rails javascript/ajax helpers. -homepage: http://www.ujs4rails.com -plugin: http://source.ujs4rails.com -license: MIT -version: 0.3 \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/assets/javascripts/lowpro.js b/vendor/plugins/unobtrusive_javascript/assets/javascripts/lowpro.js deleted file mode 100644 index a119f20a..00000000 --- a/vendor/plugins/unobtrusive_javascript/assets/javascripts/lowpro.js +++ /dev/null @@ -1,307 +0,0 @@ -LowPro = {}; -LowPro.Version = '0.1'; - -// Adapted from DOM Ready extension by Dan Webb -// http://www.vivabit.com/bollocks/2006/06/21/a-dom-ready-extension-for-prototype -// which was based on work by Matthias Miller, Dean Edwards and John Resig -// -// Usage: -// -// Event.onReady(callbackFunction); -Object.extend(Event, { - _domReady : function() { - if (arguments.callee.done) return; - arguments.callee.done = true; - - if (Event._timer) clearInterval(Event._timer); - - Event._readyCallbacks.each(function(f) { f() }); - Event._readyCallbacks = null; - - }, - onReady : function(f) { - if (!this._readyCallbacks) { - var domReady = this._domReady; - - if (domReady.done) return f(); - - if (document.addEventListener) - document.addEventListener("DOMContentLoaded", domReady, false); - - /*@cc_on @*/ - /*@if (@_win32) - document.write("') - end - - def test_should_render_script_tag_for_current_requests_behaviour - assert @output.include?('') - end - - def test_should_render_index_behaviour_when_request_path_is_just_a_forward_slash - @controller.request.stubs(:path).returns('/') - @output = javascript_include_tag(:unobtrusive).split("\n") - assert @output.include?('') - end - - def test_should_render_index_behaviour_when_request_path_is_blank_as_a_result_of_a_url_prefix - @controller.request.stubs(:path).returns('') - @output = javascript_include_tag(:unobtrusive).split("\n") - assert @output.include?('') - end -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/behaviour_helper_test.rb b/vendor/plugins/unobtrusive_javascript/test/behaviour_helper_test.rb deleted file mode 100644 index f8c800b3..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/behaviour_helper_test.rb +++ /dev/null @@ -1,180 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' -require 'prototype_helper_patches' -require 'scriptaculous_helper_patches' -require 'ujs/behaviour_helper' - -class MakeSortableTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - - def setup - initialize_test_request - end - - def test_should_output_sortable_javascript - output = make_sortable - - assert_equal sortable_element_js(javascript_variable('this')), output - end - - def test_should_pass_arguments_through - output = make_sortable :onUpdate => 'function() { alert("updated") }' - assert_equal 'Sortable.create(this, {onUpdate:function() { alert("updated") }});', output - end -end - -class MakeRemoteLinkTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - - def setup - initialize_test_request - end - - def test_should_generate_ajax_request - output = make_remote_link - assert_match(/new Ajax\.Request/, output) - end - - def test_should_default_to_element_href - output = make_remote_link - assert_match(/\(this\.href/, output) - end - - def test_should_respond_to_given_options - output = make_remote_link( :update => 'fartknocker' ) - assert_match(/new Ajax\.Updater\('fartknocker'/, output) - end -end - -class MakeRemoteFormTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - - def setup - initialize_test_request - end - - def test_should_generate_ajax_request - output = make_remote_form - assert_match(/new Ajax\.Request/, output) - end - - def test_should_default_to_form_action - output = make_remote_form - assert_match(/\(this\.action/, output) - end -end - -class MakeDraggableTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - - def setup - initialize_test_request - end - - def test_should_create_draggable_instance - output = make_draggable - assert_match(/new Draggable/, output) - end - - def test_should_pass_this - output = make_draggable - assert_match(/\(this/, output) - end - - def test_should_respond_to_options - output = make_draggable( :revert => true ) - assert_match(/revert\:true/, output) - end -end - -class MakeDropRecievingTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - - def setup - initialize_test_request - end - - def test_should_add_to_droppables - output = make_drop_receiving - assert_match(/Droppables\.add/, output) - end - - def test_should_pass_this - output = make_drop_receiving - assert_match(/\(this/, output) - end - - def test_should_generate_a_url_from_options - output = make_drop_receiving( :url => { :action => "bingo" } ) - assert_match(/controller_stub\/bingo/, output) - end -end - -class MakeObservedTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - - def setup - initialize_test_request - end - - def test_should_make_form_observer - output = make_observed(:form) - assert_match(/new Form\.EventObserver/, output) - end - - def test_should_make_field_observer - output = make_observed(:field) - assert_match(/new Form\.Element\.EventObserver/, output) - end - - def test_should_pass_this - output = make_observed(:field) - assert_match(/\(this/, output) - end - - def test_should_make_a_timed_observer_if_frequency_passed - output = make_observed(:form, :frequency => 3 ) - assert_match(/new Form.Observer/, output) - assert_match(/3,/, output) - end - - def test_should_generate_a_url_from_options - output = make_observed(:field, :url => { :action => "bingo" } ) - assert_match(/controller_stub\/bingo/, output) - end - - def test_should_respond_to_options - output = make_observed(:field, :function => 'alert("boo")' ) - assert_match(/function\(element, value\) \{alert\("boo"\)\}/, output) - end -end - diff --git a/vendor/plugins/unobtrusive_javascript/test/behaviour_script_converter_test.rb b/vendor/plugins/unobtrusive_javascript/test/behaviour_script_converter_test.rb deleted file mode 100644 index e403ed33..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/behaviour_script_converter_test.rb +++ /dev/null @@ -1,72 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' - -class DefaultBehaviourScriptConversionTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @output = UJS::BehaviourScriptConverter.convert_to_hash(@script) - end - - def test_should_have_no_rules_and_the_correct_default_options - assert_equal({ :options => { :cache => false, :reapply_after_ajax => true }, - :rules => [] }, @output) - end -end - -class EmptyBehaviourScriptWithDifferentOptionsConversionTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new(true, false) - @output = UJS::BehaviourScriptConverter.convert_to_hash(@script) - end - - def test_should_have_no_rules_and_the_correct_options - assert_equal({ :options => { :cache => true, :reapply_after_ajax => false }, - :rules => [] }, @output) - end -end - -class BehaviourScriptWithOneRuleConversionTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.add_rule('div.foo:click', 'alert("TEST")') - @output = UJS::BehaviourScriptConverter.convert_to_hash(@script) - end - - def test_should_have_one_behaviour_and_correct_options - assert_equal({ :options => { :cache => false, :reapply_after_ajax => true }, - :rules => [ - ['div.foo:click', 'alert("TEST")'] - ] }, @output) - end -end - -class BehaviourScriptWithTwoRuleConversionTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.add_rule('div.foo:click', 'alert("TEST")') - @script.add_rule('div.bar:click', 'alert("TEST 2")') - @output = UJS::BehaviourScriptConverter.convert_to_hash(@script) - end - - def test_should_have_one_behaviour_and_correct_options - assert_equal({ :options => { :cache => false, :reapply_after_ajax => true }, - :rules => [ - ['div.foo:click', 'alert("TEST")'], - ['div.bar:click', 'alert("TEST 2")'] - ] }, @output) - end -end - -class BehaviourScriptFromHashTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.add_rule('div.foo:click', 'alert("TEST")') - @script.add_rule('div.bar:click', 'alert("TEST 2")') - @converted_script = UJS::BehaviourScriptConverter.convert_from_hash(@script.to_hash) - end - - def test_should_equal_the_script_it_was_converted_from_in_the_first_place - assert_equal @script.cache?, @converted_script.cache? - assert_equal @script.reapply_after_ajax?, @converted_script.reapply_after_ajax? - assert_equal @script.rules, @converted_script.rules - end -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/behaviour_script_test.rb b/vendor/plugins/unobtrusive_javascript/test/behaviour_script_test.rb deleted file mode 100644 index 33e1f671..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/behaviour_script_test.rb +++ /dev/null @@ -1,98 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' -require 'ujs/behaviour_script' - -class NewBehaviourScriptTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - end - - def test_should_render_nothing_on_to_string - assert_equal "", @script.to_s - end - - def test_should_not_be_cached - assert !@script.cache? - end - - def test_should_be_reapplied_after_an_ajax_request - assert @script.reapply_after_ajax? - end -end - -class BehaviourScriptWithOneRuleTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.add_rule("div.header:click", "alert('Hello World')") - end - - def test_should_render_the_rule_as_a_javascript_event_on_to_s - expected_js = "Event.addBehavior({\n\"div.header:click\": function(event) {\nalert('Hello World')\n}\n});" - assert_equal expected_js, @script.to_s - end -end - -class BehaviourScriptWithTwoRulesTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.add_rule("div.header:mouseover", "alert('Hello World')") - @script.add_rule("div.header:mouseout", "alert('Goodbye World')") - end - - def test_should_render_all_rules_as_javascript_events_on_to_s - expected_js = "Event.addBehavior({\n\"div.header:mouseover\": function(event) {\nalert('Hello World')\n}," - expected_js = expected_js + "\n\"div.header:mouseout\": function(event) {\nalert('Goodbye World')\n}\n});" - assert_equal expected_js, @script.to_s - end -end - -class BehaviourScriptWithRuleThatCancelsDefaultTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.add_rule("div.header:mouseover", "alert('Hello World');", true) - end - - def test_should_render_rule_with_return_false_appended_on_to_s - expected_js = "Event.addBehavior({\n\"div.header:mouseover\": function(event) {\nalert('Hello World'); return false;\n}\n});" - assert_equal expected_js, @script.to_s - end -end - -class BehaviourScriptWithNoRulesTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - end - - def test_should_render_nothing_on_to_s - assert_equal "", @script.to_s - end -end - -class BehaviourScriptWithRulesSetToNotReapplyAfterAjaxTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new - @script.reapply_after_ajax = false - @script.add_rule("div.header:click", "alert('Hello World')") - end - - def test_should_append_reapply_javascript_to_end_of_rules_javascript_on_to_s - expected_js = "Event.addBehavior({\n\"div.header:click\": function(event) {\nalert('Hello World')\n}\n});" - expected_js = expected_js + "\nEvent.addBehavior.reapplyAfterAjax = false;" - assert_equal expected_js, @script.to_s - end -end - -class BehaviourScriptToHashTest < Test::Unit::TestCase - def setup - @script = UJS::BehaviourScript.new(true, false) - @script.add_rule("div.header:mouseover", "alert('Hello World')") - @script.add_rule("div.header:mouseout", "alert('Goodbye World')") - end - - def test_should_return_converted_behaviour_script - assert_equal({ :options => { :cache => true, :reapply_after_ajax => false }, - :rules => [ - ['div.header:mouseover', "alert('Hello World')"], - ['div.header:mouseout', "alert('Goodbye World')"] - ] }, @script.to_hash) - end -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/config/database.yml b/vendor/plugins/unobtrusive_javascript/test/config/database.yml deleted file mode 100644 index bafaf2ab..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/config/database.yml +++ /dev/null @@ -1,19 +0,0 @@ -test: - adapter: sqlite3 - dbfile: test.sqlite3.db - -# adapter: sqlite -# dbfile: test.sqlite.db - -# adapter: mysql -# host: localhost -# username: -# password: -# database: test - -# adapter: postgresql -# host: localhost -# username: -# password: -# database: test - diff --git a/vendor/plugins/unobtrusive_javascript/test/config/environment.rb b/vendor/plugins/unobtrusive_javascript/test/config/environment.rb deleted file mode 100644 index 47ed1736..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/config/environment.rb +++ /dev/null @@ -1,8 +0,0 @@ -Rails::Initializer.run do |config| - config.cache_classes = true - config.whiny_nils = true - config.action_controller.consider_all_requests_local = true - config.action_controller.perform_caching = false - config.action_mailer.delivery_method = :test - config.action_mailer.perform_deliveries = true -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/config/routes.rb b/vendor/plugins/unobtrusive_javascript/test/config/routes.rb deleted file mode 100644 index d7da080e..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/config/routes.rb +++ /dev/null @@ -1,4 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' - UJS::routes -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/config/schema.rb b/vendor/plugins/unobtrusive_javascript/test/config/schema.rb deleted file mode 100644 index 4c9c90fe..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/config/schema.rb +++ /dev/null @@ -1,3 +0,0 @@ -ActiveRecord::Schema.define(:version => 2) do - -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/controller_methods_test.rb b/vendor/plugins/unobtrusive_javascript/test/controller_methods_test.rb deleted file mode 100644 index 1f9eaa65..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/controller_methods_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' - -class ControllerWithControllerMethodsInjected < Test::Unit::TestCase - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - end - - def test_should_add_a_before_filter_that_creates_a_new_behaviour_script - assert ControllerStub.before_filters.include?(:initialise_js_behaviours) - assert_instance_of UJS::BehaviourScript, assigns(:js_behaviours) - assert_equal "", assigns(:js_behaviours).to_s - end - - def test_should_store_applied_behaviours_in_the_behaviour_script - @controller.apply_behaviour("div.foo", "alert('foo')") - assert_equal 1, assigns(:js_behaviours).rules.size - end - - def test_should_add_an_after_filter_that_stores_the_behaviour_script_in_the_session_as_a_hash - assert ControllerStub.after_filters.include?(:store_js_behaviours) - assert_equal session[:js_behaviours], assigns(:js_behaviours).to_hash - end - - def test_should_not_store_behaviour_script_in_the_session_if_js_behaviours_is_nil - @controller.send(:reset_js_behaviours) - assert_nil @controller.send(:js_behaviours) - end - - def test_should_turn_behaviour_script_caching_on_when_cache_behaviours_is_called - @controller.cache_behaviours - assert assigns(:js_behaviours).cache? - end - - def test_should_toggle_reload_after_ajax_when_set - @controller.reapply_behaviours_after_ajax = false - assert !assigns(:js_behaviours).reapply_after_ajax? - @controller.reapply_behaviours_after_ajax = true - assert assigns(:js_behaviours).reapply_after_ajax? - end - - def test_should_also_allow_american_spelling_for_apply_behaviour - @controller.apply_behavior("div.foo", "alert('foo')") - assert_equal 1, assigns(:js_behaviours).rules.size - end -end \ No newline at end of file diff --git a/vendor/plugins/unobtrusive_javascript/test/helpers_test.rb b/vendor/plugins/unobtrusive_javascript/test/helpers_test.rb deleted file mode 100644 index 405e0a50..00000000 --- a/vendor/plugins/unobtrusive_javascript/test/helpers_test.rb +++ /dev/null @@ -1,186 +0,0 @@ -require File.dirname(__FILE__) + '/test_helper' - -class ApplyingBehaviourWithStringOfJavascriptTest < Test::Unit::TestCase - include UJS::Helpers - - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - @output = apply_behaviour("#mydiv:click", "alert('hello world')") - end - - def test_should_store_registered_behaviour - assert_equal 1, assigns(:js_behaviours).rules.size - assert_equal "#mydiv:click", assigns(:js_behaviours).rules.first[0] - assert_equal "alert('hello world');", assigns(:js_behaviours).rules.first[1] - end -end - -class ApplyingBehaviourThatIsRendererdInlineTest < Test::Unit::TestCase - include UJS::Helpers - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::TagHelper - - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - @output = apply_behaviour("#mydiv:click", "alert('hello world')", :external => false) - end - - def test_should_not_store_registered_behaviour - assert_equal 0, assigns(:js_behaviours).rules.size - end -end - -class PreventDefaultBehaviourOptionTest < Test::Unit::TestCase - include UJS::Helpers - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::TagHelper - - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - @output = apply_behaviour("#mydiv:click", "alert('hello world')", :prevent_default => true) - end - - def test_should_return_false_with_prevent_default - assert_equal ['#mydiv:click', "alert('hello world'); return false;"], assigns(:js_behaviours).rules.last - end -end - -class ApplyingBehaviourWithBlockTest < Test::Unit::TestCase - include UJS::Helpers - - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - end - - def test_should_use_page_argument - apply_behaviour '#thing' do |page| - page.alert('hello') - end - - assert_equal '#thing', assigns(:js_behaviours).rules.last[0] - assert_equal "alert(\"hello\");", assigns(:js_behaviours).rules.last[1] - end - - def test_should_use_element_argument - apply_behaviour '#thing' do |page, element| - element.hide - end - - assert_equal '#thing', assigns(:js_behaviours).rules.last[0] - assert_equal "this.hide();", assigns(:js_behaviours).rules.last[1] - end - - def test_should_use_event_argument - apply_behaviour '#thing' do |page, element, event| - event.stop - end - - assert_equal '#thing', assigns(:js_behaviours).rules.last[0] - assert_equal "Event.stop(event);", assigns(:js_behaviours).rules.last[1] - end - - def test_should_use_allow_multiple_calls - apply_behaviour '#thing' do |page, element, event| - page.alert('hiding thing') - element.hide - element.show - event.stop - end - - assert_equal '#thing', assigns(:js_behaviours).rules.last[0] - assert_equal "alert(\"hiding thing\");\nthis.hide();\nthis.show();\nEvent.stop(event);", assigns(:js_behaviours).rules.last[1] - end - - def test_should_allow_options_with_block_without_specifying_string - apply_behaviour '#thing2', :prevent_default => true do |page| - page.alert('boo') - end - - assert_equal '#thing2', assigns(:js_behaviours).rules.last[0] - assert_equal "alert(\"boo\"); return false;", assigns(:js_behaviours).rules.last[1] - end - - def test_should_allow_element_proxy_methods_to_be_called - apply_behaviour '#thing3' do |page, element| - element.replace_html 'Wow!' - end - - assert_equal '#thing3', assigns(:js_behaviours).rules.last[0] - assert_equal "this.update(\"Wow!\");", assigns(:js_behaviours).rules.last[1] - end -end - -class MultipleBehavioursAppliedAtOnceTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - include UJS::Helpers - - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - apply_behaviours do - on "div.foo", "alert('foo')" - on "div.bar", "alert('bar')" - end - end - - def test_should_all_get_registered_in_the_behaviour_script - assert_equal 2, assigns(:js_behaviours).rules.size - end - - def test_should_work_with_apply_behaviour_helpers - apply_behaviours do - on "ul.sortable", make_sortable - end - assert_equal 3, assigns(:js_behaviours).rules.size - end -end - -class MultipleBehavioursAppliedAtOnceWithExternalFalseTest < Test::Unit::TestCase - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::ScriptaculousHelper - include ActionView::Helpers::PrototypeHelper - include ActionView::Helpers::UrlHelper - include ActionView::Helpers::TagHelper - include UJS::BehaviourHelper - include UJS::Helpers - - def setup - @controller = ControllerStub.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - get :index - @output = apply_behaviours do - on "div.foo", "alert('foo')", :external => false - on "div.bar", :external => false do |page| - page.alert('bar') - end - end - end - - def test_should_output_behaviours - assert_not_equal '', @output - assert_match(/