compages 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.project +18 -0
- data/README +180 -0
- data/Rakefile +10 -0
- data/app/controllers/application.rb +4 -0
- data/app/controllers/contents_controller.rb +116 -0
- data/app/controllers/pages_controller.rb +59 -0
- data/app/controllers/render_controller.rb +24 -0
- data/app/helpers/application_helper.rb +6 -0
- data/app/helpers/contents_helper.rb +5 -0
- data/app/helpers/pages_helper.rb +5 -0
- data/app/helpers/render_helper.rb +2 -0
- data/app/models/content.rb +26 -0
- data/app/models/meta_data.rb +3 -0
- data/app/models/page.rb +106 -0
- data/app/models/page_element.rb +9 -0
- data/app/views/contents/_content_preview.rhtml +1 -0
- data/app/views/contents/_contents_list.rhtml +3 -0
- data/app/views/contents/_show_library.rhtml +60 -0
- data/app/views/contents/_write_now.rhtml +42 -0
- data/app/views/layouts/pages.rhtml +24 -0
- data/app/views/layouts/render.rhtml +11 -0
- data/app/views/pages/_change_theme.rhtml +0 -0
- data/app/views/pages/_edit_menu.rhtml +62 -0
- data/app/views/pages/_page_listed.rhtml +13 -0
- data/app/views/pages/_select_theme.rhtml +4 -0
- data/app/views/pages/edit.rhtml +35 -0
- data/app/views/pages/index.rhtml +45 -0
- data/app/views/pages/list.rhtml +41 -0
- data/app/views/pages/list_a.rhtml +40 -0
- data/app/views/pages/welcome.rhtml +27 -0
- data/app/views/render/_blank.rhtml +3 -0
- data/app/views/render/show.rhtml +1 -0
- data/bin/compages +14 -0
- data/config/boot.rb +44 -0
- data/config/database.yml.home +35 -0
- data/config/environment.rb +53 -0
- data/config/environments/development.rb +21 -0
- data/config/environments/production.rb +18 -0
- data/config/environments/test.rb +19 -0
- data/config/routes.rb +32 -0
- data/db/Copia di schema.rb +48 -0
- data/db/migrate/001_create_pages.rb +12 -0
- data/db/migrate/002_create_contents.rb +12 -0
- data/db/migrate/003_create_meta_datas.rb +14 -0
- data/db/migrate/004_create_page_elements.rb +17 -0
- data/db/migrate/005_add_urlnames.rb +15 -0
- data/db/migrate/006_add_sessions.rb +15 -0
- data/db/schema.mysql.sql +65 -0
- data/db/schema.postgresql.sql +65 -0
- data/db/schema.rb +49 -0
- data/db/schema.sqlite.sql +65 -0
- data/db/schema.sqlserver.sql +71 -0
- data/db/schema_version +1 -0
- data/doc/ER-model/v1.dia +0 -0
- data/doc/ER-model/v2.dia +0 -0
- data/doc/ER-model/v3.dia +0 -0
- data/doc/README_FOR_APP +2 -0
- data/doc/esempi/doc-vir/ecds.htm +2362 -0
- data/doc/esempi/doc-vir/ecds_files/search.gif +0 -0
- data/doc/esempi/doc-vir/ecds_files/upld.gif +0 -0
- data/doc/esempi/doc-vir/ecds_files/upld.jpg +0 -0
- data/installer/apache13.conf.example.template +33 -0
- data/installer/apache20.conf.example.template +40 -0
- data/installer/lighttpd.conf.example.template +6 -0
- data/installer/rails_installer_defaults.yml +5 -0
- data/lib/redcloth.rb +1130 -0
- data/lib/render_engine.rb +94 -0
- data/lib/tasks/release.rake +46 -0
- data/public/.htaccess +41 -0
- data/public/404.html +8 -0
- data/public/500.html +8 -0
- data/public/_index.html +277 -0
- data/public/favicon.ico +0 -0
- data/public/images/body_bg.gif +0 -0
- data/public/images/body_bg_short.gif +0 -0
- data/public/images/ie_shadow.png +0 -0
- data/public/images/journal_reflex.gif +0 -0
- data/public/images/journal_shadow.gif +0 -0
- data/public/images/logo_journal_small.bmp +0 -0
- data/public/images/logo_journal_small.png +0 -0
- data/public/images/page_edit_shadow.png +0 -0
- data/public/images/restore_bar.png +0 -0
- data/public/images/spinner.gif +0 -0
- data/public/javascripts/application.js +23 -0
- data/public/javascripts/controls.js +815 -0
- data/public/javascripts/dragdrop.js +913 -0
- data/public/javascripts/effects.js +958 -0
- data/public/javascripts/lowpro.js +307 -0
- data/public/javascripts/prototype.js +2006 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/compages.css +196 -0
- data/public/stylesheets/editing.css +180 -0
- data/public/stylesheets/editing_ie_filth.css +36 -0
- data/public/themes/Doc_basic/_script.js +342 -0
- data/public/themes/Doc_basic/images/Thumbs.db +0 -0
- data/public/themes/Doc_basic/images/search.gif +0 -0
- data/public/themes/Doc_basic/images/upld.gif +0 -0
- data/public/themes/Doc_basic/images/upld.jpg +0 -0
- data/public/themes/Doc_basic/index.html +114 -0
- data/public/themes/Doc_basic/style.css +1743 -0
- data/public/themes/color7boxes/default2.css +42 -0
- data/public/themes/color7boxes/index.html +40 -0
- data/public/themes/prova/index.html +12 -0
- data/public/zDoc/images/search.gif +0 -0
- data/public/zDoc/images/upld.gif +0 -0
- data/public/zDoc/images/upld.jpg +0 -0
- data/public/zDoc/index.html +176 -0
- data/public/zDoc/script.js +342 -0
- data/public/zDoc/style.css +1741 -0
- data/script/about +3 -0
- data/script/breakpointer +3 -0
- data/script/console +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/plugin +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/fixtures/contents.yml +5 -0
- data/test/fixtures/meta_datas.yml +5 -0
- data/test/fixtures/page_elements.yml +5 -0
- data/test/fixtures/pages.yml +5 -0
- data/test/functional/contents_controller_test.rb +18 -0
- data/test/functional/pages_controller_test.rb +18 -0
- data/test/functional/render_controller_test.rb +18 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/content_test.rb +10 -0
- data/test/unit/meta_data_test.rb +10 -0
- data/test/unit/page_element_test.rb +10 -0
- data/test/unit/page_test.rb +10 -0
- data/tmp/sessions/ruby_sess.0ced4c30e36477ab +0 -0
- data/tmp/sessions/ruby_sess.20fbe26671422e70 +0 -0
- data/tmp/sessions/ruby_sess.2c72521f3a7e2ba9 +0 -0
- data/tmp/sessions/ruby_sess.4107a69d982a2eb7 +0 -0
- data/tmp/sessions/ruby_sess.573ded9c7fdd9035 +0 -0
- data/tmp/sessions/ruby_sess.5a9767815bb96258 +0 -0
- data/tmp/sessions/ruby_sess.85d723b794005388 +0 -0
- data/tmp/sessions/ruby_sess.875b3b3e3529afdb +0 -0
- data/tmp/sessions/ruby_sess.936766f3a397c88b +0 -0
- data/tmp/sessions/ruby_sess.984e2e4c9a2e7891 +0 -0
- data/tmp/sessions/ruby_sess.a1faebd7448bc45d +0 -0
- data/tmp/sessions/ruby_sess.a415768c7635bc15 +0 -0
- data/tmp/sessions/ruby_sess.b2dadcbe6c1b0add +0 -0
- data/tmp/sessions/ruby_sess.ca9100beb103a428 +0 -0
- data/tmp/sessions/ruby_sess.d649c800a046efde +0 -0
- data/tmp/sessions/ruby_sess.db73bbfafd5a537c +0 -0
- data/tmp/sessions/ruby_sess.e32487b847524df1 +0 -0
- data/tmp/sessions/ruby_sess.f4e45d67828cc437 +0 -0
- data/tmp/sessions/ruby_sess.f5a3f064f2f7a26f +0 -0
- data/tmp/sessions/ruby_sess.ff0c47b35f238cda +0 -0
- data/vendor/plugins/acts_as_urlnameable.tar.gz +0 -0
- data/vendor/plugins/acts_as_urlnameable/LICENSE +19 -0
- data/vendor/plugins/acts_as_urlnameable/README +193 -0
- data/vendor/plugins/acts_as_urlnameable/Rakefile +25 -0
- data/vendor/plugins/acts_as_urlnameable/TODO +5 -0
- data/vendor/plugins/acts_as_urlnameable/db/00x_add_urlnames_table.rb +15 -0
- data/vendor/plugins/acts_as_urlnameable/db/urlnames_table.sql +7 -0
- data/vendor/plugins/acts_as_urlnameable/doc/classes/ActiveRecord/Acts/Urlnameable/ClassMethods.html +167 -0
- data/vendor/plugins/acts_as_urlnameable/doc/classes/ActiveRecord/Acts/Urlnameable/InstanceMethods.html +213 -0
- data/vendor/plugins/acts_as_urlnameable/doc/classes/ActiveRecord/Acts/Urlnameable/SingletonMethods.html +189 -0
- data/vendor/plugins/acts_as_urlnameable/doc/created.rid +1 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/LICENSE.html +129 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/README.html +333 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/TODO.html +121 -0
- data/vendor/plugins/acts_as_urlnameable/doc/files/lib/acts_as_urlnameable_rb.html +101 -0
- data/vendor/plugins/acts_as_urlnameable/doc/fr_class_index.html +29 -0
- data/vendor/plugins/acts_as_urlnameable/doc/fr_file_index.html +30 -0
- data/vendor/plugins/acts_as_urlnameable/doc/fr_method_index.html +34 -0
- data/vendor/plugins/acts_as_urlnameable/doc/index.html +24 -0
- data/vendor/plugins/acts_as_urlnameable/doc/rdoc-style.css +208 -0
- data/vendor/plugins/acts_as_urlnameable/init.rb +3 -0
- data/vendor/plugins/acts_as_urlnameable/lib/acts_as_urlnameable.rb +159 -0
- data/vendor/plugins/acts_as_urlnameable/lib/urlname.rb +3 -0
- data/vendor/plugins/acts_as_urlnameable/test/acts_as_urlnameable_test.rb +233 -0
- data/vendor/plugins/acts_as_urlnameable/test/connection.rb +8 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/article.rb +13 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/articles.yml +62 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/page.rb +14 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/pages.yml +35 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/people.yml +9 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/person.rb +26 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/schema.rb +24 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/section.rb +5 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/sections.yml +9 -0
- data/vendor/plugins/acts_as_urlnameable/test/fixtures/urlnames.yml +153 -0
- data/vendor/plugins/acts_as_urlnameable/test/test_helper.rb +42 -0
- data/vendor/plugins/gems/README +30 -0
- data/vendor/plugins/gems/init.rb +9 -0
- data/vendor/plugins/gems/tasks/gems_tasks.rake +32 -0
- data/vendor/plugins/unobtrusive_javascript/CHANGELOG +72 -0
- data/vendor/plugins/unobtrusive_javascript/README +73 -0
- data/vendor/plugins/unobtrusive_javascript/Rakefile +33 -0
- data/vendor/plugins/unobtrusive_javascript/about.yml +6 -0
- data/vendor/plugins/unobtrusive_javascript/assets/javascripts/lowpro.js +307 -0
- data/vendor/plugins/unobtrusive_javascript/init.rb +21 -0
- data/vendor/plugins/unobtrusive_javascript/install.rb +1 -0
- data/vendor/plugins/unobtrusive_javascript/lib/actionview_helpers_patches.rb +17 -0
- data/vendor/plugins/unobtrusive_javascript/lib/asset_tag_helper_patches.rb +33 -0
- data/vendor/plugins/unobtrusive_javascript/lib/behaviour_caching.rb +70 -0
- data/vendor/plugins/unobtrusive_javascript/lib/controllers/unobtrusive_javascript_controller.rb +52 -0
- data/vendor/plugins/unobtrusive_javascript/lib/prototype_helper_patches.rb +72 -0
- data/vendor/plugins/unobtrusive_javascript/lib/scriptaculous_helper_patches.rb +62 -0
- data/vendor/plugins/unobtrusive_javascript/lib/tag_helper_patches.rb +37 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs.rb +32 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_helper.rb +62 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_script.rb +54 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/behaviour_script_converter.rb +23 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/controller_methods.rb +55 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/helpers.rb +152 -0
- data/vendor/plugins/unobtrusive_javascript/lib/ujs/javascript_proxies.rb +57 -0
- data/vendor/plugins/unobtrusive_javascript/tasks/unobtrusive_javascript_tasks.rake +15 -0
- data/vendor/plugins/unobtrusive_javascript/test/asset_tag_helper_patches_test.rb +32 -0
- data/vendor/plugins/unobtrusive_javascript/test/behaviour_helper_test.rb +180 -0
- data/vendor/plugins/unobtrusive_javascript/test/behaviour_script_converter_test.rb +72 -0
- data/vendor/plugins/unobtrusive_javascript/test/behaviour_script_test.rb +98 -0
- data/vendor/plugins/unobtrusive_javascript/test/config/environment.rb +8 -0
- data/vendor/plugins/unobtrusive_javascript/test/config/routes.rb +4 -0
- data/vendor/plugins/unobtrusive_javascript/test/config/schema.rb +3 -0
- data/vendor/plugins/unobtrusive_javascript/test/controller_methods_test.rb +48 -0
- data/vendor/plugins/unobtrusive_javascript/test/helpers_test.rb +186 -0
- data/vendor/plugins/unobtrusive_javascript/test/javascript_proxies_test.rb +3 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/boot.rb +26 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/action_controller.rb +11 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/action_mailer.rb +4 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/active_record.rb +27 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/gem/rails.rb +31 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/ptk.rb +148 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/ptk/suite/difference.rb +23 -0
- data/vendor/plugins/unobtrusive_javascript/test/lib/stubs/controller_stub.rb +10 -0
- data/vendor/plugins/unobtrusive_javascript/test/ptk_helper.rb +29 -0
- data/vendor/plugins/unobtrusive_javascript/test/tag_helper_patches_test.rb +59 -0
- data/vendor/plugins/unobtrusive_javascript/test/test_helper.rb +25 -0
- data/vendor/plugins/unobtrusive_javascript/test/unobtrusive_javascript_controller_test.rb +95 -0
- data/vendor/plugins/unobtrusive_javascript/uninstall.rb +1 -0
- data/vendor/redcloth/bin/redcloth +3 -0
- data/vendor/redcloth/doc/CHANGELOG +160 -0
- data/vendor/redcloth/doc/COPYING +25 -0
- data/vendor/redcloth/doc/README +106 -0
- data/vendor/redcloth/doc/REFERENCE +216 -0
- data/vendor/redcloth/doc/make.rb +359 -0
- data/vendor/redcloth/lib/redcloth.rb +1130 -0
- data/vendor/redcloth/run-tests.rb +28 -0
- data/vendor/redcloth/setup.rb +1376 -0
- data/vendor/redcloth/tests/code.yml +105 -0
- data/vendor/redcloth/tests/hard_breaks.yml +26 -0
- data/vendor/redcloth/tests/images.yml +171 -0
- data/vendor/redcloth/tests/instiki.yml +39 -0
- data/vendor/redcloth/tests/links.yml +155 -0
- data/vendor/redcloth/tests/lists.yml +77 -0
- data/vendor/redcloth/tests/markdown.yml +218 -0
- data/vendor/redcloth/tests/poignant.yml +64 -0
- data/vendor/redcloth/tests/table.yml +198 -0
- data/vendor/redcloth/tests/textism.yml +406 -0
- metadata +432 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
class DefaultBehaviourScriptConversionTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@script = UJS::BehaviourScript.new
|
|
6
|
+
@output = UJS::BehaviourScriptConverter.convert_to_hash(@script)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_should_have_no_rules_and_the_correct_default_options
|
|
10
|
+
assert_equal({ :options => { :cache => false, :reapply_after_ajax => true },
|
|
11
|
+
:rules => [] }, @output)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class EmptyBehaviourScriptWithDifferentOptionsConversionTest < Test::Unit::TestCase
|
|
16
|
+
def setup
|
|
17
|
+
@script = UJS::BehaviourScript.new(true, false)
|
|
18
|
+
@output = UJS::BehaviourScriptConverter.convert_to_hash(@script)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_should_have_no_rules_and_the_correct_options
|
|
22
|
+
assert_equal({ :options => { :cache => true, :reapply_after_ajax => false },
|
|
23
|
+
:rules => [] }, @output)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class BehaviourScriptWithOneRuleConversionTest < Test::Unit::TestCase
|
|
28
|
+
def setup
|
|
29
|
+
@script = UJS::BehaviourScript.new
|
|
30
|
+
@script.add_rule('div.foo:click', 'alert("TEST")')
|
|
31
|
+
@output = UJS::BehaviourScriptConverter.convert_to_hash(@script)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_should_have_one_behaviour_and_correct_options
|
|
35
|
+
assert_equal({ :options => { :cache => false, :reapply_after_ajax => true },
|
|
36
|
+
:rules => [
|
|
37
|
+
['div.foo:click', 'alert("TEST")']
|
|
38
|
+
] }, @output)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class BehaviourScriptWithTwoRuleConversionTest < Test::Unit::TestCase
|
|
43
|
+
def setup
|
|
44
|
+
@script = UJS::BehaviourScript.new
|
|
45
|
+
@script.add_rule('div.foo:click', 'alert("TEST")')
|
|
46
|
+
@script.add_rule('div.bar:click', 'alert("TEST 2")')
|
|
47
|
+
@output = UJS::BehaviourScriptConverter.convert_to_hash(@script)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_should_have_one_behaviour_and_correct_options
|
|
51
|
+
assert_equal({ :options => { :cache => false, :reapply_after_ajax => true },
|
|
52
|
+
:rules => [
|
|
53
|
+
['div.foo:click', 'alert("TEST")'],
|
|
54
|
+
['div.bar:click', 'alert("TEST 2")']
|
|
55
|
+
] }, @output)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class BehaviourScriptFromHashTest < Test::Unit::TestCase
|
|
60
|
+
def setup
|
|
61
|
+
@script = UJS::BehaviourScript.new
|
|
62
|
+
@script.add_rule('div.foo:click', 'alert("TEST")')
|
|
63
|
+
@script.add_rule('div.bar:click', 'alert("TEST 2")')
|
|
64
|
+
@converted_script = UJS::BehaviourScriptConverter.convert_from_hash(@script.to_hash)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_should_equal_the_script_it_was_converted_from_in_the_first_place
|
|
68
|
+
assert_equal @script.cache?, @converted_script.cache?
|
|
69
|
+
assert_equal @script.reapply_after_ajax?, @converted_script.reapply_after_ajax?
|
|
70
|
+
assert_equal @script.rules, @converted_script.rules
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
require 'ujs/behaviour_script'
|
|
3
|
+
|
|
4
|
+
class NewBehaviourScriptTest < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
@script = UJS::BehaviourScript.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_should_render_nothing_on_to_string
|
|
10
|
+
assert_equal "", @script.to_s
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_should_not_be_cached
|
|
14
|
+
assert !@script.cache?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_should_be_reapplied_after_an_ajax_request
|
|
18
|
+
assert @script.reapply_after_ajax?
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class BehaviourScriptWithOneRuleTest < Test::Unit::TestCase
|
|
23
|
+
def setup
|
|
24
|
+
@script = UJS::BehaviourScript.new
|
|
25
|
+
@script.add_rule("div.header:click", "alert('Hello World')")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_should_render_the_rule_as_a_javascript_event_on_to_s
|
|
29
|
+
expected_js = "Event.addBehavior({\n\"div.header:click\": function(event) {\nalert('Hello World')\n}\n});"
|
|
30
|
+
assert_equal expected_js, @script.to_s
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class BehaviourScriptWithTwoRulesTest < Test::Unit::TestCase
|
|
35
|
+
def setup
|
|
36
|
+
@script = UJS::BehaviourScript.new
|
|
37
|
+
@script.add_rule("div.header:mouseover", "alert('Hello World')")
|
|
38
|
+
@script.add_rule("div.header:mouseout", "alert('Goodbye World')")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_should_render_all_rules_as_javascript_events_on_to_s
|
|
42
|
+
expected_js = "Event.addBehavior({\n\"div.header:mouseover\": function(event) {\nalert('Hello World')\n},"
|
|
43
|
+
expected_js = expected_js + "\n\"div.header:mouseout\": function(event) {\nalert('Goodbye World')\n}\n});"
|
|
44
|
+
assert_equal expected_js, @script.to_s
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class BehaviourScriptWithRuleThatCancelsDefaultTest < Test::Unit::TestCase
|
|
49
|
+
def setup
|
|
50
|
+
@script = UJS::BehaviourScript.new
|
|
51
|
+
@script.add_rule("div.header:mouseover", "alert('Hello World');", true)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_should_render_rule_with_return_false_appended_on_to_s
|
|
55
|
+
expected_js = "Event.addBehavior({\n\"div.header:mouseover\": function(event) {\nalert('Hello World'); return false;\n}\n});"
|
|
56
|
+
assert_equal expected_js, @script.to_s
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class BehaviourScriptWithNoRulesTest < Test::Unit::TestCase
|
|
61
|
+
def setup
|
|
62
|
+
@script = UJS::BehaviourScript.new
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_should_render_nothing_on_to_s
|
|
66
|
+
assert_equal "", @script.to_s
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class BehaviourScriptWithRulesSetToNotReapplyAfterAjaxTest < Test::Unit::TestCase
|
|
71
|
+
def setup
|
|
72
|
+
@script = UJS::BehaviourScript.new
|
|
73
|
+
@script.reapply_after_ajax = false
|
|
74
|
+
@script.add_rule("div.header:click", "alert('Hello World')")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_should_append_reapply_javascript_to_end_of_rules_javascript_on_to_s
|
|
78
|
+
expected_js = "Event.addBehavior({\n\"div.header:click\": function(event) {\nalert('Hello World')\n}\n});"
|
|
79
|
+
expected_js = expected_js + "\nEvent.addBehavior.reapplyAfterAjax = false;"
|
|
80
|
+
assert_equal expected_js, @script.to_s
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class BehaviourScriptToHashTest < Test::Unit::TestCase
|
|
85
|
+
def setup
|
|
86
|
+
@script = UJS::BehaviourScript.new(true, false)
|
|
87
|
+
@script.add_rule("div.header:mouseover", "alert('Hello World')")
|
|
88
|
+
@script.add_rule("div.header:mouseout", "alert('Goodbye World')")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_should_return_converted_behaviour_script
|
|
92
|
+
assert_equal({ :options => { :cache => true, :reapply_after_ajax => false },
|
|
93
|
+
:rules => [
|
|
94
|
+
['div.header:mouseover', "alert('Hello World')"],
|
|
95
|
+
['div.header:mouseout', "alert('Goodbye World')"]
|
|
96
|
+
] }, @script.to_hash)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Rails::Initializer.run do |config|
|
|
2
|
+
config.cache_classes = true
|
|
3
|
+
config.whiny_nils = true
|
|
4
|
+
config.action_controller.consider_all_requests_local = true
|
|
5
|
+
config.action_controller.perform_caching = false
|
|
6
|
+
config.action_mailer.delivery_method = :test
|
|
7
|
+
config.action_mailer.perform_deliveries = true
|
|
8
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
class ControllerWithControllerMethodsInjected < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@controller = ControllerStub.new
|
|
6
|
+
@request = ActionController::TestRequest.new
|
|
7
|
+
@response = ActionController::TestResponse.new
|
|
8
|
+
get :index
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_should_add_a_before_filter_that_creates_a_new_behaviour_script
|
|
12
|
+
assert ControllerStub.before_filters.include?(:initialise_js_behaviours)
|
|
13
|
+
assert_instance_of UJS::BehaviourScript, assigns(:js_behaviours)
|
|
14
|
+
assert_equal "", assigns(:js_behaviours).to_s
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_should_store_applied_behaviours_in_the_behaviour_script
|
|
18
|
+
@controller.apply_behaviour("div.foo", "alert('foo')")
|
|
19
|
+
assert_equal 1, assigns(:js_behaviours).rules.size
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_should_add_an_after_filter_that_stores_the_behaviour_script_in_the_session_as_a_hash
|
|
23
|
+
assert ControllerStub.after_filters.include?(:store_js_behaviours)
|
|
24
|
+
assert_equal session[:js_behaviours], assigns(:js_behaviours).to_hash
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_should_not_store_behaviour_script_in_the_session_if_js_behaviours_is_nil
|
|
28
|
+
@controller.send(:reset_js_behaviours)
|
|
29
|
+
assert_nil @controller.send(:js_behaviours)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_should_turn_behaviour_script_caching_on_when_cache_behaviours_is_called
|
|
33
|
+
@controller.cache_behaviours
|
|
34
|
+
assert assigns(:js_behaviours).cache?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_should_toggle_reload_after_ajax_when_set
|
|
38
|
+
@controller.reapply_behaviours_after_ajax = false
|
|
39
|
+
assert !assigns(:js_behaviours).reapply_after_ajax?
|
|
40
|
+
@controller.reapply_behaviours_after_ajax = true
|
|
41
|
+
assert assigns(:js_behaviours).reapply_after_ajax?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_should_also_allow_american_spelling_for_apply_behaviour
|
|
45
|
+
@controller.apply_behavior("div.foo", "alert('foo')")
|
|
46
|
+
assert_equal 1, assigns(:js_behaviours).rules.size
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
class ApplyingBehaviourWithStringOfJavascriptTest < Test::Unit::TestCase
|
|
4
|
+
include UJS::Helpers
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@controller = ControllerStub.new
|
|
8
|
+
@request = ActionController::TestRequest.new
|
|
9
|
+
@response = ActionController::TestResponse.new
|
|
10
|
+
get :index
|
|
11
|
+
@output = apply_behaviour("#mydiv:click", "alert('hello world')")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_should_store_registered_behaviour
|
|
15
|
+
assert_equal 1, assigns(:js_behaviours).rules.size
|
|
16
|
+
assert_equal "#mydiv:click", assigns(:js_behaviours).rules.first[0]
|
|
17
|
+
assert_equal "alert('hello world');", assigns(:js_behaviours).rules.first[1]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class ApplyingBehaviourThatIsRendererdInlineTest < Test::Unit::TestCase
|
|
22
|
+
include UJS::Helpers
|
|
23
|
+
include ActionView::Helpers::JavaScriptHelper
|
|
24
|
+
include ActionView::Helpers::TagHelper
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
@controller = ControllerStub.new
|
|
28
|
+
@request = ActionController::TestRequest.new
|
|
29
|
+
@response = ActionController::TestResponse.new
|
|
30
|
+
get :index
|
|
31
|
+
@output = apply_behaviour("#mydiv:click", "alert('hello world')", :external => false)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_should_not_store_registered_behaviour
|
|
35
|
+
assert_equal 0, assigns(:js_behaviours).rules.size
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class PreventDefaultBehaviourOptionTest < Test::Unit::TestCase
|
|
40
|
+
include UJS::Helpers
|
|
41
|
+
include ActionView::Helpers::JavaScriptHelper
|
|
42
|
+
include ActionView::Helpers::TagHelper
|
|
43
|
+
|
|
44
|
+
def setup
|
|
45
|
+
@controller = ControllerStub.new
|
|
46
|
+
@request = ActionController::TestRequest.new
|
|
47
|
+
@response = ActionController::TestResponse.new
|
|
48
|
+
get :index
|
|
49
|
+
@output = apply_behaviour("#mydiv:click", "alert('hello world')", :prevent_default => true)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_should_return_false_with_prevent_default
|
|
53
|
+
assert_equal ['#mydiv:click', "alert('hello world'); return false;"], assigns(:js_behaviours).rules.last
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class ApplyingBehaviourWithBlockTest < Test::Unit::TestCase
|
|
58
|
+
include UJS::Helpers
|
|
59
|
+
|
|
60
|
+
def setup
|
|
61
|
+
@controller = ControllerStub.new
|
|
62
|
+
@request = ActionController::TestRequest.new
|
|
63
|
+
@response = ActionController::TestResponse.new
|
|
64
|
+
get :index
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_should_use_page_argument
|
|
68
|
+
apply_behaviour '#thing' do |page|
|
|
69
|
+
page.alert('hello')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
assert_equal '#thing', assigns(:js_behaviours).rules.last[0]
|
|
73
|
+
assert_equal "alert(\"hello\");", assigns(:js_behaviours).rules.last[1]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_should_use_element_argument
|
|
77
|
+
apply_behaviour '#thing' do |page, element|
|
|
78
|
+
element.hide
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
assert_equal '#thing', assigns(:js_behaviours).rules.last[0]
|
|
82
|
+
assert_equal "this.hide();", assigns(:js_behaviours).rules.last[1]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_should_use_event_argument
|
|
86
|
+
apply_behaviour '#thing' do |page, element, event|
|
|
87
|
+
event.stop
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
assert_equal '#thing', assigns(:js_behaviours).rules.last[0]
|
|
91
|
+
assert_equal "Event.stop(event);", assigns(:js_behaviours).rules.last[1]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_should_use_allow_multiple_calls
|
|
95
|
+
apply_behaviour '#thing' do |page, element, event|
|
|
96
|
+
page.alert('hiding thing')
|
|
97
|
+
element.hide
|
|
98
|
+
element.show
|
|
99
|
+
event.stop
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
assert_equal '#thing', assigns(:js_behaviours).rules.last[0]
|
|
103
|
+
assert_equal "alert(\"hiding thing\");\nthis.hide();\nthis.show();\nEvent.stop(event);", assigns(:js_behaviours).rules.last[1]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_should_allow_options_with_block_without_specifying_string
|
|
107
|
+
apply_behaviour '#thing2', :prevent_default => true do |page|
|
|
108
|
+
page.alert('boo')
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
assert_equal '#thing2', assigns(:js_behaviours).rules.last[0]
|
|
112
|
+
assert_equal "alert(\"boo\"); return false;", assigns(:js_behaviours).rules.last[1]
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_should_allow_element_proxy_methods_to_be_called
|
|
116
|
+
apply_behaviour '#thing3' do |page, element|
|
|
117
|
+
element.replace_html '<strong>Wow!</strong>'
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
assert_equal '#thing3', assigns(:js_behaviours).rules.last[0]
|
|
121
|
+
assert_equal "this.update(\"<strong>Wow!</strong>\");", assigns(:js_behaviours).rules.last[1]
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class MultipleBehavioursAppliedAtOnceTest < Test::Unit::TestCase
|
|
126
|
+
include ActionView::Helpers::JavaScriptHelper
|
|
127
|
+
include ActionView::Helpers::ScriptaculousHelper
|
|
128
|
+
include ActionView::Helpers::PrototypeHelper
|
|
129
|
+
include ActionView::Helpers::UrlHelper
|
|
130
|
+
include ActionView::Helpers::TagHelper
|
|
131
|
+
include UJS::BehaviourHelper
|
|
132
|
+
include UJS::Helpers
|
|
133
|
+
|
|
134
|
+
def setup
|
|
135
|
+
@controller = ControllerStub.new
|
|
136
|
+
@request = ActionController::TestRequest.new
|
|
137
|
+
@response = ActionController::TestResponse.new
|
|
138
|
+
get :index
|
|
139
|
+
apply_behaviours do
|
|
140
|
+
on "div.foo", "alert('foo')"
|
|
141
|
+
on "div.bar", "alert('bar')"
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_should_all_get_registered_in_the_behaviour_script
|
|
146
|
+
assert_equal 2, assigns(:js_behaviours).rules.size
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_should_work_with_apply_behaviour_helpers
|
|
150
|
+
apply_behaviours do
|
|
151
|
+
on "ul.sortable", make_sortable
|
|
152
|
+
end
|
|
153
|
+
assert_equal 3, assigns(:js_behaviours).rules.size
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
class MultipleBehavioursAppliedAtOnceWithExternalFalseTest < Test::Unit::TestCase
|
|
158
|
+
include ActionView::Helpers::JavaScriptHelper
|
|
159
|
+
include ActionView::Helpers::ScriptaculousHelper
|
|
160
|
+
include ActionView::Helpers::PrototypeHelper
|
|
161
|
+
include ActionView::Helpers::UrlHelper
|
|
162
|
+
include ActionView::Helpers::TagHelper
|
|
163
|
+
include UJS::BehaviourHelper
|
|
164
|
+
include UJS::Helpers
|
|
165
|
+
|
|
166
|
+
def setup
|
|
167
|
+
@controller = ControllerStub.new
|
|
168
|
+
@request = ActionController::TestRequest.new
|
|
169
|
+
@response = ActionController::TestResponse.new
|
|
170
|
+
get :index
|
|
171
|
+
@output = apply_behaviours do
|
|
172
|
+
on "div.foo", "alert('foo')", :external => false
|
|
173
|
+
on "div.bar", :external => false do |page|
|
|
174
|
+
page.alert('bar')
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def test_should_output_behaviours
|
|
180
|
+
assert_not_equal '', @output
|
|
181
|
+
assert_match(/<script/, @output)
|
|
182
|
+
assert_match(/alert\('foo'\)/, @output)
|
|
183
|
+
assert_match(/alert\("bar"\)/, @output)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# We are always a test environment and should never be anything else
|
|
2
|
+
ENV["RAILS_ENV"] ||= "test"
|
|
3
|
+
|
|
4
|
+
require File.join(File.dirname(__FILE__), 'ptk')
|
|
5
|
+
|
|
6
|
+
# Set up RAILS_ROOT to #{plugin_path}/test
|
|
7
|
+
unless defined?(RAILS_ROOT)
|
|
8
|
+
root_path = PTK::LoadPath.expand(__FILE__, '..', '..')
|
|
9
|
+
|
|
10
|
+
unless RUBY_PLATFORM =~ /mswin32/
|
|
11
|
+
require 'pathname'
|
|
12
|
+
root_path = Pathname.new(root_path).cleanpath(true).to_s
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RAILS_ROOT = root_path
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# add #{plugin_path}/test/lib
|
|
19
|
+
PTK::LoadPath.add RAILS_ROOT, 'lib'
|
|
20
|
+
|
|
21
|
+
# add #{plugin_path}/lib
|
|
22
|
+
PTK::LoadPath.add RAILS_ROOT, '..', 'lib'
|
|
23
|
+
|
|
24
|
+
require 'rubygems'
|
|
25
|
+
require 'test/unit'
|
|
26
|
+
require 'active_support'
|