motiro 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +280 -0
- data/README +28 -0
- data/README.en +175 -0
- data/README.pt-br +175 -0
- data/Rakefile +10 -0
- data/app/controllers/account_controller.rb +62 -0
- data/app/controllers/application.rb +72 -0
- data/app/controllers/edition_controller.rb +13 -0
- data/app/controllers/javascript_controller.rb +21 -0
- data/app/controllers/report_controller.rb +79 -0
- data/app/controllers/root_controller.rb +7 -0
- data/app/controllers/wiki_controller.rb +102 -0
- data/app/core/cache_reporter.rb +53 -0
- data/app/core/cache_reporter_fetcher.rb +33 -0
- data/app/core/chief_editor.rb +69 -0
- data/app/core/reporter.rb +105 -0
- data/app/core/reporter_driver.rb +36 -0
- data/app/core/reporter_fetcher.rb +39 -0
- data/app/core/settings.rb +43 -0
- data/app/core/version.rb +1 -0
- data/app/core/wiki_page_not_found.rb +33 -0
- data/app/core/wiki_reporter.rb +83 -0
- data/app/helpers/account_helper.rb +2 -0
- data/app/helpers/application_helper.rb +68 -0
- data/app/helpers/default_page_provider.rb +28 -0
- data/app/helpers/report_helper.rb +2 -0
- data/app/helpers/root_helper.rb +2 -0
- data/app/helpers/wiki_helper.rb +3 -0
- data/app/models/change.rb +96 -0
- data/app/models/diff_table_builder.rb +285 -0
- data/app/models/event.rb +18 -0
- data/app/models/headline.rb +109 -0
- data/app/models/page.rb +114 -0
- data/app/models/page_sweeper.rb +26 -0
- data/app/models/user.rb +85 -0
- data/app/ports/chdir_runner.rb +36 -0
- data/app/ports/reporter_loader.rb +9 -0
- data/app/ports/runner.rb +64 -0
- data/app/reporters/darcs_connection.rb +54 -0
- data/app/reporters/darcs_reporter.rb +104 -0
- data/app/reporters/darcs_settings.rb +9 -0
- data/app/reporters/darcs_temp_repo.rb +40 -0
- data/app/reporters/events_reporter.rb +28 -0
- data/app/reporters/features_reporter.rb +24 -0
- data/app/reporters/subversion_reporter.rb +203 -0
- data/app/reporters/svn_connection.rb +62 -0
- data/app/reporters/svn_settings.rb +40 -0
- data/app/views/account/_authorization.rhtml +54 -0
- data/app/views/account/_availability.rhtml +5 -0
- data/app/views/account/availability.rhtml +1 -0
- data/app/views/account/login.rhtml +22 -0
- data/app/views/account/logout.rhtml +10 -0
- data/app/views/javascript/motiro.rjs +132 -0
- data/app/views/javascript/niftycube.rjs +300 -0
- data/app/views/layouts/_bottom.rhtml +5 -0
- data/app/views/layouts/_header.rhtml +7 -0
- data/app/views/layouts/_top.rhtml +25 -0
- data/app/views/layouts/application.rhtml +3 -0
- data/app/views/layouts/scaffold.rhtml +13 -0
- data/app/views/layouts/wiki_edit.rhtml +26 -0
- data/app/views/report/list.rhtml +32 -0
- data/app/views/report/older.rhtml +26 -0
- data/app/views/report/rss.rxml +29 -0
- data/app/views/report/show.rhtml +20 -0
- data/app/views/root/index.rhtml +33 -0
- data/app/views/wiki/_editbar.rhtml +26 -0
- data/app/views/wiki/_properties_edit.rhtml +5 -0
- data/app/views/wiki/_properties_show.rhtml +5 -0
- data/app/views/wiki/edit.rhtml +56 -0
- data/app/views/wiki/properties_edit.rhtml +1 -0
- data/app/views/wiki/show.rhtml +9 -0
- data/bin/motiro +44 -0
- data/config/boot.rb +19 -0
- data/config/database.yml +14 -0
- data/config/environment.rb +64 -0
- data/config/environments/development.rb +20 -0
- data/config/environments/production.rb +19 -0
- data/config/environments/test.rb +19 -0
- data/config/motiro.yml +43 -0
- data/config/routes.rb +79 -0
- data/db/migrate/005_globalize_migration.rb +11363 -0
- data/db/migrate/006_remove_headline_title.rb +14 -0
- data/db/migrate/007_stretch_rid.rb +11 -0
- data/db/migrate/008_add_page_editors.rb +12 -0
- data/db/migrate/009_add_page_original_author.rb +12 -0
- data/db/migrate/010_remove_empty_string_defaults_from_pages.rb +17 -0
- data/db/migrate/011_add_title_and_kind_to_pages.rb +13 -0
- data/db/migrate/012_page_modification_info.rb +13 -0
- data/db/migrate/013_nullify_initial_page_attributes.rb +21 -0
- data/db/migrate/014_events_are_wiki_pages.rb +13 -0
- data/db/migrate/015_migrate_previous_event_data.rb +23 -0
- data/db/migrate/1_initial_structure.rb +36 -0
- data/db/migrate/2_add_authentication.rb +12 -0
- data/db/migrate/3_drop_articles.rb +26 -0
- data/db/migrate/4_add_page_editing.rb +14 -0
- data/db/motirodb.sqlite.initial +0 -0
- data/db/schema_version +1 -0
- data/db/translation/pt-BR.rb +76 -0
- data/doc/README_FOR_APP +2 -0
- data/installer/rails_installer_defaults.yml +5 -0
- data/lib/import_translations.rb +154 -0
- data/lib/login_system.rb +89 -0
- data/lib/relative_time.rb +48 -0
- data/lib/string_extensions.rb +10 -0
- data/lib/stub_hash.rb +22 -0
- data/lib/tasks/packaging.rake +93 -0
- data/lib/tasks/testing.rake +32 -0
- data/lib/tick_daemon.rb +41 -0
- data/lib/translator.rb +67 -0
- data/lib/wiki_renderer.rb +42 -0
- data/lib/wiki_url_generator.rb +29 -0
- data/log/.keepdir +0 -0
- data/public/404.html +8 -0
- data/public/500.html +8 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/calendar.png +0 -0
- data/public/images/rss.png +0 -0
- data/public/javascripts/controls.js +750 -0
- data/public/javascripts/dragdrop.js +584 -0
- data/public/javascripts/effects.js +854 -0
- data/public/javascripts/prototype.js +1785 -0
- data/public/robots.txt +1 -0
- data/public/stylesheets/motiro.css +269 -0
- data/public/stylesheets/niftyCorners.css +35 -0
- data/public/stylesheets/scaffold.css +74 -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/process/spinner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/script/ticker +29 -0
- data/test/acceptance/account_test.rb +186 -0
- data/test/acceptance/darcs_test.rb +62 -0
- data/test/acceptance/events_test.rb +47 -0
- data/test/acceptance/main_page_test.rb +92 -0
- data/test/acceptance/subversion_test.rb +319 -0
- data/test/acceptance/ts_all_suites.rb +27 -0
- data/test/acceptance/wiki_test.rb +202 -0
- data/test/contract/darcs_test.rb +51 -0
- data/test/contract/remote_darcs_test.rb +61 -0
- data/test/contract/svn_test.rb +53 -0
- data/test/fixtures/changes.yml +25 -0
- data/test/fixtures/headlines.yml +45 -0
- data/test/fixtures/pages.yml +98 -0
- data/test/fixtures/users.yml +31 -0
- data/test/functional/account_controller_test.rb +96 -0
- data/test/functional/report_controller_test.rb +113 -0
- data/test/functional/report_features_test.rb +38 -0
- data/test/functional/report_subversion_test.rb +79 -0
- data/test/functional/root_controller_test.rb +127 -0
- data/test/functional/wiki_controller_test.rb +280 -0
- data/test/lib/acceptance_test_case.rb +43 -0
- data/test/lib/configuration.rb +53 -0
- data/test/lib/darcs_excerpts.rb +181 -0
- data/test/lib/darcs_repo.rb +77 -0
- data/test/lib/live_mode_test.rb +51 -0
- data/test/lib/local_svn.rb +157 -0
- data/test/lib/netutils.rb +42 -0
- data/test/lib/platform_thread.rb +62 -0
- data/test/lib/repoutils.rb +23 -0
- data/test/lib/selenium_extensions.rb +32 -0
- data/test/lib/stubio.rb +37 -0
- data/test/lib/svn_excerpts.rb +288 -0
- data/test/lib/test_configuration.rb +14 -0
- data/test/lib/webserver.rb +71 -0
- data/test/meta/configuration_test.rb +72 -0
- data/test/meta/darcs_repo_test.rb +118 -0
- data/test/meta/local_svn_test.rb +125 -0
- data/test/meta/platform_thread_test.rb +46 -0
- data/test/meta/stubio_test.rb +44 -0
- data/test/mocks/headline.rb +34 -0
- data/test/mocks/svn_reporter.rb +29 -0
- data/test/stubs/svn_settings.rb +19 -0
- data/test/stubs/url_generator.rb +24 -0
- data/test/test_helper.rb +36 -0
- data/test/unit/cache_reporter_fetcher_test.rb +46 -0
- data/test/unit/cache_reporter_test.rb +97 -0
- data/test/unit/caching_test.rb +78 -0
- data/test/unit/change_test.rb +152 -0
- data/test/unit/chdir_runner_test.rb +77 -0
- data/test/unit/chief_editor_test.rb +234 -0
- data/test/unit/darcs_connection_test.rb +109 -0
- data/test/unit/darcs_reporter_test.rb +146 -0
- data/test/unit/darcs_settings_test.rb +37 -0
- data/test/unit/darcs_temp_repo_test.rb +51 -0
- data/test/unit/default_page_provider_test.rb +46 -0
- data/test/unit/diff_table_builder_test.rb +602 -0
- data/test/unit/headline_test.rb +259 -0
- data/test/unit/page_test.rb +145 -0
- data/test/unit/relative_time_test.rb +56 -0
- data/test/unit/reporter_driver_test.rb +85 -0
- data/test/unit/reporter_fetcher_test.rb +31 -0
- data/test/unit/reporter_test.rb +81 -0
- data/test/unit/runner_test.rb +93 -0
- data/test/unit/settings_test.rb +55 -0
- data/test/unit/string_extensions_test.rb +10 -0
- data/test/unit/svn_connection_test.rb +183 -0
- data/test/unit/svn_reporter_interaction_test.rb +38 -0
- data/test/unit/svn_reporter_test.rb +286 -0
- data/test/unit/svn_settings_test.rb +86 -0
- data/test/unit/translator_test.rb +96 -0
- data/test/unit/user_test.rb +125 -0
- data/test/unit/wiki_renderer_test.rb +87 -0
- data/test/unit/wiki_reporter_test.rb +94 -0
- data/test/unit/wiki_url_generator_test.rb +31 -0
- data/vendor/motiro-installer.rb +159 -0
- data/vendor/plugins/globalize/LICENSE +9 -0
- data/vendor/plugins/globalize/README +49 -0
- data/vendor/plugins/globalize/data/country_data.csv +240 -0
- data/vendor/plugins/globalize/data/language_data.csv +188 -0
- data/vendor/plugins/globalize/data/translation_data.csv +3421 -0
- data/vendor/plugins/globalize/generators/globalize/USAGE +10 -0
- data/vendor/plugins/globalize/generators/globalize/globalize_generator.rb +42 -0
- data/vendor/plugins/globalize/generators/globalize/templates/migration.rb.gz +0 -0
- data/vendor/plugins/globalize/generators/globalize/templates/tiny_migration.rb.gz +0 -0
- data/vendor/plugins/globalize/init.rb +30 -0
- data/vendor/plugins/globalize/lib/globalize/localization/core_ext.rb +170 -0
- data/vendor/plugins/globalize/lib/globalize/localization/core_ext_hooks.rb +33 -0
- data/vendor/plugins/globalize/lib/globalize/localization/db_translate.rb +494 -0
- data/vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb +152 -0
- data/vendor/plugins/globalize/lib/globalize/localization/locale.rb +173 -0
- data/vendor/plugins/globalize/lib/globalize/localization/rfc_3066.rb +40 -0
- data/vendor/plugins/globalize/lib/globalize/models/country.rb +24 -0
- data/vendor/plugins/globalize/lib/globalize/models/currency.rb +188 -0
- data/vendor/plugins/globalize/lib/globalize/models/language.rb +84 -0
- data/vendor/plugins/globalize/lib/globalize/models/model_translation.rb +4 -0
- data/vendor/plugins/globalize/lib/globalize/models/translation.rb +9 -0
- data/vendor/plugins/globalize/lib/globalize/models/view_translation.rb +14 -0
- data/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb +125 -0
- data/vendor/plugins/globalize/lib/globalize/rails/action_view.rb +79 -0
- data/vendor/plugins/globalize/lib/globalize/rails/active_record.rb +129 -0
- data/vendor/plugins/globalize/lib/globalize/rails/active_record_helper.rb +33 -0
- data/vendor/plugins/globalize/populators/pop_dates.rb +81 -0
- data/vendor/plugins/globalize/populators/pop_migration.rb +18 -0
- data/vendor/plugins/globalize/populators/pop_pluralization.rb +26 -0
- data/vendor/plugins/globalize/populators/pop_seps.rb +32 -0
- data/vendor/plugins/globalize/tasks/data.rake +130 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en-US.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.he.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.plain.text.rhtml +1 -0
- data/vendor/plugins/globalize/test/action_mailer_test.rb +54 -0
- data/vendor/plugins/globalize/test/config/database.yml.default +16 -0
- data/vendor/plugins/globalize/test/config/database.yml.example +22 -0
- data/vendor/plugins/globalize/test/core_ext_test.rb +61 -0
- data/vendor/plugins/globalize/test/currency_test.rb +141 -0
- data/vendor/plugins/globalize/test/date_helper_test.rb +634 -0
- data/vendor/plugins/globalize/test/db/schema.rb +90 -0
- data/vendor/plugins/globalize/test/db_translation_test.rb +374 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_categories.yml +7 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_categories_products.yml +7 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_countries.yml +41 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_languages.yml +64 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_manufacturers.yml +5 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_products.yml +29 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_simples.yml +5 -0
- data/vendor/plugins/globalize/test/fixtures/globalize_translations.yml +354 -0
- data/vendor/plugins/globalize/test/locale_test.rb +27 -0
- data/vendor/plugins/globalize/test/mime_responds_test.rb +358 -0
- data/vendor/plugins/globalize/test/model_test.rb +17 -0
- data/vendor/plugins/globalize/test/standard_data_test_helper.rb +33 -0
- data/vendor/plugins/globalize/test/test_helper.rb +19 -0
- data/vendor/plugins/globalize/test/test_standard_data.rb +54 -0
- data/vendor/plugins/globalize/test/validation_test.rb +29 -0
- data/vendor/plugins/globalize/test/view_picking_test.rb +49 -0
- data/vendor/plugins/globalize/test/view_translation_test.rb +237 -0
- data/vendor/plugins/globalize/test/views/layouts/standard.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rxml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rjs +1 -0
- data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rxml +1 -0
- data/vendor/plugins/globalize/test/views/test.he-IL.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/test.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/test2.he.rhtml +1 -0
- data/vendor/plugins/globalize/test/views/test2.rhtml +1 -0
- data/vendor/plugins/test_xml/MIT-LICENSE +20 -0
- data/vendor/plugins/test_xml/README +20 -0
- data/vendor/plugins/test_xml/Rakefile +22 -0
- data/vendor/plugins/test_xml/init.rb +7 -0
- data/vendor/plugins/test_xml/lib/xml_assertions.rb +22 -0
- data/vendor/plugins/test_xml/test/test_xml_test.rb +40 -0
- metadata +505 -0
@@ -0,0 +1,358 @@
|
|
1
|
+
# Contain same tests as action_pack/test/mime_responds_test.rb and some more
|
2
|
+
# to check multilingual rendering of templates with respond_to.
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/test_helper'
|
5
|
+
|
6
|
+
class RespondToController < ActionController::Base
|
7
|
+
layout :set_layout
|
8
|
+
|
9
|
+
def html_xml_or_rss
|
10
|
+
respond_to do |type|
|
11
|
+
type.html { render :text => "HTML" }
|
12
|
+
type.xml { render :text => "XML" }
|
13
|
+
type.rss { render :text => "RSS" }
|
14
|
+
type.all { render :text => "Nothing" }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def js_or_html
|
19
|
+
respond_to do |type|
|
20
|
+
type.html { render :text => "HTML" }
|
21
|
+
type.js { render :text => "JS" }
|
22
|
+
type.all { render :text => "Nothing" }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def html_or_xml
|
27
|
+
respond_to do |type|
|
28
|
+
type.html { render :text => "HTML" }
|
29
|
+
type.xml { render :text => "XML" }
|
30
|
+
type.all { render :text => "Nothing" }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def just_xml
|
35
|
+
respond_to do |type|
|
36
|
+
type.xml { render :text => "XML" }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def using_defaults
|
41
|
+
respond_to do |type|
|
42
|
+
type.html
|
43
|
+
type.js
|
44
|
+
type.xml
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def using_defaults_with_type_list
|
49
|
+
respond_to(:html, :js, :xml)
|
50
|
+
end
|
51
|
+
|
52
|
+
def made_for_content_type
|
53
|
+
respond_to do |type|
|
54
|
+
type.rss { render :text => "RSS" }
|
55
|
+
type.atom { render :text => "ATOM" }
|
56
|
+
type.all { render :text => "Nothing" }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def custom_type_handling
|
61
|
+
respond_to do |type|
|
62
|
+
type.html { render :text => "HTML" }
|
63
|
+
type.custom("application/crazy-xml") { render :text => "Crazy XML" }
|
64
|
+
type.all { render :text => "Nothing" }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def handle_any
|
69
|
+
respond_to do |type|
|
70
|
+
type.html { render :text => "HTML" }
|
71
|
+
type.any(:js, :xml) { render :text => "Either JS or XML" }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def all_types_with_layout
|
76
|
+
respond_to do |type|
|
77
|
+
type.html
|
78
|
+
type.js
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def rescue_action(e)
|
83
|
+
raise
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
def set_layout
|
88
|
+
if action_name == "all_types_with_layout"
|
89
|
+
"standard"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
RespondToController.template_root = File.dirname(__FILE__) + "/views"
|
95
|
+
|
96
|
+
class MimeControllerTest < Test::Unit::TestCase
|
97
|
+
include Globalize
|
98
|
+
def setup
|
99
|
+
Locale.set(nil)
|
100
|
+
@request = ActionController::TestRequest.new
|
101
|
+
@response = ActionController::TestResponse.new
|
102
|
+
|
103
|
+
@controller = RespondToController.new
|
104
|
+
@request.host = "www.example.com"
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_html
|
108
|
+
@request.env["HTTP_ACCEPT"] = "text/html"
|
109
|
+
get :js_or_html
|
110
|
+
assert_equal 'HTML', @response.body
|
111
|
+
|
112
|
+
get :html_or_xml
|
113
|
+
assert_equal 'HTML', @response.body
|
114
|
+
|
115
|
+
get :just_xml
|
116
|
+
assert_response 406
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_fr_html
|
120
|
+
Locale.set('fr')
|
121
|
+
test_html
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_all
|
125
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
126
|
+
get :js_or_html
|
127
|
+
assert_equal 'HTML', @response.body # js is not part of all
|
128
|
+
|
129
|
+
get :html_or_xml
|
130
|
+
assert_equal 'HTML', @response.body
|
131
|
+
|
132
|
+
get :just_xml
|
133
|
+
assert_equal 'XML', @response.body
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_fr_all
|
137
|
+
Locale.set('fr')
|
138
|
+
test_all
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_xml
|
142
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
143
|
+
get :html_xml_or_rss
|
144
|
+
assert_equal 'XML', @response.body
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_js_or_html
|
148
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript, text/html"
|
149
|
+
get :js_or_html
|
150
|
+
assert_equal 'JS', @response.body
|
151
|
+
|
152
|
+
get :html_or_xml
|
153
|
+
assert_equal 'HTML', @response.body
|
154
|
+
|
155
|
+
get :just_xml
|
156
|
+
assert_response 406
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_js_or_anything
|
160
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript, */*"
|
161
|
+
get :js_or_html
|
162
|
+
assert_equal 'JS', @response.body
|
163
|
+
|
164
|
+
get :html_or_xml
|
165
|
+
assert_equal 'HTML', @response.body
|
166
|
+
|
167
|
+
get :just_xml
|
168
|
+
assert_equal 'XML', @response.body
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_fr_js_or_anything
|
172
|
+
Locale.set('fr')
|
173
|
+
test_js_or_anything
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_using_defaults
|
177
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
178
|
+
get :using_defaults
|
179
|
+
assert_equal 'Hello world!', @response.body
|
180
|
+
|
181
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
182
|
+
get :using_defaults
|
183
|
+
assert_equal '$("body").visualEffect("highlight");', @response.body
|
184
|
+
|
185
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
186
|
+
get :using_defaults
|
187
|
+
assert_equal "<p>Hello world!</p>\n", @response.body
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_fr_using_defaults
|
191
|
+
Locale.set('fr')
|
192
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
193
|
+
get :using_defaults
|
194
|
+
assert_equal 'Bonjour le monde !', @response.body
|
195
|
+
|
196
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
197
|
+
get :using_defaults
|
198
|
+
assert_equal '$("body").visualEffect("highlight");', @response.body
|
199
|
+
|
200
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
201
|
+
get :using_defaults
|
202
|
+
assert_equal "<p>Bonjour le monde !</p>\n", @response.body
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_fr_CH_fallback_to_fr_using_defaults
|
206
|
+
Locale.set('fr-CH')
|
207
|
+
test_fr_using_defaults
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_de_fallback_to_default
|
211
|
+
Locale.set('de')
|
212
|
+
test_using_defaults
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_using_defaults_with_type_list
|
216
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
217
|
+
get :using_defaults_with_type_list
|
218
|
+
assert_equal 'Hello world!', @response.body
|
219
|
+
|
220
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
221
|
+
get :using_defaults_with_type_list
|
222
|
+
assert_equal '$("body").visualEffect("highlight");', @response.body
|
223
|
+
|
224
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
225
|
+
get :using_defaults_with_type_list
|
226
|
+
assert_equal "<p>Hello world!</p>\n", @response.body
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_fr_using_defaults_with_type_list
|
230
|
+
Locale.set('fr')
|
231
|
+
|
232
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
233
|
+
get :using_defaults_with_type_list
|
234
|
+
assert_equal 'Bonjour le monde !', @response.body
|
235
|
+
|
236
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
237
|
+
get :using_defaults_with_type_list
|
238
|
+
assert_equal '$("body").visualEffect("highlight");', @response.body
|
239
|
+
|
240
|
+
@request.env["HTTP_ACCEPT"] = "application/xml"
|
241
|
+
get :using_defaults_with_type_list
|
242
|
+
assert_equal "<p>Bonjour le monde !</p>\n", @response.body
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_with_content_type
|
246
|
+
@request.env["CONTENT_TYPE"] = "application/atom+xml"
|
247
|
+
get :made_for_content_type
|
248
|
+
assert_equal "ATOM", @response.body
|
249
|
+
|
250
|
+
@request.env["CONTENT_TYPE"] = "application/rss+xml"
|
251
|
+
get :made_for_content_type
|
252
|
+
assert_equal "RSS", @response.body
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_fr_with_content_type
|
256
|
+
Locale.set('fr')
|
257
|
+
test_with_content_type
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_synonyms
|
261
|
+
@request.env["HTTP_ACCEPT"] = "application/javascript"
|
262
|
+
get :js_or_html
|
263
|
+
assert_equal 'JS', @response.body
|
264
|
+
|
265
|
+
@request.env["HTTP_ACCEPT"] = "application/x-xml"
|
266
|
+
get :html_xml_or_rss
|
267
|
+
assert_equal "XML", @response.body
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_fr_synonyms
|
271
|
+
Locale.set('fr')
|
272
|
+
test_synonyms
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_custom_types
|
276
|
+
@request.env["HTTP_ACCEPT"] = "application/crazy-xml"
|
277
|
+
get :custom_type_handling
|
278
|
+
assert_equal 'Crazy XML', @response.body
|
279
|
+
|
280
|
+
@request.env["HTTP_ACCEPT"] = "text/html"
|
281
|
+
get :custom_type_handling
|
282
|
+
assert_equal 'HTML', @response.body
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_fr_custom_types
|
286
|
+
Locale.set('fr')
|
287
|
+
test_custom_types
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_xhtml_alias
|
291
|
+
@request.env["HTTP_ACCEPT"] = "application/xhtml+xml,application/xml"
|
292
|
+
get :html_or_xml
|
293
|
+
assert_equal 'HTML', @response.body
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_fr_xhtml_alias
|
297
|
+
Locale.set('fr')
|
298
|
+
test_custom_types
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_firefox_simulation
|
302
|
+
@request.env["HTTP_ACCEPT"] = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
|
303
|
+
get :html_or_xml
|
304
|
+
assert_equal 'HTML', @response.body
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_fr_firefox_simulation
|
308
|
+
Locale.set('fr')
|
309
|
+
test_firefox_simulation
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_handle_any
|
313
|
+
@request.env["HTTP_ACCEPT"] = "*/*"
|
314
|
+
get :handle_any
|
315
|
+
assert_equal 'HTML', @response.body
|
316
|
+
|
317
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
318
|
+
get :handle_any
|
319
|
+
assert_equal 'Either JS or XML', @response.body
|
320
|
+
|
321
|
+
@request.env["HTTP_ACCEPT"] = "text/xml"
|
322
|
+
get :handle_any
|
323
|
+
assert_equal 'Either JS or XML', @response.body
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_fr_handle_any
|
327
|
+
Locale.set('fr')
|
328
|
+
test_handle_any
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_all_types_with_layout
|
332
|
+
@request.env["HTTP_ACCEPT"] = "text/javascript"
|
333
|
+
get :all_types_with_layout
|
334
|
+
assert_equal 'RJS for all_types_with_layout', @response.body
|
335
|
+
|
336
|
+
@request.env["HTTP_ACCEPT"] = "text/html"
|
337
|
+
get :all_types_with_layout
|
338
|
+
assert_equal '<html>HTML for all_types_with_layout</html>', @response.body
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_fr_all_types_with_layout
|
342
|
+
Locale.set('fr')
|
343
|
+
test_all_types_with_layout
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_xhr
|
347
|
+
xhr :get, :js_or_html
|
348
|
+
assert_equal 'JS', @response.body
|
349
|
+
|
350
|
+
xhr :get, :using_defaults
|
351
|
+
assert_equal '$("body").visualEffect("highlight");', @response.body
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_fr_xhr
|
355
|
+
Locale.set('fr')
|
356
|
+
test_xhr
|
357
|
+
end
|
358
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ModelTest < Test::Unit::TestCase
|
4
|
+
include Globalize
|
5
|
+
|
6
|
+
fixtures :globalize_languages
|
7
|
+
|
8
|
+
def setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_language
|
12
|
+
rfc = RFC_3066.parse 'en-US'
|
13
|
+
lang = Language.pick(rfc)
|
14
|
+
assert_equal 'en', lang.code
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../config/environment')
|
3
|
+
require 'logger'
|
4
|
+
require 'test_help'
|
5
|
+
|
6
|
+
def inflate_schema(source, dest)
|
7
|
+
File.open(dest, 'w') do |f|
|
8
|
+
Zlib::GzipReader.open(source) do |gzip|
|
9
|
+
gzip.each do |line|
|
10
|
+
line.chomp!
|
11
|
+
f.puts line
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
plugin_path = RAILS_ROOT + "/vendor/plugins/globalize"
|
18
|
+
|
19
|
+
config_location = plugin_path + "/test/config/database.yml"
|
20
|
+
|
21
|
+
config = YAML::load(ERB.new(IO.read(config_location)).result)
|
22
|
+
ActiveRecord::Base.logger = Logger.new(plugin_path + "/test/log/test.log")
|
23
|
+
ActiveRecord::Base.establish_connection(config['test'])
|
24
|
+
|
25
|
+
mig_file = plugin_path + "/test/db/migrate/001_globalize_migration.rb"
|
26
|
+
gzipped_file = plugin_path + "/generators/globalize/templates/tiny_migration.rb.gz"
|
27
|
+
inflate_schema(gzipped_file, mig_file)
|
28
|
+
|
29
|
+
ActiveRecord::Migrator.migrate(plugin_path + "/test/db/migrate/", nil)
|
30
|
+
Test::Unit::TestCase.fixture_path = plugin_path + "/test/fixtures/"
|
31
|
+
|
32
|
+
$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
|
33
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../../config/environment')
|
3
|
+
require 'logger'
|
4
|
+
require 'test_help'
|
5
|
+
|
6
|
+
plugin_path = RAILS_ROOT + "/vendor/plugins/globalize"
|
7
|
+
|
8
|
+
config_location = plugin_path + "/test/config/database.yml"
|
9
|
+
|
10
|
+
config = YAML::load(ERB.new(IO.read(config_location)).result)
|
11
|
+
ActiveRecord::Base.logger = Logger.new(plugin_path + "/test/log/test.log")
|
12
|
+
ActiveRecord::Base.establish_connection(config['test'])
|
13
|
+
|
14
|
+
schema_file = plugin_path + "/test/db/schema.rb"
|
15
|
+
load(schema_file) if File.exist?(schema_file)
|
16
|
+
|
17
|
+
Test::Unit::TestCase.fixture_path = plugin_path + "/test/fixtures/"
|
18
|
+
|
19
|
+
$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/standard_data_test_helper'
|
2
|
+
|
3
|
+
class TestStandardData < Test::Unit::TestCase
|
4
|
+
include Globalize
|
5
|
+
|
6
|
+
def setup
|
7
|
+
Locale.clear_cache
|
8
|
+
Locale.set("en-US")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_numbers
|
12
|
+
assert_equal "23,123,456", 23123456.localize
|
13
|
+
assert_equal "23,123,456.45625", 23123456.45625.localize
|
14
|
+
Locale.set("de-DE")
|
15
|
+
assert_equal "23.123.456", 23123456.localize
|
16
|
+
assert_equal "23.123.456,45625", 23123456.45625.localize
|
17
|
+
Locale.set("de-CH")
|
18
|
+
assert_equal "23'123'456", 23123456.localize
|
19
|
+
assert_equal "23'123'456,45625", 23123456.45625.localize
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_indian_scheme
|
23
|
+
Locale.set("en-IN")
|
24
|
+
assert_equal "2,31,23,456", 23123456.localize
|
25
|
+
assert_equal "23,12,34,56,789", 23123456789.localize
|
26
|
+
assert_equal "2,31,23,456.45625", 23123456.45625.localize
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_times
|
30
|
+
t = Time.mktime(2005, 10, 17, 0, 0, 0, 0)
|
31
|
+
assert_equal "Mon Oct 17", t.localize("%a %b %d")
|
32
|
+
Locale.set("he-IL")
|
33
|
+
assert_equal "יום ב', 17 אוק 2005", t.localize("%a, %d %b %Y")
|
34
|
+
assert_equal "2005-10-17", t.localize("%c")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_dates
|
38
|
+
d = Date.new(2005, 10, 17)
|
39
|
+
assert_equal "Mon Oct 17", d.localize("%a %b %d")
|
40
|
+
Locale.set("he-IL")
|
41
|
+
assert_equal "יום ב', 17 אוק 2005", d.localize("%a, %d %b %Y")
|
42
|
+
assert_equal "2005-10-17", d.localize("%c")
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_nil_locale
|
46
|
+
Locale.set(nil)
|
47
|
+
assert_equal "12345", 12345.localize
|
48
|
+
assert_equal "Not translated", _("Not translated")
|
49
|
+
end
|
50
|
+
|
51
|
+
def teardown
|
52
|
+
Locale.set("en-US")
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ValidationTest < Test::Unit::TestCase
|
4
|
+
include Globalize
|
5
|
+
|
6
|
+
fixtures :globalize_languages, :globalize_countries,
|
7
|
+
:globalize_translations, :globalize_products
|
8
|
+
|
9
|
+
class Product < ActiveRecord::Base
|
10
|
+
set_table_name "globalize_products"
|
11
|
+
|
12
|
+
validates_length_of :name, :minimum => 5
|
13
|
+
validates_length_of :specs, :maximum => 10
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup
|
17
|
+
Globalize::Locale.set("he-IL")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_max_validation
|
21
|
+
prod = Product.find(2)
|
22
|
+
assert !prod.valid?
|
23
|
+
assert_equal "המפרט ארוך מדי (המקסימום הוא 10 תווים)", prod.errors.full_messages[1]
|
24
|
+
|
25
|
+
prod = Product.find(3)
|
26
|
+
assert !prod.valid?
|
27
|
+
assert_equal "Name is too short (minimum is 5 characters)", prod.errors.full_messages.first
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class ViewPickingTest < Test::Unit::TestCase
|
4
|
+
include Globalize
|
5
|
+
fixtures :globalize_languages, :globalize_countries
|
6
|
+
|
7
|
+
class TestController < ActionView::Base
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Locale.set("en-US")
|
12
|
+
@base_path = File.dirname(__FILE__) + '/views'
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_first
|
16
|
+
tc = TestController.new
|
17
|
+
tc.base_path = @base_path
|
18
|
+
assert_match /English/, tc.render("test")
|
19
|
+
assert_no_match /Hebrew/, tc.render("test")
|
20
|
+
Locale.set("he-IL")
|
21
|
+
assert_match /Hebrew/, tc.render("test")
|
22
|
+
assert_no_match /English/, tc.render("test")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_non_full_path
|
26
|
+
tc = TestController.new
|
27
|
+
tc.base_path = @base_path
|
28
|
+
assert_match /English/, tc.render_file("#{@base_path}/test.rhtml", false)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_nil
|
32
|
+
Locale.set(nil)
|
33
|
+
tc = TestController.new
|
34
|
+
tc.base_path = @base_path
|
35
|
+
assert_match /English/, tc.render("test")
|
36
|
+
assert_no_match /Hebrew/, tc.render("test")
|
37
|
+
Locale.set("he-IL")
|
38
|
+
assert_match /Hebrew/, tc.render("test")
|
39
|
+
assert_no_match /English/, tc.render("test")
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_non_full_path_nil
|
43
|
+
Locale.set(nil)
|
44
|
+
tc = TestController.new
|
45
|
+
tc.base_path = @base_path
|
46
|
+
assert_match /English/, tc.render_file("#{@base_path}/test.rhtml", false)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|