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,259 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class HeadlineTest < Test::Unit::TestCase
|
|
4
|
+
fixtures :headlines, :changes
|
|
5
|
+
|
|
6
|
+
def test_create
|
|
7
|
+
headline = Headline.find(1)
|
|
8
|
+
|
|
9
|
+
assert_equal 'raulseixas', headline.author
|
|
10
|
+
assert_equal 'gita', headline.description
|
|
11
|
+
assert_equal Time.local(2005, 1, 1), headline.happened_at
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_latest_one
|
|
15
|
+
hls = Headline.latest(1, 'subversion')
|
|
16
|
+
hl = hls.first
|
|
17
|
+
|
|
18
|
+
assert_equal 'o dia em que a terra parou', hl.description
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_cached
|
|
22
|
+
svn_demo_headline = headlines('svn_demo_headline')
|
|
23
|
+
headline = Headline.new(:author => svn_demo_headline.author,
|
|
24
|
+
:description => svn_demo_headline.description,
|
|
25
|
+
:happened_at => [2006, 03, 23, 11, 10, 04])
|
|
26
|
+
|
|
27
|
+
assert headline.cached?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_not_cached
|
|
31
|
+
headline = Headline.new(:author => 'chicobuarque',
|
|
32
|
+
:description => 'a banda',
|
|
33
|
+
:happened_at => [1983, 1, 1])
|
|
34
|
+
|
|
35
|
+
assert ! headline.cached?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_record_time
|
|
39
|
+
headline = Headline.new(:author => 'thiagoarrais',
|
|
40
|
+
:description => 'fiz besteira',
|
|
41
|
+
:happened_at => [1983, 1, 1, 00, 15, 12])
|
|
42
|
+
|
|
43
|
+
headline.save
|
|
44
|
+
|
|
45
|
+
headline = Headline.find(:first,
|
|
46
|
+
:conditions => "author = 'thiagoarrais' and description = 'fiz besteira'")
|
|
47
|
+
|
|
48
|
+
assert_equal Time.local(1983, 1, 1, 00, 15, 12), headline.happened_at
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_cache_with_date_time
|
|
52
|
+
aHeadline = Headline.new(:author => 'thiagoarrais',
|
|
53
|
+
:description => 'fiz besteira',
|
|
54
|
+
:happened_at => [1983, 1, 1, 00, 15, 12])
|
|
55
|
+
aHeadline.save
|
|
56
|
+
|
|
57
|
+
assert aHeadline.cached?
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_cache_new
|
|
61
|
+
aHeadline = Headline.new(:author => 'herbertvianna',
|
|
62
|
+
:description => 'this is a new headline',
|
|
63
|
+
:happened_at => [1983, 1, 1, 00, 15, 12])
|
|
64
|
+
|
|
65
|
+
aHeadline.cache
|
|
66
|
+
|
|
67
|
+
hls = Headline.find(:all, :conditions => ['author = ?', 'herbertvianna'])
|
|
68
|
+
assert_equal(1, hls.size)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_cache_already_recorded
|
|
72
|
+
contents = { :author => 'zeramalho',
|
|
73
|
+
:description => 'we will try to cache this headline twice',
|
|
74
|
+
:happened_at => [1983, 8, 8, 07, 15, 12] }
|
|
75
|
+
Headline.new(contents).cache
|
|
76
|
+
Headline.new(contents).cache
|
|
77
|
+
hls = Headline.find(:all, :conditions => ['author = ?', 'zeramalho'])
|
|
78
|
+
|
|
79
|
+
assert_equal(1, hls.size)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_search_by_reporter_name_and_rid
|
|
83
|
+
svn_demo_headline = headlines('svn_demo_headline')
|
|
84
|
+
aHeadline = Headline.find_with_reporter_and_rid(svn_demo_headline.reported_by,
|
|
85
|
+
svn_demo_headline.rid)
|
|
86
|
+
|
|
87
|
+
assert_not_nil aHeadline
|
|
88
|
+
assert_equal svn_demo_headline, aHeadline
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_not_filled
|
|
92
|
+
fst_change, snd_change = FlexMock.new, FlexMock.new
|
|
93
|
+
|
|
94
|
+
fst_change.should_receive(:filled?).
|
|
95
|
+
returns(true)
|
|
96
|
+
snd_change.should_receive(:filled?).
|
|
97
|
+
returns(false)
|
|
98
|
+
|
|
99
|
+
a_headline = create_headline_with_changes(fst_change, snd_change)
|
|
100
|
+
|
|
101
|
+
assert !a_headline.filled?
|
|
102
|
+
|
|
103
|
+
[fst_change, snd_change].each do |m|
|
|
104
|
+
m.mock_verify
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_filled
|
|
109
|
+
change = FlexMock.new
|
|
110
|
+
|
|
111
|
+
change.should_receive(:filled?).
|
|
112
|
+
returns(true)
|
|
113
|
+
|
|
114
|
+
a_headline = create_headline_with_changes(change, change)
|
|
115
|
+
|
|
116
|
+
assert a_headline.filled?
|
|
117
|
+
|
|
118
|
+
change.mock_verify
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_recaches_failed
|
|
122
|
+
filled_change = Change.new(:summary => 'A /trunk/app/models/headline.rb',
|
|
123
|
+
:resource_kind => 'file',
|
|
124
|
+
:diff => '+change')
|
|
125
|
+
failed_change = Change.new(:summary => 'A /trunk/test/unit/headline_test.rb',
|
|
126
|
+
:resource_kind => 'file',
|
|
127
|
+
:diff => nil)
|
|
128
|
+
|
|
129
|
+
a_headline = create_headline_with_changes(filled_change, failed_change)
|
|
130
|
+
|
|
131
|
+
a_headline.cache
|
|
132
|
+
|
|
133
|
+
failed_change.diff = '+def test_headline; end'
|
|
134
|
+
|
|
135
|
+
a_headline = create_headline_with_changes(filled_change, failed_change)
|
|
136
|
+
|
|
137
|
+
assert !a_headline.cached?
|
|
138
|
+
|
|
139
|
+
a_headline.cache
|
|
140
|
+
|
|
141
|
+
assert a_headline.cached?
|
|
142
|
+
|
|
143
|
+
hls = Headline.find(:all, :conditions => ["description = ?",
|
|
144
|
+
a_headline.description])
|
|
145
|
+
|
|
146
|
+
assert_equal 1, hls.size
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_empty_title_for_empty_description
|
|
150
|
+
a_headline= Headline.new(:author => 'thiagoarrais',
|
|
151
|
+
:reported_by => 'subversion',
|
|
152
|
+
:description => "\n")
|
|
153
|
+
|
|
154
|
+
assert_equal '', a_headline.title(Translator.for(nil))
|
|
155
|
+
assert_equal '', a_headline.title(Translator.for('en'))
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def test_translating_title
|
|
159
|
+
a_headline= Headline.new(:author => 'thiagoarrais',
|
|
160
|
+
:reported_by => 'subversion',
|
|
161
|
+
:description => "este eh o titulo da manchete\n" +
|
|
162
|
+
"\n" +
|
|
163
|
+
"--- en -----\n" +
|
|
164
|
+
"\n" +
|
|
165
|
+
"this is the headline title\n")
|
|
166
|
+
|
|
167
|
+
assert_equal 'this is the headline title',
|
|
168
|
+
a_headline.title(Translator.for('en'))
|
|
169
|
+
assert_equal 'este eh o titulo da manchete',
|
|
170
|
+
a_headline.title(Translator.for(nil))
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_set_title_on_construction_and_retrieve_it
|
|
174
|
+
a_headline = Headline.new(:author => 'thiagoarrais',
|
|
175
|
+
:title => 'this is the headline title',
|
|
176
|
+
:description => 'this is the description')
|
|
177
|
+
|
|
178
|
+
assert_equal 'this is the headline title', a_headline.title
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def test_translating_description
|
|
182
|
+
english_description = "this is the headline title\n" +
|
|
183
|
+
"\n" +
|
|
184
|
+
"these are some commit details\n\n"
|
|
185
|
+
portuguese_description = "este eh o titulo da manchete\n" +
|
|
186
|
+
"\n" +
|
|
187
|
+
"aqui vao os detalhes sobre o commit"
|
|
188
|
+
a_headline = Headline.new(:author => 'thiagoarrais',
|
|
189
|
+
:description => english_description +
|
|
190
|
+
"--- pt-BR ----\n\n" +
|
|
191
|
+
portuguese_description)
|
|
192
|
+
|
|
193
|
+
assert_equal english_description, a_headline.description(Translator.for('en'))
|
|
194
|
+
assert_equal portuguese_description, a_headline.description(Translator.for('pt-BR'))
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def test_unspecified_translation_returns_default_description
|
|
198
|
+
english_description = "this is the headline title\n" +
|
|
199
|
+
"\n" +
|
|
200
|
+
"these are some commit details\n\n"
|
|
201
|
+
portuguese_description = "este eh o titulo da manchete\n" +
|
|
202
|
+
"\n" +
|
|
203
|
+
"aqui vao os detalhes sobre o commit"
|
|
204
|
+
a_headline = Headline.new(:author => 'thiagoarrais',
|
|
205
|
+
:description => english_description +
|
|
206
|
+
"--- pt-BR ----\n\n" +
|
|
207
|
+
portuguese_description)
|
|
208
|
+
|
|
209
|
+
assert_equal english_description, a_headline.description
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def test_extracts_title_with_carriage_returns
|
|
213
|
+
a_headline = Headline.new :description => "this is the title\r\n\this is the description"
|
|
214
|
+
|
|
215
|
+
assert_equal 'this is the title', a_headline.title
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def test_does_not_recache_translated_headlines
|
|
219
|
+
contents = { :author => 'ritalee',
|
|
220
|
+
:description => "this is the english description\n" +
|
|
221
|
+
"\n" +
|
|
222
|
+
"--- pt-BR --------\n" +
|
|
223
|
+
"\n" +
|
|
224
|
+
"esta eh a descricao em portugues",
|
|
225
|
+
:happened_at => [2006, 07, 25, 19, 21, 43] }
|
|
226
|
+
|
|
227
|
+
Headline.new(contents).cache
|
|
228
|
+
Headline.new(contents).cache
|
|
229
|
+
hls = Headline.find(:all, :conditions => ['author = ?', 'ritalee'])
|
|
230
|
+
|
|
231
|
+
assert_equal(1, hls.size)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def test_retrieves_latest_filled_headline
|
|
235
|
+
hl = headlines(:svn_demo_headline)
|
|
236
|
+
assert_equal hl.rid, Headline.latest_filled_headline_rid_for(hl.reported_by)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def test_returns_nil_for_latest_rid_when_none_found
|
|
240
|
+
assert_nil Headline.latest_filled_headline_rid_for('not_a_reporter')
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
private
|
|
244
|
+
|
|
245
|
+
def create_headline_with_changes(*changes)
|
|
246
|
+
a_headline = Headline.new(:author => 'thiagoarrais',
|
|
247
|
+
:description => 'this is the headline title',
|
|
248
|
+
:reported_by => 'subversion',
|
|
249
|
+
:happened_at => [1983, 1, 1, 02, 15, 12],
|
|
250
|
+
:rid => 'r47')
|
|
251
|
+
|
|
252
|
+
changes.reverse.each do |c|
|
|
253
|
+
a_headline.changes.unshift(c)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
return a_headline
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
end
|
|
@@ -0,0 +1,145 @@
|
|
|
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 PageTest < Test::Unit::TestCase
|
|
21
|
+
fixtures :pages
|
|
22
|
+
|
|
23
|
+
def test_is_open_to_all
|
|
24
|
+
attrs = { :name => 'SomePage', :text => 'Page text' }
|
|
25
|
+
assert !Page.new(attrs.merge(:editors => 'john')).is_open_to_all?
|
|
26
|
+
assert Page.new(attrs.merge(:editors => '')).is_open_to_all?
|
|
27
|
+
assert Page.new(attrs.merge(:editors => ' ')).is_open_to_all?
|
|
28
|
+
assert !Page.new(attrs.merge(:editors => ' john ')).is_open_to_all?
|
|
29
|
+
assert Page.new(attrs.merge(:editors => "\n")).is_open_to_all?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_fresh_page_is_open_to_all
|
|
33
|
+
page = Page.new(:name => 'FreshPage')
|
|
34
|
+
|
|
35
|
+
assert page.is_open_to_all?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_fresh_page_has_empty_editors_list
|
|
39
|
+
page = Page.new(:name => 'AnotherFreshPage')
|
|
40
|
+
|
|
41
|
+
assert_equal 0, page.editors.size
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_page_name_is_title_camelized
|
|
45
|
+
page = Page.new(:title => 'How to write a Motiro page')
|
|
46
|
+
|
|
47
|
+
assert_equal 'HowToWriteAMotiroPage', page.name
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_user_entered_page_name_takes_precedence_over_camelized_title
|
|
51
|
+
page = Page.new(:name => 'MyFirstPageName')
|
|
52
|
+
page.title = 'My first page title'
|
|
53
|
+
|
|
54
|
+
assert_equal 'MyFirstPageName', page.name
|
|
55
|
+
|
|
56
|
+
page = Page.new(:title => 'My second page title')
|
|
57
|
+
page.name = 'MySecondPageName'
|
|
58
|
+
|
|
59
|
+
assert_equal 'MySecondPageName', page.name
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_converts_utf8_decorated_vowels_when_generating_name
|
|
63
|
+
assert_equal 'MinhaPagina', Page.new(:title => 'Minha página').name
|
|
64
|
+
assert_equal 'AaaaaEeeeIiiiiYyyOooooUuuuu',
|
|
65
|
+
Page.new(:title => 'ãàáâä èéêë ĩìíîï ÿýý õòóôö ũùúûü').name
|
|
66
|
+
assert_equal 'AaaaaEeeeIiiiiYyOooooUuuuu',
|
|
67
|
+
Page.new(:title => 'ÃÀÁÂÄ ÈÉÊË ĨÌÍÎÏ ÝŸ ÕÒÓÔÖ ŨÙÚÛÜ').name
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_converts_utf8_decorated_consonants_when_generating_name
|
|
71
|
+
assert_equal 'ElNino', Page.new(:title => 'El Niño').name
|
|
72
|
+
assert_equal 'NnCcSrlzNnCcSrlz',
|
|
73
|
+
Page.new(:title => 'ñń ćç śŕĺź ÑŃ ÇĆ ŚŔĹŹ').name
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_drops_non_alpha_numeric_characters_when_generating_name
|
|
77
|
+
assert_equal 'ThisHasLotsOfPunctuation',
|
|
78
|
+
Page.new(:title => 'This, has. lots! of? punctuation').name
|
|
79
|
+
assert_equal 'TitleWithSomeStrangeCharacters',
|
|
80
|
+
Page.new(:title => 'Title%with$some&strange*characters').name
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_resolve_clashing_page_names
|
|
84
|
+
fst_page = Page.new(:title => 'My first Motiro page', :text => '')
|
|
85
|
+
assert_equal 'MyFirstMotiroPage', fst_page.name
|
|
86
|
+
fst_page.save
|
|
87
|
+
|
|
88
|
+
snd_page = Page.new(:title => 'My first Motiro page', :text => '')
|
|
89
|
+
assert_equal 'MyFirstMotiroPage2', snd_page.name
|
|
90
|
+
snd_page.save
|
|
91
|
+
|
|
92
|
+
trd_page = Page.new(:title => 'My first Motiro page')
|
|
93
|
+
assert_equal 'MyFirstMotiroPage3', trd_page.name
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def test_uses_place_holder_title_when_nil
|
|
97
|
+
page = Page.new
|
|
98
|
+
|
|
99
|
+
assert_equal PLACE_HOLDER_TITLE.t, page.title
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def test_uses_place_holder_title_when_empty
|
|
103
|
+
page = Page.new(:title => '')
|
|
104
|
+
|
|
105
|
+
assert_equal PLACE_HOLDER_TITLE.t, page.title
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_translates_default_title
|
|
109
|
+
Locale.set 'pt-br'
|
|
110
|
+
|
|
111
|
+
assert_equal 'Digite o título aqui', Page.new.title
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_saves_default_title_based_on_page_kind_when_title_is_place_holder
|
|
115
|
+
common_page = Page.new
|
|
116
|
+
|
|
117
|
+
common_page.save
|
|
118
|
+
assert_equal 'Common page', common_page.title
|
|
119
|
+
|
|
120
|
+
feature_page = Page.new(:kind => 'feature')
|
|
121
|
+
feature_page.save
|
|
122
|
+
assert_equal 'Feature page', feature_page.title
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_numbers_titles_when_already_used
|
|
126
|
+
Page.new.save
|
|
127
|
+
|
|
128
|
+
snd_page = Page.new
|
|
129
|
+
snd_page.save
|
|
130
|
+
|
|
131
|
+
assert_equal 'Common page 2', snd_page.title
|
|
132
|
+
|
|
133
|
+
trd_page = Page.new
|
|
134
|
+
trd_page.save
|
|
135
|
+
|
|
136
|
+
assert_equal 'Common page 3', trd_page.title
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def test_generates_page_title_based_on_name
|
|
140
|
+
page = Page.new(:name => 'YetAnotherMotiroPage')
|
|
141
|
+
|
|
142
|
+
assert_equal 'Yet another motiro page', page.title
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
class RelativeTimeTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def midnight_17_july_2006; Time.local(2006, 07, 17, 00, 00, 00); end
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
Locale.set('en')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_time_ago_in_weeks
|
|
12
|
+
t = Time.local(2006, 07, 1, 15, 32, 27)
|
|
13
|
+
assert_equal '2 weeks ago', t.relative_to_now(midnight_17_july_2006)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_time_ago_in_days
|
|
17
|
+
t = Time.local(2006, 07, 15, 00, 00, 00)
|
|
18
|
+
assert_equal '2 days ago', t.relative_to_now(midnight_17_july_2006)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_exactly_one_day_ago
|
|
22
|
+
t = Time.local(2006, 07, 16, 00, 00, 00)
|
|
23
|
+
assert_equal 'Yesterday', t.relative_to_now(midnight_17_july_2006)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_time_ago_in_hours
|
|
27
|
+
t = Time.local(2006, 07, 16, 22, 50, 00)
|
|
28
|
+
assert_equal '1 hour ago', t.relative_to_now(midnight_17_july_2006)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_less_than_one_minute_ago
|
|
32
|
+
t = Time.local(2006, 07, 16, 23, 59, 43)
|
|
33
|
+
assert_equal 'Less than one minute ago', t.relative_to_now(midnight_17_july_2006)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_time_ago_in_months
|
|
37
|
+
t = Time.local(2006, 03, 16, 23, 59, 43)
|
|
38
|
+
assert_equal '4 months ago', t.relative_to_now(midnight_17_july_2006)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_time_ago_in_years
|
|
42
|
+
t = Time.local(2003, 03, 16, 23, 59, 43)
|
|
43
|
+
assert_equal '3 years ago', t.relative_to_now(midnight_17_july_2006)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_time_from_now
|
|
47
|
+
t = Time.local(2006, 07, 20, 00, 00, 00)
|
|
48
|
+
assert_equal '3 days from now', t.relative_to_now(midnight_17_july_2006)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_one_day_from_now
|
|
52
|
+
t = Time.local(2006, 07, 18, 12, 00, 00)
|
|
53
|
+
assert_equal 'Tomorrow', t.relative_to_now(midnight_17_july_2006)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
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 'core/reporter_driver'
|
|
21
|
+
|
|
22
|
+
class ReporterDriverTest < Test::Unit::TestCase
|
|
23
|
+
|
|
24
|
+
def test_ticks_one_reporter
|
|
25
|
+
FlexMock.use('1', '2') do |fetcher, reporter|
|
|
26
|
+
fetcher.should_receive(:active_reporters).once.returns([reporter])
|
|
27
|
+
reporter.should_receive(:name).once.returns('subversion')
|
|
28
|
+
reporter.should_receive(:latest_headlines).once.returns([])
|
|
29
|
+
|
|
30
|
+
driver = ReporterDriver.new(fetcher)
|
|
31
|
+
|
|
32
|
+
driver.tick
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_ticks_more_than_one_reporter
|
|
37
|
+
FlexMock.use('1', '2') do |fetcher, reporter|
|
|
38
|
+
fetcher.should_receive(:active_reporters).once.
|
|
39
|
+
returns([reporter, reporter])
|
|
40
|
+
reporter.should_receive(:name).twice.returns('subversion')
|
|
41
|
+
reporter.should_receive(:latest_headlines).twice.returns([])
|
|
42
|
+
|
|
43
|
+
driver = ReporterDriver.new(fetcher)
|
|
44
|
+
|
|
45
|
+
driver.tick
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_caches_headlines
|
|
50
|
+
FlexMock.use('1', '2') do |reporter, fetcher|
|
|
51
|
+
headlines = [FlexMock.new, FlexMock.new, FlexMock.new,
|
|
52
|
+
FlexMock.new, FlexMock.new]
|
|
53
|
+
fetcher.should_receive(:active_reporters).returns([reporter])
|
|
54
|
+
reporter.should_receive(:name).returns('subversion')
|
|
55
|
+
reporter.should_receive(:latest_headlines).returns(headlines)
|
|
56
|
+
headlines.each do |hl|
|
|
57
|
+
hl.should_receive(:cache).once
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
driver = ReporterDriver.new(fetcher)
|
|
61
|
+
|
|
62
|
+
driver.tick
|
|
63
|
+
|
|
64
|
+
headlines.each do |hl|
|
|
65
|
+
hl.mock_verify
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_askes_for_new_headlines_only
|
|
71
|
+
FlexMock.use('1', '2', '3') do |reporter, fetcher, headline_cache|
|
|
72
|
+
fetcher.should_receive(:active_reporters).returns([reporter])
|
|
73
|
+
reporter.should_receive(:name).returns('subversion')
|
|
74
|
+
headline_cache.should_receive(:latest_filled_headline_rid_for).
|
|
75
|
+
with('subversion').returns('r523')
|
|
76
|
+
reporter.should_receive(:latest_headlines).with('r523').returns([])
|
|
77
|
+
|
|
78
|
+
ReporterDriver.new(fetcher, headline_cache).tick
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# TODO what when there are no headlines yet cached or the ones cached aren't
|
|
83
|
+
# filled?
|
|
84
|
+
|
|
85
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
|
2
|
+
|
|
3
|
+
require 'core/reporter_fetcher'
|
|
4
|
+
|
|
5
|
+
require 'reporters/events_reporter'
|
|
6
|
+
require 'reporters/features_reporter'
|
|
7
|
+
|
|
8
|
+
class ReporterFetcherTest < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
def test_loads_only_active_reporters_plus_events_and_features
|
|
11
|
+
FlexMock.use('1', '2') do |loader, reporter|
|
|
12
|
+
settings = StubConnectionSettingsProvider.new(
|
|
13
|
+
:active_reporter_ids => ['darcs', 'mail'])
|
|
14
|
+
|
|
15
|
+
loader.should_receive(:create_reporter).with('darcs').
|
|
16
|
+
returns(reporter).once
|
|
17
|
+
loader.should_receive(:create_reporter).with('mail').
|
|
18
|
+
returns(reporter).once
|
|
19
|
+
|
|
20
|
+
fetcher = ReporterFetcher.new(settings, loader)
|
|
21
|
+
|
|
22
|
+
reporters = fetcher.active_reporters
|
|
23
|
+
assert_equal(4, reporters.size)
|
|
24
|
+
assert_equal([reporter, reporter], reporters[0..1])
|
|
25
|
+
assert_equal(FeaturesReporter, reporters[2].class)
|
|
26
|
+
assert_equal(EventsReporter, reporters[3].class)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
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 'core/reporter'
|
|
21
|
+
|
|
22
|
+
class MyDefaultReporter < MotiroReporter; end
|
|
23
|
+
|
|
24
|
+
class MyCustomReporter < MotiroReporter
|
|
25
|
+
title 'This is the Custom reporter'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class TwoButtonReporter < MotiroReporter
|
|
29
|
+
add button[:new_event]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class NonCachingReporter < MotiroReporter
|
|
33
|
+
caching :off
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class MotiroReporterTest < Test::Unit::TestCase
|
|
37
|
+
|
|
38
|
+
def test_default_title
|
|
39
|
+
default_reporter = MyDefaultReporter.new
|
|
40
|
+
|
|
41
|
+
assert_equal 'Latest news from My default',
|
|
42
|
+
default_reporter.channel_title
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_custom_title
|
|
46
|
+
custom_reporter = MyCustomReporter.new
|
|
47
|
+
|
|
48
|
+
assert_equal 'This is the Custom reporter',
|
|
49
|
+
custom_reporter.channel_title
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_guesses_reporter_name
|
|
53
|
+
default_reporter = MyDefaultReporter.new
|
|
54
|
+
custom_reporter = MyCustomReporter.new
|
|
55
|
+
|
|
56
|
+
assert_equal 'my_default', default_reporter.name
|
|
57
|
+
assert_equal 'my_custom', custom_reporter.name
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_one_button_reporter
|
|
61
|
+
assert_equal [ MotiroReporter.button[:older] ], MyCustomReporter.new.buttons
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_two_button_reporter
|
|
65
|
+
assert_equal [ MotiroReporter.button[:older],
|
|
66
|
+
MotiroReporter.button[:new_event] ],
|
|
67
|
+
TwoButtonReporter.new.buttons
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_switch_headline_caching
|
|
71
|
+
assert ! NonCachingReporter.new.cache?
|
|
72
|
+
assert MyDefaultReporter.new.cache?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_generates_request_params_from_rid
|
|
76
|
+
expected_params = { :controller => 'report', :action => 'show',
|
|
77
|
+
:reporter => 'my_default', :id => 'd25' }
|
|
78
|
+
assert_equal(expected_params, MyDefaultReporter.new.params_for('d25'))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|