motiro 0.6.3
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/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,86 @@
|
|
|
1
|
+
# Motiro - A project tracking tool
|
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
19
|
+
|
|
20
|
+
require 'stringio'
|
|
21
|
+
|
|
22
|
+
require 'reporters/svn_settings'
|
|
23
|
+
|
|
24
|
+
EXPECTED_FILE_NAME = File.expand_path(File.dirname(__FILE__) +
|
|
25
|
+
'../../../config/motiro.yml')
|
|
26
|
+
|
|
27
|
+
class SubversionSettingsProviderTest < Test::Unit::TestCase
|
|
28
|
+
|
|
29
|
+
def setup
|
|
30
|
+
@opener = FlexMock.new
|
|
31
|
+
|
|
32
|
+
@opener.should_receive(:open).with(EXPECTED_FILE_NAME).
|
|
33
|
+
zero_or_more_times.
|
|
34
|
+
returns do
|
|
35
|
+
StringIO.new( "package_size: 8\n" +
|
|
36
|
+
"update_interval: 10\n" +
|
|
37
|
+
"subversion:\n" +
|
|
38
|
+
" repo: svn://svn.berlios.de/motiro\n")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
@provider = SubversionSettingsProvider.new(@opener)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_fetches_repo_url
|
|
45
|
+
assert_equal 'svn://svn.berlios.de/motiro', @provider.repo_url
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_returns_nil_when_credentials_not_specified
|
|
49
|
+
assert_nil @provider.repo_user
|
|
50
|
+
assert_nil @provider.repo_password
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def teardown
|
|
54
|
+
@opener.mock_verify
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#TODO ill-formed yaml
|
|
58
|
+
#TODO one or more options not present in the file
|
|
59
|
+
#TODO file does not exist
|
|
60
|
+
#TODO somebody messed the config file and placed a non-number on package_size
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class SubversionSettingsProviderAuthenticatedTest < Test::Unit::TestCase
|
|
65
|
+
|
|
66
|
+
def test_fetches_credentials
|
|
67
|
+
FlexMock.use do |opener|
|
|
68
|
+
opener.should_receive(:open).with(EXPECTED_FILE_NAME).
|
|
69
|
+
zero_or_more_times.
|
|
70
|
+
returns do
|
|
71
|
+
StringIO.new( "package_size: 8\n" +
|
|
72
|
+
"update_interval: 10\n" +
|
|
73
|
+
"subversion:\n" +
|
|
74
|
+
" repo: svn://svn.berlios.de/motiro\n" +
|
|
75
|
+
" user: eddie\n" +
|
|
76
|
+
" password: vedder\n")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
provider = SubversionSettingsProvider.new(opener)
|
|
80
|
+
|
|
81
|
+
assert_equal 'eddie', provider.repo_user
|
|
82
|
+
assert_equal 'vedder', provider.repo_password
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
# Multiple languages can be specified for a page. Languages are identified
|
|
4
|
+
# by a line starting with three dashes, followed by a language/locale string
|
|
5
|
+
# followed by three or more dashes.
|
|
6
|
+
#
|
|
7
|
+
# lang_separator: '--- ' locale ' ---' ('-')*
|
|
8
|
+
class TranslatorTest < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
EN_ONLY = "This is the default locale text"
|
|
11
|
+
|
|
12
|
+
EN_PT = "This is the default locale text\n\n" +
|
|
13
|
+
"--- pt-BR -----\n\n" +
|
|
14
|
+
"Este é o texto em português."
|
|
15
|
+
|
|
16
|
+
EN_PT_DE = "Welcome to Motiro\n\n" +
|
|
17
|
+
"--- pt-BR -----\n" +
|
|
18
|
+
"Bem-vindo ao Motiro\n\n" +
|
|
19
|
+
"--- de -----\n" +
|
|
20
|
+
"Wilkommen zum Motiro"
|
|
21
|
+
|
|
22
|
+
EN_PT_PT = "Motiro updated\n\n" +
|
|
23
|
+
"--- pt-BR -----\n" +
|
|
24
|
+
"Motiro atualizado\n\n" +
|
|
25
|
+
"--- pt-PT -----\n" +
|
|
26
|
+
"Motiro actualizado"
|
|
27
|
+
|
|
28
|
+
def test_default_locale_with_translation_available
|
|
29
|
+
assert_equal "This is the default locale text\n\n",
|
|
30
|
+
Translator.default.localize(EN_PT)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_default_locale_without_available_translation
|
|
34
|
+
assert_equal "This is the default locale text",
|
|
35
|
+
Translator.default.localize(EN_ONLY)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_resorts_to_default_locale_when_translation_not_available
|
|
39
|
+
assert_equal "This is the default locale text\n\n",
|
|
40
|
+
Translator.for('de').localize(EN_PT)
|
|
41
|
+
assert_equal "This is the default locale text",
|
|
42
|
+
Translator.for('de').localize(EN_ONLY)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_locates_right_translation_for_fully_matching_locale_code
|
|
46
|
+
assert_equal "Este é o texto em português.",
|
|
47
|
+
Translator.for('pt-BR').localize(EN_PT)
|
|
48
|
+
assert_equal "Bem-vindo ao Motiro\n\n",
|
|
49
|
+
Translator.for('pt-BR').localize(EN_PT_DE)
|
|
50
|
+
assert_equal "Wilkommen zum Motiro",
|
|
51
|
+
Translator.for('de').localize(EN_PT_DE)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_locates_right_translation_using_language_code_only
|
|
55
|
+
assert_equal "Este é o texto em português.",
|
|
56
|
+
Translator.for('pt').localize(EN_PT)
|
|
57
|
+
assert_equal "Bem-vindo ao Motiro\n\n",
|
|
58
|
+
Translator.for('pt').localize(EN_PT_DE)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_resorts_to_matching_language_code_only_when_locale_not_found
|
|
62
|
+
assert_equal "Bem-vindo ao Motiro\n\n",
|
|
63
|
+
Translator.for('pt-AO').localize(EN_PT_DE)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_locates_most_specific_locale_when_available
|
|
67
|
+
assert_equal "Motiro actualizado",
|
|
68
|
+
Translator.for('pt-PT').localize(EN_PT_PT)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_nil_locale_code_is_the_same_as_default
|
|
72
|
+
assert_same Translator.default, Translator.for(nil)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_recognizes_languages_with_carriage_return_characters
|
|
76
|
+
input = "= Motiro =\n\nBem-vindo ao Motiro\n\r\n" +
|
|
77
|
+
"--- en ---------\r\n" +
|
|
78
|
+
"= Motiro =\n\nWelcome to Motiro\n\n" +
|
|
79
|
+
"--- de ---------\n" +
|
|
80
|
+
"= Motiro =\n\nWillkommen zum Motiro\n\n"
|
|
81
|
+
assert_equal "= Motiro =\n\nBem-vindo ao Motiro\n\r\n",
|
|
82
|
+
Translator.default.localize(input)
|
|
83
|
+
assert_equal "= Motiro =\n\nWelcome to Motiro\n\n",
|
|
84
|
+
Translator.for('en').localize(input)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_strips_extra_blank_lines_after_language_separator
|
|
88
|
+
input = "= Motiro =\n\nBem-vindo ao Motiro\n\n" +
|
|
89
|
+
"--- en ---------\n" +
|
|
90
|
+
"\n\n= Motiro =\n\nWelcome to Motiro\n\n"
|
|
91
|
+
|
|
92
|
+
assert_equal "= Motiro =\n\nWelcome to Motiro\n\n",
|
|
93
|
+
Translator.for('en').localize(input)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Motiro - A project tracking tool
|
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
19
|
+
|
|
20
|
+
class UserTest < Test::Unit::TestCase
|
|
21
|
+
|
|
22
|
+
self.use_instantiated_fixtures = true
|
|
23
|
+
|
|
24
|
+
fixtures :users, :pages
|
|
25
|
+
|
|
26
|
+
def test_auth
|
|
27
|
+
|
|
28
|
+
assert_equal @bob, User.authenticate("bob", "test")
|
|
29
|
+
assert_nil User.authenticate("nonbob", "test")
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_disallowed_passwords
|
|
34
|
+
|
|
35
|
+
u = User.new
|
|
36
|
+
u.login = "nonbob"
|
|
37
|
+
|
|
38
|
+
u.password = u.password_confirmation = "tiny"
|
|
39
|
+
assert !u.save
|
|
40
|
+
assert u.errors.invalid?('password')
|
|
41
|
+
|
|
42
|
+
u.password = u.password_confirmation = "hugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehugehuge"
|
|
43
|
+
assert !u.save
|
|
44
|
+
assert u.errors.invalid?('password')
|
|
45
|
+
|
|
46
|
+
u.password = u.password_confirmation = ""
|
|
47
|
+
assert !u.save
|
|
48
|
+
assert u.errors.invalid?('password')
|
|
49
|
+
|
|
50
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
|
51
|
+
assert u.save
|
|
52
|
+
assert u.errors.empty?
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_bad_logins
|
|
57
|
+
|
|
58
|
+
u = User.new
|
|
59
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
|
60
|
+
|
|
61
|
+
u.login = "x"
|
|
62
|
+
assert !u.save
|
|
63
|
+
assert u.errors.invalid?('login')
|
|
64
|
+
|
|
65
|
+
u.login = "hugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhugebobhug"
|
|
66
|
+
assert !u.save
|
|
67
|
+
assert u.errors.invalid?('login')
|
|
68
|
+
|
|
69
|
+
u.login = ""
|
|
70
|
+
assert !u.save
|
|
71
|
+
assert u.errors.invalid?('login')
|
|
72
|
+
|
|
73
|
+
u.login = "okbob"
|
|
74
|
+
assert u.save
|
|
75
|
+
assert u.errors.empty?
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_collision
|
|
81
|
+
u = User.new
|
|
82
|
+
u.login = "existingbob"
|
|
83
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
|
84
|
+
assert !u.save
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_create
|
|
89
|
+
u = User.new
|
|
90
|
+
u.login = "nonexistingbob"
|
|
91
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
|
92
|
+
|
|
93
|
+
assert u.save
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def test_sha1
|
|
98
|
+
u = User.new
|
|
99
|
+
u.login = "nonexistingbob"
|
|
100
|
+
u.password = u.password_confirmation = "bobs_secure_password"
|
|
101
|
+
assert u.save
|
|
102
|
+
|
|
103
|
+
assert_equal '352ebf77709ac891cd242c2ec74fa20a3726c1f8', u.password
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_page_edition_authorization
|
|
107
|
+
u = User.new(:login => 'john')
|
|
108
|
+
attrs = { :name => 'TestPage', :text => '' }
|
|
109
|
+
|
|
110
|
+
assert u.can_edit?(Page.new(attrs.merge(:editors => 'john')))
|
|
111
|
+
assert !u.can_edit?(Page.new(attrs.merge(:editors => 'eric')))
|
|
112
|
+
assert u.can_edit?(Page.new(attrs.merge(:editors => ' ')))
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_original_author_can_always_edit_page
|
|
116
|
+
bob = users('bob')
|
|
117
|
+
john = users('john')
|
|
118
|
+
bobs_page = pages('bob_and_erics_page')
|
|
119
|
+
|
|
120
|
+
bobs_page.editors = 'john'
|
|
121
|
+
assert john.can_edit?(bobs_page)
|
|
122
|
+
assert bob.can_edit?(bobs_page)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Motiro - A project tracking tool
|
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
19
|
+
|
|
20
|
+
require 'stubs/url_generator'
|
|
21
|
+
|
|
22
|
+
class WikiRendererTest < Test::Unit::TestCase
|
|
23
|
+
|
|
24
|
+
attr_reader :renderer
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
@renderer = WikiRenderer.new(url_generator)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_renders_title
|
|
31
|
+
assert_equal "<h1>Motiro</h1>", renderer.render_html('= Motiro =')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_breaks_paragraphs_on_linebreak_and_return_feed
|
|
35
|
+
line_break_only_text = "= Motiro =\n\nThis is project Motiro"
|
|
36
|
+
feed_return_text = "= Motiro =\r\n\r\nThis is project Motiro"
|
|
37
|
+
expected_text = '<h1>Motiro</h1><p>This is project Motiro</p>'
|
|
38
|
+
|
|
39
|
+
assert_equal expected_text, renderer.render_html(line_break_only_text)
|
|
40
|
+
assert_equal expected_text, renderer.render_html(feed_return_text)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_render_external_links
|
|
44
|
+
expected = "<p><a href=\"http://nowhere.com\" rel=\"nofollow\">Nowhere</a></p>"
|
|
45
|
+
assert_equal expected, renderer.render_html('[http://nowhere.com Nowhere]')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_renders_multiple_languages
|
|
49
|
+
wiki_text = "Bem-vindo ao Motiro\n\n" +
|
|
50
|
+
"--- en ---\n" +
|
|
51
|
+
"Welcome to Motiro"
|
|
52
|
+
assert_equal "<p>Bem-vindo ao Motiro</p>", renderer.render_html(wiki_text)
|
|
53
|
+
assert_equal "<p>Welcome to Motiro</p>",
|
|
54
|
+
WikiRenderer.new(url_generator, 'en').render_html(wiki_text)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_renders_internal_link
|
|
58
|
+
expected = "<p><a href=\"http://test.host/wiki/show/AnotherPage\" rel=\"nofollow\">go somewhere else</a></p>"
|
|
59
|
+
assert_equal expected, renderer.render_html('[AnotherPage go somewhere else]')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_renders_multiple_internal_links
|
|
63
|
+
expected = "<p><a href=\"http://test.host/wiki/show/InternalPage\" rel=\"nofollow\">go there</a> <a href=\"http://test.host/wiki/show/OtherInternalPage\" rel=\"nofollow\">and there</a></p>"
|
|
64
|
+
assert_equal expected, renderer.render_html("[InternalPage go there] " +
|
|
65
|
+
"[OtherInternalPage and there]")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_do_not_expand_links_when_there_is_a_break_inside_the_brackets
|
|
69
|
+
expected = "<p>[ThisIsNotALink\nto anywhere]</p>"
|
|
70
|
+
assert_equal expected, renderer.render_html("[ThisIsNotALink\nto anywhere]")
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_expands_internal_links_with_address_only
|
|
74
|
+
expected = "<p><a href=\"http://test.host/wiki/show/AnotherPage\" rel=\"nofollow\">AnotherPage</a></p>"
|
|
75
|
+
assert_equal expected, renderer.render_html("[AnotherPage]")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_recover_from_unmatched_opening_bracket_inside_link_text
|
|
79
|
+
assert_equal "<p><a href=\"http://test.host/wiki/show/SomeoneMistankenly\" rel=\"nofollow\">placed an opening bracket [ inside the link text, but Motiro managed to recover correctly</a></p>",
|
|
80
|
+
renderer.render_html("[SomeoneMistankenly placed an opening bracket [ inside the link text, but Motiro managed to recover correctly]")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def url_generator; TestingUrlGenerator.new; end
|
|
86
|
+
|
|
87
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Motiro - A project tracking tool
|
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
19
|
+
|
|
20
|
+
NEW_EVENT_BUTTON =
|
|
21
|
+
"if current_user.nil?; " +
|
|
22
|
+
" content_tag('span', 'Add'.t, :class => 'disabled'); " +
|
|
23
|
+
"else; " +
|
|
24
|
+
" link_to( 'Add'.t, :controller => 'wiki', " +
|
|
25
|
+
":action => 'new', :kind => 'event'); " +
|
|
26
|
+
"end;"
|
|
27
|
+
|
|
28
|
+
NEW_FEATURE_BUTTON =
|
|
29
|
+
"if current_user.nil?; " +
|
|
30
|
+
" content_tag('span', 'Add'.t, :class => 'disabled'); " +
|
|
31
|
+
"else; " +
|
|
32
|
+
" link_to( 'Add'.t, :controller => 'wiki', " +
|
|
33
|
+
":action => 'new', :kind => 'feature'); " +
|
|
34
|
+
"end;"
|
|
35
|
+
|
|
36
|
+
class WikiReporterTest < Test::Unit::TestCase
|
|
37
|
+
|
|
38
|
+
def button; MotiroReporter.button; end
|
|
39
|
+
|
|
40
|
+
def test_title
|
|
41
|
+
assert_equal 'Recently changed suggestions', FeaturesReporter.new.channel_title
|
|
42
|
+
assert_equal 'Scheduled events', EventsReporter.new.channel_title
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_button
|
|
46
|
+
assert_equal [button[:older], NEW_FEATURE_BUTTON], FeaturesReporter.new.buttons
|
|
47
|
+
assert_equal [button[:older], NEW_EVENT_BUTTON], EventsReporter.new.buttons
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_kind
|
|
51
|
+
FlexMock.use do |page_provider|
|
|
52
|
+
page_provider.should_receive(:find).
|
|
53
|
+
once.and_return([]).
|
|
54
|
+
with(:all, :conditions => "kind = 'feature'",
|
|
55
|
+
:order => 'modified_at DESC')
|
|
56
|
+
page_provider.should_receive(:find).
|
|
57
|
+
once.and_return([]).
|
|
58
|
+
with(:all, :conditions => "kind = 'event'",
|
|
59
|
+
:order => 'happens_at DESC')
|
|
60
|
+
|
|
61
|
+
FeaturesReporter.new(:page_provider => page_provider).headlines
|
|
62
|
+
EventsReporter.new(:page_provider => page_provider).headlines
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_features_reporter_uses_modification_time
|
|
67
|
+
FlexMock.use do |page_provider|
|
|
68
|
+
mod_time = Time.local(2007, 1, 19, 15, 23, 8)
|
|
69
|
+
page_provider.should_receive(:find).
|
|
70
|
+
zero_or_more_times.
|
|
71
|
+
and_return([Page.new(:name => 'FeaturePage',
|
|
72
|
+
:last_editor => User.new(:login => 'arrais'),
|
|
73
|
+
:modified_at => mod_time,
|
|
74
|
+
:title => 'Feature page')])
|
|
75
|
+
hl = FeaturesReporter.new(:page_provider => page_provider).headlines[0]
|
|
76
|
+
assert_equal mod_time, hl.happened_at
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_events_reporter_uses_planned_date
|
|
81
|
+
FlexMock.use do |page_provider|
|
|
82
|
+
planned_date = Date.civil(2007, 1, 19)
|
|
83
|
+
page_provider.should_receive(:find).
|
|
84
|
+
zero_or_more_times.
|
|
85
|
+
and_return([Page.new(:name => 'FeaturePage',
|
|
86
|
+
:last_editor => User.new(:login => 'arrais'),
|
|
87
|
+
:happens_at => planned_date,
|
|
88
|
+
:title => 'Feature page')])
|
|
89
|
+
hl = EventsReporter.new(:page_provider => page_provider).headlines[0]
|
|
90
|
+
assert_equal planned_date.to_t, hl.happened_at
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Motiro - A project tracking tool
|
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
19
|
+
|
|
20
|
+
class WikiUrlGeneratorTest < Test::Unit::TestCase
|
|
21
|
+
|
|
22
|
+
def test_delegates_generation_to_controller
|
|
23
|
+
FlexMock.use do |cont|
|
|
24
|
+
cont.should_receive(:server_url_for).once.returns('a').
|
|
25
|
+
with(:controller => 'wiki', :action => 'show', :page_name => 'MyPage')
|
|
26
|
+
|
|
27
|
+
assert_equal 'a', WikiUrlGenerator.new(cont).generate_url_for('MyPage')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Motiro - A project tracking tool
|
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
7
|
+
# any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License
|
|
15
|
+
# along with this program; if not, write to the Free Software
|
|
16
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17
|
+
|
|
18
|
+
require 'rubygems'
|
|
19
|
+
require 'rails-installer'
|
|
20
|
+
|
|
21
|
+
# motiro-installer.rb includes some patches to rails-app-installer that
|
|
22
|
+
# make it work on most win32 environments
|
|
23
|
+
module Kernel
|
|
24
|
+
def sistem(cmd)
|
|
25
|
+
system("echo | #{cmd}")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class RailsInstaller
|
|
30
|
+
|
|
31
|
+
def pre_migrate_database
|
|
32
|
+
old_schema_version = get_schema_version
|
|
33
|
+
new_schema_version = File.read(File.join(source_directory,'db','schema_version')).to_i
|
|
34
|
+
|
|
35
|
+
return unless old_schema_version > 0
|
|
36
|
+
|
|
37
|
+
# Are we downgrading?
|
|
38
|
+
if old_schema_version > new_schema_version
|
|
39
|
+
message "Downgrading schema from #{old_schema_version} to #{new_schema_version}"
|
|
40
|
+
|
|
41
|
+
in_directory install_directory do
|
|
42
|
+
unless sistem("rake -s migrate VERSION=#{new_schema_version}")
|
|
43
|
+
raise InstallFailed, "Downgrade migrating from #{old_schema_version} to #{new_schema_version} failed."
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def migrate
|
|
50
|
+
message "Migrating #{@@app_name.capitalize}'s database to newest release"
|
|
51
|
+
|
|
52
|
+
in_directory install_directory do
|
|
53
|
+
unless sistem("rake -s migrate")
|
|
54
|
+
raise InstallFailed, "Migration failed"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def system_silently(command)
|
|
60
|
+
if RUBY_PLATFORM =~ /mswin32/
|
|
61
|
+
null = 'NUL:'
|
|
62
|
+
else
|
|
63
|
+
null = '/dev/null'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
sistem("#{command} > #{null} 2> #{null}")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class Database
|
|
70
|
+
class Postgresql < RailsInstaller::Database
|
|
71
|
+
def self.create_database(installer)
|
|
72
|
+
installer.message "Creating PostgreSQL database"
|
|
73
|
+
sistem("createdb -U #{db_user installer} #{db_name installer}")
|
|
74
|
+
sistem("createdb -U #{db_user installer} #{db_name installer}-test")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class Mysql < RailsInstaller::Database
|
|
79
|
+
def self.create_database(installer)
|
|
80
|
+
installer.message "Creating MySQL database"
|
|
81
|
+
base_command = "mysql -u #{db_user installer} "
|
|
82
|
+
base_command << "-p#{installer.config['db_password']}" if installer.config['db_password']
|
|
83
|
+
sistem("#{base_command} -e 'create database #{db_name installer}'")
|
|
84
|
+
sistem("#{base_command} -e 'create database #{db_name installer}_test'")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class WebServer
|
|
90
|
+
class Mongrel < RailsInstaller::WebServer
|
|
91
|
+
def self.start(installer, foreground)
|
|
92
|
+
args = {}
|
|
93
|
+
args['-p'] = installer.config['port-number']
|
|
94
|
+
args['-a'] = installer.config['bind-address']
|
|
95
|
+
args['-e'] = installer.config['rails-environment']
|
|
96
|
+
args['-d'] = foreground
|
|
97
|
+
args['-P'] = pid_file(installer)
|
|
98
|
+
args['--prefix'] = installer.config['url-prefix']
|
|
99
|
+
|
|
100
|
+
# Remove keys with nil values
|
|
101
|
+
args.delete_if {|k,v| v==nil}
|
|
102
|
+
|
|
103
|
+
args_array = args.to_a.flatten.map {|e| e.to_s}
|
|
104
|
+
args_array = ['mongrel_rails', 'start', installer.install_directory] + args_array
|
|
105
|
+
installer.message "Starting #{installer.app_name.capitalize} on port #{installer.config['port-number']}"
|
|
106
|
+
in_directory installer.install_directory do
|
|
107
|
+
sistem(args_array.join(' '))
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def self.stop(installer)
|
|
112
|
+
args = {}
|
|
113
|
+
args['-P'] = pid_file(installer)
|
|
114
|
+
|
|
115
|
+
args_array = args.to_a.flatten.map {|e| e.to_s}
|
|
116
|
+
args_array = ['mongrel_rails', 'stop', installer.install_directory] + args_array
|
|
117
|
+
installer.message "Stopping #{installer.app_name.capitalize}"
|
|
118
|
+
in_directory installer.install_directory do
|
|
119
|
+
sistem(args_array.join(' '))
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
class MongrelCluster < RailsInstaller::WebServer
|
|
126
|
+
def self.start(installer, foreground)
|
|
127
|
+
args = {}
|
|
128
|
+
args['-p'] = installer.config['port-number']
|
|
129
|
+
args['-a'] = installer.config['bind-address']
|
|
130
|
+
args['-e'] = installer.config['rails-environment']
|
|
131
|
+
args['-N'] = installer.config['threads']
|
|
132
|
+
args['--prefix'] = installer.config['url-prefix']
|
|
133
|
+
|
|
134
|
+
# Remove keys with nil values
|
|
135
|
+
args.delete_if {|k,v| v==nil}
|
|
136
|
+
|
|
137
|
+
args_array = args.to_a.flatten.map {|e| e.to_s}
|
|
138
|
+
args_array = ['mongrel_rails', 'cluster::configure'] + args_array
|
|
139
|
+
installer.message "Configuring mongrel_cluster for #{installer.app_name.capitalize}"
|
|
140
|
+
in_directory installer.install_directory do
|
|
141
|
+
sistem(args_array.join(' '))
|
|
142
|
+
end
|
|
143
|
+
installer.message "Starting #{installer.app_name.capitalize} on port #{installer.config['port-number']}"
|
|
144
|
+
in_directory installer.install_directory do
|
|
145
|
+
sistem('mongrel_rails cluster::start')
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def self.stop(installer)
|
|
151
|
+
installer.message "Stopping #{installer.app_name.capitalize}"
|
|
152
|
+
in_directory installer.install_directory do
|
|
153
|
+
sistem('mongrel_rails cluster::stop')
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright (c) 2005 Joshua Harvey [Jerusalem, Israel]
|
|
2
|
+
|
|
3
|
+
This is the MIT license, the license Ruby on Rails itself is licensed under.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|