Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Trying to update this thing to 2.1

  • Loading branch information...
commit e6d3af7e6258e346969e2f8be780fbb4ea744bfa 1 parent ed82a25
Nick Quaranto qrush authored

Showing 279 changed files with 9,957 additions and 2,257 deletions. Show diff stats Hide diff stats

  1. +2 2 app/helpers/application_helper.rb
  2. +93 4 app/helpers/users_helper.rb
  3. +4 0 app/models/user.rb
  4. +3 4 app/views/forums/show.html.erb
  5. +16 0 app/views/sessions/new.html.erb
  6. +8 0 app/views/users/_user_bar.html.erb
  7. +19 0 app/views/users/new.html.erb
  8. +6 6 config/boot.rb
  9. +1 1  config/environment.rb
  10. +0 1  config/environments/development.rb
  11. +38 0 config/initializers/site_keys.rb
  12. +2 0  config/routes.rb
  13. +1 1  db/schema.rb
  14. +107 44 lib/authenticated_system.rb
  15. +20 0 lib/authenticated_test_helper.rb
  16. +1 1  public/javascripts/controls.js
  17. +1 1  public/javascripts/dragdrop.js
  18. +1 1  public/javascripts/effects.js
  19. +3 0  script/autospec
  20. +3 0  script/dbconsole
  21. +22 5 script/spec_server
  22. +4 1 spec/controllers/moderatorships_controller_spec.rb
  23. +31 0 spec/fixtures/users.yml
  24. +141 0 spec/helpers/users_helper_spec.rb
  25. +1 0  spec/models/forum_spec.rb
  26. +12 11 spec/spec_helper.rb
  27. +4 0 stories/all.rb
  28. +3 0  stories/helper.rb
  29. +22 0 stories/rest_auth_stories.rb
  30. +81 0 stories/rest_auth_stories_helper.rb
  31. +49 0 stories/steps/ra_navigation_steps.rb
  32. +179 0 stories/steps/ra_resource_steps.rb
  33. +171 0 stories/steps/ra_response_steps.rb
  34. +136 0 stories/steps/user_steps.rb
  35. +109 0 stories/users/accounts.story
  36. +134 0 stories/users/sessions.story
  37. +10 0 vendor/plugins/model_stubbing/init.rb
  38. +1 1  vendor/plugins/model_stubbing/lib/model_stubbing.rb
  39. +1 1  vendor/plugins/model_stubbing/lib/model_stubbing/definition.rb
  40. +28 9 vendor/plugins/model_stubbing/lib/model_stubbing/model.rb
  41. +7 2 vendor/plugins/model_stubbing/lib/model_stubbing/stub.rb
  42. +2 8 vendor/plugins/model_stubbing/tasks/stubs.rake
  43. +20 0 vendor/plugins/restful_authentication/.gitignore
  44. +68 0 vendor/plugins/restful_authentication/CHANGELOG
  45. +0 63 vendor/plugins/restful_authentication/README
  46. +224 0 vendor/plugins/restful_authentication/README.textile
  47. +15 0 vendor/plugins/restful_authentication/TODO
  48. +1 1  vendor/plugins/restful_authentication/generators/authenticated/USAGE
  49. +307 87 vendor/plugins/restful_authentication/generators/authenticated/authenticated_generator.rb
  50. +54 0 vendor/plugins/restful_authentication/generators/authenticated/lib/insert_routes.rb
  51. +8 0 vendor/plugins/restful_authentication/generators/authenticated/templates/_model_partial.html.erb
  52. +3 0  vendor/plugins/restful_authentication/generators/authenticated/templates/activation.erb
  53. +0 3  vendor/plugins/restful_authentication/generators/authenticated/templates/activation.rhtml
  54. +105 43 vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_system.rb
  55. +16 4 vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb
  56. +21 9 vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb
  57. +0 19 vendor/plugins/restful_authentication/generators/authenticated/templates/fixtures.yml
  58. +0 74 vendor/plugins/restful_authentication/generators/authenticated/templates/functional_spec.rb
  59. +16 0 vendor/plugins/restful_authentication/generators/authenticated/templates/login.html.erb
  60. +0 14 vendor/plugins/restful_authentication/generators/authenticated/templates/login.rhtml
  61. +11 7 vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb
  62. +51 109 vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb
  63. +49 28 vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb
  64. +0 72 vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_spec.rb
  65. +92 1 vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb
  66. +158 0 vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper_spec.rb
  67. +1 1  vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb
  68. +19 0 vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb
  69. +0 16 vendor/plugins/restful_authentication/generators/authenticated/templates/signup.rhtml
  70. +8 0 vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.erb
  71. +0 8 vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.rhtml
  72. +38 0 vendor/plugins/restful_authentication/generators/authenticated/templates/site_keys.rb
  73. +90 0 ...r/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb
  74. +102 0 ...ins/restful_authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb
  75. +139 0 ...gins/restful_authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb
  76. +198 0 ...plugins/restful_authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb
  77. +60 0 vendor/plugins/restful_authentication/generators/authenticated/templates/spec/fixtures/users.yml
  78. +141 0 vendor/plugins/restful_authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb
  79. +290 0 vendor/plugins/restful_authentication/generators/authenticated/templates/spec/models/user_spec.rb
  80. +22 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories.rb
  81. +81 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb
  82. +49 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb
  83. +179 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb
  84. +171 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb
  85. +153 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/user_steps.rb
  86. +186 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/accounts.story
  87. +134 0 vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/sessions.story
  88. +12 15 vendor/plugins/restful_authentication/generators/authenticated/templates/{ → test}/functional_test.rb
  89. 0  vendor/plugins/restful_authentication/generators/authenticated/templates/{ → test}/mailer_test.rb
  90. +17 10 ...r/plugins/restful_authentication/generators/authenticated/templates/{ → test}/model_functional_test.rb
  91. +36 5 vendor/plugins/restful_authentication/generators/authenticated/templates/{ → test}/unit_test.rb
  92. +0 134 vendor/plugins/restful_authentication/generators/authenticated/templates/unit_spec.rb
  93. +3 0  vendor/plugins/restful_authentication/init.rb
  94. +40 0 vendor/plugins/restful_authentication/lib/authentication.rb
  95. +82 0 vendor/plugins/restful_authentication/lib/authentication/by_cookie_token.rb
  96. +64 0 vendor/plugins/restful_authentication/lib/authentication/by_password.rb
  97. +14 0 vendor/plugins/restful_authentication/lib/authorization.rb
  98. +63 0 vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb
  99. +62 0 vendor/plugins/restful_authentication/lib/authorization/stateful_roles.rb
  100. +14 0 vendor/plugins/restful_authentication/lib/trustification.rb
  101. +20 0 vendor/plugins/restful_authentication/lib/trustification/email_validation.rb
  102. +2 0  vendor/plugins/restful_authentication/notes/AccessControl.txt
  103. +5 0 vendor/plugins/restful_authentication/notes/Authentication.txt
  104. +154 0 vendor/plugins/restful_authentication/notes/Authorization.txt
  105. +78 0 vendor/plugins/restful_authentication/notes/RailsPlugins.txt
  106. BIN  vendor/plugins/restful_authentication/notes/SecurityFramework.graffle
  107. BIN  vendor/plugins/restful_authentication/notes/SecurityFramework.png
  108. +163 0 vendor/plugins/restful_authentication/notes/SecurityPatterns.txt
  109. +126 0 vendor/plugins/restful_authentication/notes/Tradeoffs.txt
  110. +49 0 vendor/plugins/restful_authentication/notes/Trustification.txt
  111. +33 0 vendor/plugins/restful_authentication/tasks/auth.rake
  112. +14 0 vendor/plugins/rspec-rails/History.txt
  113. +13 4 vendor/plugins/rspec-rails/Manifest.txt
  114. +8 5 vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb
  115. +3 0  vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec
  116. +19 0 vendor/plugins/rspec-rails/generators/rspec_default_values.rb
  117. +7 2 vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb
  118. +2 14 vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb
  119. +13 15 vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb
  120. +0 5 vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb
  121. +2 1  vendor/plugins/rspec-rails/lib/spec/rails.rb
  122. +5 5 vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
  123. +20 9 vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb
  124. +6 2 vendor/plugins/rspec-rails/lib/spec/rails/example/cookies_proxy.rb
  125. +3 0  vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb
  126. +3 1 vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb
  127. +9 5 vendor/plugins/rspec-rails/lib/spec/rails/example/rails_example_group.rb
  128. +6 1 vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb
  129. +5 1 vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb
  130. +14 0 vendor/plugins/rspec-rails/lib/spec/rails/interop/testcase.rb
  131. +1 0  vendor/plugins/rspec-rails/lib/spec/rails/matchers/assert_select.rb
  132. +26 6 vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb
  133. +10 4 vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb
  134. +11 3 vendor/plugins/rspec-rails/lib/spec/rails/story_adapter.rb
  135. +0 8 vendor/plugins/rspec-rails/spec/rails/autotest/rails_rspec_spec.rb
  136. +35 30 vendor/plugins/rspec-rails/spec/rails/example/assigns_hash_proxy_spec.rb
  137. +20 6 vendor/plugins/rspec-rails/spec/rails/example/controller_spec_spec.rb
  138. +18 9 vendor/plugins/rspec-rails/spec/rails/example/cookies_proxy_spec.rb
  139. +34 27 vendor/plugins/rspec-rails/spec/rails/example/view_spec_spec.rb
  140. +66 0 vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
  141. +11 3 vendor/plugins/rspec-rails/spec/rails/matchers/assert_select_spec.rb
  142. +10 16 vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb
  143. +1 1  vendor/plugins/rspec-rails/spec/rails/matchers/redirect_to_spec.rb
  144. +21 14 vendor/plugins/rspec-rails/spec/rails/matchers/{render_spec.rb → render_template_spec.rb}
  145. +26 0 vendor/plugins/rspec-rails/spec/rails/mocks/mock_model_spec.rb
  146. +96 96 vendor/plugins/rspec-rails/spec/rails/spec_server_spec.rb
  147. +12 1 vendor/plugins/rspec-rails/spec/spec_helper.rb
  148. +17 1 vendor/plugins/rspec-rails/spec_resources/controllers/controller_spec_controller.rb
  149. +4 0 vendor/plugins/rspec-rails/spec_resources/controllers/render_spec_controller.rb
  150. 0  vendor/plugins/rspec-rails/spec_resources/views/layouts/application.rhtml
  151. 0  vendor/plugins/rspec-rails/spec_resources/views/layouts/simple.rhtml
  152. +1 0  vendor/plugins/rspec-rails/spec_resources/views/objects/_object.html.erb
  153. 0  vendor/plugins/rspec-rails/spec_resources/views/render_spec/action_with_alternate_layout.rhtml
  154. +3 0  vendor/plugins/rspec-rails/spec_resources/views/view_spec/block_helper.rhtml
  155. +3 0  vendor/plugins/rspec-rails/spec_resources/views/view_spec/should_not_receive.rhtml
  156. +7 0 vendor/plugins/rspec/History.txt
  157. +1 1  vendor/plugins/rspec/README.txt
  158. +2 2 vendor/plugins/rspec/Rakefile
  159. +2 1  vendor/plugins/rspec/bin/autospec
  160. +1 1  vendor/plugins/rspec/bin/spec
  161. +33 0 vendor/plugins/rspec/examples/pure/yielding_example.rb
  162. +2 28 vendor/plugins/rspec/lib/autotest/rspec.rb
  163. +2 5 vendor/plugins/rspec/lib/spec.rb
  164. +6 0 vendor/plugins/rspec/lib/spec/example/errors.rb
  165. +11 11 vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
  166. +2 17 vendor/plugins/rspec/lib/spec/extensions/main.rb
  167. +2 2 vendor/plugins/rspec/lib/spec/matchers/change.rb
  168. +1 1  vendor/plugins/rspec/lib/spec/matchers/has.rb
  169. +17 14 vendor/plugins/rspec/lib/spec/matchers/have.rb
  170. +2 2 vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb
  171. +26 0 vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb
  172. +14 2 vendor/plugins/rspec/lib/spec/mocks/methods.rb
  173. +18 4 vendor/plugins/rspec/lib/spec/mocks/proxy.rb
  174. +3 3 vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb
  175. +16 3 vendor/plugins/rspec/lib/spec/runner.rb
  176. +6 7 vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb
  177. +6 17 vendor/plugins/rspec/lib/spec/runner/command_line.rb
  178. +3 1 vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb
  179. +5 9 vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb
  180. +1 1  vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb
  181. +1 1  vendor/plugins/rspec/lib/spec/runner/formatter/nested_text_formatter.rb
  182. +1 1  vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb
  183. +1 1  vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb
  184. +14 1 vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb
  185. +12 6 vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb
  186. +42 0 vendor/plugins/rspec/lib/spec/runner/formatter/story/progress_bar_formatter.rb
  187. +2 2 vendor/plugins/rspec/lib/spec/runner/heckle_runner.rb
  188. +1 0  vendor/plugins/rspec/lib/spec/runner/option_parser.rb
  189. +17 8 vendor/plugins/rspec/lib/spec/runner/options.rb
  190. +22 4 vendor/plugins/rspec/lib/spec/runner/reporter.rb
  191. +1 1  vendor/plugins/rspec/lib/spec/runner/spec_parser.rb
  192. +1 2  vendor/plugins/rspec/lib/spec/story/runner.rb
  193. +3 3 vendor/plugins/rspec/lib/spec/story/step.rb
  194. +2 1  vendor/plugins/rspec/lib/spec/story/step_mother.rb
  195. +1 1  vendor/plugins/rspec/rake_tasks/verify_rcov.rake
  196. +6 66 vendor/plugins/rspec/spec/autotest/rspec_spec.rb
  197. +112 0 vendor/plugins/rspec/spec/spec/example/base_formatter_spec.rb
  198. +2 2 vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb
  199. +4 2 vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb
  200. +3 2 vendor/plugins/rspec/spec/spec/example/example_group_spec.rb
  201. +3 3 vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb
  202. +27 0 vendor/plugins/rspec/spec/spec/example/pending_module_spec.rb
  203. +1 1  vendor/plugins/rspec/spec/spec/example/shared_example_group_spec.rb
  204. +3 8 vendor/plugins/rspec/spec/spec/extensions/main_spec.rb
  205. +12 0 vendor/plugins/rspec/spec/spec/matchers/change_spec.rb
  206. +10 0 vendor/plugins/rspec/spec/spec/matchers/has_spec.rb
  207. +68 0 vendor/plugins/rspec/spec/spec/matchers/have_spec.rb
  208. +24 1 vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb
  209. +7 0 vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb
  210. +17 0 vendor/plugins/rspec/spec/spec/mocks/bug_report_496.rb
  211. +47 2 vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb
  212. +14 0 vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb
  213. +18 28 vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb
  214. +6 0 vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb
  215. +5 12 vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb
  216. +11 4 vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb
  217. +2 1  vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb
  218. +3 3 vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb
  219. +20 2 vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb
  220. +2 1  vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb
  221. +3 3 vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb
  222. +48 0 vendor/plugins/rspec/spec/spec/runner/formatter/story/html_formatter_spec.rb
  223. +52 0 vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb
  224. +82 0 vendor/plugins/rspec/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb
  225. +8 8 vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb
  226. +20 5 vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb
  227. +1 1  vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture_runner.rb
  228. +6 0 vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb
  229. +76 4 vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb
  230. +4 4 vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb
  231. +2 5 vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb
  232. +1 3 vendor/plugins/rspec/spec/spec/story/scenario_spec.rb
  233. +12 0 vendor/plugins/rspec/spec/spec/story/step_mother_spec.rb
  234. +24 2 vendor/plugins/rspec/spec/spec/story/step_spec.rb
  235. +1 3 vendor/plugins/rspec/spec/spec/story/story_spec.rb
  236. +21 68 vendor/plugins/rspec/spec/spec_helper.rb
  237. +0 2  vendor/plugins/rspec/stories/configuration/before_blocks.story
  238. +3 2 vendor/plugins/rspec_on_rails_on_crack/lib/rspec_on_rails_on_crack/controller_example_group_methods.rb
  239. +4 0 vendor/plugins/will_paginate/.gitignore
  240. +49 0 vendor/plugins/will_paginate/.manifest
  241. +100 0 vendor/plugins/will_paginate/CHANGELOG.rdoc
  242. +0 119 vendor/plugins/will_paginate/README
  243. +107 0 vendor/plugins/will_paginate/README.rdoc
  244. +52 16 vendor/plugins/will_paginate/Rakefile
  245. BIN  vendor/plugins/will_paginate/examples/apple-circle.gif
  246. +69 0 vendor/plugins/will_paginate/examples/index.haml
  247. +92 0 vendor/plugins/will_paginate/examples/index.html
  248. +90 0 vendor/plugins/will_paginate/examples/pagination.css
  249. +91 0 vendor/plugins/will_paginate/examples/pagination.sass
  250. +1 4 vendor/plugins/will_paginate/init.rb
  251. +42 17 vendor/plugins/will_paginate/lib/will_paginate.rb
  252. +16 0 vendor/plugins/will_paginate/lib/will_paginate/array.rb
  253. +59 26 vendor/plugins/will_paginate/lib/will_paginate/collection.rb
  254. +1 30 vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb
  255. +168 86 vendor/plugins/will_paginate/lib/will_paginate/finder.rb
  256. +132 0 vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
  257. +39 0 vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb
  258. +9 0 vendor/plugins/will_paginate/lib/will_paginate/version.rb
  259. +328 81 vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
  260. +12 15 vendor/plugins/will_paginate/test/boot.rb
  261. +51 32 vendor/plugins/will_paginate/test/{array_pagination_test.rb → collection_test.rb}
  262. +2 3 vendor/plugins/will_paginate/test/console
  263. +22 0 vendor/plugins/will_paginate/test/database.yml
  264. +248 85 vendor/plugins/will_paginate/test/finder_test.rb
  265. +3 0  vendor/plugins/will_paginate/test/fixtures/developer.rb
  266. +3 4 vendor/plugins/will_paginate/test/fixtures/projects.yml
  267. +0 5 vendor/plugins/will_paginate/test/fixtures/replies.yml
  268. +2 0  vendor/plugins/will_paginate/test/fixtures/reply.rb
  269. +14 14 vendor/plugins/will_paginate/test/fixtures/schema.rb
  270. +2 0  vendor/plugins/will_paginate/test/fixtures/topic.rb
  271. +15 3 vendor/plugins/will_paginate/test/helper.rb
  272. +15 2 vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb
  273. +36 30 vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb
  274. +3 5 vendor/plugins/will_paginate/test/lib/load_fixtures.rb
  275. +165 0 vendor/plugins/will_paginate/test/lib/view_test_process.rb
  276. +0 146 vendor/plugins/will_paginate/test/pagination_test.rb
  277. +59 0 vendor/plugins/will_paginate/test/tasks.rake
  278. +363 0 vendor/plugins/will_paginate/test/view_test.rb
  279. +20 0 vendor/plugins/will_paginate/will_paginate.gemspec
4 app/helpers/application_helper.rb
@@ -6,7 +6,7 @@ def feed_icon_tag(title, url)
6 6 end
7 7
8 8 def pagination(collection)
9   - if collection.page_count > 1
  9 + if collection.total_entries > 1
10 10 "<p class='pages'>" + 'Pages'[:pages_title] + ": <strong>" +
11 11 will_paginate(collection, :inner_window => 10, :next_label => "next"[], :prev_label => "previous"[]) +
12 12 "</strong></p>"
@@ -14,7 +14,7 @@ def pagination(collection)
14 14 end
15 15
16 16 def next_page(collection)
17   - unless collection.current_page == collection.page_count or collection.page_count == 0
  17 + unless collection.current_page == collection.total_entries or collection.total_entries == 0
18 18 "<p style='float:right;'>" + link_to("Next page"[], { :page => collection.current_page.next }.merge(params.reject{|k,v| k=="page"})) + "</p>"
19 19 end
20 20 end
97 app/helpers/users_helper.rb
... ... @@ -1,15 +1,104 @@
1 1 module UsersHelper
2   -
3 2 def user_count
4 3 pluralize current_site.users.size, 'user'[:user]
5 4 end
6   -
  5 +
7 6 def active_user_count
8 7 pluralize current_site.users.count('users.posts_count > 0'), 'active user'[:active_user]
9 8 end
10   -
  9 +
11 10 def lurking_user_count
12 11 pluralize current_site.users.count('users.posts_count = 0'), 'lurking user'[:lurking_user]
13 12 end
  13 +
  14 + #
  15 + # Use this to wrap view elements that the user can't access.
  16 + # !! Note: this is an *interface*, not *security* feature !!
  17 + # You need to do all access control at the controller level.
  18 + #
  19 + # Example:
  20 + # <%= if_authorized?(:index, User) do link_to('List all users', users_path) end %> |
  21 + # <%= if_authorized?(:edit, @user) do link_to('Edit this user', edit_user_path) end %> |
  22 + # <%= if_authorized?(:destroy, @user) do link_to 'Destroy', @user, :confirm => 'Are you sure?', :method => :delete end %>
  23 + #
  24 + #
  25 + def if_authorized?(action, resource, &block)
  26 + if authorized?(action, resource)
  27 + yield action, resource
  28 + end
  29 + end
  30 +
  31 + #
  32 + # Link to user's page ('users/1')
  33 + #
  34 + # By default, their login is used as link text and link title (tooltip)
  35 + #
  36 + # Takes options
  37 + # * :content_text => 'Content text in place of user.login', escaped with
  38 + # the standard h() function.
  39 + # * :content_method => :user_instance_method_to_call_for_content_text
  40 + # * :title_method => :user_instance_method_to_call_for_title_attribute
  41 + # * as well as link_to()'s standard options
  42 + #
  43 + # Examples:
  44 + # link_to_user @user
  45 + # # => <a href="/users/3" title="barmy">barmy</a>
  46 + #
  47 + # # if you've added a .name attribute:
  48 + # content_tag :span, :class => :vcard do
  49 + # (link_to_user user, :class => 'fn n', :title_method => :login, :content_method => :name) +
  50 + # ': ' + (content_tag :span, user.email, :class => 'email')
  51 + # end
  52 + # # => <span class="vcard"><a href="/users/3" title="barmy" class="fn n">Cyril Fotheringay-Phipps</a>: <span class="email">barmy@blandings.com</span></span>
  53 + #
  54 + # link_to_user @user, :content_text => 'Your user page'
  55 + # # => <a href="/users/3" title="barmy" class="nickname">Your user page</a>
  56 + #
  57 + def link_to_user(user, options={})
  58 + raise "Invalid user" unless user
  59 + options.reverse_merge! :content_method => :login, :title_method => :login, :class => :nickname
  60 + content_text = options.delete(:content_text)
  61 + content_text ||= user.send(options.delete(:content_method))
  62 + options[:title] ||= user.send(options.delete(:title_method))
  63 + link_to h(content_text), user_path(user), options
  64 + end
  65 +
  66 + #
  67 + # Link to login page using remote ip address as link content
  68 + #
  69 + # The :title (and thus, tooltip) is set to the IP address
  70 + #
  71 + # Examples:
  72 + # link_to_login_with_IP
  73 + # # => <a href="/login" title="169.69.69.69">169.69.69.69</a>
  74 + #
  75 + # link_to_login_with_IP :content_text => 'not signed in'
  76 + # # => <a href="/login" title="169.69.69.69">not signed in</a>
  77 + #
  78 + def link_to_login_with_IP content_text=nil, options={}
  79 + ip_addr = request.remote_ip
  80 + content_text ||= ip_addr
  81 + options.reverse_merge! :title => ip_addr
  82 + if tag = options.delete(:tag)
  83 + content_tag tag, h(content_text), options
  84 + else
  85 + link_to h(content_text), login_path, options
  86 + end
  87 + end
  88 +
  89 + #
  90 + # Link to the current user's page (using link_to_user) or to the login page
  91 + # (using link_to_login_with_IP).
  92 + #
  93 + def link_to_current_user(options={})
  94 + if current_user
  95 + link_to_user current_user, options
  96 + else
  97 + content_text = options.delete(:content_text) || 'not signed in'
  98 + # kill ignored options from link_to_user
  99 + [:content_method, :title_method].each{|opt| options.delete(opt)}
  100 + link_to_login_with_IP content_text, options
  101 + end
  102 + end
14 103
15   -end
  104 +end
4 app/models/user.rb
... ... @@ -1,4 +1,8 @@
1 1 class User < ActiveRecord::Base
  2 + #include Authentication
  3 + # include Authentication::ByPassword
  4 + # include Authentication::ByCookieToken
  5 +
2 6 concerned_with :validation, :states, :activation, :posting
3 7 formats_attributes :bio
4 8
7 app/views/forums/show.html.erb
@@ -35,11 +35,11 @@
35 35 <%= '{count} post(s)'[(count=@forum.posts.size)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>
36 36 </p>
37 37
38   -<% if @topics.page_count > 1 -%>
  38 +<% if @topics.total_entries > 1 -%>
39 39 <% if logged_in? %>
40 40 <p style="float:right; margin-top:0;"><%= link_to 'New topic'[], new_topic_path(@forum), :class => "utility" %></p>
41 41 <% end %>
42   -<%= pagination @topics %>
  42 +<%= will_paginate @topics %>
43 43 <% end -%>
44 44
45 45 <table border="0" cellspacing="0" cellpadding="0" class="wide topics">
@@ -88,8 +88,7 @@
88 88 <% end %>
89 89 </table>
90 90
91   -<%= next_page @topics %>
92   -<%= pagination @topics %>
  91 +<%= will_paginate @topics %>
93 92
94 93 <% if logged_in? %>
95 94 <p><%= link_to 'New topic'[:new_topic], new_forum_topic_path(@forum), :class => "utility" %></p>
16 app/views/sessions/new.html.erb
... ... @@ -0,0 +1,16 @@
  1 +<h1>Log In</h1>
  2 +
  3 +<% form_tag session_path do -%>
  4 +<p><%= label_tag 'login' %><br />
  5 +<%= text_field_tag 'login', @login %></p>
  6 +
  7 +<p><%= label_tag 'password' %><br/>
  8 +<%= password_field_tag 'password', nil %></p>
  9 +
  10 +<!-- Uncomment this if you want this functionality
  11 +<p><%= label_tag 'remember_me', 'Remember me' %>
  12 +<%= check_box_tag 'remember_me', '1', @remember_me %></p>
  13 +-->
  14 +
  15 +<p><%= submit_tag 'Log in' %></p>
  16 +<% end -%>
8 app/views/users/_user_bar.html.erb
... ... @@ -0,0 +1,8 @@
  1 +<% if logged_in? -%>
  2 + <div id="user-bar-greeting">Logged in as <%= link_to_current_user :content_method => :login %></div>
  3 + <div id="user-bar-action" >(<%= link_to "Log out", logout_path, { :title => "Log out" } %>)</div>
  4 +<% else -%>
  5 + <div id="user-bar-greeting"><%= link_to_login_with_IP 'Not logged in', :style => 'border: none;' %></div>
  6 + <div id="user-bar-action" ><%= link_to "Log in", login_path, { :title => "Log in" } %> /
  7 + <%= link_to "Sign up", signup_path, { :title => "Create an account" } %></div>
  8 +<% end -%>
19 app/views/users/new.html.erb
... ... @@ -0,0 +1,19 @@
  1 +<h1>Sign up as a new user</h1>
  2 +<% @user.password = @user.password_confirmation = nil %>
  3 +
  4 +<%= error_messages_for :user %>
  5 +<% form_for :user, :url => users_path do |f| -%>
  6 +<p><%= label_tag 'login' %><br/>
  7 +<%= f.text_field :login %></p>
  8 +
  9 +<p><%= label_tag 'email' %><br/>
  10 +<%= f.text_field :email %></p>
  11 +
  12 +<p><%= label_tag 'password' %><br/>
  13 +<%= f.password_field :password %></p>
  14 +
  15 +<p><%= label_tag 'password_confirmation', 'Confirm Password' %><br/>
  16 +<%= f.password_field :password_confirmation %></p>
  17 +
  18 +<p><%= submit_tag 'Sign up' %></p>
  19 +<% end -%>
12 config/boot.rb
@@ -24,9 +24,8 @@ def vendor_rails?
24 24 File.exist?("#{RAILS_ROOT}/vendor/rails")
25 25 end
26 26
27   - # FIXME : Ruby 1.9
28 27 def preinitialize
29   - load(preinitializer_path) if File.exists?(preinitializer_path)
  28 + load(preinitializer_path) if File.exist?(preinitializer_path)
30 29 end
31 30
32 31 def preinitializer_path
@@ -44,6 +43,7 @@ def run
44 43 class VendorBoot < Boot
45 44 def load_initializer
46 45 require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
  46 + Rails::Initializer.run(:install_gem_spec_stubs)
47 47 end
48 48 end
49 49
@@ -82,14 +82,14 @@ def gem_version
82 82
83 83 def load_rubygems
84 84 require 'rubygems'
85   -
86   - unless rubygems_version >= '0.9.4'
87   - $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
  85 + min_version = '1.1.1'
  86 + unless rubygems_version >= min_version
  87 + $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
88 88 exit 1
89 89 end
90 90
91 91 rescue LoadError
92   - $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
  92 + $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93 93 exit 1
94 94 end
95 95
2  config/environment.rb
@@ -5,7 +5,7 @@
5 5 # ENV['RAILS_ENV'] ||= 'production'
6 6
7 7 # Specifies gem version of Rails to use when vendor/rails is not present
8   -RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
  8 +RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION
9 9
10 10 # Bootstrap the Rails environment, frameworks, and default configuration
11 11 require File.join(File.dirname(__FILE__), 'boot')
1  config/environments/development.rb
@@ -12,7 +12,6 @@
12 12 config.action_controller.consider_all_requests_local = true
13 13 config.action_view.debug_rjs = true
14 14 config.action_controller.perform_caching = false
15   -config.action_view.cache_template_extensions = false
16 15
17 16 # Don't care if the mailer can't send
18 17 config.action_mailer.raise_delivery_errors = false
38 config/initializers/site_keys.rb
... ... @@ -0,0 +1,38 @@
  1 +
  2 +# A Site key gives additional protection against a dictionary attack if your
  3 +# DB is ever compromised. With no site key, we store
  4 +# DB_password = hash(user_password, DB_user_salt)
  5 +# If your database were to be compromised you'd be vulnerable to a dictionary
  6 +# attack on all your stupid users' passwords. With a site key, we store
  7 +# DB_password = hash(user_password, DB_user_salt, Code_site_key)
  8 +# That means an attacker needs access to both your site's code *and* its
  9 +# database to mount an "offline dictionary attack.":http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/web-authentication.html
  10 +#
  11 +# It's probably of minor importance, but recommended by best practices: 'defense
  12 +# in depth'. Needless to say, if you upload this to github or the youtubes or
  13 +# otherwise place it in public view you'll kinda defeat the point. Your users'
  14 +# passwords are still secure, and the world won't end, but defense_in_depth -= 1.
  15 +#
  16 +# Please note: if you change this, all the passwords will be invalidated, so DO
  17 +# keep it someplace secure. Use the random value given or type in the lyrics to
  18 +# your favorite Jay-Z song or something; any moderately long, unpredictable text.
  19 +REST_AUTH_SITE_KEY = '5bac03451eef26959eacd908c304242011250e66'
  20 +
  21 +# Repeated applications of the hash make brute force (even with a compromised
  22 +# database and site key) harder, and scale with Moore's law.
  23 +#
  24 +# bq. "To squeeze the most security out of a limited-entropy password or
  25 +# passphrase, we can use two techniques [salting and stretching]... that are
  26 +# so simple and obvious that they should be used in every password system.
  27 +# There is really no excuse not to use them." http://tinyurl.com/37lb73
  28 +# Practical Security (Ferguson & Scheier) p350
  29 +#
  30 +# A modest 10 foldings (the default here) adds 3ms. This makes brute forcing 10
  31 +# times harder, while reducing an app that otherwise serves 100 reqs/s to 78 signin
  32 +# reqs/s, an app that does 10reqs/s to 9.7 reqs/s
  33 +#
  34 +# More:
  35 +# * http://www.owasp.org/index.php/Hashing_Java
  36 +# * "An Illustrated Guide to Cryptographic Hashes":http://www.unixwiz.net/techtips/iguide-crypto-hashes.html
  37 +
  38 +REST_AUTH_DIGEST_STRETCHES = 10
2  config/routes.rb
... ... @@ -1,4 +1,6 @@
1 1 ActionController::Routing::Routes.draw do |map|
  2 + map.resource :session
  3 +
2 4 map.resources :sites, :moderatorships
3 5
4 6 map.resources :forums, :has_many => :posts do |forum|
2  db/schema.rb
... ... @@ -1,5 +1,5 @@
1 1 # This file is auto-generated from the current state of the database. Instead of editing this file,
2   -# please use the migrations feature of ActiveRecord to incrementally modify your database, and
  2 +# please use the migrations feature of Active Record to incrementally modify your database, and
3 3 # then regenerate this schema definition.
4 4 #
5 5 # Note that this schema.rb definition is the authoritative source for your database schema. If you need
151 lib/authenticated_system.rb
@@ -3,36 +3,37 @@ module AuthenticatedSystem
3 3 def current_site
4 4 @current_site ||= Site.find_by_host(request.host) or raise Site::UndefinedError
5 5 end
6   -
  6 +
7 7 # Returns true or false if the user is logged in.
8 8 # Preloads @current_user with the user model if they're logged in.
9 9 def logged_in?
10   - current_user != :false
  10 + !!current_user
11 11 end
12   -
13   - # Accesses the current user from the session. Set it to :false if login fails
14   - # so that future calls do not hit the database.
  12 +
  13 + # Accesses the current user from the session.
  14 + # Future calls avoid the database because nil is not equal to false.
15 15 def current_user
16   - @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || :false)
  16 + @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_user == false
17 17 end
18   -
19   - # Store the given user in the session.
  18 +
  19 + # Store the given user id in the session.
20 20 def current_user=(new_user)
21   - session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id
22   - @current_user = new_user
  21 + session[:user_id] = new_user ? new_user.id : nil
  22 + @current_user = new_user || false
23 23 end
24   -
  24 +
25 25 def admin?
26 26 logged_in? && current_user.admin?
27 27 end
28 28
29 29 def moderator_of?(record)
30   - return true if admin?
  30 + return true if admin?
31 31 return false unless logged_in?
32 32 forum = record.respond_to?(:forum) ? record.forum : record
33 33 current_user.moderator_of? forum
34 34 end
35   -
  35 +
  36 +
36 37 # Check if the user is authorized
37 38 #
38 39 # Override this method in your controllers if you want to restrict access
@@ -45,8 +46,9 @@ def moderator_of?(record)
45 46 # def authorized?
46 47 # current_user.login != "bob"
47 48 # end
48   - def authorized?
49   - true
  49 + #
  50 + def authorized?(action = action_name, resource = nil)
  51 + logged_in?
50 52 end
51 53
52 54 # Filter method to enforce a login requirement.
@@ -64,9 +66,9 @@ def authorized?
64 66 # skip_before_filter :login_required
65 67 #
66 68 def login_required
67   - (logged_in? && authorized?) || access_denied
  69 + authorized? || access_denied
68 70 end
69   -
  71 +
70 72 def admin_required
71 73 admin? || access_denied
72 74 end
@@ -80,67 +82,128 @@ def admin_required
80 82 # to access the requested action. For example, a popup window might
81 83 # simply close itself.
82 84 def access_denied
83   - respond_to do |accepts|
84   - accepts.html do
  85 + respond_to do |format|
  86 + format.html do
85 87 store_location
86   - redirect_to :controller => '/sessions', :action => 'new'
  88 + redirect_to new_session_path
87 89 end
88   - accepts.xml do
89   - headers["Status"] = "Unauthorized"
90   - headers["WWW-Authenticate"] = %(Basic realm="Web Password")
91   - render :text => "Could't authenticate you", :status => '401 Unauthorized'
  90 + # format.any doesn't work in rails version < http://dev.rubyonrails.org/changeset/8987
  91 + # Add any other API formats here. (Some browsers, notably IE6, send Accept: */* and trigger
  92 + # the 'format.any' block incorrectly. See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2
  93 + # for a workaround.)
  94 + format.any(:json, :xml) do
  95 + request_http_basic_authentication 'Web Password'
92 96 end
93 97 end
94   - false
95   - end
96   -
  98 + end
  99 +
97 100 # Store the URI of the current request in the session.
98 101 #
99 102 # We can return to this location by calling #redirect_back_or_default.
100 103 def store_location
101 104 session[:return_to] = request.request_uri
102 105 end
103   -
  106 +
104 107 # Redirect to the URI stored by the most recent store_location call or
105   - # to the passed default.
  108 + # to the passed default. Set an appropriately modified
  109 + # after_filter :store_location, :only => [:index, :new, :show, :edit]
  110 + # for any controller you want to be bounce-backable.
106 111 def redirect_back_or_default(default)
107 112 redirect_to(session[:return_to] || default)
108 113 session[:return_to] = nil
109 114 end
110   -
  115 +
111 116 # Inclusion hook to make #current_user and #logged_in?
112 117 # available as ActionView helper methods.
113 118 def self.included(base)
114   - base.send :helper_method, :current_user, :logged_in?, :current_site, :admin?, :moderator_of?
  119 + base.send :helper_method, :current_user, :logged_in?, :current_site, :admin?, :moderator_of? if base.respond_to? :helper_method
115 120 end
116 121
  122 + #
  123 + # Login
  124 + #
  125 +
117 126 # Called from #current_user. First attempt to login by the user id stored in the session.
118 127 def login_from_session
119   - self.current_user = current_site.users.find_by_id(session[:user]) if session[:user]
  128 + self.current_user = User.find_by_id(session[:user_id]) if session[:user_id]
120 129 end
121 130
122 131 # Called from #current_user. Now, attempt to login by basic authentication information.
123 132 def login_from_basic_auth
124   - username, passwd = get_auth_data
125   - self.current_user = current_site.users.authenticate(username, passwd) if username && passwd
  133 + authenticate_with_http_basic do |login, password|
  134 + self.current_user = User.authenticate(login, password)
  135 + end
126 136 end
  137 +
  138 + #
  139 + # Logout
  140 + #
127 141
128 142 # Called from #current_user. Finaly, attempt to login by an expiring token in the cookie.
  143 + # for the paranoid: we _should_ be storing user_token = hash(cookie_token, request IP)
129 144 def login_from_cookie
130   - user = cookies[:auth_token] && current_site.users.find_by_remember_token(cookies[:auth_token])
  145 + user = cookies[:auth_token] && User.find_by_remember_token(cookies[:auth_token])
131 146 if user && user.remember_token?
132   - user.remember_me
133   - cookies[:auth_token] = { :value => user.remember_token, :expires => user.remember_token_expires_at }
134 147 self.current_user = user
  148 + handle_remember_cookie! false # freshen cookie token (keeping date)
  149 + self.current_user
135 150 end
136 151 end
137 152
138   - private
139   - @@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization)
140   - # gets BASIC auth info
141   - def get_auth_data
142   - auth_key = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
143   - auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
144   - return auth_data && auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil]
  153 + # This is ususally what you want; resetting the session willy-nilly wreaks
  154 + # havoc with forgery protection, and is only strictly necessary on login.
  155 + # However, **all session state variables should be unset here**.
  156 + def logout_keeping_session!
  157 + # Kill server-side auth cookie
  158 + @current_user.forget_me if @current_user.is_a? User
  159 + @current_user = false # not logged in, and don't do it for me
  160 + kill_remember_cookie! # Kill client-side auth cookie
  161 + session[:user_id] = nil # keeps the session but kill our variable
  162 + # explicitly kill any other session variables you set
145 163 end
  164 +
  165 + # The session should only be reset at the tail end of a form POST --
  166 + # otherwise the request forgery protection fails. It's only really necessary
  167 + # when you cross quarantine (logged-out to logged-in).
  168 + def logout_killing_session!
  169 + logout_keeping_session!
  170 + reset_session
  171 + end
  172 +
  173 + #
  174 + # Remember_me Tokens
  175 + #
  176 + # Cookies shouldn't be allowed to persist past their freshness date,
  177 + # and they should be changed at each login
  178 +
  179 + # Cookies shouldn't be allowed to persist past their freshness date,
  180 + # and they should be changed at each login
  181 +
  182 + def valid_remember_cookie?
  183 + return nil unless @current_user
  184 + (@current_user.remember_token?) &&
  185 + (cookies[:auth_token] == @current_user.remember_token)
  186 + end
  187 +
  188 + # Refresh the cookie auth token if it exists, create it otherwise
  189 + def handle_remember_cookie!(new_cookie_flag)
  190 + return unless @current_user
  191 + case
  192 + when valid_remember_cookie? then @current_user.refresh_token # keeping same expiry date
  193 + when new_cookie_flag then @current_user.remember_me
  194 + else @current_user.forget_me
  195 + end
  196 + send_remember_cookie!
  197 + end
  198 +
  199 + def kill_remember_cookie!
  200 + cookies.delete :auth_token
  201 + end
  202 +
  203 + def send_remember_cookie!
  204 + cookies[:auth_token] = {
  205 + :value => @current_user.remember_token,
  206 + :expires => @current_user.remember_token_expires_at }
  207 + end
  208 +
146 209 end
20 lib/authenticated_test_helper.rb
... ... @@ -0,0 +1,20 @@
  1 +module AuthenticatedTestHelper
  2 + # Sets the current user in the session from the user fixtures.
  3 + def login_as(user)
  4 + @request.session[:user_id] = user ? users(user).id : nil
  5 + end
  6 +
  7 + def authorize_as(user)
  8 + @request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAuthentication::Basic.encode_credentials(users(user).login, 'monkey') : nil
  9 + end
  10 +
  11 + # rspec
  12 + def mock_user
  13 + user = mock_model(User, :id => 1,
  14 + :login => 'user_name',
  15 + :name => 'U. Surname',
  16 + :to_xml => "User-in-XML", :to_json => "User-in-JSON",
  17 + :errors => [])
  18 + user
  19 + end
  20 +end
2  public/javascripts/controls.js
... ... @@ -1,4 +1,4 @@
1   -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
  1 +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2 2 // (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
3 3 // (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
4 4 // Contributors:
2  public/javascripts/dragdrop.js
... ... @@ -1,4 +1,4 @@
1   -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
  1 +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2 2 // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
3 3 //
4 4 // script.aculo.us is freely distributable under the terms of an MIT-style license.
2  public/javascripts/effects.js
... ... @@ -1,4 +1,4 @@
1   -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
  1 +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2 2 // Contributors:
3 3 // Justin Palmer (http://encytemedia.com/)
4 4 // Mark Pilgrim (http://diveintomark.org/)
3  script/autospec
... ... @@ -0,0 +1,3 @@
  1 +#!/usr/bin/env ruby
  2 +ENV['RSPEC'] = 'true'
  3 +system 'autotest'
3  script/dbconsole
... ... @@ -0,0 +1,3 @@
  1 +#!/usr/bin/env ruby
  2 +require File.dirname(__FILE__) + '/../config/boot'
  3 +require 'commands/dbconsole'
27 script/spec_server
... ... @@ -1,5 +1,4 @@
1 1 #!/usr/bin/env ruby
2   -$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
3 2 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
4 3 require 'rubygems'
5 4 require 'drb/drb'
@@ -23,17 +22,29 @@ module Spec
23 22 active_connections.delete(name)
24 23 end
25 24 end
26   - end
  25 + end
27 26
28   - if ::Dispatcher.respond_to?(:cleanup_application)
29   - ::Dispatcher.cleanup_application
  27 + if ActionController.const_defined?(:Dispatcher)
  28 + dispatcher = ::ActionController::Dispatcher.new($stdout)
  29 + dispatcher.cleanup_application
30 30 elsif ::Dispatcher.respond_to?(:reset_application!)
31 31 ::Dispatcher.reset_application!
  32 + else
  33 + raise "Application reloading failed"
  34 + end
  35 + if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
  36 + Fixtures.reset_cache
32 37 end
  38 +
33 39 ::Dependencies.mechanism = :load
34 40 require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
35 41 load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
36 42
  43 + if in_memory_database?
  44 + load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
  45 + ActiveRecord::Migrator.up('db/migrate') # use migrations
  46 + end
  47 +
37 48 ::Spec::Runner::CommandLine.run(
38 49 ::Spec::Runner::OptionParser.parse(
39 50 argv,
@@ -42,6 +53,12 @@ module Spec
42 53 )
43 54 )
44 55 end
  56 +
  57 + def in_memory_database?
  58 + ENV["RAILS_ENV"] == "test" and
  59 + ::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
  60 + ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
  61 + end
45 62 end
46 63 end
47 64 end
@@ -88,7 +105,7 @@ opts.parse!(ARGV)
88 105 puts "Ready"
89 106 exec_server = lambda {
90 107 trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
91   - DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new)
  108 + DRb.start_service("druby://127.0.0.1:8989", Spec::Runner::RailsSpecServer.new)
92 109 DRb.thread.join
93 110 }
94 111
5 spec/controllers/moderatorships_controller_spec.rb
@@ -21,7 +21,9 @@
21 21 it_assigns :moderatorship, :flash => {:notice => nil, :error => :not_nil}
22 22 it_redirects_to { user_path(users(:default)) }
23 23 end
24   -
  24 +
  25 +# Seriously, I could give a crap about XML.
  26 +=begin
25 27 describe ModeratorshipsController, "(successful creation, xml)" do
26 28 define_models
27 29 act! { post :create, :moderatorship => @attributes, :format => 'xml' }
@@ -41,6 +43,7 @@
41 43 assigns(:moderatorship).errors.to_xml
42 44 end
43 45 end
  46 +=end
44 47 end
45 48
46 49 describe ModeratorshipsController, "DELETE #destroy" do
31 spec/fixtures/users.yml
... ... @@ -0,0 +1,31 @@
  1 +
  2 +quentin:
  3 + id: 1
  4 + login: quentin
  5 + email: quentin@example.com
  6 + salt: 356a192b7913b04c54574d18c28d46e6395428ab # SHA1('0')
  7 + crypted_password: 5ac9f13821d511a4a9715eab643ec00ab405f50e # 'monkey'
  8 + created_at: <%= 5.days.ago.to_s :db %>
  9 + remember_token_expires_at: <%= 1.days.from_now.to_s %>
  10 + remember_token: 77de68daecd823babbb58edb1c8e14d7106e83bb
  11 +
  12 +aaron:
  13 + id: 2
  14 + login: aaron
  15 + email: aaron@example.com
  16 + salt: da4b9237bacccdf19c0760cab7aec4a8359010b0 # SHA1('1')
  17 + crypted_password: d6c89070e3b4691acf4108ea26c0fbcc1880e3a3 # 'monkey'
  18 + created_at: <%= 1.days.ago.to_s :db %>
  19 + remember_token_expires_at:
  20 + remember_token:
  21 +
  22 +
  23 +old_password_holder:
  24 + id: 3
  25 + login: old_password_holder
  26 + email: salty_dog@example.com
  27 + salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
  28 + crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
  29 + created_at: <%= 1.days.ago.to_s :db %>
  30 +
  31 +
141 spec/helpers/users_helper_spec.rb
... ... @@ -0,0 +1,141 @@
  1 +require File.dirname(__FILE__) + '/../spec_helper'
  2 +include ApplicationHelper
  3 +include UsersHelper
  4 +include AuthenticatedTestHelper
  5 +
  6 +describe UsersHelper do
  7 + before do
  8 + @user = mock_user
  9 + end
  10 +
  11 + describe "if_authorized" do
  12 + it "yields if authorized" do
  13 + should_receive(:authorized?).with('a','r').and_return(true)
  14 + if_authorized?('a','r'){|action,resource| [action,resource,'hi'] }.should == ['a','r','hi']
  15 + end
  16 + it "does nothing if not authorized" do
  17 + should_receive(:authorized?).with('a','r').and_return(false)
  18 + if_authorized?('a','r'){ 'hi' }.should be_nil
  19 + end
  20 + end
  21 +
  22 + describe "link_to_user" do
  23 + it "should give an error on a nil user" do
  24 + lambda { link_to_user(nil) }.should raise_error('Invalid user')
  25 + end
  26 + it "should link to the given user" do
  27 + should_receive(:user_path).at_least(:once).and_return('/users/1')
  28 + link_to_user(@user).should have_tag("a[href='/users/1']")
  29 + end
  30 + it "should use given link text if :content_text is specified" do
  31 + link_to_user(@user, :content_text => 'Hello there!').should have_tag("a", 'Hello there!')
  32 + end
  33 + it "should use the login as link text with no :content_method specified" do
  34 + link_to_user(@user).should have_tag("a", 'user_name')
  35 + end
  36 + it "should use the name as link text with :content_method => :name" do
  37 + link_to_user(@user, :content_method => :name).should have_tag("a", 'U. Surname')
  38 + end
  39 + it "should use the login as title with no :title_method specified" do
  40 + link_to_user(@user).should have_tag("a[title='user_name']")
  41 + end
  42 + it "should use the name as link title with :content_method => :name" do
  43 + link_to_user(@user, :title_method => :name).should have_tag("a[title='U. Surname']")
  44 + end
  45 + it "should have nickname as a class by default" do
  46 + link_to_user(@user).should have_tag("a.nickname")
  47 + end
  48 + it "should take other classes and no longer have the nickname class" do
  49 + result = link_to_user(@user, :class => 'foo bar')
  50 + result.should have_tag("a.foo")
  51 + result.should have_tag("a.bar")
  52 + end
  53 + end
  54 +
  55 + describe "link_to_login_with_IP" do
  56 + it "should link to the login_path" do
  57 + link_to_login_with_IP().should have_tag("a[href='/login']")
  58 + end
  59 + it "should use given link text if :content_text is specified" do
  60 + link_to_login_with_IP('Hello there!').should have_tag("a", 'Hello there!')
  61 + end
  62 + it "should use the login as link text with no :content_method specified" do
  63 + link_to_login_with_IP().should have_tag("a", '0.0.0.0')
  64 + end
  65 + it "should use the ip address as title" do
  66 + link_to_login_with_IP().should have_tag("a[title='0.0.0.0']")
  67 + end
  68 + it "should by default be like school in summer and have no class" do
  69 + link_to_login_with_IP().should_not have_tag("a.nickname")
  70 + end
  71 + it "should have some class if you tell it to" do
  72 + result = link_to_login_with_IP(nil, :class => 'foo bar')
  73 + result.should have_tag("a.foo")
  74 + result.should have_tag("a.bar")
  75 + end
  76 + it "should have some class if you tell it to" do
  77 + result = link_to_login_with_IP(nil, :tag => 'abbr')
  78 + result.should have_tag("abbr[title='0.0.0.0']")
  79 + end
  80 + end
  81 +
  82 + describe "link_to_current_user, When logged in" do
  83 + before do
  84 + stub!(:current_user).and_return(@user)
  85 + end
  86 + it "should link to the given user" do
  87 + should_receive(:user_path).at_least(:once).and_return('/users/1')
  88 + link_to_current_user().should have_tag("a[href='/users/1']")
  89 + end
  90 + it "should use given link text if :content_text is specified" do
  91 + link_to_current_user(:content_text => 'Hello there!').should have_tag("a", 'Hello there!')
  92 + end
  93 + it "should use the login as link text with no :content_method specified" do
  94 + link_to_current_user().should have_tag("a", 'user_name')
  95 + end
  96 + it "should use the name as link text with :content_method => :name" do
  97 + link_to_current_user(:content_method => :name).should have_tag("a", 'U. Surname')
  98 + end
  99 + it "should use the login as title with no :title_method specified" do
  100 + link_to_current_user().should have_tag("a[title='user_name']")
  101 + end
  102 + it "should use the name as link title with :content_method => :name" do
  103 + link_to_current_user(:title_method => :name).should have_tag("a[title='U. Surname']")
  104 + end
  105 + it "should have nickname as a class" do
  106 + link_to_current_user().should have_tag("a.nickname")
  107 + end
  108 + it "should take other classes and no longer have the nickname class" do
  109 + result = link_to_current_user(:class => 'foo bar')
  110 + result.should have_tag("a.foo")
  111 + result.should have_tag("a.bar")
  112 + end
  113 + end
  114 +
  115 + describe "link_to_current_user, When logged out" do
  116 + before do
  117 + stub!(:current_user).and_return(nil)
  118 + end
  119 + it "should link to the login_path" do
  120 + link_to_current_user().should have_tag("a[href='/login']")
  121 + end
  122 + it "should use given link text if :content_text is specified" do
  123 + link_to_current_user(:content_text => 'Hello there!').should have_tag("a", 'Hello there!')
  124 + end
  125 + it "should use 'not signed in' as link text with no :content_method specified" do
  126 + link_to_current_user().should have_tag("a", 'not signed in')
  127 + end
  128 + it "should use the ip address as title" do
  129 + link_to_current_user().should have_tag("a[title='0.0.0.0']")
  130 + end
  131 + it "should by default be like school in summer and have no class" do
  132 + link_to_current_user().should_not have_tag("a.nickname")
  133 + end
  134 + it "should have some class if you tell it to" do
  135 + result = link_to_current_user(:class => 'foo bar')
  136 + result.should have_tag("a.foo")
  137 + result.should have_tag("a.bar")
  138 + end
  139 + end
  140 +
  141 +end
1  spec/models/forum_spec.rb
... ... @@ -1,4 +1,5 @@
1 1 require File.dirname(__FILE__) + '/../spec_helper'
  2 +require 'model_stubbing'
2 3
3 4 describe Forum do
4 5 define_models do
23 spec/spec_helper.rb
@@ -7,10 +7,11 @@
7 7 require 'rspec_on_rails_on_crack'
8 8 require 'model_stubbing'
9 9 require File.dirname(__FILE__) + "/model_stubs"
10   -require 'ruby-debug'
11   -Debugger.start
  10 +#require 'ruby-debug'
  11 +#Debugger.start
12 12
13 13 Spec::Runner.configure do |config|
  14 + include AuthenticatedTestHelper
14 15 config.use_transactional_fixtures = true
15 16 config.use_instantiated_fixtures = false
16 17 config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
@@ -18,13 +19,13 @@
18 19 def current_site(site)
19 20 @controller.stub!(:current_site).and_return(@site = site ? sites(site) : nil)
20 21 end
21   -
  22 +
22 23 # Sets the current user in the session from the user fixtures.
23   - def login_as(user)
24   - controller.stub!(:current_user).and_return(@user = user ? users(user) : nil)
25   - end
26   -
27   - def authorize_as(user)
28   - @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil
29   - end
30   -end
  24 +# def login_as(user)
  25 + # controller.stub!(:current_user).and_return(@user = user ? users(user) : nil)
  26 + # end
  27 +
  28 + #def authorize_as(user)
  29 + # @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test")}" : nil
  30 + #end
  31 +end
4 stories/all.rb
... ... @@ -0,0 +1,4 @@
  1 +dir = File.dirname(__FILE__)
  2 +Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
  3 + require file
  4 +end
3  stories/helper.rb
... ... @@ -0,0 +1,3 @@
  1 +ENV["RAILS_ENV"] = "test"
  2 +require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
  3 +require 'spec/rails/story_adapter'
22 stories/rest_auth_stories.rb
... ... @@ -0,0 +1,22 @@
  1 +#!/usr/bin/env ruby
  2 +ENV["RAILS_ENV"] = "test"
  3 +require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
  4 +require 'spec/rails/story_adapter'
  5 +require 'spec/story'
  6 +require File.expand_path(File.dirname(__FILE__) + "/rest_auth_stories_helper.rb")