voluntary 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +48 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/javascripts/voluntary/application.js +6 -0
  5. data/app/assets/javascripts/voluntary/base.js.coffee +34 -0
  6. data/app/assets/javascripts/voluntary/bootstrap.js.coffee +4 -0
  7. data/app/assets/javascripts/voluntary/functions.js +24 -0
  8. data/app/assets/javascripts/voluntary/users.js.coffee +12 -0
  9. data/app/assets/stylesheets/voluntary/application.css +15 -0
  10. data/app/assets/stylesheets/voluntary/base.css.scss +40 -0
  11. data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.less +67 -0
  12. data/app/controllers/areas_controller.rb +66 -0
  13. data/app/controllers/candidatures_controller.rb +79 -0
  14. data/app/controllers/comments_controller.rb +70 -0
  15. data/app/controllers/devise_extensions/registrations_controller.rb +37 -0
  16. data/app/controllers/home_controller.rb +7 -0
  17. data/app/controllers/organizations_controller.rb +67 -0
  18. data/app/controllers/pages_controller.rb +54 -0
  19. data/app/controllers/products_controller.rb +62 -0
  20. data/app/controllers/professions_controller.rb +66 -0
  21. data/app/controllers/projects_controller.rb +56 -0
  22. data/app/controllers/results_controller.rb +93 -0
  23. data/app/controllers/stories_controller.rb +96 -0
  24. data/app/controllers/tasks_controller.rb +88 -0
  25. data/app/controllers/users_controller.rb +52 -0
  26. data/app/controllers/vacancies_controller.rb +79 -0
  27. data/app/controllers/voluntary/application_controller.rb +92 -0
  28. data/app/controllers/workflow/candidatures_controller.rb +20 -0
  29. data/app/controllers/workflow/products_controller.rb +6 -0
  30. data/app/controllers/workflow/project_owner_controller.rb +33 -0
  31. data/app/controllers/workflow/stories_controller.rb +6 -0
  32. data/app/controllers/workflow/tasks_controller.rb +147 -0
  33. data/app/controllers/workflow/user_controller.rb +6 -0
  34. data/app/controllers/workflow/vacancies_controller.rb +17 -0
  35. data/app/controllers/workflow_controller.rb +7 -0
  36. data/app/helpers/application_helper.rb +65 -0
  37. data/app/helpers/collection_helper.rb +31 -0
  38. data/app/helpers/comments_helper.rb +11 -0
  39. data/app/helpers/form_helper.rb +39 -0
  40. data/app/helpers/language_helper.rb +15 -0
  41. data/app/helpers/layout_helper.rb +24 -0
  42. data/app/helpers/product_helper.rb +32 -0
  43. data/app/helpers/show_helper.rb +65 -0
  44. data/app/helpers/wizard_helper.rb +27 -0
  45. data/app/models/area.rb +19 -0
  46. data/app/models/area_user.rb +19 -0
  47. data/app/models/candidature.rb +35 -0
  48. data/app/models/comment.rb +16 -0
  49. data/app/models/history_tracker.rb +3 -0
  50. data/app/models/mongo_db_document.rb +11 -0
  51. data/app/models/organization.rb +19 -0
  52. data/app/models/page.rb +30 -0
  53. data/app/models/product.rb +99 -0
  54. data/app/models/product/new_product.rb +3 -0
  55. data/app/models/product/project_management.rb +29 -0
  56. data/app/models/profession.rb +13 -0
  57. data/app/models/project.rb +66 -0
  58. data/app/models/project_user.rb +13 -0
  59. data/app/models/result.rb +55 -0
  60. data/app/models/role.rb +8 -0
  61. data/app/models/role/admin.rb +2 -0
  62. data/app/models/role/master.rb +2 -0
  63. data/app/models/role/project_owner.rb +2 -0
  64. data/app/models/role/user.rb +2 -0
  65. data/app/models/state_machines/candidature.rb +42 -0
  66. data/app/models/state_machines/page.rb +18 -0
  67. data/app/models/state_machines/story.rb +51 -0
  68. data/app/models/state_machines/task.rb +46 -0
  69. data/app/models/state_machines/vacancy.rb +41 -0
  70. data/app/models/story.rb +82 -0
  71. data/app/models/task.rb +85 -0
  72. data/app/models/user.rb +95 -0
  73. data/app/models/user_role.rb +6 -0
  74. data/app/models/vacancy.rb +41 -0
  75. data/app/observers/candidature_observer.rb +29 -0
  76. data/app/observers/story_observer.rb +6 -0
  77. data/app/observers/task_observer.rb +34 -0
  78. data/app/presenters/layout/application_presenter.rb +3 -0
  79. data/app/presenters/layout_presenter.rb +9 -0
  80. data/app/presenters/presenter.rb +46 -0
  81. data/app/presenters/resource_presenter.rb +30 -0
  82. data/app/presenters/resources/general/wizard_presenter.rb +17 -0
  83. data/app/presenters/resources/general/wizards/story/steps/activate_presenter.rb +3 -0
  84. data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +5 -0
  85. data/app/presenters/resources/general/wizards/story_presenter.rb +3 -0
  86. data/app/presenters/resources/user/form_presenter.rb +16 -0
  87. data/app/presenters/shared/collection/table_presenter.rb +33 -0
  88. data/app/views/areas/_form.html.erb +11 -0
  89. data/app/views/areas/edit.html.erb +3 -0
  90. data/app/views/areas/index.html.erb +5 -0
  91. data/app/views/areas/new.html.erb +3 -0
  92. data/app/views/areas/show.html.erb +6 -0
  93. data/app/views/candidatures/_form.html.erb +13 -0
  94. data/app/views/candidatures/edit.html.erb +3 -0
  95. data/app/views/candidatures/index.html.erb +11 -0
  96. data/app/views/candidatures/new.html.erb +3 -0
  97. data/app/views/candidatures/show.html.erb +18 -0
  98. data/app/views/comments/_form.html.erb +16 -0
  99. data/app/views/comments/_resource.html.erb +16 -0
  100. data/app/views/comments/edit.html.erb +3 -0
  101. data/app/views/comments/new.html.erb +3 -0
  102. data/app/views/devise/mailer/confirmation_instructions.html.erb +10 -0
  103. data/app/views/devise/registrations/new.html.erb +5 -0
  104. data/app/views/general/wizard.html.erb +16 -0
  105. data/app/views/kaminari/_first_page.html.erb +13 -0
  106. data/app/views/kaminari/_gap.html.erb +8 -0
  107. data/app/views/kaminari/_last_page.html.erb +13 -0
  108. data/app/views/kaminari/_next_page.html.erb +13 -0
  109. data/app/views/kaminari/_page.html.erb +12 -0
  110. data/app/views/kaminari/_paginator.html.erb +25 -0
  111. data/app/views/kaminari/_prev_page.html.erb +13 -0
  112. data/app/views/layouts/application.html.erb +48 -0
  113. data/app/views/layouts/shared/_flash_messages.html.erb +7 -0
  114. data/app/views/layouts/shared/_navigation.html.erb +7 -0
  115. data/app/views/organizations/_form.html.erb +11 -0
  116. data/app/views/organizations/edit.html.erb +3 -0
  117. data/app/views/organizations/index.html.erb +5 -0
  118. data/app/views/organizations/new.html.erb +3 -0
  119. data/app/views/organizations/show.html.erb +6 -0
  120. data/app/views/pages/_form.html.erb +12 -0
  121. data/app/views/pages/edit.html.erb +3 -0
  122. data/app/views/pages/index.html.erb +5 -0
  123. data/app/views/pages/new.html.erb +3 -0
  124. data/app/views/pages/show.html.erb +10 -0
  125. data/app/views/products/_form.html.erb +28 -0
  126. data/app/views/products/edit.html.erb +3 -0
  127. data/app/views/products/index.html.erb +5 -0
  128. data/app/views/products/mixins/_keywords.html.erb +4 -0
  129. data/app/views/products/new.html.erb +3 -0
  130. data/app/views/products/show.html.erb +11 -0
  131. data/app/views/products/types/text_creation/stories/_form.html.erb +19 -0
  132. data/app/views/products/types/text_creation/stories/_task_fields.html.erb +7 -0
  133. data/app/views/projects/_form.html.erb +16 -0
  134. data/app/views/projects/edit.html.erb +3 -0
  135. data/app/views/projects/index.html.erb +5 -0
  136. data/app/views/projects/new.html.erb +3 -0
  137. data/app/views/projects/show.html.erb +13 -0
  138. data/app/views/shared/_comments.html.erb +7 -0
  139. data/app/views/shared/collection/_list.html.erb +37 -0
  140. data/app/views/shared/collection/_table.html.erb +36 -0
  141. data/app/views/shared/form/_error_messages.html.erb +10 -0
  142. data/app/views/shared/resource/_actions.html.erb +26 -0
  143. data/app/views/shared/resource/_event_elements.html.erb +7 -0
  144. data/app/views/stories/_collection.html.erb +8 -0
  145. data/app/views/stories/_form.html.erb +19 -0
  146. data/app/views/stories/_task_fields.html.erb +11 -0
  147. data/app/views/stories/index.html.erb +1 -0
  148. data/app/views/stories/show.html.erb +13 -0
  149. data/app/views/stories/steps/_activate.html.erb +17 -0
  150. data/app/views/stories/steps/_setup_tasks.html.erb +35 -0
  151. data/app/views/stories/tasks.html.erb +0 -0
  152. data/app/views/tasks/_collection.html.erb +12 -0
  153. data/app/views/users/_form.html.erb +43 -0
  154. data/app/views/users/edit.html.erb +3 -0
  155. data/app/views/users/index.html.erb +6 -0
  156. data/app/views/users/new.html.erb +3 -0
  157. data/app/views/users/preferences.html.erb +11 -0
  158. data/app/views/users/show.html.erb +6 -0
  159. data/app/views/vacancies/_form.html.erb +15 -0
  160. data/app/views/vacancies/edit.html.erb +3 -0
  161. data/app/views/vacancies/index.html.erb +7 -0
  162. data/app/views/vacancies/new.html.erb +3 -0
  163. data/app/views/vacancies/show.html.erb +17 -0
  164. data/app/views/workflow/index.html.erb +0 -0
  165. data/app/views/workflow/products/show.html.erb +34 -0
  166. data/app/views/workflow/project_owner/_candidatures.html.erb +31 -0
  167. data/app/views/workflow/project_owner/_stories.html.erb +29 -0
  168. data/app/views/workflow/project_owner/_tasks.html.erb +34 -0
  169. data/app/views/workflow/project_owner/_vacancies.html.erb +27 -0
  170. data/app/views/workflow/project_owner/index.html.erb +24 -0
  171. data/app/views/workflow/tasks/_work_form.html.erb +8 -0
  172. data/app/views/workflow/tasks/_work_head.html.erb +15 -0
  173. data/app/views/workflow/tasks/edit.html.erb +3 -0
  174. data/app/views/workflow/tasks/index.html.erb +31 -0
  175. data/app/views/workflow/tasks/next.html.erb +0 -0
  176. data/app/views/workflow/tasks/steps/_complete.html.erb +11 -0
  177. data/app/views/workflow/tasks/steps/_review.html.erb +13 -0
  178. data/app/views/workflow/tasks/steps/_work.html.erb +17 -0
  179. data/app/views/workflow/user/_tasks.html.erb +30 -0
  180. data/app/views/workflow/user/index.html.erb +14 -0
  181. data/config/initializers/1_initialize_app_config.rb +5 -0
  182. data/config/initializers/devise.rb +193 -0
  183. data/config/initializers/locale_settings.rb +42 -0
  184. data/config/initializers/mongoid-history.rb +2 -0
  185. data/config/initializers/recaptcha.rb +7 -0
  186. data/config/initializers/simple_form.rb +178 -0
  187. data/config/initializers/simple_navigation.rb +2 -0
  188. data/config/locales/devise.en.yml +59 -0
  189. data/config/locales/en.yml +26 -0
  190. data/config/locales/general/en.yml +71 -0
  191. data/config/locales/resources/area/en.yml +12 -0
  192. data/config/locales/resources/candidature/en.yml +19 -0
  193. data/config/locales/resources/comment/en.yml +11 -0
  194. data/config/locales/resources/organization/en.yml +11 -0
  195. data/config/locales/resources/page/en.yml +11 -0
  196. data/config/locales/resources/product/en.yml +23 -0
  197. data/config/locales/resources/project/en.yml +9 -0
  198. data/config/locales/resources/result/en.yml +9 -0
  199. data/config/locales/resources/story/en.yml +34 -0
  200. data/config/locales/resources/task/en.yml +36 -0
  201. data/config/locales/resources/user/en.yml +14 -0
  202. data/config/locales/resources/vacancy/en.yml +29 -0
  203. data/config/locales/simple_form.en.yml +26 -0
  204. data/config/locales/workflow/en.yml +37 -0
  205. data/config/routes.rb +188 -0
  206. data/db/migrate/20120907144853_create_schema.rb +217 -0
  207. data/db/migrate/20120911093743_remove_timestamps_from_habtm_tables.rb +21 -0
  208. data/db/migrate/20120919161831_add_unique_index_for_one_user_candidature_per_vacancy.rb +9 -0
  209. data/db/migrate/20120922201955_create_mongo_db_documents.rb +13 -0
  210. data/db/migrate/20120923140109_add_product_to_project.rb +6 -0
  211. data/db/migrate/20121004061413_add_extra_user_attributes.rb +9 -0
  212. data/db/migrate/20121004132105_create_professions.rb +13 -0
  213. data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +6 -0
  214. data/db/migrate/20121006170407_add_type_attribute_to_roles.rb +5 -0
  215. data/db/migrate/20121007071543_add_foreign_languages_to_user.rb +6 -0
  216. data/db/migrate/20121028073712_create_organizations.rb +13 -0
  217. data/db/seeds.rb +14 -0
  218. data/lib/applicat/mvc/controller.rb +171 -0
  219. data/lib/applicat/mvc/controller/error_handling.rb +40 -0
  220. data/lib/applicat/mvc/controller/resource.rb +19 -0
  221. data/lib/applicat/mvc/controller/transition_actions.rb +43 -0
  222. data/lib/applicat/mvc/model/resource/base.rb +56 -0
  223. data/lib/applicat/mvc/model/tokenable.rb +24 -0
  224. data/lib/applicat/mvc/model/tree.rb +82 -0
  225. data/lib/db_seed.rb +150 -0
  226. data/lib/environment_configuration.rb +54 -0
  227. data/lib/generators/voluntary/install/install_generator.rb +118 -0
  228. data/lib/generators/voluntary/install/templates/app/controllers/application_controller.rb +3 -0
  229. data/lib/generators/voluntary/install/templates/app/models/ability.rb +49 -0
  230. data/lib/generators/voluntary/install/templates/app/models/app_config.rb +32 -0
  231. data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +50 -0
  232. data/lib/generators/voluntary/install/templates/config/application.yml +147 -0
  233. data/lib/generators/voluntary/install/templates/config/cucumber.yml +8 -0
  234. data/lib/generators/voluntary/install/templates/config/database.example.yml +28 -0
  235. data/lib/generators/voluntary/install/templates/config/deploy.rb +59 -0
  236. data/lib/generators/voluntary/install/templates/config/email.example.yml +9 -0
  237. data/lib/generators/voluntary/install/templates/config/initializers/recaptcha_example +4 -0
  238. data/lib/generators/voluntary/install/templates/config/locale_settings.yml +121 -0
  239. data/lib/generators/voluntary/install/templates/config/main_navigation.rb +262 -0
  240. data/lib/generators/voluntary/install/templates/config/mongoid.yml +78 -0
  241. data/lib/generators/voluntary/install/templates/config/nginx.conf +27 -0
  242. data/lib/generators/voluntary/install/templates/config/unicorn.rb +9 -0
  243. data/lib/generators/voluntary/install/templates/config/unicorn_init.sh +84 -0
  244. data/lib/generators/voluntary/install/templates/db/seeds.rb +14 -0
  245. data/lib/generators/voluntary/install/templates/features/step_definitions/email_steps.rb +89 -0
  246. data/lib/generators/voluntary/install/templates/features/step_definitions/factory_steps.rb +120 -0
  247. data/lib/generators/voluntary/install/templates/features/step_definitions/javascript_steps.rb +15 -0
  248. data/lib/generators/voluntary/install/templates/features/step_definitions/navigation_steps.rb +3 -0
  249. data/lib/generators/voluntary/install/templates/features/step_definitions/resources_steps.rb +8 -0
  250. data/lib/generators/voluntary/install/templates/features/step_definitions/session_steps.rb +35 -0
  251. data/lib/generators/voluntary/install/templates/features/step_definitions/web_steps.rb +271 -0
  252. data/lib/generators/voluntary/install/templates/features/support/database_cleaner_patches.rb +24 -0
  253. data/lib/generators/voluntary/install/templates/features/support/env.rb +83 -0
  254. data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +32 -0
  255. data/lib/generators/voluntary/install/templates/features/support/integration_sessions_form.html.erb +1 -0
  256. data/lib/generators/voluntary/install/templates/features/support/paths.rb +98 -0
  257. data/lib/generators/voluntary/install/templates/features/support/selectors.rb +44 -0
  258. data/lib/generators/voluntary/install/templates/features/support/spork_env +72 -0
  259. data/lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb +78 -0
  260. data/lib/generators/voluntary/install/templates/lib/volontariat_seed.rb +36 -0
  261. data/lib/generators/voluntary/install/templates/spec/spec_helper.rb +72 -0
  262. data/lib/generators/voluntary/install/templates/spec/support/deferred_garbage_collector.rb +45 -0
  263. data/lib/generators/voluntary/install/templates/spec/support/devise.rb +3 -0
  264. data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +19 -0
  265. data/lib/generators/voluntary/install/templates/vendor/assets/javascripts/jquery.tokeninput.js +915 -0
  266. data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-facebook.css +122 -0
  267. data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-mac.css +204 -0
  268. data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input.css +127 -0
  269. data/lib/i18n_interpolation_fallbacks.rb +21 -0
  270. data/lib/model/mongo_db/commentable.rb +17 -0
  271. data/lib/model/mongo_db/core_extensions.rb +10 -0
  272. data/lib/model/mongo_db/customizable.rb +23 -0
  273. data/lib/model/mongo_db/product/keywords.rb +31 -0
  274. data/lib/model/mongo_db/state_version_attributes.rb +15 -0
  275. data/lib/tasks/cucumber.rake +65 -0
  276. data/lib/tasks/voluntary_tasks.rake +4 -0
  277. data/lib/vendors/active_model/naming.rb +14 -0
  278. data/lib/vendors/simple_navigation/renderer/breadcrumbs_without_method_links.rb +30 -0
  279. data/lib/vendors/simple_navigation/renderer/twitter_sidenav.rb +34 -0
  280. data/lib/voluntary.rb +87 -0
  281. data/lib/voluntary/engine.rb +11 -0
  282. data/lib/voluntary/helpers/application.rb +69 -0
  283. data/lib/voluntary/helpers/collection.rb +35 -0
  284. data/lib/voluntary/helpers/comments.rb +15 -0
  285. data/lib/voluntary/helpers/form.rb +43 -0
  286. data/lib/voluntary/helpers/language.rb +19 -0
  287. data/lib/voluntary/helpers/layout.rb +28 -0
  288. data/lib/voluntary/helpers/product.rb +36 -0
  289. data/lib/voluntary/helpers/show.rb +69 -0
  290. data/lib/voluntary/helpers/wizard.rb +31 -0
  291. data/lib/voluntary/version.rb +3 -0
  292. data/lib/wizard.rb +58 -0
  293. data/lib/wizard/controller/concerns/paths.rb +31 -0
  294. data/lib/wizard/controller/concerns/steps.rb +142 -0
  295. metadata +1217 -0
@@ -0,0 +1,3 @@
1
+ When /^I click the (\d+)(?:st|nd|rd|th) link of the (\d+)(?:st|nd|rd|th) row$/ do |link_position, row_position|
2
+ within(:row, row_position.to_i) { find(:xpath, ".//a[#{link_position.to_i}]").click }
3
+ end
@@ -0,0 +1,8 @@
1
+ When /^I delete the (\d+)(?:st|nd|rd|th) "([^\"]*)"$/ do |pos, resource_name|
2
+ visit eval("#{resource_name.pluralize}_path")
3
+
4
+ within(:row, pos.to_i) { find(:xpath, ".//a[contains(text(), 'Actions')]").click }
5
+
6
+ page.execute_script 'window.confirm = function () { return true }'
7
+ click_link I18n.t('general.destroy')
8
+ end
@@ -0,0 +1,35 @@
1
+
2
+ Given /^(?:I am signed in|I sign in)$/ do
3
+ automatic_login
4
+ confirm_login
5
+ end
6
+
7
+ When /^I (?:sign|log) in as "([^"]*)"$/ do |name|
8
+ @me = User.find_by_name(name)
9
+ @me.password = 'password'
10
+ automatic_login
11
+ end
12
+
13
+ When /^I fill out change password section with my password and "([^"]*)" and "([^"]*)"$/ do |new_pass, confirm_pass|
14
+ fill_change_password_section(@me.password, new_pass, confirm_pass)
15
+ end
16
+
17
+ When /^I fill out forgot password form with "([^"]*)"$/ do |email|
18
+ fill_forgot_password_form(email)
19
+ end
20
+
21
+ When /^I submit forgot password form$/ do
22
+ submit_forgot_password_form
23
+ end
24
+
25
+ When /^I fill out reset password form with "([^"]*)" and "([^"]*)"$/ do |new_pass,confirm_pass|
26
+ fill_reset_password_form(new_pass, confirm_pass)
27
+ end
28
+
29
+ When /^I submit reset password form$/ do
30
+ submit_reset_password_form
31
+ end
32
+
33
+ When /^I (?:log|sign) out$/ do
34
+ logout
35
+ end
@@ -0,0 +1,271 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file was generated by Cucumber-Rails and is only here to get you a head start
4
+ # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
+ # visit pages, interact with widgets and make assertions about page content.
6
+ #
7
+ # If you use these step definitions as basis for your features you will quickly end up
8
+ # with features that are:
9
+ #
10
+ # * Hard to maintain
11
+ # * Verbose to read
12
+ #
13
+ # A much better approach is to write your own higher level step definitions, following
14
+ # the advice in the following blog posts:
15
+ #
16
+ # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
+ # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
+ # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
+ #
20
+
21
+
22
+ require 'uri'
23
+ require 'cgi'
24
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
+
27
+ module WithinHelpers
28
+ def with_scope(locator)
29
+ locator ? within(*selector_for(locator)) { yield } : yield
30
+ end
31
+ end
32
+ World(WithinHelpers)
33
+
34
+ # Single-line step scoper
35
+ When /^(.*) within (.*[^:])$/ do |step, parent|
36
+ with_scope(parent) { When step }
37
+ end
38
+
39
+ # Multi-line step scoper
40
+ When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
41
+ with_scope(parent) { When "#{step}:", table_or_string }
42
+ end
43
+
44
+ Given /^(?:|I )am on (.+)$/ do |page_name|
45
+ visit path_to(page_name)
46
+ end
47
+
48
+ When /^(?:|I )go to (.+)$/ do |page_name|
49
+ visit path_to(page_name)
50
+ end
51
+
52
+ When /^(?:|I )press "([^"]*)"$/ do |button|
53
+ click_button(button)
54
+ end
55
+
56
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
57
+ click_link(link)
58
+ end
59
+
60
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
61
+ fill_in(field, :with => value)
62
+ end
63
+
64
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
65
+ fill_in(field, :with => value)
66
+ end
67
+
68
+ # TODO: get more than the 1st fieldset working
69
+ When /^(?:|I )fill in the (\d+)(?:st|nd|rd|th) field of "([^"]*)" with "([^"]*)"$/ do |pos, field, value|
70
+ raise NotImplementedError unless pos.to_i == 1
71
+
72
+ within(find(:xpath, "//fieldset[#{pos.to_i}]")) do
73
+ fill_in(field, :with => value)
74
+ end
75
+ end
76
+
77
+ # Use this to fill in an entire form with data from a table. Example:
78
+ #
79
+ # When I fill in the following:
80
+ # | Account Number | 5002 |
81
+ # | Expiry date | 2009-11-01 |
82
+ # | Note | Nice guy |
83
+ # | Wants Email? | |
84
+ #
85
+ # TODO: Add support for checkbox, select or option
86
+ # based on naming conventions.
87
+ #
88
+ When /^(?:|I )fill in the following:$/ do |fields|
89
+ fields.rows_hash.each do |name, value|
90
+ When %{I fill in "#{name}" with "#{value}"}
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
95
+ select(value, :from => field)
96
+ end
97
+
98
+ When /^(?:|I )check "([^"]*)"$/ do |field|
99
+ check(field)
100
+ end
101
+
102
+ When /^(?:|I )uncheck "([^"]*)"$/ do |field|
103
+ uncheck(field)
104
+ end
105
+
106
+ When /^(?:|I )choose "([^"]*)"$/ do |field|
107
+ choose(field)
108
+ end
109
+
110
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
111
+ attach_file(field, File.expand_path(path))
112
+ end
113
+
114
+ When /^(?:|I )click element "([^"]*)"$/ do |selector|
115
+ find(selector_for(selector)).click
116
+ end
117
+
118
+ When /^(?:|I )click on "([^"]*)" inside "([^"]*)"$/ do |selector, container|
119
+ find(container).find(selector).click
120
+ end
121
+
122
+ Then /^(?:|I )should see "([^"]*)"$/ do |text|
123
+ if page.respond_to? :should
124
+ page.should have_content(text)
125
+ else
126
+ assert page.has_content?(text)
127
+ end
128
+ end
129
+
130
+ Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
131
+ regexp = Regexp.new(regexp)
132
+
133
+ if page.respond_to? :should
134
+ page.should have_xpath('//*', :text => regexp)
135
+ else
136
+ assert page.has_xpath?('//*', :text => regexp)
137
+ end
138
+ end
139
+
140
+ Then /^(?:|I )should not see "([^"]*)"$/ do |text|
141
+ if page.respond_to? :should
142
+ page.should have_no_content(text)
143
+ else
144
+ assert page.has_no_content?(text)
145
+ end
146
+ end
147
+
148
+ Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
149
+ regexp = Regexp.new(regexp)
150
+
151
+ if page.respond_to? :should
152
+ page.should have_no_xpath('//*', :text => regexp)
153
+ else
154
+ assert page.has_no_xpath?('//*', :text => regexp)
155
+ end
156
+ end
157
+
158
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
159
+ with_scope(parent) do
160
+ field = find_field(field)
161
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
162
+ if field_value.respond_to? :should
163
+ field_value.should =~ /#{value}/
164
+ else
165
+ assert_match(/#{value}/, field_value)
166
+ end
167
+ end
168
+ end
169
+
170
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
171
+ with_scope(parent) do
172
+ field = find_field(field)
173
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
174
+ if field_value.respond_to? :should_not
175
+ field_value.should_not =~ /#{value}/
176
+ else
177
+ assert_no_match(/#{value}/, field_value)
178
+ end
179
+ end
180
+ end
181
+
182
+ Then /^the "([^"]*)" field should have the error "([^"]*)"$/ do |field, error_message|
183
+ element = find_field(field)
184
+ classes = element.find(:xpath, '..')[:class].split(' ')
185
+
186
+ form_for_input = element.find(:xpath, 'ancestor::form[1]')
187
+ using_formtastic = form_for_input[:class].include?('formtastic')
188
+ error_class = using_formtastic ? 'error' : 'field_with_errors'
189
+
190
+ if classes.respond_to? :should
191
+ classes.should include(error_class)
192
+ else
193
+ assert classes.include?(error_class)
194
+ end
195
+
196
+ if page.respond_to?(:should)
197
+ if using_formtastic
198
+ error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
199
+ error_paragraph.should have_content(error_message)
200
+ else
201
+ page.should have_content("#{field.titlecase} #{error_message}")
202
+ end
203
+ else
204
+ if using_formtastic
205
+ error_paragraph = element.find(:xpath, '../*[@class="inline-errors"][1]')
206
+ assert error_paragraph.has_content?(error_message)
207
+ else
208
+ assert page.has_content?("#{field.titlecase} #{error_message}")
209
+ end
210
+ end
211
+ end
212
+
213
+ Then /^the "([^"]*)" field should have no error$/ do |field|
214
+ element = find_field(field)
215
+ classes = element.find(:xpath, '..')[:class].split(' ')
216
+ if classes.respond_to? :should
217
+ classes.should_not include('field_with_errors')
218
+ classes.should_not include('error')
219
+ else
220
+ assert !classes.include?('field_with_errors')
221
+ assert !classes.include?('error')
222
+ end
223
+ end
224
+
225
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
226
+ with_scope(parent) do
227
+ field_checked = find_field(label)['checked']
228
+ if field_checked.respond_to? :should
229
+ field_checked.should be_true
230
+ else
231
+ assert field_checked
232
+ end
233
+ end
234
+ end
235
+
236
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
237
+ with_scope(parent) do
238
+ field_checked = find_field(label)['checked']
239
+ if field_checked.respond_to? :should
240
+ field_checked.should be_false
241
+ else
242
+ assert !field_checked
243
+ end
244
+ end
245
+ end
246
+
247
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
248
+ current_path = URI.parse(current_url).path
249
+ if current_path.respond_to? :should
250
+ current_path.should == path_to(page_name)
251
+ else
252
+ assert_equal path_to(page_name), current_path
253
+ end
254
+ end
255
+
256
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
257
+ query = URI.parse(current_url).query
258
+ actual_params = query ? CGI.parse(query) : {}
259
+ expected_params = {}
260
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
261
+
262
+ if actual_params.respond_to? :should
263
+ actual_params.should == expected_params
264
+ else
265
+ assert_equal expected_params, actual_params
266
+ end
267
+ end
268
+
269
+ Then /^show me the page$/ do
270
+ save_and_open_page
271
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2010-2011, Diaspora Inc. This file is
2
+ # licensed under the Affero General Public License version 3 or later. See
3
+ # the COPYRIGHT file.
4
+
5
+ # disable_referential_integrity doesn't work when using PostgreSQL
6
+ # with a non-root user.
7
+ # See http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error
8
+ module ActiveRecord
9
+ module ConnectionAdapters
10
+ class PostgreSQLAdapter < AbstractAdapter
11
+ def disable_referential_integrity(&block)
12
+ transaction {
13
+ begin
14
+ execute "SET CONSTRAINTS ALL DEFERRED"
15
+ yield
16
+ ensure
17
+ execute "SET CONSTRAINTS ALL IMMEDIATE"
18
+ end
19
+ }
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,83 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ if ENV['COVERAGE_REPORT']
8
+ require 'simplecov'
9
+ SimpleCov.start 'rails'
10
+ end
11
+
12
+ require 'cucumber/rails'
13
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/mongo_database_cleaner')
14
+ require File.join(File.dirname(__FILE__), "integration_sessions_controller")
15
+
16
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
17
+ # order to ease the transition to Capybara we set the default here. If you'd
18
+ # prefer to use XPath just remove this line and adjust any selectors in your
19
+ # steps to use the XPath syntax.
20
+ Capybara.default_selector = :css
21
+
22
+ Capybara.javascript_driver = ENV['JAVASCRIPT_DRIVER'] ? ENV['JAVASCRIPT_DRIVER'].to_sym : :webkit
23
+
24
+ Capybara.add_selector(:row) do
25
+ xpath { |num| ".//tbody/tr[#{num}]" }
26
+ end
27
+
28
+ # By default, any exception happening in your Rails application will bubble up
29
+ # to Cucumber so that your scenario will fail. This is a different from how
30
+ # your application behaves in the production environment, where an error page will
31
+ # be rendered instead.
32
+ #
33
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
34
+ # exceptions and display an error page (just like when the app is running in production).
35
+ # Typical scenarios where you want to do this is when you test your error pages.
36
+ # There are two ways to allow Rails to rescue exceptions:
37
+ #
38
+ # 1) Tag your scenario (or feature) with @allow-rescue
39
+ #
40
+ # 2) Set the value below to true. Beware that doing this globally is not
41
+ # recommended as it will mask a lot of errors for you!
42
+ #
43
+ ActionController::Base.allow_rescue = false
44
+
45
+ # Remove/comment out the lines below if your app doesn't have a database.
46
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
47
+ begin
48
+ DatabaseCleaner.strategy = :truncation
49
+ Cucumber::Rails::World.use_transactional_fixtures = false
50
+ rescue NameError
51
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
52
+ end
53
+
54
+ After do
55
+ # TODO: find a better solution
56
+ begin
57
+ MongoDatabaseCleaner.clean
58
+ rescue
59
+ DatabaseCleaner.logger.error "Exception encountered by DatabaseCleaner in Cucumber After block: #{e}"
60
+ end
61
+ end
62
+
63
+
64
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
65
+ # See the DatabaseCleaner documentation for details. Example:
66
+ #
67
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
68
+ # # { :except => [:widgets] } may not do what you expect here
69
+ # # as tCucumber::Rails::Database.javascript_strategy overrides
70
+ # # this setting.
71
+ # DatabaseCleaner.strategy = :truncation
72
+ # end
73
+ #
74
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
75
+ # DatabaseCleaner.strategy = :transaction
76
+ # end
77
+ #
78
+
79
+ # Possible values are :truncation and :transaction
80
+ # The :transaction strategy is faster, but might give you threading problems.
81
+ # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
82
+ Cucumber::Rails::Database.javascript_strategy = :truncation
83
+
@@ -0,0 +1,32 @@
1
+ class IntegrationSessionsController < ActionController::Base
2
+ def new
3
+ @user_id = params[:user_id]
4
+ render 'features/support/integration_sessions_form', layout: false
5
+ end
6
+
7
+ def create
8
+ logger.info User.find(params[:user_id]).inspect
9
+ sign_in_and_redirect User.find(params[:user_id])
10
+ end
11
+ end
12
+
13
+ #Copypasta from http://openhood.com/rails/rails%203/2010/07/20/add-routes-at-runtime-rails-3/
14
+ _routes = nil
15
+
16
+ begin
17
+ _routes = Volontariat::Application.routes
18
+ _routes.disable_clear_and_finalize = true
19
+ _routes.clear!
20
+
21
+ Volontariat::Application.routes_reloader.paths.each{ |path| load(path) }
22
+
23
+ _routes.draw do
24
+ # here you can add any route you want
25
+ post 'integration_sessions' => 'integration_sessions#create', :as => 'integration_sessions'
26
+ get 'integration_sessions' => 'integration_sessions#new', :as => 'new_integration_sessions'
27
+ end
28
+
29
+ ActiveSupport.on_load(:action_controller) { _routes.finalize! }
30
+ ensure
31
+ _routes.disable_clear_and_finalize = false
32
+ end