motiro 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. data/LICENSE +280 -0
  2. data/README +28 -0
  3. data/README.en +175 -0
  4. data/README.pt-br +175 -0
  5. data/Rakefile +10 -0
  6. data/app/controllers/account_controller.rb +62 -0
  7. data/app/controllers/application.rb +72 -0
  8. data/app/controllers/edition_controller.rb +13 -0
  9. data/app/controllers/javascript_controller.rb +21 -0
  10. data/app/controllers/report_controller.rb +79 -0
  11. data/app/controllers/root_controller.rb +7 -0
  12. data/app/controllers/wiki_controller.rb +102 -0
  13. data/app/core/cache_reporter.rb +53 -0
  14. data/app/core/cache_reporter_fetcher.rb +33 -0
  15. data/app/core/chief_editor.rb +69 -0
  16. data/app/core/reporter.rb +105 -0
  17. data/app/core/reporter_driver.rb +36 -0
  18. data/app/core/reporter_fetcher.rb +39 -0
  19. data/app/core/settings.rb +43 -0
  20. data/app/core/version.rb +1 -0
  21. data/app/core/wiki_page_not_found.rb +33 -0
  22. data/app/core/wiki_reporter.rb +83 -0
  23. data/app/helpers/account_helper.rb +2 -0
  24. data/app/helpers/application_helper.rb +68 -0
  25. data/app/helpers/default_page_provider.rb +28 -0
  26. data/app/helpers/report_helper.rb +2 -0
  27. data/app/helpers/root_helper.rb +2 -0
  28. data/app/helpers/wiki_helper.rb +3 -0
  29. data/app/models/change.rb +96 -0
  30. data/app/models/diff_table_builder.rb +285 -0
  31. data/app/models/event.rb +18 -0
  32. data/app/models/headline.rb +109 -0
  33. data/app/models/page.rb +114 -0
  34. data/app/models/page_sweeper.rb +26 -0
  35. data/app/models/user.rb +85 -0
  36. data/app/ports/chdir_runner.rb +36 -0
  37. data/app/ports/reporter_loader.rb +9 -0
  38. data/app/ports/runner.rb +64 -0
  39. data/app/reporters/darcs_connection.rb +54 -0
  40. data/app/reporters/darcs_reporter.rb +104 -0
  41. data/app/reporters/darcs_settings.rb +9 -0
  42. data/app/reporters/darcs_temp_repo.rb +40 -0
  43. data/app/reporters/events_reporter.rb +28 -0
  44. data/app/reporters/features_reporter.rb +24 -0
  45. data/app/reporters/subversion_reporter.rb +203 -0
  46. data/app/reporters/svn_connection.rb +62 -0
  47. data/app/reporters/svn_settings.rb +40 -0
  48. data/app/views/account/_authorization.rhtml +54 -0
  49. data/app/views/account/_availability.rhtml +5 -0
  50. data/app/views/account/availability.rhtml +1 -0
  51. data/app/views/account/login.rhtml +22 -0
  52. data/app/views/account/logout.rhtml +10 -0
  53. data/app/views/javascript/motiro.rjs +132 -0
  54. data/app/views/javascript/niftycube.rjs +300 -0
  55. data/app/views/layouts/_bottom.rhtml +5 -0
  56. data/app/views/layouts/_header.rhtml +7 -0
  57. data/app/views/layouts/_top.rhtml +25 -0
  58. data/app/views/layouts/application.rhtml +3 -0
  59. data/app/views/layouts/scaffold.rhtml +13 -0
  60. data/app/views/layouts/wiki_edit.rhtml +26 -0
  61. data/app/views/report/list.rhtml +32 -0
  62. data/app/views/report/older.rhtml +26 -0
  63. data/app/views/report/rss.rxml +29 -0
  64. data/app/views/report/show.rhtml +20 -0
  65. data/app/views/root/index.rhtml +33 -0
  66. data/app/views/wiki/_editbar.rhtml +26 -0
  67. data/app/views/wiki/_properties_edit.rhtml +5 -0
  68. data/app/views/wiki/_properties_show.rhtml +5 -0
  69. data/app/views/wiki/edit.rhtml +56 -0
  70. data/app/views/wiki/properties_edit.rhtml +1 -0
  71. data/app/views/wiki/show.rhtml +9 -0
  72. data/bin/motiro +44 -0
  73. data/config/boot.rb +19 -0
  74. data/config/database.yml +14 -0
  75. data/config/environment.rb +64 -0
  76. data/config/environments/development.rb +20 -0
  77. data/config/environments/production.rb +19 -0
  78. data/config/environments/test.rb +19 -0
  79. data/config/motiro.yml +43 -0
  80. data/config/routes.rb +79 -0
  81. data/db/migrate/005_globalize_migration.rb +11363 -0
  82. data/db/migrate/006_remove_headline_title.rb +14 -0
  83. data/db/migrate/007_stretch_rid.rb +11 -0
  84. data/db/migrate/008_add_page_editors.rb +12 -0
  85. data/db/migrate/009_add_page_original_author.rb +12 -0
  86. data/db/migrate/010_remove_empty_string_defaults_from_pages.rb +17 -0
  87. data/db/migrate/011_add_title_and_kind_to_pages.rb +13 -0
  88. data/db/migrate/012_page_modification_info.rb +13 -0
  89. data/db/migrate/013_nullify_initial_page_attributes.rb +21 -0
  90. data/db/migrate/014_events_are_wiki_pages.rb +13 -0
  91. data/db/migrate/015_migrate_previous_event_data.rb +23 -0
  92. data/db/migrate/1_initial_structure.rb +36 -0
  93. data/db/migrate/2_add_authentication.rb +12 -0
  94. data/db/migrate/3_drop_articles.rb +26 -0
  95. data/db/migrate/4_add_page_editing.rb +14 -0
  96. data/db/motirodb.sqlite.initial +0 -0
  97. data/db/schema_version +1 -0
  98. data/db/translation/pt-BR.rb +76 -0
  99. data/doc/README_FOR_APP +2 -0
  100. data/installer/rails_installer_defaults.yml +5 -0
  101. data/lib/import_translations.rb +154 -0
  102. data/lib/login_system.rb +89 -0
  103. data/lib/relative_time.rb +48 -0
  104. data/lib/string_extensions.rb +10 -0
  105. data/lib/stub_hash.rb +22 -0
  106. data/lib/tasks/packaging.rake +93 -0
  107. data/lib/tasks/testing.rake +32 -0
  108. data/lib/tick_daemon.rb +41 -0
  109. data/lib/translator.rb +67 -0
  110. data/lib/wiki_renderer.rb +42 -0
  111. data/lib/wiki_url_generator.rb +29 -0
  112. data/log/.keepdir +0 -0
  113. data/public/404.html +8 -0
  114. data/public/500.html +8 -0
  115. data/public/dispatch.cgi +10 -0
  116. data/public/dispatch.fcgi +24 -0
  117. data/public/dispatch.rb +10 -0
  118. data/public/favicon.ico +0 -0
  119. data/public/images/calendar.png +0 -0
  120. data/public/images/rss.png +0 -0
  121. data/public/javascripts/controls.js +750 -0
  122. data/public/javascripts/dragdrop.js +584 -0
  123. data/public/javascripts/effects.js +854 -0
  124. data/public/javascripts/prototype.js +1785 -0
  125. data/public/robots.txt +1 -0
  126. data/public/stylesheets/motiro.css +269 -0
  127. data/public/stylesheets/niftyCorners.css +35 -0
  128. data/public/stylesheets/scaffold.css +74 -0
  129. data/script/about +3 -0
  130. data/script/breakpointer +3 -0
  131. data/script/console +3 -0
  132. data/script/destroy +3 -0
  133. data/script/generate +3 -0
  134. data/script/performance/benchmarker +3 -0
  135. data/script/performance/profiler +3 -0
  136. data/script/plugin +3 -0
  137. data/script/process/reaper +3 -0
  138. data/script/process/spawner +3 -0
  139. data/script/process/spinner +3 -0
  140. data/script/runner +3 -0
  141. data/script/server +3 -0
  142. data/script/ticker +29 -0
  143. data/test/acceptance/account_test.rb +186 -0
  144. data/test/acceptance/darcs_test.rb +62 -0
  145. data/test/acceptance/events_test.rb +47 -0
  146. data/test/acceptance/main_page_test.rb +92 -0
  147. data/test/acceptance/subversion_test.rb +319 -0
  148. data/test/acceptance/ts_all_suites.rb +27 -0
  149. data/test/acceptance/wiki_test.rb +202 -0
  150. data/test/contract/darcs_test.rb +51 -0
  151. data/test/contract/remote_darcs_test.rb +61 -0
  152. data/test/contract/svn_test.rb +53 -0
  153. data/test/fixtures/changes.yml +25 -0
  154. data/test/fixtures/headlines.yml +45 -0
  155. data/test/fixtures/pages.yml +98 -0
  156. data/test/fixtures/users.yml +31 -0
  157. data/test/functional/account_controller_test.rb +96 -0
  158. data/test/functional/report_controller_test.rb +113 -0
  159. data/test/functional/report_features_test.rb +38 -0
  160. data/test/functional/report_subversion_test.rb +79 -0
  161. data/test/functional/root_controller_test.rb +127 -0
  162. data/test/functional/wiki_controller_test.rb +280 -0
  163. data/test/lib/acceptance_test_case.rb +43 -0
  164. data/test/lib/configuration.rb +53 -0
  165. data/test/lib/darcs_excerpts.rb +181 -0
  166. data/test/lib/darcs_repo.rb +77 -0
  167. data/test/lib/live_mode_test.rb +51 -0
  168. data/test/lib/local_svn.rb +157 -0
  169. data/test/lib/netutils.rb +42 -0
  170. data/test/lib/platform_thread.rb +62 -0
  171. data/test/lib/repoutils.rb +23 -0
  172. data/test/lib/selenium_extensions.rb +32 -0
  173. data/test/lib/stubio.rb +37 -0
  174. data/test/lib/svn_excerpts.rb +288 -0
  175. data/test/lib/test_configuration.rb +14 -0
  176. data/test/lib/webserver.rb +71 -0
  177. data/test/meta/configuration_test.rb +72 -0
  178. data/test/meta/darcs_repo_test.rb +118 -0
  179. data/test/meta/local_svn_test.rb +125 -0
  180. data/test/meta/platform_thread_test.rb +46 -0
  181. data/test/meta/stubio_test.rb +44 -0
  182. data/test/mocks/headline.rb +34 -0
  183. data/test/mocks/svn_reporter.rb +29 -0
  184. data/test/stubs/svn_settings.rb +19 -0
  185. data/test/stubs/url_generator.rb +24 -0
  186. data/test/test_helper.rb +36 -0
  187. data/test/unit/cache_reporter_fetcher_test.rb +46 -0
  188. data/test/unit/cache_reporter_test.rb +97 -0
  189. data/test/unit/caching_test.rb +78 -0
  190. data/test/unit/change_test.rb +152 -0
  191. data/test/unit/chdir_runner_test.rb +77 -0
  192. data/test/unit/chief_editor_test.rb +234 -0
  193. data/test/unit/darcs_connection_test.rb +109 -0
  194. data/test/unit/darcs_reporter_test.rb +146 -0
  195. data/test/unit/darcs_settings_test.rb +37 -0
  196. data/test/unit/darcs_temp_repo_test.rb +51 -0
  197. data/test/unit/default_page_provider_test.rb +46 -0
  198. data/test/unit/diff_table_builder_test.rb +602 -0
  199. data/test/unit/headline_test.rb +259 -0
  200. data/test/unit/page_test.rb +145 -0
  201. data/test/unit/relative_time_test.rb +56 -0
  202. data/test/unit/reporter_driver_test.rb +85 -0
  203. data/test/unit/reporter_fetcher_test.rb +31 -0
  204. data/test/unit/reporter_test.rb +81 -0
  205. data/test/unit/runner_test.rb +93 -0
  206. data/test/unit/settings_test.rb +55 -0
  207. data/test/unit/string_extensions_test.rb +10 -0
  208. data/test/unit/svn_connection_test.rb +183 -0
  209. data/test/unit/svn_reporter_interaction_test.rb +38 -0
  210. data/test/unit/svn_reporter_test.rb +286 -0
  211. data/test/unit/svn_settings_test.rb +86 -0
  212. data/test/unit/translator_test.rb +96 -0
  213. data/test/unit/user_test.rb +125 -0
  214. data/test/unit/wiki_renderer_test.rb +87 -0
  215. data/test/unit/wiki_reporter_test.rb +94 -0
  216. data/test/unit/wiki_url_generator_test.rb +31 -0
  217. data/vendor/motiro-installer.rb +159 -0
  218. data/vendor/plugins/globalize/LICENSE +9 -0
  219. data/vendor/plugins/globalize/README +49 -0
  220. data/vendor/plugins/globalize/data/country_data.csv +240 -0
  221. data/vendor/plugins/globalize/data/language_data.csv +188 -0
  222. data/vendor/plugins/globalize/data/translation_data.csv +3421 -0
  223. data/vendor/plugins/globalize/generators/globalize/USAGE +10 -0
  224. data/vendor/plugins/globalize/generators/globalize/globalize_generator.rb +42 -0
  225. data/vendor/plugins/globalize/generators/globalize/templates/migration.rb.gz +0 -0
  226. data/vendor/plugins/globalize/generators/globalize/templates/tiny_migration.rb.gz +0 -0
  227. data/vendor/plugins/globalize/init.rb +30 -0
  228. data/vendor/plugins/globalize/lib/globalize/localization/core_ext.rb +170 -0
  229. data/vendor/plugins/globalize/lib/globalize/localization/core_ext_hooks.rb +33 -0
  230. data/vendor/plugins/globalize/lib/globalize/localization/db_translate.rb +494 -0
  231. data/vendor/plugins/globalize/lib/globalize/localization/db_view_translator.rb +152 -0
  232. data/vendor/plugins/globalize/lib/globalize/localization/locale.rb +173 -0
  233. data/vendor/plugins/globalize/lib/globalize/localization/rfc_3066.rb +40 -0
  234. data/vendor/plugins/globalize/lib/globalize/models/country.rb +24 -0
  235. data/vendor/plugins/globalize/lib/globalize/models/currency.rb +188 -0
  236. data/vendor/plugins/globalize/lib/globalize/models/language.rb +84 -0
  237. data/vendor/plugins/globalize/lib/globalize/models/model_translation.rb +4 -0
  238. data/vendor/plugins/globalize/lib/globalize/models/translation.rb +9 -0
  239. data/vendor/plugins/globalize/lib/globalize/models/view_translation.rb +14 -0
  240. data/vendor/plugins/globalize/lib/globalize/rails/action_mailer.rb +125 -0
  241. data/vendor/plugins/globalize/lib/globalize/rails/action_view.rb +79 -0
  242. data/vendor/plugins/globalize/lib/globalize/rails/active_record.rb +129 -0
  243. data/vendor/plugins/globalize/lib/globalize/rails/active_record_helper.rb +33 -0
  244. data/vendor/plugins/globalize/populators/pop_dates.rb +81 -0
  245. data/vendor/plugins/globalize/populators/pop_migration.rb +18 -0
  246. data/vendor/plugins/globalize/populators/pop_pluralization.rb +26 -0
  247. data/vendor/plugins/globalize/populators/pop_seps.rb +32 -0
  248. data/vendor/plugins/globalize/tasks/data.rake +130 -0
  249. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en-US.plain.text.rhtml +1 -0
  250. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.en.plain.text.rhtml +1 -0
  251. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.he.plain.text.rhtml +1 -0
  252. data/vendor/plugins/globalize/test/action_mailer_test/globalize_mailer/test.plain.text.rhtml +1 -0
  253. data/vendor/plugins/globalize/test/action_mailer_test.rb +54 -0
  254. data/vendor/plugins/globalize/test/config/database.yml.default +16 -0
  255. data/vendor/plugins/globalize/test/config/database.yml.example +22 -0
  256. data/vendor/plugins/globalize/test/core_ext_test.rb +61 -0
  257. data/vendor/plugins/globalize/test/currency_test.rb +141 -0
  258. data/vendor/plugins/globalize/test/date_helper_test.rb +634 -0
  259. data/vendor/plugins/globalize/test/db/schema.rb +90 -0
  260. data/vendor/plugins/globalize/test/db_translation_test.rb +374 -0
  261. data/vendor/plugins/globalize/test/fixtures/globalize_categories.yml +7 -0
  262. data/vendor/plugins/globalize/test/fixtures/globalize_categories_products.yml +7 -0
  263. data/vendor/plugins/globalize/test/fixtures/globalize_countries.yml +41 -0
  264. data/vendor/plugins/globalize/test/fixtures/globalize_languages.yml +64 -0
  265. data/vendor/plugins/globalize/test/fixtures/globalize_manufacturers.yml +5 -0
  266. data/vendor/plugins/globalize/test/fixtures/globalize_products.yml +29 -0
  267. data/vendor/plugins/globalize/test/fixtures/globalize_simples.yml +5 -0
  268. data/vendor/plugins/globalize/test/fixtures/globalize_translations.yml +354 -0
  269. data/vendor/plugins/globalize/test/locale_test.rb +27 -0
  270. data/vendor/plugins/globalize/test/mime_responds_test.rb +358 -0
  271. data/vendor/plugins/globalize/test/model_test.rb +17 -0
  272. data/vendor/plugins/globalize/test/standard_data_test_helper.rb +33 -0
  273. data/vendor/plugins/globalize/test/test_helper.rb +19 -0
  274. data/vendor/plugins/globalize/test/test_standard_data.rb +54 -0
  275. data/vendor/plugins/globalize/test/validation_test.rb +29 -0
  276. data/vendor/plugins/globalize/test/view_picking_test.rb +49 -0
  277. data/vendor/plugins/globalize/test/view_translation_test.rb +237 -0
  278. data/vendor/plugins/globalize/test/views/layouts/standard.rhtml +1 -0
  279. data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rhtml +1 -0
  280. data/vendor/plugins/globalize/test/views/respond_to/all_types_with_layout.rjs +1 -0
  281. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rhtml +1 -0
  282. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rjs +1 -0
  283. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.en.rxml +1 -0
  284. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rhtml +1 -0
  285. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rjs +1 -0
  286. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.fr.rxml +1 -0
  287. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rhtml +1 -0
  288. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rjs +1 -0
  289. data/vendor/plugins/globalize/test/views/respond_to/using_defaults.rxml +1 -0
  290. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rhtml +1 -0
  291. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rjs +1 -0
  292. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.en.rxml +1 -0
  293. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rhtml +1 -0
  294. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rjs +1 -0
  295. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.fr.rxml +1 -0
  296. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rhtml +1 -0
  297. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rjs +1 -0
  298. data/vendor/plugins/globalize/test/views/respond_to/using_defaults_with_type_list.rxml +1 -0
  299. data/vendor/plugins/globalize/test/views/test.he-IL.rhtml +1 -0
  300. data/vendor/plugins/globalize/test/views/test.rhtml +1 -0
  301. data/vendor/plugins/globalize/test/views/test2.he.rhtml +1 -0
  302. data/vendor/plugins/globalize/test/views/test2.rhtml +1 -0
  303. data/vendor/plugins/test_xml/MIT-LICENSE +20 -0
  304. data/vendor/plugins/test_xml/README +20 -0
  305. data/vendor/plugins/test_xml/Rakefile +22 -0
  306. data/vendor/plugins/test_xml/init.rb +7 -0
  307. data/vendor/plugins/test_xml/lib/xml_assertions.rb +22 -0
  308. data/vendor/plugins/test_xml/test/test_xml_test.rb +40 -0
  309. metadata +505 -0
@@ -0,0 +1,113 @@
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
+ require 'report_controller'
20
+
21
+ require 'mocks/headline'
22
+ require 'stubs/svn_settings'
23
+
24
+ # Re-raise errors caught by the controller.
25
+ class ReportController; def rescue_action(e) raise e end; end
26
+
27
+ class ReportControllerTest < Test::Unit::TestCase
28
+
29
+ fixtures :headlines
30
+
31
+ def setup
32
+ @controller = ReportController.new
33
+ @request = ActionController::TestRequest.new
34
+ @response = ActionController::TestResponse.new
35
+ end
36
+
37
+ def test_fetches_headlines_from_cache
38
+ get :list, { :reporter => 'subversion' }
39
+ assert_response :success
40
+ assert_not_nil assigns(:headlines)
41
+ expected = Headline.find(:all, :conditions => "reported_by = 'subversion'")
42
+ assert_equal expected.size, assigns(:headlines).size
43
+ end
44
+
45
+ def test_routes_localized_feeds
46
+ assert_routing('/feed/subversion/en-gb',
47
+ :controller => 'report', :action => 'rss',
48
+ :reporter => 'subversion', :locale => 'en-gb' )
49
+ end
50
+
51
+ def test_fetches_individual_headline_based_on_rid
52
+ svn_demo_headline = headlines('svn_demo_headline')
53
+ get :show, { :reporter => svn_demo_headline.reported_by,
54
+ :id => svn_demo_headline.rid }
55
+ assert_response :success
56
+ assert_not_nil assigns(:headline)
57
+ end
58
+
59
+ def test_calling_show_with_an_id_delegates_to_chief_editor
60
+ FlexMock.use do |editor|
61
+ editor.should_receive(:reporter_with).with('subversion').
62
+ and_return(SubversionReporter.new)
63
+ editor.should_receive(:headline_with).with('subversion', '3').
64
+ returns(headlines('svn_demo_headline')).
65
+ once
66
+
67
+ @controller = ReportController.new(editor)
68
+
69
+ get :show, {:reporter => 'subversion', :id => 3}
70
+ end
71
+ end
72
+
73
+ def test_calling_show_with_invalid_rid_redirects_to_index
74
+ get :show, { :reporter => 'subversion', :id => 'r300' }
75
+ assert_equal 'The article r300 from the Subversion reporter could not be found', flash[:notice]
76
+ assert_redirected_to :controller => 'root', :action => 'index'
77
+ end
78
+
79
+ def test_include_headline_date_on_guid
80
+ gita = headlines('gita')
81
+
82
+ get :rss, { :reporter => gita.reported_by }
83
+
84
+ assert_xml_element "//guid[contains(text(), '#{gita.happened_at.strftime('%Y%m%d%H%M%S')}')]"
85
+ end
86
+
87
+ #TODO what happens if there are no cached headlines?
88
+ #TODO more headlines registered than the package size
89
+
90
+ def test_shows_breadcrumbs_trail_for_subversion_revision_pages
91
+ svn_demo = headlines('svn_demo_headline')
92
+ get :show, :reporter => svn_demo.reported_by, :id => svn_demo.rid
93
+
94
+ assert_xml_element "//div[@id = 'crumbs' and contains(text(), 'You are here')]/a[@href = '/' and text() = 'Home']"
95
+ assert_xml_element "//div[@id = 'crumbs']/a[@href = '/report/older/subversion' and text() = 'Latest news from Subversion']"
96
+ assert_xml_element "//div[@id = 'crumbs']/a[@href = '/report/subversion/#{svn_demo.rid}' and text() = '#{svn_demo.title}']"
97
+ end
98
+
99
+ def test_shows_breadcrumbs_trail_for_older_news_page
100
+ get :older, :reporter => 'subversion'
101
+
102
+ assert_xml_element "//div[@id = 'crumbs' and contains(text(), 'You are here')]/a[@href = '/' and text() = 'Home']"
103
+ assert_xml_element "//div[@id = 'crumbs']/a[@href = '/report/older/subversion' and text() = 'Latest news from Subversion']"
104
+ end
105
+
106
+ private
107
+
108
+ def assert_template(expected)
109
+ assert_equal File.expand_path("#{__FILE__}/../../../app/views/#{expected}.rhtml"),
110
+ File.expand_path(@response.rendered_file)
111
+ end
112
+
113
+ end
@@ -0,0 +1,38 @@
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
+ # Re-raise errors caught by the controller.
21
+ class ReportController; def rescue_action(e) raise e end; end
22
+
23
+ class ReportFeaturesTest < Test::Unit::TestCase
24
+
25
+ fixtures :pages
26
+
27
+ def setup
28
+ @controller = ReportController.new
29
+ @request = ActionController::TestRequest.new
30
+ @response = ActionController::TestResponse.new
31
+ end
32
+
33
+ def test_links_to_feature_pages_from_rss_feed
34
+ get :rss, :reporter => 'features'
35
+ assert_xml_element "//link[text() = 'http://test.host/wiki/show/ListLastModifiedFeatures']"
36
+ end
37
+
38
+ end
@@ -0,0 +1,79 @@
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
+ require 'live_mode_test'
20
+
21
+ # Re-raise errors caught by the controller.
22
+ class ReportController; def rescue_action(e) raise e end; end
23
+
24
+ class ReportSubversionTest < Test::Unit::TestCase
25
+ include LiveModeTestCase
26
+
27
+ def do_setup
28
+ @controller = ReportController.new
29
+ @request = ActionController::TestRequest.new
30
+ @response = ActionController::TestResponse.new
31
+ end
32
+
33
+ def test_report_rss
34
+ commit_title = 'Created my project'
35
+ commit_msg = "#{commit_title}\n" +
36
+ "\n" +
37
+ "This revision creates a brand new directory where we \n" +
38
+ "will keep our project files"
39
+
40
+ @repo.mkdir('myproject', commit_msg)
41
+
42
+ get :rss, :reporter => 'subversion'
43
+ assert_xml_element("//rss/channel/title[text() = 'Motiro - Subversion']")
44
+ assert_xml_element("//rss/channel/generator[text() = 'Motiro']")
45
+ assert_xml_element("//rss/channel/item/title[text() = '#{commit_title}']")
46
+ assert_xml_element("//rss/channel/item/description[contains(text(), 'This revision creates')]")
47
+ assert_xml_element("//rss/channel/item/*[local-name() = 'creator' and text() = '#{@repo.username}']")
48
+ end
49
+
50
+ def test_do_not_show_page_text_div_on_feed
51
+ commit_title = 'Created my project'
52
+ commit_msg = "#{commit_title}\n" +
53
+ "\n" +
54
+ "This revision creates a brand new directory where we \n" +
55
+ "will keep our project files"
56
+
57
+ @repo.mkdir('myproject', commit_msg)
58
+
59
+ get :rss, :reporter => 'subversion'
60
+ assert_no_xml_element("//description[contains(text(), 'pagetext')]")
61
+ end
62
+
63
+ def test_translates_rss_feed
64
+ english_msg = "I changed something in the source code repository"
65
+ portuguese_msg = "Mudei algo no repositorio de codigo fonte"
66
+ commit_msg = english_msg + "\n\n--- pt-br ----\n\n" + portuguese_msg
67
+
68
+ @repo.mkdir('myproject', commit_msg)
69
+
70
+ get :rss, :reporter => 'subversion', :locale => 'en'
71
+ assert_xml_element("//rss/channel/item/title[text() = '#{english_msg}']")
72
+ assert_no_xml_element("//rss/channel/item/title[text() = '#{portuguese_msg}']")
73
+
74
+ get :rss, :reporter => 'subversion', :locale => 'pt-br'
75
+ assert_xml_element("//rss/channel/item/title[text() = '#{portuguese_msg}']")
76
+ assert_no_xml_element("//rss/channel/item/title[text() = '#{english_msg}']")
77
+ end
78
+
79
+ end
@@ -0,0 +1,127 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'root_controller'
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class RootController; def rescue_action(e) raise e end; end
6
+
7
+ class RootControllerTest < Test::Unit::TestCase
8
+
9
+ fixtures :users, :pages
10
+
11
+ def setup
12
+ @controller = RootController.new
13
+ @request = ActionController::TestRequest.new
14
+ @response = ActionController::TestResponse.new
15
+ end
16
+
17
+ def test_version_number
18
+ get :index, :locale => 'en'
19
+
20
+ assert_tag :content => /Motiro version 0.6.3/
21
+ end
22
+
23
+
24
+ def test_routes_language_specified_on_url
25
+ assert_routing('/en', :controller => 'root',
26
+ :action => 'index',
27
+ :locale => 'en')
28
+ end
29
+
30
+ def test_routes_to_nil_locale_when_language_not_specified
31
+ assert_routing('/', :controller => 'root',
32
+ :action => 'index',
33
+ :locale => nil)
34
+ end
35
+
36
+ def test_recognizes_locale_for_only_one_language_on_accept_language
37
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'pt-BR'
38
+ get :index
39
+
40
+ assert_equal('pt-BR', assigns(:locale))
41
+ assert_equal('pt-BR', Locale.active.code)
42
+ end
43
+
44
+ def test_recognizes_locale_for_multiple_language_request
45
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'pt-br,en-us;q=0.5'
46
+ get :index
47
+
48
+ assert_equal('pt-br', assigns(:locale))
49
+ assert_equal('pt-br', Locale.active.code)
50
+ end
51
+
52
+ def test_url_with_locale_takes_precedence
53
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'pt-BR'
54
+ get :index, { :locale => 'de' }
55
+
56
+ assert_equal('de', assigns(:locale))
57
+ assert_equal('de', Locale.active.code)
58
+ end
59
+
60
+ def test_recognizes_locale_when_quality_specified
61
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'pt-br;q=1,en-us;q=0.5'
62
+ get :index
63
+
64
+ assert_equal('pt-br', assigns(:locale))
65
+ assert_equal('pt-br', Locale.active.code)
66
+ end
67
+
68
+ def test_invalid_language_code_defaults_to_english
69
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = '7h'
70
+
71
+ get :index
72
+
73
+ assert_equal('en-US', assigns(:locale))
74
+ assert_equal('en-US', Locale.active.code)
75
+ end
76
+
77
+ def test_uses_last_language_when_language_not_specified
78
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr'
79
+ get :index
80
+
81
+ assert_equal('fr', Locale.active.code)
82
+
83
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = nil
84
+ get :index, { :locale => 'de' }
85
+
86
+ assert_equal('de', Locale.active.code)
87
+
88
+ get :index
89
+
90
+ assert_equal('de', assigns(:locale))
91
+ assert_equal('de', Locale.active.code)
92
+ end
93
+
94
+ def test_uses_last_specified_language_when_accept_language_differs
95
+ get :index, { :locale => 'sw' }
96
+
97
+ assert_equal('sw', Locale.active.code)
98
+
99
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'pt-BR'
100
+ get :index
101
+
102
+ assert_equal('sw', assigns(:locale))
103
+ assert_equal('sw', Locale.active.code)
104
+ end
105
+
106
+ def test_defaults_to_english_when_not_otherwise_specified
107
+ get :index
108
+
109
+ assert_equal('en-US', assigns(:locale))
110
+ assert_equal('en-US', Locale.active.code)
111
+ end
112
+
113
+ def test_empty_language_string_on_accept_language_means_nothing
114
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = ''
115
+ get :index
116
+
117
+ assert_equal('en-US', assigns(:locale))
118
+ assert_equal('en-US', Locale.active.code)
119
+ end
120
+
121
+ def test_lists_last_changed_feature_pages
122
+ get :index
123
+ assert_tag :tag => 'div', :attributes => {:id => 'features'},
124
+ :content => Regexp.new(pages('list_last_modified_features_page').title)
125
+ end
126
+
127
+ end
@@ -0,0 +1,280 @@
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
+ require 'wiki_controller'
20
+ require 'test_configuration'
21
+
22
+ # Re-raise errors caught by the controller.
23
+ class WikiController; def rescue_action(e) raise e end; end
24
+
25
+ class WikiControllerTest < Test::Unit::TestCase
26
+
27
+ include TestConfiguration
28
+
29
+ fixtures :users, :pages
30
+
31
+ def setup
32
+ @controller = WikiController.new
33
+ @request = ActionController::TestRequest.new
34
+ @response = ActionController::TestResponse.new
35
+ end
36
+
37
+ def test_routes_to_nil_locale_when_not_specified_on_url
38
+ assert_routing('/wiki/edit/MainPage', :controller => 'wiki',
39
+ :action => 'edit',
40
+ :page_name => 'MainPage')
41
+ end
42
+
43
+ def test_routes_to_specified_locale_page
44
+ assert_routing('/wiki/show/MainPage/en', :controller => 'wiki',
45
+ :action => 'show',
46
+ :page_name => 'MainPage',
47
+ :locale => 'en')
48
+ end
49
+
50
+ def test_blocks_edition
51
+ log_as 'bob'
52
+
53
+ page_name = pages('johns_page').name
54
+
55
+ get :edit, { :page_name => page_name }
56
+ assert_redirected_to :action => 'show', :page_name => page_name
57
+ end
58
+
59
+ def test_blocks_saving_pages_for_unauthorized_users
60
+ log_as 'john'
61
+
62
+ page_name = pages('bob_and_erics_page').name
63
+
64
+ post :save, { :page_name => page_name,
65
+ :page => { :text => 'New text',
66
+ :editors => 'john' },
67
+ 'btnSave' => true }
68
+
69
+ assert flash[:not_authorized]
70
+ assert_redirected_to :action => 'show', :page_name => page_name
71
+ end
72
+
73
+ def test_asks_page_provider_for_pages_when_editing
74
+ FlexMock.use do |page_provider|
75
+ page_provider.should_receive(:find_by_name).
76
+ with('TestPage').
77
+ once.
78
+ and_return(Page.new(:name => 'TestPage',
79
+ :text => ''))
80
+ @controller = WikiController.new(page_provider)
81
+
82
+ ensure_logged_in
83
+ get :edit, {:page_name => 'TestPage'}
84
+ assert_response :success
85
+ end
86
+ end
87
+
88
+ def test_authentication_required_for_edition
89
+ get :edit, { :page_name => 'TestPage' }
90
+ assert_redirected_to(:controller => 'account', :action => 'login')
91
+ end
92
+
93
+ def test_only_original_author_can_change_editors_list
94
+ log_as 'eric'
95
+
96
+ page_name = pages('bob_and_erics_page').name
97
+ post :save, :page_name => page_name,
98
+ :page => { :text => 'New page text',
99
+ :editors => 'bob eric john'},
100
+ :btnSave => true
101
+
102
+ log_as 'john'
103
+
104
+ get :edit, :page_name => page_name
105
+ assert flash[:not_authorized]
106
+ end
107
+
108
+ def test_noone_can_change_the_original_author
109
+ bob = users('bob')
110
+ page_name = pages('johns_page').name
111
+
112
+ log_as 'john'
113
+
114
+ post :save, :page_name => page_name,
115
+ :btnSave => true,
116
+ :page => { :original_author_id => bob.id,
117
+ :editors => 'john bob' }
118
+
119
+ log_as 'bob'
120
+
121
+ get :edit, :page_name => page_name
122
+ assert_no_tag :tag => 'label', :attributes => { :for => 'txtAuthorized' }
123
+ end
124
+
125
+ def test_uses_language_provided_by_address
126
+ FlexMock.use do |provider|
127
+ provider.should_receive(:find_by_name).
128
+ with_any_args.
129
+ and_return(mocked_page).
130
+ once
131
+
132
+ @controller = WikiController.new(provider)
133
+
134
+ get :show, {:page_name => 'TestPage', :locale => 'en'}
135
+ assert_tag :content => /You've been mocked!/
136
+ assert_no_tag :content => /Você foi enganado!/
137
+ end
138
+ end
139
+
140
+ def test_renders_page_in_default_language_when_not_specified
141
+ FlexMock.use do |provider|
142
+ provider.should_receive(:find_by_name).
143
+ with_any_args.
144
+ and_return(mocked_page).
145
+ once
146
+
147
+ @controller = WikiController.new(provider)
148
+
149
+ get :show, {:page_name => 'TestPage'}
150
+ assert_tag :content => /You've been mocked!/
151
+ assert_no_tag :content => /Você foi enganado!/
152
+ end
153
+ end
154
+
155
+ def test_considers_last_chosen_language_when_displaying_not_found_page
156
+ get '/en'
157
+
158
+ get :show, :page_name => 'NotYetCreatedPage'
159
+ assert_tag :content => /nothing to be read here/
160
+ end
161
+
162
+ def test_auto_selects_page_kind
163
+ log_as 'bob'
164
+
165
+ get :new, :kind => 'feature'
166
+ assert_tag :tag => 'option', :attributes => { :value => 'feature',
167
+ :selected => 'selected' }
168
+ end
169
+
170
+ def test_inserts_page_name_as_title_on_edition
171
+ log_as 'bob'
172
+
173
+ get :edit, :page_name => 'BrandNewPage'
174
+ assert_tag :tag => 'input', :attributes => { :type => 'text',
175
+ :value => 'Brand new page' }
176
+ end
177
+
178
+ def test_shows_page_title_as_level_one_header
179
+ non_matching_title_page = pages('non_matching_title_page')
180
+ get :show, :page_name => pages('test_page').name
181
+ assert_tag :tag => 'h1', :content => 'Test page'
182
+
183
+ get :show, :page_name => non_matching_title_page.name
184
+ assert_tag :tag => 'h1', :content => non_matching_title_page.title
185
+ end
186
+
187
+ def test_saves_last_editor_and_modification_date
188
+ log_as 'john'
189
+
190
+ post :save, :btnSave => true,
191
+ :page => { :title => 'Page written by John',
192
+ :text => 'Anyone can change it',
193
+ :kind => 'feature',
194
+ :editors => '' }
195
+
196
+ page = Page.find_by_name('PageWrittenByJohn')
197
+
198
+ assert_equal users('john'), page.last_editor
199
+ assert_in_delta Time.now, page.modified_at, 1.0
200
+
201
+ log_as 'bob'
202
+
203
+ post :save, :page_name => 'PageWrittenByJohn',
204
+ :btnSave => true,
205
+ :page => { :title => 'Page written by John',
206
+ :text => 'Bob changed the text',
207
+ :kind => 'feature',
208
+ :editors => '' }
209
+ page = Page.find_by_name('PageWrittenByJohn')
210
+
211
+ assert_equal users('bob'), page.last_editor
212
+ end
213
+
214
+ def test_shows_modification_editor_and_date_on_wiki_pages
215
+ log_as 'john'
216
+
217
+ post :save, :page_name => 'AnotherBoringWikiPage',
218
+ :btnSave => true,
219
+ :page => { :title => 'Another boring wiki page',
220
+ :text => 'Some boring text',
221
+ :kind => 'common',
222
+ :editors => '' }
223
+
224
+ expected_time = Time.now.to_s(:rfc822).slice(0, 19) # Wed, 03 Jan 2007 00
225
+ assert_redirected_to :action => 'show', :page_name => 'AnotherBoringWikiPage'
226
+ follow_redirect
227
+ assert_tag :content => /john/
228
+ assert_tag :content => Regexp.new(expected_time)
229
+ end
230
+
231
+ def test_displays_date_edition_field_when_editing_events
232
+ log_as 'bob'
233
+
234
+ get :edit, :page_name => pages('release_event').name
235
+
236
+ assert_xml_element "//select[@id = 'page_happens_at_1i']"
237
+ end
238
+
239
+ def test_displays_date_when_detailing_events
240
+ get :show, :page_name => pages('release_event').name
241
+
242
+ assert_tag :content => /This event was planned for 24 January 2007/
243
+ end
244
+
245
+ def test_does_not_try_to_display_date_when_detailing_common_pages
246
+ get :show, :page_name => pages('test_page').name
247
+
248
+ assert_no_tag :content => /This event was planned for/
249
+ end
250
+
251
+ def test_shows_breadcrumbs_trail_for_common_wiki_pages
252
+ test_page = pages('test_page')
253
+ get :show, :page_name => test_page.name
254
+
255
+ assert_xml_element "//div[@id = 'crumbs' and contains(text(), 'You are here')]/a[@href = '/' and text() = 'Home']"
256
+ assert_xml_element "//div[@id = 'crumbs']/a[@href = '/wiki/show/#{test_page.name}' and text() = '#{test_page.title}']"
257
+ end
258
+
259
+ def test_shows_breadcrumbs_trail_for_special_wiki_pages
260
+ release_event = pages('release_event')
261
+ get :show, :page_name => release_event.name
262
+
263
+ assert_xml_element "//div[@id = 'crumbs' and contains(text(), 'You are here')]/a[@href = '/' and text() = 'Home']"
264
+ assert_xml_element "//div[@id = 'crumbs']/a[@href = '/report/older/events' and text() = 'Events']"
265
+ assert_xml_element "//div[@id = 'crumbs']/a[@href = '/wiki/show/#{release_event.name}' and text() = '#{release_event.title}']"
266
+ end
267
+
268
+ private
269
+
270
+ def log_as(user_name)
271
+ @request.session[:user] = users(user_name)
272
+ end
273
+
274
+ def mocked_page
275
+ Page.new(:name => 'MockedPage', :title => 'Mocked page',
276
+ :last_editor => nil, :modified_at => nil, :kind => 'common',
277
+ :text => "You've been mocked!\n\n--- pt-br ----\n\nVocê foi enganado!")
278
+ end
279
+
280
+ end
@@ -0,0 +1,43 @@
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__) + "/../../vendor/selenium/selenium"
19
+
20
+ require 'selenium_extensions'
21
+
22
+ class AcceptanceTestCase < SeleniumTestCase
23
+
24
+ include SeleniumExtensions
25
+
26
+ TEST_PASSWORDS = { :bob => 'test', :john => 'lennon', :eric => 'clapton',
27
+ :existingbob => 'test', :longbob => 'longtest' }
28
+
29
+ def log_as(user, passwd=nil)
30
+ open('/en')
31
+
32
+ type('user_login', user.to_s)
33
+ type('user_password', passwd || TEST_PASSWORDS[user])
34
+
35
+ click 'login'
36
+ wait_for_page_to_load(2000)
37
+ end
38
+
39
+ def log_out
40
+ open '/account/logout'
41
+ end
42
+
43
+ end