your_platform 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (704) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +39 -11
  3. data/Rakefile +15 -1
  4. data/app/assets/images/file.png +0 -0
  5. data/app/assets/images/img/excel2013_file_128.png +0 -0
  6. data/app/assets/images/img/excel2013_file_bw_107.png +0 -0
  7. data/app/assets/images/img/excel2013_file_bw_semitransparent_107.png +0 -0
  8. data/app/assets/images/img/glyphicons-halflings-white.png +0 -0
  9. data/app/assets/images/img/glyphicons-halflings.png +0 -0
  10. data/app/assets/images/img/gmaps_yellow_marker.png +0 -0
  11. data/app/assets/images/img/gmaps_yellow_marker_38.png +0 -0
  12. data/app/assets/images/markdown_help.png +0 -0
  13. data/app/assets/images/your_platform/breadcrumb-sep.png +0 -0
  14. data/app/assets/javascripts/app-ng.js.coffee +5 -0
  15. data/app/assets/javascripts/attachments.js +2 -0
  16. data/app/assets/javascripts/controllers-ng/bookmark_list_controller.js.coffee +30 -0
  17. data/app/assets/javascripts/controllers-ng/box_controller.js.coffee +37 -0
  18. data/app/assets/javascripts/controllers-ng/profile_angular.js.coffee +151 -0
  19. data/app/assets/javascripts/directives-ng/box_directive.js.coffee +91 -0
  20. data/app/assets/javascripts/directives-ng/star_tool_directive.js.coffee +111 -0
  21. data/app/assets/javascripts/filters-ng/some_filter.js.coffee +0 -0
  22. data/app/assets/javascripts/jquery.appear-1.1.1.js +138 -0
  23. data/app/assets/javascripts/make-js-more-like-ruby.js.coffee +32 -0
  24. data/app/assets/javascripts/mercury.js +456 -0
  25. data/app/assets/javascripts/models-ng/bookmark.js.coffee +28 -0
  26. data/app/assets/javascripts/services-ng/current_user_bookmarks.js.coffee +39 -0
  27. data/app/assets/javascripts/your_platform.js +27 -0
  28. data/app/assets/javascripts/your_platform/address_labels.js.coffee +40 -0
  29. data/app/assets/javascripts/your_platform/attachments.js.coffee +61 -0
  30. data/app/assets/javascripts/your_platform/auto-completion.js.coffee +90 -0
  31. data/app/assets/javascripts/your_platform/best_in_place.js.coffee +8 -0
  32. data/app/assets/javascripts/your_platform/best_in_place_hyperlinks.js.coffee +25 -0
  33. data/app/assets/javascripts/your_platform/best_in_place_tab_key.js.coffee +28 -0
  34. data/app/assets/javascripts/your_platform/boxes.js.coffee +11 -0
  35. data/app/assets/javascripts/your_platform/change_password.js.coffee +22 -0
  36. data/app/assets/javascripts/your_platform/close_dropdowns.js.coffee +18 -0
  37. data/app/assets/javascripts/your_platform/copy_to_clipboard.js.coffee +6 -0
  38. data/app/assets/javascripts/your_platform/datatables.coffee +112 -0
  39. data/app/assets/javascripts/your_platform/datepicker_settings.js.coffee +16 -0
  40. data/app/assets/javascripts/your_platform/edit_tools.js.coffee +19 -0
  41. data/app/assets/javascripts/your_platform/editable_dbl_click.js.coffee +42 -0
  42. data/app/assets/javascripts/your_platform/events.js.coffee +126 -0
  43. data/app/assets/javascripts/your_platform/fix_textarea.js.coffee +11 -0
  44. data/app/assets/javascripts/your_platform/galleria.js.coffee +112 -0
  45. data/app/assets/javascripts/your_platform/groups.js.coffee +36 -0
  46. data/app/assets/javascripts/your_platform/hidden.js.coffee +5 -0
  47. data/app/assets/javascripts/your_platform/links_to_external_sites.js.coffee +12 -0
  48. data/app/assets/javascripts/your_platform/maps.js.coffee +13 -0
  49. data/app/assets/javascripts/your_platform/may_need_review.js.coffee +10 -0
  50. data/app/assets/javascripts/your_platform/navable_title_rename.js.coffee +17 -0
  51. data/app/assets/javascripts/your_platform/officers.js.coffee +35 -0
  52. data/app/assets/javascripts/your_platform/popovers.js.coffee +38 -0
  53. data/app/assets/javascripts/your_platform/posts.js.coffee +58 -0
  54. data/app/assets/javascripts/your_platform/profile_fields.js.coffee +61 -0
  55. data/app/assets/javascripts/your_platform/search.js.coffee +26 -0
  56. data/app/assets/javascripts/your_platform/tooltips.js.coffee +10 -0
  57. data/app/assets/javascripts/your_platform/turbolinks_loading_spinner.js.coffee +83 -0
  58. data/app/assets/javascripts/your_platform/user_avatars.js.coffee +33 -0
  59. data/app/assets/javascripts/your_platform/user_group_memberships.js.coffee +11 -0
  60. data/app/assets/javascripts/your_platform/user_settings.js.coffee +18 -0
  61. data/app/assets/javascripts/your_platform/users_new.js.coffee +54 -0
  62. data/app/assets/stylesheets/bootstrap_layout.css.sass +3 -0
  63. data/app/assets/stylesheets/bootstrap_layout/attachments.css.sass +3 -0
  64. data/app/assets/stylesheets/bootstrap_layout/boxes.css.sass +11 -0
  65. data/app/assets/stylesheets/bootstrap_layout/breadcrumb.css.sass +25 -0
  66. data/app/assets/stylesheets/bootstrap_layout/category_indicator.css.sass +5 -0
  67. data/app/assets/stylesheets/bootstrap_layout/footer.css.sass +14 -0
  68. data/app/assets/stylesheets/bootstrap_layout/galleria.css.sass +8 -0
  69. data/app/assets/stylesheets/bootstrap_layout/header_bar.css.sass +11 -0
  70. data/app/assets/stylesheets/bootstrap_layout/headings.css.sass +10 -0
  71. data/app/assets/stylesheets/bootstrap_layout/logged_in_bar.css.sass +40 -0
  72. data/app/assets/stylesheets/bootstrap_layout/logo.css.sass +2 -0
  73. data/app/assets/stylesheets/bootstrap_layout/modal_fix.css.sass +8 -0
  74. data/app/assets/stylesheets/bootstrap_layout/profiles.css.sass +10 -0
  75. data/app/assets/stylesheets/bootstrap_layout/session_bar.css.sass +60 -0
  76. data/app/assets/stylesheets/bootstrap_layout/stars.css.sass +4 -0
  77. data/app/assets/stylesheets/bootstrap_layout/turbolinks_progress_bar.css.sass +3 -0
  78. data/app/assets/stylesheets/bootstrap_layout/vertical_menu.css.sass +15 -0
  79. data/app/assets/stylesheets/bootstrap_setup.css.sass +4 -0
  80. data/app/assets/stylesheets/your_platform.css.sass +11 -0
  81. data/app/assets/stylesheets/your_platform/address_labels_modal.css.sass +8 -0
  82. data/app/assets/stylesheets/your_platform/attachments.css.sass +75 -0
  83. data/app/assets/stylesheets/your_platform/authorization_info.css.sass +16 -0
  84. data/app/assets/stylesheets/your_platform/auto-completion.css.sass +3 -0
  85. data/app/assets/stylesheets/your_platform/center.css.sass +14 -0
  86. data/app/assets/stylesheets/your_platform/change_password.css.sass +13 -0
  87. data/app/assets/stylesheets/your_platform/corporate_vita.css.sass +2 -0
  88. data/app/assets/stylesheets/your_platform/datatables.css.sass +23 -0
  89. data/app/assets/stylesheets/your_platform/datepicker.css.sass +2 -0
  90. data/app/assets/stylesheets/your_platform/dropdowns.css.sass +8 -0
  91. data/app/assets/stylesheets/your_platform/events.css.sass +68 -0
  92. data/app/assets/stylesheets/your_platform/forms.css.sass +25 -0
  93. data/app/assets/stylesheets/your_platform/galleria.css.sass +12 -0
  94. data/app/assets/stylesheets/your_platform/groups.css.sass +8 -0
  95. data/app/assets/stylesheets/your_platform/groups_table.css.sass +8 -0
  96. data/app/assets/stylesheets/your_platform/hidden.css.sass +3 -0
  97. data/app/assets/stylesheets/your_platform/images.css.sass +50 -0
  98. data/app/assets/stylesheets/your_platform/last_activities.css.sass +17 -0
  99. data/app/assets/stylesheets/your_platform/latest_members.css.sass +7 -0
  100. data/app/assets/stylesheets/your_platform/login.css.sass +4 -0
  101. data/app/assets/stylesheets/your_platform/maps.css.sass +22 -0
  102. data/app/assets/stylesheets/your_platform/markdown_help.css.sass +5 -0
  103. data/app/assets/stylesheets/your_platform/may_need_review.css.sass +3 -0
  104. data/app/assets/stylesheets/your_platform/pages.css.sass +12 -0
  105. data/app/assets/stylesheets/your_platform/password_strength.css.sass +73 -0
  106. data/app/assets/stylesheets/your_platform/picture_attachments.css.sass +7 -0
  107. data/app/assets/stylesheets/your_platform/popovers.css.sass +13 -0
  108. data/app/assets/stylesheets/your_platform/posts.css.sass +32 -0
  109. data/app/assets/stylesheets/your_platform/profiles.css.sass +153 -0
  110. data/app/assets/stylesheets/your_platform/search_preview.css.sass +4 -0
  111. data/app/assets/stylesheets/your_platform/star_tool.css.sass +2 -0
  112. data/app/assets/stylesheets/your_platform/tooltips.css.sass +7 -0
  113. data/app/assets/stylesheets/your_platform/turbolinks_loading_spinner.css.sass +3 -0
  114. data/app/assets/stylesheets/your_platform/user_avatars.css.sass +8 -0
  115. data/app/assets/stylesheets/your_platform/user_group_memberships.css.sass +4 -0
  116. data/app/assets/stylesheets/your_platform/vertical_nav.css.sass +7 -0
  117. data/app/controllers/activities_controller.rb +6 -0
  118. data/app/controllers/application_controller.rb +236 -0
  119. data/app/controllers/attachments_controller.rb +97 -0
  120. data/app/controllers/blog_posts_controller.rb +50 -0
  121. data/app/controllers/bookmarks_controller.rb +33 -0
  122. data/app/controllers/corporations_controller.rb +22 -0
  123. data/app/controllers/errors_controller.rb +27 -0
  124. data/app/controllers/events_controller.rb +262 -0
  125. data/app/controllers/groups_controller.rb +257 -0
  126. data/app/controllers/officers_controller.rb +28 -0
  127. data/app/controllers/pages_controller.rb +67 -0
  128. data/app/controllers/posts_controller.rb +81 -0
  129. data/app/controllers/profile_fields_controller.rb +132 -0
  130. data/app/controllers/root_controller.rb +35 -0
  131. data/app/controllers/search_controller.rb +149 -0
  132. data/app/controllers/sessions_controller.rb +21 -0
  133. data/app/controllers/setup_controller.rb +80 -0
  134. data/app/controllers/statistics_controller.rb +38 -0
  135. data/app/controllers/status_group_memberships_controller.rb +28 -0
  136. data/app/controllers/terms_of_use_controller.rb +35 -0
  137. data/app/controllers/user_accounts_controller.rb +55 -0
  138. data/app/controllers/user_group_memberships_controller.rb +75 -0
  139. data/app/controllers/user_settings_controller.rb +57 -0
  140. data/app/controllers/users_controller.rb +125 -0
  141. data/app/controllers/workflows_controller.rb +19 -0
  142. data/app/helpers/application_helper.rb +25 -0
  143. data/app/helpers/attachments_helper.rb +2 -0
  144. data/app/helpers/auto_completion_helper.rb +33 -0
  145. data/app/helpers/avatar_helper.rb +70 -0
  146. data/app/helpers/bookmarks_helper.rb +22 -0
  147. data/app/helpers/box_helper.rb +56 -0
  148. data/app/helpers/breadcrumbs_helper.rb +62 -0
  149. data/app/helpers/corporate_vita_helper.rb +34 -0
  150. data/app/helpers/events_helper.rb +28 -0
  151. data/app/helpers/flash_helper.rb +60 -0
  152. data/app/helpers/footer_helper.rb +13 -0
  153. data/app/helpers/galleria_helper.rb +13 -0
  154. data/app/helpers/groups_helper.rb +66 -0
  155. data/app/helpers/horizontal_nav_helper.rb +11 -0
  156. data/app/helpers/i18n_helper.rb +10 -0
  157. data/app/helpers/icon_helper.rb +35 -0
  158. data/app/helpers/mailer_helper.rb +7 -0
  159. data/app/helpers/map_helper.rb +26 -0
  160. data/app/helpers/markdown_helper.rb +22 -0
  161. data/app/helpers/markup_helper.rb +25 -0
  162. data/app/helpers/officers_helper.rb +13 -0
  163. data/app/helpers/password_helper.rb +23 -0
  164. data/app/helpers/profile_field_helper.rb +40 -0
  165. data/app/helpers/profile_helper.rb +69 -0
  166. data/app/helpers/quick_link_helper.rb +53 -0
  167. data/app/helpers/special_pages_helper.rb +9 -0
  168. data/app/helpers/structureable_helper.rb +11 -0
  169. data/app/helpers/sublime_helper.rb +16 -0
  170. data/app/helpers/title_helper.rb +52 -0
  171. data/app/helpers/tool_buttons_helper.rb +74 -0
  172. data/app/helpers/unicode_helper.rb +9 -0
  173. data/app/helpers/users_helper.rb +13 -0
  174. data/app/helpers/vertical_nav_helper.rb +84 -0
  175. data/app/helpers/workflows_helper.rb +37 -0
  176. data/app/mailers/event_mailer.rb +13 -0
  177. data/app/mailers/post_mailer.rb +11 -0
  178. data/app/mailers/user_account_mailer.rb +17 -0
  179. data/app/models/ability.rb +321 -0
  180. data/app/models/active_record_associations_patches.rb +26 -0
  181. data/app/models/active_record_cache_extension.rb +152 -0
  182. data/app/models/active_record_find_by_extension.rb +20 -0
  183. data/app/models/active_record_json_url_extension.rb +51 -0
  184. data/app/models/active_record_metric_events_extension.rb +22 -0
  185. data/app/models/active_record_read_only_extension.rb +35 -0
  186. data/app/models/active_record_update_attributes_bip_extension.rb +24 -0
  187. data/app/models/address_label.rb +50 -0
  188. data/app/models/app_version.rb +49 -0
  189. data/app/models/array.rb +15 -0
  190. data/app/models/attachment.rb +76 -0
  191. data/app/models/bashpass_password.rb +32 -0
  192. data/app/models/blog_post.rb +2 -0
  193. data/app/models/bookmark.rb +67 -0
  194. data/app/models/cache_additions.rb +15 -0
  195. data/app/models/cache_store_extension.rb +78 -0
  196. data/app/models/concerns/user_avatar.rb +16 -0
  197. data/app/models/concerns/user_corporations.rb +44 -0
  198. data/app/models/concerns/user_date_of_birth.rb +74 -0
  199. data/app/models/concerns/user_profile.rb +102 -0
  200. data/app/models/corporation.rb +80 -0
  201. data/app/models/dag_link.rb +29 -0
  202. data/app/models/event.rb +235 -0
  203. data/app/models/flag.rb +18 -0
  204. data/app/models/flagable.rb +62 -0
  205. data/app/models/geo_location.rb +92 -0
  206. data/app/models/group.rb +224 -0
  207. data/app/models/group_mixins/corporations.rb +141 -0
  208. data/app/models/group_mixins/developers.rb +41 -0
  209. data/app/models/group_mixins/everyone.rb +72 -0
  210. data/app/models/group_mixins/guests.rb +61 -0
  211. data/app/models/group_mixins/hidden_users.rb +43 -0
  212. data/app/models/group_mixins/import.rb +321 -0
  213. data/app/models/group_mixins/memberships.rb +207 -0
  214. data/app/models/group_mixins/officers.rb +47 -0
  215. data/app/models/group_mixins/roles.rb +41 -0
  216. data/app/models/horizontal_nav.rb +32 -0
  217. data/app/models/last_seen_activity.rb +10 -0
  218. data/app/models/list_export.rb +359 -0
  219. data/app/models/may_need_review.rb +54 -0
  220. data/app/models/metric_logger.rb +83 -0
  221. data/app/models/nav_node.rb +169 -0
  222. data/app/models/navable.rb +46 -0
  223. data/app/models/object_to_b_extension.rb +12 -0
  224. data/app/models/page.rb +212 -0
  225. data/app/models/password.rb +28 -0
  226. data/app/models/post.rb +199 -0
  227. data/app/models/profile.rb +36 -0
  228. data/app/models/profile_field.rb +196 -0
  229. data/app/models/profile_field_mixins/has_child_profile_fields.rb +114 -0
  230. data/app/models/profile_field_types/about.rb +9 -0
  231. data/app/models/profile_field_types/academic_degree.rb +10 -0
  232. data/app/models/profile_field_types/address.rb +88 -0
  233. data/app/models/profile_field_types/bank_account.rb +12 -0
  234. data/app/models/profile_field_types/competence.rb +7 -0
  235. data/app/models/profile_field_types/custom.rb +12 -0
  236. data/app/models/profile_field_types/date.rb +14 -0
  237. data/app/models/profile_field_types/description.rb +15 -0
  238. data/app/models/profile_field_types/email.rb +20 -0
  239. data/app/models/profile_field_types/employment.rb +24 -0
  240. data/app/models/profile_field_types/general.rb +9 -0
  241. data/app/models/profile_field_types/homepage.rb +19 -0
  242. data/app/models/profile_field_types/name_surrounding.rb +11 -0
  243. data/app/models/profile_field_types/organization.rb +24 -0
  244. data/app/models/profile_field_types/phone.rb +37 -0
  245. data/app/models/profile_field_types/professional_category.rb +8 -0
  246. data/app/models/profile_field_types/study.rb +18 -0
  247. data/app/models/profile_section.rb +49 -0
  248. data/app/models/profileable.rb +58 -0
  249. data/app/models/profileable_mixins/address.rb +118 -0
  250. data/app/models/relationship.rb +78 -0
  251. data/app/models/role.rb +164 -0
  252. data/app/models/setting.rb +9 -0
  253. data/app/models/status_group.rb +28 -0
  254. data/app/models/status_group_membership.rb +189 -0
  255. data/app/models/status_group_membership_info.rb +54 -0
  256. data/app/models/structureable.rb +164 -0
  257. data/app/models/structureable_mixins/has_special_groups.rb +127 -0
  258. data/app/models/structureable_mixins/roles.rb +275 -0
  259. data/app/models/user.rb +878 -0
  260. data/app/models/user_account.rb +162 -0
  261. data/app/models/user_alias.rb +112 -0
  262. data/app/models/user_group_membership.rb +300 -0
  263. data/app/models/user_group_membership_mixins/validity_range.rb +206 -0
  264. data/app/models/user_group_membership_mixins/validity_range_for_indirect_memberships.rb +160 -0
  265. data/app/models/user_mixins/identification.rb +36 -0
  266. data/app/models/user_mixins/memberships.rb +75 -0
  267. data/app/models/workflow.rb +40 -0
  268. data/app/models/workflow_kit/add_to_group_brick.rb +21 -0
  269. data/app/models/workflow_kit/destroy_account_and_end_memberships_if_needed_brick.rb +19 -0
  270. data/app/models/workflow_kit/last_membership_needs_review_brick.rb +19 -0
  271. data/app/models/workflow_kit/mark_as_deceased_brick.rb +17 -0
  272. data/app/models/workflow_kit/remove_from_group_brick.rb +27 -0
  273. data/app/models/workflow_kit/test_brick.rb +13 -0
  274. data/app/pdfs/address_labels_pdf.rb +157 -0
  275. data/app/presenters/base_presenter.rb +52 -0
  276. data/app/presenters/horizontal_nav_presenter.rb +106 -0
  277. data/app/uploaders/attachment_uploader.rb +148 -0
  278. data/app/views/activities/index.html.haml +25 -0
  279. data/app/views/attachments/_attachment.html.haml +20 -0
  280. data/app/views/attachments/_description.html.haml +11 -0
  281. data/app/views/attachments/_documents.html.haml +17 -0
  282. data/app/views/attachments/_drop_field.html.haml +46 -0
  283. data/app/views/attachments/_picture.html.haml +2 -0
  284. data/app/views/attachments/_pictures.html.haml +10 -0
  285. data/app/views/attachments/_video.html.haml +8 -0
  286. data/app/views/attachments/create.js.erb +1 -0
  287. data/app/views/attachments/destroy.js.erb +1 -0
  288. data/app/views/blog_posts/create.js.erb +17 -0
  289. data/app/views/bookmarks/_list.html.haml +7 -0
  290. data/app/views/bookmarks/update.js.erb +4 -0
  291. data/app/views/devise/mailer/reset_password_instructions.html.haml +8 -0
  292. data/app/views/devise/passwords/edit.html.haml +1 -0
  293. data/app/views/devise/passwords/new.html.haml +12 -0
  294. data/app/views/devise/registrations/edit.html.haml +1 -0
  295. data/app/views/devise/sessions/new.html.haml +14 -0
  296. data/app/views/devise/shared/_links.haml +26 -0
  297. data/app/views/errors/show.html.haml +5 -0
  298. data/app/views/errors/unauthorized.html.haml +7 -0
  299. data/app/views/event_mailer/invitation_email.html.erb +63 -0
  300. data/app/views/events/_event_details.html.haml +54 -0
  301. data/app/views/events/_events_lis.html.haml +29 -0
  302. data/app/views/events/_invitation_text.html.erb +8 -0
  303. data/app/views/events/_pictures.html.haml +5 -0
  304. data/app/views/events/_public_index.html.haml +16 -0
  305. data/app/views/events/index.html.haml +24 -0
  306. data/app/views/events/show.html.haml +50 -0
  307. data/app/views/groups/_address_labels_modal.html.haml +27 -0
  308. data/app/views/groups/_export_button.html.haml +66 -0
  309. data/app/views/groups/_group_list.html.haml +25 -0
  310. data/app/views/groups/_member_avatars.html.haml +4 -0
  311. data/app/views/groups/_member_list.html.haml +15 -0
  312. data/app/views/groups/index.html.erb +11 -0
  313. data/app/views/groups/index_mine.html.haml +7 -0
  314. data/app/views/groups/show.html.haml +79 -0
  315. data/app/views/last_seen_activities/_index.html.haml +19 -0
  316. data/app/views/layouts/_add_structureable_additions.html.haml +15 -0
  317. data/app/views/layouts/_box.html.haml +16 -0
  318. data/app/views/layouts/_help_button.html.haml +1 -0
  319. data/app/views/layouts/_role_preview_switcher.html.haml +20 -0
  320. data/app/views/layouts/_session_bar_avatar.html.haml +1 -0
  321. data/app/views/layouts/_vertical_nav.html.haml +5 -0
  322. data/app/views/layouts/bootstrap.html.haml +146 -0
  323. data/app/views/layouts/mercury.html.erb +23 -0
  324. data/app/views/officers/_history_notice.html.haml +4 -0
  325. data/app/views/officers/_officers_box.html.haml +33 -0
  326. data/app/views/officers/_officers_group_entry.html.haml +45 -0
  327. data/app/views/pages/_attachments.html.haml +21 -0
  328. data/app/views/pages/_page.html.haml +28 -0
  329. data/app/views/pages/_pictures.html.haml +2 -0
  330. data/app/views/pages/_videos.html.erb +8 -0
  331. data/app/views/pages/show.html.haml +39 -0
  332. data/app/views/post_mailer/post_email.html.erb +17 -0
  333. data/app/views/posts/_new_post_template_text.html.haml +6 -0
  334. data/app/views/posts/_post.html.haml +13 -0
  335. data/app/views/posts/_post_quote.html.haml +18 -0
  336. data/app/views/posts/_posts.html.haml +6 -0
  337. data/app/views/posts/index.html.haml +9 -0
  338. data/app/views/posts/new.html.haml +42 -0
  339. data/app/views/posts/show.html.haml +8 -0
  340. data/app/views/profile_fields/_postal_address_flag_switch.html.haml +21 -0
  341. data/app/views/profile_fields/_profile_field.html.haml +41 -0
  342. data/app/views/profile_fields/create.js.erb +26 -0
  343. data/app/views/profile_fields/destroy.js.erb +3 -0
  344. data/app/views/profiles/_add_profile_field_button.html.haml +15 -0
  345. data/app/views/profiles/_profile_section_ul.html.haml +8 -0
  346. data/app/views/profiles/_section.html.haml +28 -0
  347. data/app/views/profiles/_send_group_message_button.html.haml +4 -0
  348. data/app/views/root/_latest_members_box.html.haml +19 -0
  349. data/app/views/root/_start_page_elements.html.haml +0 -0
  350. data/app/views/root/_what_is_new.html.haml +21 -0
  351. data/app/views/search/_preview_blog_post.html.haml +1 -0
  352. data/app/views/search/_preview_corporation.html.haml +5 -0
  353. data/app/views/search/_preview_group.html.haml +4 -0
  354. data/app/views/search/_preview_page.html.haml +11 -0
  355. data/app/views/search/_preview_user.html.haml +14 -0
  356. data/app/views/search/index.html.haml +42 -0
  357. data/app/views/setup/index.html.haml +56 -0
  358. data/app/views/shared/_add_structureable.html.haml +22 -0
  359. data/app/views/shared/_authorization_info.html.haml +22 -0
  360. data/app/views/shared/_flags.html.haml +5 -0
  361. data/app/views/shared/_markdown_help.html.haml +4 -0
  362. data/app/views/shared/_search_box.html.haml +2 -0
  363. data/app/views/shared/_upcoming_events.html.haml +33 -0
  364. data/app/views/statistics/index.html.haml +16 -0
  365. data/app/views/statistics/show.html.haml +13 -0
  366. data/app/views/terms_of_use/_checkbox.html.haml +1 -0
  367. data/app/views/terms_of_use/_terms.html.haml +1 -0
  368. data/app/views/terms_of_use/index.html.haml +19 -0
  369. data/app/views/user_account_mailer/welcome_email.html.erb +32 -0
  370. data/app/views/user_accounts/_change_password.html.haml +149 -0
  371. data/app/views/user_accounts/_user_account.html.haml +39 -0
  372. data/app/views/user_group_memberships/_list_item.html.haml +9 -0
  373. data/app/views/user_group_memberships/_memberships_table.html.haml +56 -0
  374. data/app/views/user_group_memberships/_new.html.haml +18 -0
  375. data/app/views/user_group_memberships/create.js.erb +9 -0
  376. data/app/views/user_group_memberships/index.html.haml +5 -0
  377. data/app/views/user_settings/show.html.haml +36 -0
  378. data/app/views/users/_avatar.html.haml +16 -0
  379. data/app/views/users/_communication_box.html.haml +8 -0
  380. data/app/views/users/_corporate_vita.html.haml +23 -0
  381. data/app/views/users/_dead_badge.html.haml +3 -0
  382. data/app/views/users/_deceased_modal.html.haml +24 -0
  383. data/app/views/users/_hidden_badge.html.haml +4 -0
  384. data/app/views/users/_hidden_flag_switch.html.haml +20 -0
  385. data/app/views/users/_special_general_info_fields.html.haml +10 -0
  386. data/app/views/users/_user_corporation_attribute.html.haml +6 -0
  387. data/app/views/users/_user_name_attribute.html.haml +4 -0
  388. data/app/views/users/_user_title.html.haml +5 -0
  389. data/app/views/users/_workflow_triggers.html.haml +23 -0
  390. data/app/views/users/new.html.haml +55 -0
  391. data/app/views/users/show.html.haml +79 -0
  392. data/config/environment.rb +5 -0
  393. data/config/initializers/active_record_cache_extension.rb +1 -0
  394. data/config/initializers/active_record_find_by_extension.rb +1 -0
  395. data/config/initializers/active_record_flagable_extension.rb +2 -0
  396. data/config/initializers/active_record_json_url_extension.rb +1 -0
  397. data/config/initializers/active_record_may_need_review_extension.rb +2 -0
  398. data/config/initializers/active_record_metric_events_extension.rb +1 -0
  399. data/config/initializers/active_record_navable_extension.rb +6 -0
  400. data/config/initializers/active_record_profileable_extension.rb +4 -0
  401. data/config/initializers/active_record_read_only_extension.rb +1 -0
  402. data/config/initializers/active_record_structureable_extension.rb +3 -0
  403. data/config/initializers/active_record_update_attributes_bip_extension.rb +1 -0
  404. data/config/initializers/array_extension.rb +1 -0
  405. data/config/initializers/best_in_place_display_definitions.rb +31 -0
  406. data/config/initializers/cache_store_extension.rb +1 -0
  407. data/config/initializers/devise.rb +240 -0
  408. data/config/initializers/fnordmetric.rb +14 -0
  409. data/config/initializers/formtastic.rb +76 -0
  410. data/config/initializers/group_type_column_patches.rb +11 -0
  411. data/config/initializers/mime_types.rb +1 -0
  412. data/config/initializers/mini_profiler.rb +32 -0
  413. data/config/initializers/object_to_b_extension.rb +1 -0
  414. data/config/initializers/refile.rb +22 -0
  415. data/config/initializers/sidekiq.rb +12 -0
  416. data/config/locales/attachments/de.yml +33 -0
  417. data/config/locales/bookmarks/de.yml +3 -0
  418. data/config/locales/bookmarks/en.yml +3 -0
  419. data/config/locales/common_expressions/de.yml +5 -0
  420. data/config/locales/common_expressions/en.yml +5 -0
  421. data/config/locales/companies/de.yml +4 -0
  422. data/config/locales/companies/en.yml +4 -0
  423. data/config/locales/de.yml +30 -0
  424. data/config/locales/devise/de.yml +60 -0
  425. data/config/locales/devise/en.yml +62 -0
  426. data/config/locales/en.yml +25 -0
  427. data/config/locales/events/de.yml +34 -0
  428. data/config/locales/events/en.yml +34 -0
  429. data/config/locales/forms/de.yml +3 -0
  430. data/config/locales/groups/de.yml +56 -0
  431. data/config/locales/groups/en.yml +47 -0
  432. data/config/locales/officers/de.yml +10 -0
  433. data/config/locales/pages/de.yml +15 -0
  434. data/config/locales/pages/en.yml +14 -0
  435. data/config/locales/pagination/de.yml +6 -0
  436. data/config/locales/pagination/en.yml +5 -0
  437. data/config/locales/password_strength/de.yml +9 -0
  438. data/config/locales/password_strength/en.yml +9 -0
  439. data/config/locales/posts/de.yml +9 -0
  440. data/config/locales/profile_fields/de.yml +78 -0
  441. data/config/locales/profile_fields/en.yml +22 -0
  442. data/config/locales/profiles/de.yml +47 -0
  443. data/config/locales/profiles/en.yml +44 -0
  444. data/config/locales/roles/de.yml +9 -0
  445. data/config/locales/root/de.yml +3 -0
  446. data/config/locales/root/en.yml +3 -0
  447. data/config/locales/search/de.yml +11 -0
  448. data/config/locales/search/en.yml +11 -0
  449. data/config/locales/sessions/de.yml +37 -0
  450. data/config/locales/sessions/en.yml +37 -0
  451. data/config/locales/setup/de.yml +26 -0
  452. data/config/locales/setup/en.yml +26 -0
  453. data/config/locales/statistics/de.yml +6 -0
  454. data/config/locales/terms_of_use/de.yml +6 -0
  455. data/config/locales/tools/de.yml +9 -0
  456. data/config/locales/tools/en.yml +9 -0
  457. data/config/locales/user_accounts/de.yml +16 -0
  458. data/config/locales/user_accounts/en.yml +13 -0
  459. data/config/locales/user_settings/de.yml +9 -0
  460. data/config/locales/users/de.yml +82 -0
  461. data/config/locales/users/en.yml +51 -0
  462. data/config/locales/workflows/de.yml +4 -0
  463. data/config/locales/workflows/en.yml +4 -0
  464. data/config/routes.rb +104 -0
  465. data/db/migrate/20120403002734_create_users.rb +12 -0
  466. data/db/migrate/20120403011601_create_profile_fields.rb +11 -0
  467. data/db/migrate/20120403161549_remove_user_email_column.rb +5 -0
  468. data/db/migrate/20120405222050_encrypt_password.rb +8 -0
  469. data/db/migrate/20120425161138_create_dag_links.rb +14 -0
  470. data/db/migrate/20120425162644_create_pages.rb +10 -0
  471. data/db/migrate/20120426023322_create_groups.rb +9 -0
  472. data/db/migrate/20120426090436_create_nav_nodes.rb +18 -0
  473. data/db/migrate/20120427021934_create_user_accounts.rb +12 -0
  474. data/db/migrate/20120427044338_add_foreign_key_to_user_accounts.rb +7 -0
  475. data/db/migrate/20120427150156_add_group_token.rb +8 -0
  476. data/db/migrate/20120507165551_make_profile_fields_polymorphic.rb +11 -0
  477. data/db/migrate/20120508130729_add_profile_field_acts_as_tree.rb +9 -0
  478. data/db/migrate/20120508152233_change_profile_field_value_to_text.rb +9 -0
  479. data/db/migrate/20120508201550_add_group_internal_token.rb +11 -0
  480. data/db/migrate/20120511090234_create_workflows.rb +9 -0
  481. data/db/migrate/20120701115059_add_password_digest_to_user_accounts.rb +5 -0
  482. data/db/migrate/20120710193308_remove_salt_from_user_accounts.rb +5 -0
  483. data/db/migrate/20120713102445_add_deleted_at_to_dag_links.rb +5 -0
  484. data/db/migrate/20120722005022_create_workflow_kit_workflows.workflow_kit.rb +11 -0
  485. data/db/migrate/20120722005023_create_workflow_kit_steps.workflow_kit.rb +12 -0
  486. data/db/migrate/20120722005024_create_workflow_kit_parameters.workflow_kit.rb +12 -0
  487. data/db/migrate/20120723165226_add_female_to_users.rb +5 -0
  488. data/db/migrate/20120811140509_create_flags.rb +11 -0
  489. data/db/migrate/20120814100529_create_attachments.rb +13 -0
  490. data/db/migrate/20120815205610_add_content_type_and_file_size_to_attachments.rb +6 -0
  491. data/db/migrate/20130118220014_add_relationships_table_without_dag.rb +10 -0
  492. data/db/migrate/20130207214331_create_events.rb +12 -0
  493. data/db/migrate/20130208215253_create_status_group_membership_infos.rb +11 -0
  494. data/db/migrate/20130220184943_create_stars.rb +11 -0
  495. data/db/migrate/20130309193623_add_devise_to_user_accounts.rb +72 -0
  496. data/db/migrate/20130310003840_rename_stars_to_bookmarks.rb +9 -0
  497. data/db/migrate/20130310004622_fix_column_names_for_bookmarks.rb +6 -0
  498. data/db/migrate/20130313211414_create_geo_infos.rb +13 -0
  499. data/db/migrate/20130313234131_create_geo_locations.rb +16 -0
  500. data/db/migrate/20130314011638_drop_geo_infos.rb +5 -0
  501. data/db/migrate/20130315072759_add_invalid_to_geo_location.rb +5 -0
  502. data/db/migrate/20130315073149_exchange_invalid_for_queried_at_in_geo_location.rb +8 -0
  503. data/db/migrate/20130320003051_add_redirect_to_to_page.rb +5 -0
  504. data/db/migrate/20130329231657_create_posts.rb +15 -0
  505. data/db/migrate/20130404223735_add_entire_message_to_posts.rb +5 -0
  506. data/db/migrate/20130409192959_add_author_to_page.rb +5 -0
  507. data/db/migrate/20130908011215_add_type_to_pages.rb +5 -0
  508. data/db/migrate/20131115114715_validity_range_for_dag_links.rb +16 -0
  509. data/db/migrate/20140611170430_create_activities.rb +23 -0
  510. data/db/migrate/20140808223512_create_last_seen_activities.rb +12 -0
  511. data/db/migrate/20141008101744_add_location_to_events.rb +5 -0
  512. data/db/migrate/20141010130344_add_publish_on_website_to_events.rb +6 -0
  513. data/db/migrate/20141010134227_add_auth_token_to_user_accounts.rb +5 -0
  514. data/db/migrate/20141018143323_add_accepted_terms_to_users.rb +6 -0
  515. data/db/migrate/20141018221659_add_author_to_attachments.rb +5 -0
  516. data/db/migrate/20141102223954_add_body_to_groups.rb +5 -0
  517. data/db/migrate/20141110193830_create_settings.rb +17 -0
  518. data/db/migrate/20141202140522_add_indices.rb +6 -0
  519. data/db/migrate/20141209161946_add_keys.rb +20 -0
  520. data/db/migrate/20150127013809_add_incognito_to_users.rb +5 -0
  521. data/db/migrate/20150129194501_add_indices_for_polymorphic_references.rb +13 -0
  522. data/db/migrate/20150304192448_add_type_to_groups.rb +5 -0
  523. data/db/migrate/20150313221004_add_avatar_id_to_users.rb +5 -0
  524. data/lib/best_in_place/controller_extensions.rb +25 -0
  525. data/lib/best_in_place/helper.rb +127 -0
  526. data/lib/tasks/db_bootstrap.rake +37 -0
  527. data/lib/tasks/your_platform_tasks.rake +4 -0
  528. data/lib/templates/erb/scaffold/_form.html.erb +11 -0
  529. data/lib/your_platform.rb +6 -2
  530. data/lib/your_platform/engine.rb +127 -0
  531. data/lib/your_platform/version.rb +1 -1
  532. data/spec/factories/attachment.rb +12 -0
  533. data/spec/factories/blog_post.rb +10 -0
  534. data/spec/factories/company.rb +7 -0
  535. data/spec/factories/corporation.rb +20 -0
  536. data/spec/factories/event.rb +13 -0
  537. data/spec/factories/group.rb +36 -0
  538. data/spec/factories/html_email.eml +1059 -0
  539. data/spec/factories/mail_message.rb +30 -0
  540. data/spec/factories/page.rb +10 -0
  541. data/spec/factories/relationship.rb +13 -0
  542. data/spec/factories/status_group_membership.rb +21 -0
  543. data/spec/factories/user.rb +97 -0
  544. data/spec/factories/workflow.rb +44 -0
  545. data/spec/features/blog_post_spec.rb +46 -0
  546. data/spec/features/corporate_vita_events_spec.rb +114 -0
  547. data/spec/features/corporate_vita_spec.rb +258 -0
  548. data/spec/features/edit_mode_after_clicking_a_link_spec.rb +20 -0
  549. data/spec/features/events_spec.rb +356 -0
  550. data/spec/features/group_export_spec.rb +19 -0
  551. data/spec/features/group_post_spec.rb +89 -0
  552. data/spec/features/groups_of_groups_page_spec.rb +67 -0
  553. data/spec/features/groups_page_spec.rb +66 -0
  554. data/spec/features/groups_table_spec.rb +32 -0
  555. data/spec/features/help_page_spec.rb +22 -0
  556. data/spec/features/intranet_root_page_spec.rb +18 -0
  557. data/spec/features/locales_spec.rb +36 -0
  558. data/spec/features/maps_spec.rb +53 -0
  559. data/spec/features/mini_profiler_spec.rb +37 -0
  560. data/spec/features/officers_spec.rb +61 -0
  561. data/spec/features/page_redirects_spec.rb +23 -0
  562. data/spec/features/page_spec.rb +20 -0
  563. data/spec/features/postal_address_flag_spec.rb +46 -0
  564. data/spec/features/relationships_on_user_page_spec.rb +78 -0
  565. data/spec/features/review_membership_spec.rb +44 -0
  566. data/spec/features/search_field_spec.rb +121 -0
  567. data/spec/features/setup_spec.rb +63 -0
  568. data/spec/features/user_change_date_of_birth_spec.rb +26 -0
  569. data/spec/features/vertical_nav_spec.rb +27 -0
  570. data/spec/features/what_is_new_box_spec.rb +33 -0
  571. data/spec/helpers/attachments_helper_spec.rb +15 -0
  572. data/spec/models/ability_spec.rb +93 -0
  573. data/spec/models/active_record_cache_extension_spec.rb +177 -0
  574. data/spec/models/active_record_find_by_extension_spec.rb +26 -0
  575. data/spec/models/active_record_json_url_extension_spec.rb +79 -0
  576. data/spec/models/address_label_spec.rb +144 -0
  577. data/spec/models/app_version_spec.rb +38 -0
  578. data/spec/models/attachment_spec.rb +5 -0
  579. data/spec/models/bookmark_spec.rb +70 -0
  580. data/spec/models/concerns/user_corporations_spec.rb +71 -0
  581. data/spec/models/corporation_spec.rb +128 -0
  582. data/spec/models/dag_link_spec.rb +48 -0
  583. data/spec/models/event_spec.rb +267 -0
  584. data/spec/models/flag_spec.rb +20 -0
  585. data/spec/models/flagable_spec.rb +55 -0
  586. data/spec/models/geo_location_spec.rb +126 -0
  587. data/spec/models/group_mixins/corporations_spec.rb +95 -0
  588. data/spec/models/group_mixins/everyone_spec.rb +64 -0
  589. data/spec/models/group_mixins/guests_spec.rb +75 -0
  590. data/spec/models/group_mixins/hidden_users_spec.rb +21 -0
  591. data/spec/models/group_mixins/import_spec.rb +93 -0
  592. data/spec/models/group_mixins/memberships_spec.rb +303 -0
  593. data/spec/models/group_mixins/officers_spec.rb +63 -0
  594. data/spec/models/group_mixins/roles_spec.rb +46 -0
  595. data/spec/models/group_spec.rb +341 -0
  596. data/spec/models/list_export_spec.rb +155 -0
  597. data/spec/models/may_need_review_spec.rb +114 -0
  598. data/spec/models/nav_node_spec.rb +277 -0
  599. data/spec/models/navable_spec.rb +54 -0
  600. data/spec/models/page_spec.rb +185 -0
  601. data/spec/models/post_spec.rb +271 -0
  602. data/spec/models/profile_field_mixins/has_child_profile_fields_spec.rb +73 -0
  603. data/spec/models/profile_field_spec.rb +482 -0
  604. data/spec/models/profile_section_spec.rb +89 -0
  605. data/spec/models/profile_spec.rb +74 -0
  606. data/spec/models/profileable_mixins/adress_spec.rb +93 -0
  607. data/spec/models/profileable_spec.rb +152 -0
  608. data/spec/models/relationship_spec.rb +113 -0
  609. data/spec/models/status_group_membership_spec.rb +350 -0
  610. data/spec/models/status_group_spec.rb +103 -0
  611. data/spec/models/structureable_mixins/has_special_groups_spec.rb +479 -0
  612. data/spec/models/structureable_mixins/roles_spec.rb +517 -0
  613. data/spec/models/structureable_spec.rb +128 -0
  614. data/spec/models/user_account_spec.rb +142 -0
  615. data/spec/models/user_alias_spec.rb +57 -0
  616. data/spec/models/user_group_membership_mixins/validity_range_for_indirect_memberships_spec.rb +291 -0
  617. data/spec/models/user_group_membership_mixins/validity_range_spec.rb +293 -0
  618. data/spec/models/user_group_membership_spec.rb +428 -0
  619. data/spec/models/user_mixins/identification_spec.rb +27 -0
  620. data/spec/models/user_mixins/memberships_spec.rb +138 -0
  621. data/spec/models/user_spec.rb +1794 -0
  622. data/spec/old_yp_spec_helper.rb +46 -0
  623. data/spec/spec_helper.rb +350 -0
  624. data/spec/support/auto_complete.rb +22 -0
  625. data/spec/support/capybara/flash_helpers.rb +37 -0
  626. data/spec/support/capybara/profile_steps.rb +73 -0
  627. data/spec/support/capybara/session_steps.rb +53 -0
  628. data/spec/support/capybara/user_account_helpers.rb +15 -0
  629. data/spec/support/debug.rb +8 -0
  630. data/spec/support/devise-controller_macros.rb +15 -0
  631. data/spec/support/geocoder/stubs.rb +60 -0
  632. data/spec/support/press_enter.rb +15 -0
  633. data/spec/support/time_travel.rb +9 -0
  634. data/spec/support/uploads/image-upload.png +0 -0
  635. data/spec/support/uploads/pdf-upload.pdf +0 -0
  636. data/spec/support/wait_for_ajax.rb +39 -0
  637. data/spec/support/wait_for_cache.rb +7 -0
  638. data/spec/uploaders/attachment_uploader_spec.rb +47 -0
  639. data/vendor/assets/images/flags.png +0 -0
  640. data/vendor/assets/images/galleria/classic-loader.gif +0 -0
  641. data/vendor/assets/images/galleria/classic-map.png +0 -0
  642. data/vendor/assets/javascripts/best_in_place_datetime.js.coffee +45 -0
  643. data/vendor/assets/javascripts/galleria-classic.js +100 -0
  644. data/vendor/assets/javascripts/galleria.js +6919 -0
  645. data/vendor/assets/javascripts/gmaps4rails.js +2 -0
  646. data/vendor/assets/javascripts/gmaps4rails/all.js +1 -0
  647. data/vendor/assets/javascripts/gmaps4rails/base.coffee +1 -0
  648. data/vendor/assets/javascripts/gmaps4rails/base/common.coffee +43 -0
  649. data/vendor/assets/javascripts/gmaps4rails/base/configuration.coffee +7 -0
  650. data/vendor/assets/javascripts/gmaps4rails/base/gmaps.coffee +13 -0
  651. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/basic_interface.coffee +15 -0
  652. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/controller_interface.coffee +15 -0
  653. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/map_interface.coffee +27 -0
  654. data/vendor/assets/javascripts/gmaps4rails/base/interfaces/marker_interface.coffee +15 -0
  655. data/vendor/assets/javascripts/gmaps4rails/base/main.coffee +124 -0
  656. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/circle_controller.coffee +29 -0
  657. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/kml_controller.coffee +5 -0
  658. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/marker_controller.coffee +76 -0
  659. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polygon_controller.coffee +29 -0
  660. data/vendor/assets/javascripts/gmaps4rails/base/main_controller_extensions/polyline_controller.coffee +29 -0
  661. data/vendor/assets/javascripts/gmaps4rails/base/objects/circle.coffee +12 -0
  662. data/vendor/assets/javascripts/gmaps4rails/base/objects/kml.coffee +8 -0
  663. data/vendor/assets/javascripts/gmaps4rails/base/objects/map.coffee +62 -0
  664. data/vendor/assets/javascripts/gmaps4rails/base/objects/marker.coffee +24 -0
  665. data/vendor/assets/javascripts/gmaps4rails/base/objects/polygon.coffee +11 -0
  666. data/vendor/assets/javascripts/gmaps4rails/base/objects/polyline.coffee +11 -0
  667. data/vendor/assets/javascripts/gmaps4rails/bing.coffee +1 -0
  668. data/vendor/assets/javascripts/gmaps4rails/bing/main.coffee +29 -0
  669. data/vendor/assets/javascripts/gmaps4rails/bing/objects/map.coffee +63 -0
  670. data/vendor/assets/javascripts/gmaps4rails/bing/objects/marker.coffee +78 -0
  671. data/vendor/assets/javascripts/gmaps4rails/bing/shared.coffee +20 -0
  672. data/vendor/assets/javascripts/gmaps4rails/google.coffee +1 -0
  673. data/vendor/assets/javascripts/gmaps4rails/google/main.coffee +47 -0
  674. data/vendor/assets/javascripts/gmaps4rails/google/objects/circle.coffee +38 -0
  675. data/vendor/assets/javascripts/gmaps4rails/google/objects/kml.coffee +16 -0
  676. data/vendor/assets/javascripts/gmaps4rails/google/objects/map.coffee +71 -0
  677. data/vendor/assets/javascripts/gmaps4rails/google/objects/marker.coffee +114 -0
  678. data/vendor/assets/javascripts/gmaps4rails/google/objects/polygon.coffee +38 -0
  679. data/vendor/assets/javascripts/gmaps4rails/google/objects/polyline.coffee +49 -0
  680. data/vendor/assets/javascripts/gmaps4rails/google/shared.coffee +27 -0
  681. data/vendor/assets/javascripts/gmaps4rails/openlayers.coffee +1 -0
  682. data/vendor/assets/javascripts/gmaps4rails/openlayers/main.coffee +138 -0
  683. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/map.coffee +49 -0
  684. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/marker.coffee +68 -0
  685. data/vendor/assets/javascripts/gmaps4rails/openlayers/objects/polyline.coffee +39 -0
  686. data/vendor/assets/javascripts/gmaps4rails/openlayers/shared.coffee +19 -0
  687. data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +2223 -0
  688. data/vendor/assets/javascripts/jquery-ui-timepicker-de.js +26 -0
  689. data/vendor/assets/javascripts/jquery.ui.datepicker-de.js +23 -0
  690. data/vendor/assets/javascripts/password_strength.js +149 -0
  691. data/vendor/assets/javascripts/zxcvbn.js +43 -0
  692. data/vendor/assets/stylesheets/flags.css.scss +259 -0
  693. data/vendor/assets/stylesheets/galleria-classic.css.scss +239 -0
  694. data/vendor/assets/stylesheets/gmaps4rails.css +24 -0
  695. data/vendor/assets/stylesheets/mercury.css +24 -0
  696. data/vendor/scripts/bashpass/README.md +29 -0
  697. data/vendor/scripts/bashpass/bashpass +124 -0
  698. data/vendor/scripts/bashpass/bashpass-APACHE-LICENSE +201 -0
  699. data/vendor/scripts/bashpass/german.dic +40794 -0
  700. metadata +1540 -16
  701. data/.gitignore +0 -17
  702. data/Gemfile +0 -4
  703. data/LICENSE.txt +0 -4
  704. data/your_platform.gemspec +0 -19
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe UserMixins::Identification do
4
+
5
+ before do
6
+ @user1 = create( :user, first_name: "John", last_name: "Doe", email: "john.doe@example.com", :alias => "john.doe" )
7
+ @user2 = create( :user, first_name: "James", last_name: "Doe", email: "james.doe@example.com", :alias => "james.doe" )
8
+ end
9
+
10
+ describe ".attributes_used_for_identification" do
11
+ subject { User.attributes_used_for_identification }
12
+ it { should be_kind_of( Array ) }
13
+ its( :first ) { should be_kind_of Symbol }
14
+ end
15
+
16
+ describe ".find_all_by_identification_string" do
17
+ it "should return the matching users" do
18
+ User.find_all_by_identification_string( "doe" ).should include( @user1, @user2 )
19
+ User.find_all_by_identification_string( "john doe" ).should include( @user1 )
20
+ User.find_all_by_identification_string( "james doe" ).should include( @user2 )
21
+ User.find_all_by_identification_string( "john.doe" ).should include( @user1 )
22
+ User.find_all_by_identification_string( "John Doe" ).should include( @user1 )
23
+ User.find_all_by_identification_string( "john.doe@example.com" ).should include( @user1 )
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,138 @@
1
+ require 'spec_helper'
2
+
3
+ describe UserMixins::Memberships do
4
+
5
+ # @indirect_group
6
+ # |------------ @group
7
+ # | |------ @user1
8
+ # | |------ @user2
9
+ # |
10
+ # |------------ @group2
11
+ #
12
+ before do
13
+ @group = create(:group)
14
+ @user1 = create(:user); @group.assign_user(@user1)
15
+ @user2 = create(:user); @group.assign_user(@user2)
16
+ @user = @user1
17
+ @membership1 = UserGroupMembership.find_by(user: @user1, group: @group)
18
+ @membership2 = UserGroupMembership.find_by(user: @user2, group: @group)
19
+ @indirect_group = @group.parent_groups.create
20
+ @indirect_membership1 = UserGroupMembership.find_by(user: @user1, group: @indirect_group)
21
+ @indirect_membership2 = UserGroupMembership.find_by(user: @user2, group: @indirect_group)
22
+ @group2 = @indirect_group.child_groups.create
23
+ end
24
+
25
+
26
+ # User Group Memberships
27
+ # ==========================================================================================
28
+
29
+ describe "#memberships" do
30
+ subject { @user1.memberships }
31
+ it { should include @membership1 }
32
+ it { should include @indirect_membership1 }
33
+ it "should not include invalidated memberships" do
34
+ @membership1.invalidate at: 10.minutes.ago
35
+ subject { should_not include @membership1 }
36
+ end
37
+ it "should not include invalidated indirect memberships" do
38
+ @membership1.invalidate at: 10.minutes.ago
39
+ subject { should_not include @indirect_membership1 }
40
+ end
41
+ end
42
+
43
+ describe "#direct_memberships" do
44
+ subject { @user1.direct_memberships }
45
+ it { should include @membership1 }
46
+ it { should_not include @indirect_membership1 }
47
+ end
48
+
49
+ describe "#indirect_memberships" do
50
+ subject { @user1.indirect_memberships }
51
+ it { should include @indirect_membership1 }
52
+ it { should_not include @membership1 }
53
+ end
54
+
55
+
56
+ describe "#membership_in( group )" do
57
+ describe "for the user being a direct member" do
58
+ subject { @user.membership_in @group }
59
+ it { should == @membership1 }
60
+ end
61
+ describe "for the user being an indirect member" do
62
+ subject { @user.membership_in @indirect_group }
63
+ it { should == @indirect_membership1 }
64
+ end
65
+ end
66
+
67
+ describe "#member_of?( group )" do
68
+ describe "for the user being direct member" do
69
+ subject { @user.member_of? @group}
70
+ it { should == true }
71
+ end
72
+ describe "for the user being indirect member" do
73
+ subject { @user.member_of? @indirect_group }
74
+ it { should == true }
75
+ end
76
+ describe "for the user not being a member" do
77
+ subject { @user.member_of? @group2 }
78
+ it { should == false }
79
+ end
80
+ end
81
+
82
+
83
+ # Groups the user is member of
84
+ # ==========================================================================================
85
+
86
+ describe "#groups" do
87
+ subject { @user1.groups }
88
+ it { should include @group }
89
+ it { should include @indirect_group }
90
+ it "should not include groups of invalidated memberships" do
91
+ @membership1.invalidate at: 10.minutes.ago
92
+ subject.should_not include @group
93
+ subject.should_not include @indirect_group
94
+ end
95
+ end
96
+ describe "#groups << group" do
97
+ subject { @user.groups << @group2 }
98
+ it "should assign the user to the given group" do
99
+ @user.should_not be_in @group2.members
100
+ subject
101
+ @user.should be_in @group2.members
102
+ @user.should be_in @group2.direct_members
103
+ end
104
+ end
105
+ describe "#groups.destroy(group)" do
106
+ describe "for the membership being direct" do
107
+ subject { @user.groups.destroy(@group) }
108
+ it "should remove the user from the members list" do
109
+ @user1.should be_in @group.members
110
+ subject
111
+ @user1.should_not be_in @group.members
112
+ end
113
+ it "should remove the membership permanently" do
114
+ subject
115
+ UserGroupMembership.with_invalid.find_by_user_and_group(@user1, @group).should == nil
116
+ end
117
+ end
118
+ describe "for the membership being indirect" do
119
+ subject { @user.groups.destroy(@indirect_group) }
120
+ it "should raise an error" do
121
+ expect { subject }.to raise_error
122
+ end
123
+ end
124
+ end
125
+
126
+ describe "#direct_groups" do
127
+ subject { @user.direct_groups }
128
+ it { should include @group }
129
+ it { should_not include @indirect_group }
130
+ end
131
+
132
+ describe "#indirect_groups" do
133
+ subject { @user.indirect_groups }
134
+ it { should include @indirect_group }
135
+ it { should_not include @group }
136
+ end
137
+
138
+ end
@@ -0,0 +1,1794 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe User do
5
+
6
+ before do
7
+ @user = create( :user )
8
+ @user.save
9
+ end
10
+
11
+ subject { @user }
12
+
13
+ # Validation
14
+ # ==========================================================================================
15
+
16
+ it { should be_valid }
17
+
18
+
19
+ # Basic Properties
20
+ # ==========================================================================================
21
+
22
+ describe "accessible attributes" do
23
+ subject { @user }
24
+ [ :first_name, :last_name, :alias, :email, :create_account, :female, :add_to_group ].each do |attr|
25
+ it { should respond_to( attr ) }
26
+ it { should respond_to( "#{attr}=".to_sym ) }
27
+ end
28
+ end
29
+
30
+ describe "#name" do
31
+ subject { @user.name }
32
+ it { should == "#{@user.first_name} #{@user.last_name}" }
33
+ end
34
+
35
+ describe "#capitalize_name" do
36
+ [ { first_name: "john", last_name: "doe",
37
+ capitalized_first_name: "John", capitalized_last_name: "Doe" },
38
+ { first_name: "Bruno", last_name: "de Silva",
39
+ capitalized_first_name: "Bruno", capitalized_last_name: "de Silva" },
40
+ { first_name: "Klaus-Dieter", last_name: "Kunz",
41
+ capitalized_first_name: "Klaus-Dieter", capitalized_last_name: "Kunz" } ].each do |name_to_test|
42
+ describe "for '#{name_to_test[ :capitalized_last_name ]}'" do
43
+ before do
44
+ @user.first_name = name_to_test[ :first_name ]
45
+ @user.last_name = name_to_test[ :last_name ]
46
+ @user.capitalize_name
47
+ @user.save
48
+ end
49
+ it "should capitalize the first_name and last_name" do
50
+ @user.first_name.should == name_to_test[ :capitalized_first_name ]
51
+ @user.last_name.should == name_to_test[ :capitalized_last_name ]
52
+ @user.name.should == name_to_test[ :capitalized_first_name ] + " " +
53
+ name_to_test[ :capitalized_last_name ]
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "#title" do
60
+ subject { @user.title }
61
+ # the title is likely to be overridden in the main application. Therefore, here are
62
+ # just a few vague tests.
63
+ it { should include( @user.last_name ) }
64
+ it { should_not be_empty }
65
+ end
66
+
67
+ describe "#gender" do
68
+ it "should return :female if the user is female" do
69
+ @user.female = true
70
+ @user.gender.should == :female
71
+ end
72
+ it "should return :male if the user is not female" do
73
+ @user.female = false
74
+ @user.gender.should == :male
75
+ end
76
+ end
77
+
78
+ describe "#gender=" do
79
+ it "should set :female to true if the gender is female" do
80
+ @user.gender = :female
81
+ @user.female?.should == true
82
+ end
83
+ it "should set :female to false if the gender is male" do
84
+ @user.gender = :male
85
+ @user.female?.should == false
86
+ end
87
+ it "should set :female to false if the gender is something else" do
88
+ @user.gender = :something_else
89
+ @user.female?.should == false
90
+ end
91
+ end
92
+
93
+
94
+ describe "#date_of_birth" do
95
+ subject { @user.date_of_birth }
96
+ describe "before setting a date of birth" do
97
+ it { should == nil }
98
+ end
99
+ describe "after setting a date of birth" do
100
+ before { @user.date_of_birth = 24.years.ago.to_date }
101
+ it { should be_kind_of Date }
102
+ it "should persist" do
103
+ @user.save
104
+ @reloaded_user = User.find(@user.id)
105
+ @reloaded_user.date_of_birth.should == @user.date_of_birth
106
+ end
107
+ it "should be stored inside a ProfileField" do
108
+ @user.save
109
+ @profile_field = @user.profile_fields.where( label: 'date_of_birth' ).first
110
+ @profile_field.value.to_date.should == @user.date_of_birth
111
+ end
112
+ end
113
+ it "should be autosaved" do
114
+ @user = create(:user)
115
+ @user.date_of_birth = "2001-01-01"
116
+ @user.save
117
+ User.find(@user.id).date_of_birth.should == "2001-01-01".to_date
118
+ end
119
+ describe "after a former date of birth has been saved" do
120
+ before do
121
+ @user.date_of_birth = 27.years.ago.to_date
122
+ @user.save
123
+ end
124
+ specify "prelim: the date of birth should be saved before" do
125
+ @user.reload
126
+ @user.date_of_birth.should == 27.years.ago.to_date
127
+ end
128
+ specify "a changed date of birth should be autosaved (bug fix)" do
129
+ @user.reload
130
+ @user.date_of_birth = "2001-01-01".to_date
131
+ @user.save
132
+ User.find(@user.id).date_of_birth.should == "2001-01-01".to_date
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "#date_of_birth=" do
138
+ before { @date_of_birth = 24.years.ago.to_date }
139
+ subject { @user.date_of_birth = @date_of_birth; @user.save }
140
+ it "should set the date of birth" do
141
+ @user.date_of_birth.should == nil
142
+ subject
143
+ @user.date_of_birth.should == @date_of_birth
144
+ end
145
+ end
146
+
147
+ describe "#localized_date_of_birth" do
148
+ subject { @user.localized_date_of_birth }
149
+ describe "for a given date of birth" do
150
+ before do
151
+ @date_of_birth = "1987-01-11".to_date
152
+ @user.date_of_birth = @date_of_birth
153
+ end
154
+ it { should == I18n.localize(@date_of_birth) }
155
+ it "should return the correctly localized date" do
156
+ I18n.locale.should == :de
157
+ subject.should be_in ["11.01.1987", "11.1.1987"]
158
+ end
159
+ end
160
+ describe "for the user not having a date of birth in the database" do
161
+ it "should return nil" do
162
+ @user.date_of_birth.should == nil
163
+ subject.should == nil
164
+ end
165
+ end
166
+ end
167
+ describe "#localized_date_of_birth=" do
168
+ subject { @user.localized_date_of_birth = @given_string; @user.save }
169
+ describe "for setting a valid date of birth" do
170
+ before { @given_string = "11.01.1987" }
171
+ it "should set the date correctly" do
172
+ @user.date_of_birth.should_not == "1987-01-11".to_date
173
+ subject
174
+ @user.date_of_birth.should == "1987-01-11".to_date
175
+ end
176
+ end
177
+ describe "for setting an empty string" do
178
+ before do
179
+ @user.date_of_birth = 24.years.ago.to_date
180
+ @given_string = ""
181
+ end
182
+ it "should set the date of birth to nil" do
183
+ subject
184
+ @user.date_of_birth.should == nil
185
+ end
186
+ end
187
+ describe "for setting an invalid date string" do
188
+ before do
189
+ @user.date_of_birth = 24.years.ago.to_date
190
+ @given_string = "foo"
191
+ end
192
+ it "should set the date of birth to nil" do
193
+ subject
194
+ @user.date_of_birth.should == nil
195
+ end
196
+ end
197
+ end
198
+
199
+ describe "#date_of_birth_profile_field" do
200
+ subject { @user.date_of_birth_profile_field }
201
+ describe "for no date of birth field created" do
202
+ it { should == nil }
203
+ end
204
+ describe "for an existing date of birth" do
205
+ before { @user.date_of_birth = "1900-01-01".to_date }
206
+ it { should be_kind_of ProfileField }
207
+ its(:type) { should == "ProfileFieldTypes::Date" }
208
+ end
209
+ it "should be autosaved" do
210
+ @field = @user.build_date_of_birth_profile_field
211
+ @field.value = "2001-01-01"
212
+ @user.save
213
+ @user = User.find(@user.id)
214
+ subject.value.to_date.should == "2001-01-01".to_date
215
+ end
216
+ end
217
+ describe "#find_or_build_date_of_birth_profile_field" do
218
+ subject { @user.find_or_build_date_of_birth_profile_field }
219
+ describe "for no date of birth field created" do
220
+ it { should be_kind_of ProfileField }
221
+ its(:type) { should == "ProfileFieldTypes::Date" }
222
+ its(:new_record?) { should == true }
223
+ end
224
+ describe "for an existing date of birth" do
225
+ before { @user.date_of_birth = "1900-01-01".to_date }
226
+ it { should be_kind_of ProfileField }
227
+ its(:type) { should == "ProfileFieldTypes::Date" }
228
+ end
229
+ describe "for a date of birth existing in the database" do
230
+ before do
231
+ @user.date_of_birth = "1900-01-01".to_date
232
+ @user.save
233
+ @user = User.find(@user.id)
234
+ end
235
+ it { should be_kind_of ProfileField }
236
+ its(:type) { should == "ProfileFieldTypes::Date" }
237
+ its('value.to_date') { should == "1900-01-01".to_date }
238
+ its(:new_record?) { should == false }
239
+ end
240
+ end
241
+ describe "#find_or_create_date_of_birth_profile_field" do
242
+ subject { @user.find_or_create_date_of_birth_profile_field }
243
+ describe "for no date of birth field existing" do
244
+ it { should be_kind_of ProfileField }
245
+ its(:type) { should == "ProfileFieldTypes::Date" }
246
+ its(:new_record?) { should == false }
247
+ its(:id) { should be_kind_of Integer }
248
+ end
249
+ describe "for a date of birth existing in the database" do
250
+ before do
251
+ @user.date_of_birth = "1900-01-01".to_date
252
+ @user.save
253
+ @user = User.find(@user.id)
254
+ end
255
+ it { should be_kind_of ProfileField }
256
+ its(:type) { should == "ProfileFieldTypes::Date" }
257
+ its('value.to_date') { should == "1900-01-01".to_date }
258
+ its(:new_record?) { should == false }
259
+ end
260
+ end
261
+
262
+ describe "#age" do
263
+ subject { @user.age }
264
+ describe "without date of birth" do
265
+ it { should == nil }
266
+ end
267
+ describe "with date of birth" do
268
+ before { @user.date_of_birth = 24.years.ago }
269
+ it "should return the correct age as number" do
270
+ subject.should == 24
271
+ end
272
+ end
273
+ end
274
+
275
+ describe "#birthday_this_year" do
276
+ subject { @user.birthday_this_year }
277
+ describe "without date of birth" do
278
+ it { should == nil }
279
+ end
280
+ describe "with date of birth" do
281
+ before { @user.date_of_birth = 24.years.ago }
282
+ it "should return the correct date" do
283
+ subject.should == Time.zone.now.to_date
284
+ end
285
+ end
286
+ end
287
+
288
+ describe "postal address: " do
289
+ before do
290
+ @other_field = ProfileFieldTypes::Address.create(label: "My Work", value: "Some Other Address")
291
+ @profile_field = ProfileFieldTypes::Address.create(label: "My Home", value: "Some Address")
292
+ @user.profile_fields << @other_field
293
+ @user.profile_fields << @profile_field
294
+ end
295
+ describe "#postal_address_field" do
296
+ subject { @user.postal_address_field }
297
+ describe "for no primary postal address being set" do
298
+ it "should return nil" do
299
+ subject.should == nil
300
+ end
301
+ end
302
+ describe "for a primary postal address being set" do
303
+ before { @profile_field.postal_address = true }
304
+ it "should return the address field" do
305
+ subject.should == @profile_field
306
+ end
307
+ end
308
+ end
309
+ describe "#postal_address" do
310
+ subject { @user.postal_address }
311
+ describe "for no primary postal address being set" do
312
+ it "should return the first address of the user" do
313
+ subject.should == @other_field.value
314
+ end
315
+ end
316
+ describe "for a primary postal address being set" do
317
+ before { @profile_field.postal_address = true }
318
+ it "should return the address field's value" do
319
+ subject.should == "Some Address"
320
+ end
321
+ end
322
+ end
323
+ describe "#postal_address_with_name_surrounding" do
324
+ subject { @user.postal_address_with_name_surrounding }
325
+ before do
326
+ @name_surrounding = @user.profile_fields.create(type: 'ProfileFieldTypes::NameSurrounding').becomes(ProfileFieldTypes::NameSurrounding)
327
+ @name_surrounding.name_prefix = "Dr."
328
+ @name_surrounding.name_suffix = "M.Sc."
329
+ @name_surrounding.text_above_name = "Herrn"
330
+ @name_surrounding.text_below_name = "Bankdirektor"
331
+ @name_surrounding.save
332
+ @user.save
333
+ end
334
+ specify "prelims" do
335
+ @user.name_surrounding_profile_field.should == @name_surrounding
336
+ @user.name_surrounding_profile_field.text_above_name.should == "Herrn"
337
+ @user.text_above_name.should == "Herrn"
338
+ end
339
+ it { should ==
340
+ "Herrn\n" +
341
+ "Dr. #{@user.first_name} #{@user.last_name} M.Sc.\n" +
342
+ "Bankdirektor\n" +
343
+ @user.postal_address
344
+ }
345
+ describe "when no name surroundings are given" do
346
+ before { @name_surrounding.destroy }
347
+ it { should == "#{@user.name}\n#{@user.postal_address}" }
348
+ end
349
+ describe "when the user has the same personal title as given in the name prefix" do
350
+ before do
351
+ @user.profile_fields.create(type: 'ProfileFieldTypes::General', label: 'personal_title', value: "Dr.")
352
+ @user.save
353
+ end
354
+ it "should not print it twice" do
355
+ subject.should ==
356
+ "Herrn\n" +
357
+ "Dr. #{@user.first_name} #{@user.last_name} M.Sc.\n" +
358
+ "Bankdirektor\n" +
359
+ @user.postal_address
360
+ end
361
+ end
362
+ describe "when there is no text below the name" do
363
+ before { @name_surrounding.update_attributes(text_below_name: nil) }
364
+ it "should leave no blank line" do
365
+ subject.should ==
366
+ "Herrn\n" +
367
+ "Dr. #{@user.first_name} #{@user.last_name} M.Sc.\n" +
368
+ @user.postal_address
369
+ end
370
+ end
371
+ describe "when there is no text above the name" do
372
+ before { @name_surrounding.update_attributes(text_above_name: nil) }
373
+ it "should not begin with a blnak line" do
374
+ subject.should ==
375
+ "Dr. #{@user.first_name} #{@user.last_name} M.Sc.\n" +
376
+ "Bankdirektor\n" +
377
+ @user.postal_address
378
+ end
379
+ end
380
+ describe "when there is neither prefix nor personal title" do
381
+ before { @name_surrounding.update_attributes(name_prefix: nil) }
382
+ it "should set no spaces before the name" do
383
+ subject.should ==
384
+ "Herrn\n" +
385
+ "#{@user.first_name} #{@user.last_name} M.Sc.\n" +
386
+ "Bankdirektor\n" +
387
+ @user.postal_address
388
+ end
389
+ end
390
+ describe "when there is no name suffix" do
391
+ before { @name_surrounding.update_attributes(name_suffix: nil) }
392
+ it "should set no spaces after the name" do
393
+ subject.should ==
394
+ "Herrn\n" +
395
+ "Dr. #{@user.first_name} #{@user.last_name}\n" +
396
+ "Bankdirektor\n" +
397
+ @user.postal_address
398
+ end
399
+ end
400
+ end
401
+ end
402
+
403
+ describe "#phone_profile_fields" do
404
+ subject { @user.phone_profile_fields }
405
+ before do
406
+ @phone_field = @user.profile_fields.create(label: 'Phone', type: 'ProfileFieldTypes::Phone', value: '123456').becomes(ProfileFieldTypes::Phone)
407
+ @fax_field = @user.profile_fields.create(label: 'Fax', type: 'ProfileFieldTypes::Phone', value: '123457').becomes(ProfileFieldTypes::Phone)
408
+ @mobile_field = @user.profile_fields.create(label: 'Mobile', type: 'ProfileFieldTypes::Phone', value: '01234').becomes(ProfileFieldTypes::Phone)
409
+ @user.reload
410
+ end
411
+ it { should include @phone_field }
412
+ it { should_not include @fax_field }
413
+ it { should include @mobile_field }
414
+ end
415
+
416
+ describe "#phone" do
417
+ subject { @user.phone }
418
+ describe "for a phone number given" do
419
+ before { @phone_field = @user.profile_fields.create(label: 'Phone', type: 'ProfileFieldTypes::Phone', value: '09131 123 45 67').becomes(ProfileFieldTypes::Phone) }
420
+ it { should == @phone_field.value }
421
+ end
422
+ describe "for a phone and a mobile number given" do
423
+ before do
424
+ @mobile_field = @user.profile_fields.create(label: 'Mobile', type: 'ProfileFieldTypes::Phone', value: '09131 123 45 67').becomes(ProfileFieldTypes::Phone)
425
+ @phone_field = @user.profile_fields.create(label: 'Phone', type: 'ProfileFieldTypes::Phone', value: '0171 123 45 67').becomes(ProfileFieldTypes::Phone)
426
+ end
427
+ it { should == @phone_field.value }
428
+ end
429
+ describe "for no phone number given" do
430
+ it { should == nil }
431
+ end
432
+ end
433
+
434
+ describe "#phone=" do
435
+ before { @new_phone_number = "+49 9131 123 45" }
436
+ subject { @user.phone = @new_phone_number }
437
+ describe "if no phone field is present" do
438
+ it "should create a new one" do
439
+ @user.phone_profile_fields.count.should == 0
440
+ subject
441
+ @user.phone_profile_fields.first.value.should == @new_phone_number
442
+ @user.phone_profile_fields.first.label.should == "Telefon"
443
+ end
444
+ end
445
+ describe "if a phone field is present" do
446
+ before { @phone_field = @user.profile_fields.create(label: 'Telefon', value: '09131 123 45 56', type: 'ProfileFieldTypes::Phone') }
447
+ it "should modify the existing one" do
448
+ subject
449
+ @phone_field.reload.value.should == @new_phone_number
450
+ end
451
+ end
452
+ end
453
+
454
+ describe "#mobile" do
455
+ subject { @user.mobile }
456
+ describe "for a mobile phone number given" do
457
+ before { @phone_field = @user.profile_fields.create(label: 'Mobile', type: 'ProfileFieldTypes::Phone', value: '0161 123 45 67').becomes(ProfileFieldTypes::Phone) }
458
+ it { should == @phone_field.value }
459
+ end
460
+ describe "for a phone and a mobile number given" do
461
+ before do
462
+ @phone_field = @user.profile_fields.create(label: 'Phone', type: 'ProfileFieldTypes::Phone', value: '0171 123 45 67').becomes(ProfileFieldTypes::Phone)
463
+ @mobile_field = @user.profile_fields.create(label: 'Mobile', type: 'ProfileFieldTypes::Phone', value: '09131 123 45 67').becomes(ProfileFieldTypes::Phone)
464
+ end
465
+ it { should == @mobile_field.value }
466
+ end
467
+ describe "for no phone number given" do
468
+ it { should == nil }
469
+ end
470
+ end
471
+ describe "#mobile=" do
472
+ before { @new_phone_number = "+49 9131 123 45" }
473
+ subject { @user.mobile = @new_phone_number }
474
+ describe "if no phone field is present" do
475
+ it "should create a new one" do
476
+ @user.phone_profile_fields.count.should == 0
477
+ subject
478
+ @user.phone_profile_fields.first.value.should == @new_phone_number
479
+ @user.phone_profile_fields.first.label.should == "Mobil"
480
+ end
481
+ end
482
+ describe "if a phone field is present" do
483
+ before { @phone_field = @user.profile_fields.create(label: 'Mobil', value: '0161 123 45 56', type: 'ProfileFieldTypes::Phone') }
484
+ it "should modify the existing one" do
485
+ subject
486
+ @phone_field.reload.value.should == @new_phone_number
487
+ end
488
+ end
489
+ end
490
+
491
+
492
+ # Associated Objects
493
+ # ==========================================================================================
494
+
495
+ # Alias
496
+ # ------------------------------------------------------------------------------------------
497
+
498
+ describe "#alias" do
499
+ describe "for an already created user" do
500
+ subject { @user.alias }
501
+ it { should be_kind_of( UserAlias ) }
502
+ it { should_not be_empty }
503
+ end
504
+ describe "for a newly built user without alias being set" do
505
+ before do
506
+ @user = User.new(first_name: "James", last_name: "Doe", email: "doe@example.com")
507
+ end
508
+ subject { @user.alias }
509
+ it { should == nil }
510
+ end
511
+ end
512
+
513
+ describe "#alias=" do
514
+ it "should set the alias attribute" do
515
+ @user.alias = "New Alias"
516
+ @user.alias.should == "New Alias"
517
+ end
518
+ end
519
+
520
+ describe "#generate_alias" do
521
+ before do
522
+ @user = build(:user, first_name: "Tamara", last_name: "Sweet")
523
+ end
524
+ subject { @user.generate_alias }
525
+ it "should generate the alias" do
526
+ subject.should be_kind_of UserAlias
527
+ subject.should == "sweet"
528
+ end
529
+ it "should not set the alias of the user" do
530
+ subject
531
+ @user.alias.should_not == "sweet"
532
+ end
533
+ end
534
+
535
+ describe "#generate_alias!" do
536
+ before do
537
+ @user = build(:user, first_name: "Tamara", last_name: "Sweet")
538
+ end
539
+ subject { @user.generate_alias! }
540
+ it "should generate the alias" do
541
+ subject.should be_kind_of UserAlias
542
+ subject.should == "sweet"
543
+ end
544
+ it "should set the alias of the user" do
545
+ subject
546
+ @user.alias.should == "sweet"
547
+ end
548
+ end
549
+
550
+ specify "changed behaviour: on creating the default alias should be nil" do
551
+ @user = User.create(first_name: "James", last_name: "Doe", email: "doe@example.com")
552
+ @user.alias.should == nil
553
+ end
554
+
555
+
556
+ # User Account
557
+ # ------------------------------------------------------------------------------------------
558
+
559
+ context "for a user with account" do
560
+ before { @user_with_account = create( :user_with_account ) }
561
+ subject { @user_with_account }
562
+
563
+ describe "#has_account?" do
564
+ subject { @user_with_account.has_account? }
565
+ it { should == true }
566
+ end
567
+
568
+ describe "#activate_account" do
569
+ it "should keep the existing account" do
570
+ @existing_account = @user_with_account.account
571
+ @user_with_account.activate_account
572
+ @user_with_account.account.should == @existing_account
573
+ end
574
+ end
575
+
576
+ describe "#deactivate_account" do
577
+ it "should destroy the existing account" do
578
+ @user_with_account.account.should_not be_nil
579
+ @user_with_account.deactivate_account
580
+ @user_with_account.account.should be_nil
581
+ @user_with_account.has_account?.should == false
582
+ end
583
+ end
584
+
585
+ specify "the new user should have an initial password" do
586
+ # This is to avoid the bug of welcome emails with a blank password.
587
+ subject.account.password.should_not be_empty
588
+ end
589
+ end
590
+
591
+ context "for a user without account" do
592
+ before { @user_without_account = create( :user, :create_account => false ) }
593
+
594
+ describe "#has_account?" do
595
+ subject { @user_without_account.has_account? }
596
+ it { should == false }
597
+ end
598
+
599
+ describe "#activate_account" do
600
+ it "should create an account" do
601
+ @user_without_account.account.should == nil
602
+ @user_without_account.activate_account
603
+ @user_without_account.account.should be_kind_of( UserAccount )
604
+ @user_without_account.should_not be_nil
605
+ end
606
+ end
607
+
608
+ describe "#deactivate_account" do
609
+ it "should raise an error, since no account exists" do
610
+ expect { @user_without_account.deactivate_account }.to raise_error
611
+ end
612
+ end
613
+ end
614
+
615
+ describe "#create_account attribute" do
616
+ describe "#create_account == true" do
617
+ it "should cause the user to be created with account" do
618
+ create( :user, create_account: true ).account.should_not be_nil
619
+ end
620
+ end
621
+ describe "#create_account == false" do
622
+ it "should cause the user to be created without account" do
623
+ create( :user, create_account: false ).account.should be_nil
624
+ end
625
+ end
626
+ describe "#create_account == 0" do
627
+ it "should cause the user to be created without account" do
628
+ create( :user, create_account: 0 ).account.should be_nil
629
+ end
630
+ end
631
+ describe "#create_account == 1" do
632
+ it "should cause the user to be created with account" do
633
+ create( :user, create_account: 1 ).account.should_not be_nil
634
+ end
635
+ end
636
+ describe "#create_account == '0'" do # for HTML forms
637
+ it "should cause the user to be created without account" do
638
+ create( :user, create_account: "0" ).account.should be_nil
639
+ end
640
+ end
641
+ describe "#create_account == '1'" do # for HTML forms
642
+ it "should cause the user to be created with account" do
643
+ create( :user, create_account: "1" ).account.should_not be_nil
644
+ end
645
+ end
646
+ describe "#create_account == ''" do
647
+ it "should cause the user to be created without account" do
648
+ create( :user, create_account: "" ).account.should be_nil
649
+ end
650
+ end
651
+ end
652
+
653
+
654
+ # Groups
655
+ # ------------------------------------------------------------------------------------------
656
+
657
+ describe "#groups" do
658
+ before do
659
+ @group = create( :group )
660
+ @everyone_group = Group.everyone
661
+ @group.parent_groups << @everyone_group
662
+ @user.save
663
+ @user.parent_groups << @group
664
+ @user.reload
665
+ end
666
+ subject { @user.groups }
667
+ it "should include the groups the user is a direct member of" do
668
+ subject.should include( @group )
669
+ end
670
+ it "should include the groups the user is an indirect member of" do
671
+ subject.should include( Group.everyone )
672
+ end
673
+ it "should return all ancestor groups" do
674
+ subject.should == @user.ancestor_groups
675
+ end
676
+ end
677
+
678
+ describe "#add_to_group attribute" do
679
+ before do
680
+ @group = create( :group )
681
+ end
682
+ describe "#add_to_group == nil" do
683
+ subject { create( :user, :add_to_group => nil ) }
684
+ it "should not add the user to a group during creation" do
685
+ subject.parent_groups.should_not include( @group )
686
+ end
687
+ end
688
+ describe "#add_to_group == some_group" do
689
+ subject { create( :user, :add_to_group => @group ) }
690
+ it "should add the user to the group during creation" do
691
+ subject.parent_groups.should include( @group )
692
+ end
693
+ end
694
+ describe "#add_to_group == some_group_id" do
695
+ subject { create( :user, :add_to_group => @group.id ) }
696
+ it "should add the user to the group during creation" do
697
+ subject.parent_groups.should include( @group )
698
+ end
699
+ end
700
+ end
701
+
702
+
703
+ # Corporations
704
+ # ------------------------------------------------------------------------------------------
705
+
706
+ describe "#corporations" do
707
+ before do
708
+ @corporation = create( :corporation )
709
+ @subgroup = create( :group ); @subgroup.parent_groups << @corporation
710
+ @user.save
711
+ @user.parent_groups << @subgroup
712
+ @user.reload
713
+ end
714
+ subject { @user.corporations }
715
+ it "should return an array of the user's corporations" do
716
+ subject.should == [ @corporation ]
717
+ end
718
+ it "should return an array of Corporation-type objects" do
719
+ subject.should be_kind_of Array
720
+ subject.first.should be_kind_of Corporation
721
+ end
722
+ end
723
+
724
+ describe "#cached(:corporations)" do
725
+ before do
726
+ @corporationE = create( :corporation_with_status_groups, :token => "E" )
727
+ @corporationS = create( :corporation_with_status_groups, :token => "S" )
728
+ @corporationH = create( :corporation_with_status_groups, :token => "H" )
729
+ @subgroup = create( :group );
730
+ @subgroup.parent_groups << @corporationE
731
+ @user.save
732
+ @first_membership_E = StatusGroupMembership.create( user: @user, group: @corporationE.status_groups.first )
733
+ @user.parent_groups << @subgroup
734
+ @user.reload
735
+ end
736
+ subject { @user.cached(:corporations) }
737
+ it "should return an array of the user's corporations" do
738
+ should == @user.corporations
739
+ end
740
+ context "when user entered corporation S" do
741
+ before do
742
+ @user.cached(:corporations)
743
+ wait_for_cache
744
+
745
+ first_membership_S = StatusGroupMembership.create( user: @user, group: @corporationS.status_groups.first )
746
+ first_membership_S.update_attributes(valid_from: "2010-05-01".to_datetime)
747
+ @user.reload
748
+ end
749
+ it { should == @user.corporations }
750
+ end
751
+ context "when user entered corporation H as guest" do
752
+ before do
753
+ @user.cached(:corporations)
754
+ wait_for_cache
755
+
756
+ first_membership_H = StatusGroupMembership.create( user: @user, group: @corporationH.guests_parent )
757
+ first_membership_H.update_attributes(valid_from: "2010-05-01".to_datetime)
758
+ @user.reload
759
+ end
760
+ it { should == @user.corporations }
761
+ end
762
+ context "when user left corporation E" do
763
+ before do
764
+ @user.cached(:corporations)
765
+ former_group = @corporationE.child_groups.create
766
+ former_group.add_flag :former_members_parent
767
+ second_membership_E = StatusGroupMembership.create( user: @user, group: former_group )
768
+ second_membership_E.update_attributes(valid_from: "2014-05-01".to_datetime)
769
+ @first_membership_E.update_attributes(valid_to: "2014-05-01".to_datetime)
770
+ @user.reload
771
+ end
772
+ it { should == @user.corporations }
773
+ end
774
+ end
775
+
776
+ describe "#current_corporations" do
777
+ before do
778
+ @corporationE = create( :corporation_with_status_groups, :token => "E" )
779
+ @corporationS = create( :corporation_with_status_groups, :token => "S" )
780
+ @corporationH = create( :corporation_with_status_groups, :token => "H" )
781
+ @subgroup = create( :group );
782
+ @subgroup.parent_groups << @corporationE
783
+ @user.save
784
+ @first_membership_E = StatusGroupMembership.create( user: @user, group: @corporationE.status_groups.first )
785
+ @user.parent_groups << @subgroup
786
+ @user.reload
787
+ end
788
+ subject { @user.current_corporations }
789
+ it "should return an array of the user's corporations" do
790
+ should == @user.corporations
791
+ should include @corporationE
792
+ should_not include @corporationS, @corporationH
793
+ end
794
+ context "when user entered corporation S" do
795
+ before do
796
+ first_membership_S = StatusGroupMembership.create( user: @user, group: @corporationS.status_groups.first )
797
+ first_membership_S.update_attributes(valid_from: "2010-05-01".to_datetime)
798
+ @user.reload
799
+ end
800
+ it { should == [ @corporationE, @corporationS ] }
801
+ end
802
+ context "when user entered corporation H as guest" do
803
+ before do
804
+ first_membership_H = StatusGroupMembership.create( user: @user, group: @corporationH.guests_parent )
805
+ first_membership_H.update_attributes(valid_from: "2010-05-01".to_datetime)
806
+ @user.reload
807
+ end
808
+ it { should == [ @corporationE ] }
809
+ end
810
+ context "when user left corporation E" do
811
+ before do
812
+ former_group = @corporationE.child_groups.create
813
+ former_group.add_flag :former_members_parent
814
+ second_membership_E = StatusGroupMembership.create( user: @user, group: former_group )
815
+ second_membership_E.update_attributes(valid_from: "2014-05-01".to_datetime)
816
+ @first_membership_E.update_attributes(valid_to: "2014-05-01".to_datetime)
817
+ @user.reload
818
+ end
819
+ it { should be_empty }
820
+ end
821
+ context "when joining an event of a corporation" do
822
+ before do
823
+ @event = @corporationH.child_events.create
824
+ @user.join @event
825
+ time_travel 2.seconds; @user.reload
826
+ end
827
+ it { should_not include @corporationH }
828
+ end
829
+ end
830
+
831
+ describe "#cached(:current_corporations)" do
832
+ before do
833
+ @corporationE = create( :corporation_with_status_groups, :token => "E" )
834
+ @corporationS = create( :corporation_with_status_groups, :token => "S" )
835
+ @corporationH = create( :corporation_with_status_groups, :token => "H" )
836
+ @subgroup = create( :group );
837
+ @subgroup.parent_groups << @corporationE
838
+ @user.save
839
+ @first_membership_E = StatusGroupMembership.create( user: @user, group: @corporationE.status_groups.first )
840
+ @user.parent_groups << @subgroup
841
+ @user.reload
842
+ end
843
+ subject { @user.cached(:current_corporations) }
844
+ it "should return an array of the user's corporations" do
845
+ should == @user.corporations
846
+ end
847
+ context "when user entered corporation S" do
848
+ before do
849
+ @user.cached(:current_corporations)
850
+ wait_for_cache
851
+
852
+ first_membership_S = StatusGroupMembership.create( user: @user, group: @corporationS.status_groups.first )
853
+ first_membership_S.update_attributes(valid_from: "2010-05-01".to_datetime)
854
+ @user.reload
855
+ end
856
+ it { should == [ @corporationE, @corporationS ] }
857
+ end
858
+ context "when user entered corporation H as guest" do
859
+ before do
860
+ @user.cached(:current_corporations)
861
+ first_membership_H = StatusGroupMembership.create( user: @user, group: @corporationH.guests_parent )
862
+ first_membership_H.update_attributes(valid_from: "2010-05-01".to_datetime)
863
+ @user.reload
864
+ end
865
+ it { should == [ @corporationE ] }
866
+ end
867
+ context "when user left corporation E" do
868
+ before do
869
+ @user.cached(:current_corporations)
870
+ wait_for_cache
871
+
872
+ former_group = @corporationE.child_groups.create
873
+ former_group.add_flag :former_members_parent
874
+ second_membership_E = StatusGroupMembership.create( user: @user, group: former_group )
875
+ second_membership_E.update_attributes(valid_from: "2014-05-01".to_datetime)
876
+ @first_membership_E.update_attributes(valid_to: "2014-05-01".to_datetime)
877
+ @user.reload
878
+ end
879
+ it { should be_empty }
880
+ end
881
+ end
882
+
883
+ describe "#first_corporation" do
884
+ before do
885
+ @corporation1 = create( :corporation_with_status_groups )
886
+ @corporation2 = create( :corporation_with_status_groups )
887
+ @corporation1.status_groups.first.assign_user @user, at: 1.year.ago
888
+ @corporation2.status_groups.first.assign_user @user, at: 3.months.ago
889
+ @user.reload
890
+ end
891
+ subject { @user.first_corporation }
892
+ it "should return the user's first corporation" do
893
+ subject.should == @corporation1
894
+ end
895
+ end
896
+
897
+ describe "#my_groups_in_first_corporation" do
898
+ before do
899
+ @corporation1 = create :corporation_with_status_groups
900
+ @corporation2 = create :corporation_with_status_groups
901
+ @corporation1.status_groups.first.assign_user @user
902
+ @corporation1.status_groups.last.assign_user @user
903
+ @corporation2.status_groups.first.assign_user @user
904
+ @corporation1.admins << @user
905
+ time_travel 5.seconds
906
+ @user.reload
907
+ end
908
+ subject { @user.my_groups_in_first_corporation }
909
+ it "should return the non special groups of user's first corporation" do
910
+ subject.should == [ @corporation1.status_groups.first, @corporation1.status_groups.last ]
911
+ end
912
+ end
913
+
914
+ describe "#last_group_in_first_corporation" do
915
+ before do
916
+ @corporation1 = create :corporation_with_status_groups
917
+ @corporation2 = create :corporation_with_status_groups
918
+ @corporation1.status_groups.first.assign_user @user, at: 10.months.ago
919
+ @corporation1.status_groups.last.assign_user @user, at: 2.months.ago
920
+ @corporation2.status_groups.first.assign_user @user, at: 1.month.ago
921
+ @corporation1.admins << @user
922
+ @user.reload
923
+ end
924
+ subject { @user.cached(:last_group_in_first_corporation) }
925
+ it "should return the last non special group of user's first corporation" do
926
+ subject.should == @corporation1.status_groups.last
927
+ subject.should_not == @corporation1.admins_parent
928
+ end
929
+ end
930
+
931
+ # Status Groups
932
+ # ------------------------------------------------------------------------------------------
933
+
934
+ describe "#status_groups" do
935
+ before do
936
+ @corporation = create( :corporation_with_status_groups )
937
+ @status_group = @corporation.status_groups.first
938
+ @status_group.assign_user @user
939
+ @another_group = create( :group )
940
+ @another_group.assign_user @user
941
+ end
942
+ subject { @user.status_groups }
943
+
944
+ it "should include the status groups of the user" do
945
+ subject.should include @status_group
946
+ end
947
+ it "should not include the non-status groups of the user" do
948
+ subject.should_not include @another_group
949
+ end
950
+ end
951
+
952
+ describe "#current_status_membership_in(corporation)" do
953
+ before do
954
+ @corporation = create( :corporation_with_status_groups )
955
+ @status_group = @corporation.status_groups.first
956
+ @status_group.assign_user @user
957
+ @status_group_membership = StatusGroupMembership.find_by_user_and_group(@user, @status_group)
958
+ end
959
+ subject { @user.current_status_membership_in(@corporation) }
960
+
961
+ it "should return the correct membership" do
962
+ subject.should == @status_group_membership
963
+ end
964
+ end
965
+
966
+
967
+ # Memberships
968
+ # ------------------------------------------------------------------------------------------
969
+
970
+ describe "#memberships" do
971
+ before do
972
+ @group = create( :group )
973
+ @group.child_users << @user
974
+ @membership = UserGroupMembership.find_by( user: @user, group: @group )
975
+ end
976
+ subject { @user.memberships }
977
+ it "should return an array of the user's memberships" do
978
+ subject.should == [ @membership ]
979
+ end
980
+ it "should be the same as UserGroupMembership.find_all_by_user" do
981
+ subject.should == UserGroupMembership.find_all_by_user( @user )
982
+ end
983
+ it "should allow to chain other ActiveRelation scopes, like `only_valid`" do
984
+ subject.only_valid.should == [ @membership ]
985
+ end
986
+ end
987
+
988
+
989
+ # Relationships
990
+ # ------------------------------------------------------------------------------------------
991
+
992
+ describe "#relationships" do
993
+ before do
994
+ @other_user = create( :user )
995
+ @relationship = create( :relationship, who: @user, of: @other_user )
996
+ end
997
+ subject { @user.relationships }
998
+ it "should return the relationships of the user" do
999
+ subject.should == [ @relationship ]
1000
+ end
1001
+ end
1002
+
1003
+
1004
+ # Workflows
1005
+ # ------------------------------------------------------------------------------------------
1006
+
1007
+ describe "#workflows" do
1008
+ before do
1009
+ @group = create( :group )
1010
+ @workflow = create( :workflow ); @workflow.parent_groups << @group
1011
+ @user.save
1012
+ @user.parent_groups << @group
1013
+ @user.reload
1014
+ end
1015
+ subject { @user.workflows }
1016
+ it "should return an array of all workflows of all groups of the user" do
1017
+ subject.should == [ @workflow ]
1018
+ end
1019
+ end
1020
+
1021
+
1022
+ # Events
1023
+ # ------------------------------------------------------------------------------------------
1024
+
1025
+ describe "#upcoming_events" do
1026
+ subject { @user.upcoming_events }
1027
+ describe "(timing)" do
1028
+ before do
1029
+ @group1 = @user.parent_groups.create
1030
+ @group2 = @group1.parent_groups.create
1031
+ @upcoming_events = [ @group1.child_events.create( start_at: 5.hours.from_now ),
1032
+ @group2.child_events.create( start_at: 6.hours.from_now ) ]
1033
+ @recent_events = [ @group1.child_events.create( start_at: 2.days.ago ) ]
1034
+ @unrelated_events = [ Event.create( start_at: 4.hours.from_now ) ]
1035
+ end
1036
+ it { should include *@upcoming_events }
1037
+ it { should_not include *@recent_events }
1038
+ it { should_not include *@unrelated_events }
1039
+ it "should return the upcoming events in ascending order" do
1040
+ subject.first.start_at.should < subject.last.start_at
1041
+ end
1042
+ end
1043
+ describe "(direct/indirect)" do
1044
+ # group_a
1045
+ # |----- event_0 <<===
1046
+ # |----- group_b
1047
+ # | |------ event_1 <<===
1048
+ # | |------ user
1049
+ # |
1050
+ # |----- group_c
1051
+ # |------ event_2
1052
+ before do
1053
+ @group_a = create( :group )
1054
+ @event_0 = @group_a.child_events.create( start_at: 5.hours.from_now )
1055
+ @group_b = @group_a.child_groups.create
1056
+ @group_b.child_users << @user
1057
+ @event_1 = @group_b.child_events.create( start_at: 5.hours.from_now )
1058
+ @group_c = @group_a.child_groups.create
1059
+ @event_2 = @group_c.child_events.create( start_at: 5.hours.from_now )
1060
+ @user.reload
1061
+ end
1062
+ it "should list direct events of the user's groups" do # "<<===" above
1063
+ @user.ancestor_groups.should include @group_a, @group_b
1064
+ subject.should include @event_0, @event_1
1065
+ end
1066
+ it "should not list in-direct events" do
1067
+ # otherwise all users will see all events, since everyone is member of Group.everyone.
1068
+ subject.should_not include @event_2
1069
+ end
1070
+ end
1071
+ end
1072
+
1073
+ describe "#join" do
1074
+ subject { @user.join(@event_or_group); time_travel(2.seconds) }
1075
+ describe "(joining an event)" do
1076
+ before { @event_or_group = @event = create(:event); subject }
1077
+ specify { @event.attendees.should include @user}
1078
+ specify { @event.attendees_group.members.should include @user }
1079
+ specify "the user should be able to join and leave and re-join without error" do
1080
+ @user.join @event; time_travel 2.seconds
1081
+ @user.leave @event; time_travel 2.seconds
1082
+ @user.join @event; time_travel 2.seconds
1083
+ @event.attendees.should include @user
1084
+ end
1085
+ end
1086
+ describe "(joining a group)" do
1087
+ before { @event_or_group = @group = create(:group); subject }
1088
+ specify { @group.members.should include @user }
1089
+ end
1090
+ end
1091
+ describe "#leave" do
1092
+ subject { @user.leave(@event_or_group); time_travel(2.seconds) }
1093
+ before do
1094
+ @event = create :event; @user.join @event
1095
+ @group = create :group; @user.join @group
1096
+ time_travel 2.seconds
1097
+ end
1098
+ describe "(leaving an event)" do
1099
+ # TODO: We need multiple dag links between two nodes!
1100
+ before { @event_or_group = @event; subject }
1101
+ specify { @event.attendees.should_not include @user}
1102
+ specify { @event.attendees_group.members.should_not include @user }
1103
+ specify { @event.attendees_group.child_users.should_not include @user }
1104
+ end
1105
+ describe "(leaving a group)" do
1106
+ before { @event_or_group = @group; subject }
1107
+ # TODO: We need multiple dag links between two nodes!
1108
+ # specify { @group.members.should_not include @user }
1109
+ # specify { @group.members.former.should include @user }
1110
+ # specify { @group.child_users.should include @user }
1111
+ end
1112
+ end
1113
+
1114
+
1115
+
1116
+ # News Pages
1117
+ # ------------------------------------------------------------------------------------------
1118
+
1119
+ # List news (Pages) that concern the user.
1120
+ #
1121
+ # independent_page <--- show
1122
+ #
1123
+ # root_page --- page_0 <--- show
1124
+ # |
1125
+ # everyone ---- page_1 ---- page_2 <--- show
1126
+ # |
1127
+ # |----- group_1 ---- page_3 <--- DO NOT show
1128
+ # |
1129
+ # |----- group_2 ---- user
1130
+ # | |-- page_4 <--- show
1131
+ # |
1132
+ # |--- user
1133
+ #
1134
+ describe "#news_pages" do
1135
+ subject { @user.news_pages }
1136
+ before do
1137
+ @independent_page = create :page, title: 'independent_page'
1138
+ @root_page = Page.find_root
1139
+ @page_0 = @root_page.child_pages.create title: 'page_0'
1140
+ @everyone = Group.everyone
1141
+ @page_1 = @everyone.child_pages.create title: 'page_1'
1142
+ @page_2 = @page_1.child_pages.create title: 'page_2'
1143
+ @group_1 = @everyone.child_groups.create name: 'group_1'
1144
+ @page_3 = @group_1.child_pages.create title: 'page_3'
1145
+ @group_2 = @everyone.child_groups.create name: 'group_2'
1146
+ @group_2.assign_user @user
1147
+ @page_4 = @group_2.child_pages.create title: 'page_4'
1148
+ time_travel 2.seconds
1149
+ @user.reload
1150
+ end
1151
+ specify 'requirements' do
1152
+ @group_1.members.should_not include @user
1153
+ end
1154
+ it "should list pages that are without group" do
1155
+ subject.should include @independent_page
1156
+ end
1157
+ it "should list pages under the root page" do
1158
+ subject.should include @page_0
1159
+ end
1160
+ it "should list pages directly under the everyone group" do
1161
+ subject.should include @page_1, @page_2
1162
+ end
1163
+ it "should NOT list pages of groups the user is not member of" do
1164
+ subject.should_not include @page_3
1165
+ end
1166
+ specify "(but users that are in @group_1 should have @page_3 listed)" do
1167
+ @user_of_group_1 = create :user
1168
+ @group_1.assign_user @user_of_group_1, at: 1.hour.ago
1169
+ @user_of_group_1.reload.news_pages.should include @page_3
1170
+ end
1171
+ it "should list pages of other groups the user is member of" do
1172
+ subject.should include @page_4
1173
+ end
1174
+ end
1175
+
1176
+ # Roles
1177
+ # ==========================================================================================
1178
+
1179
+ describe "#role_for" do
1180
+ before do
1181
+ @object = create( :page )
1182
+ @object.create_main_admins_parent_group
1183
+ @sub_object = create( :group ); @sub_object.parent_pages << @object
1184
+ @sub_sub_object = create( :user ); @sub_sub_object.parent_groups << @sub_object
1185
+ end
1186
+ subject { @user.role_for @object }
1187
+ context "for the user being not related to the object" do
1188
+ it { should == nil }
1189
+ end
1190
+ context "for the user being a member of the object" do
1191
+ before do
1192
+ @group = create( :group )
1193
+ @group.child_users << @user
1194
+ @object.child_groups << @group
1195
+ end
1196
+ it { should == :member }
1197
+ end
1198
+ context "for the user being an admin of the object" do
1199
+ before { @object.admins << @user }
1200
+ it { should == :admin }
1201
+ end
1202
+ context "for the user being a main_admin of the object" do
1203
+ before { @object.main_admins << @user }
1204
+ it { should == :main_admin }
1205
+ end
1206
+ context "for the object being not structureable" do
1207
+ before { @object = "This is a string." }
1208
+ it { should == nil }
1209
+ end
1210
+ context "for descendant objects of administrated objects" do
1211
+ before { @object.admins << @user }
1212
+ it "should return the inherited role" do
1213
+ @user.role_for( @object ).should == :admin
1214
+ @user.role_for( @sub_object ).should == :admin
1215
+ @user.role_for( @sub_sub_object ).should == :admin
1216
+ end
1217
+ end
1218
+ end
1219
+
1220
+ # Member Status
1221
+ # ------------------------------------------------------------------------------------------
1222
+
1223
+ describe "#member_of?" do
1224
+ before do
1225
+ @group = create( :group ); @group.child_users << @user
1226
+ @page = create( :page )
1227
+ end
1228
+ context "for the user being a descendant of the object" do
1229
+ before { @page.child_groups << @group }
1230
+ subject { @user.member_of? @page }
1231
+ it { should == true }
1232
+ end
1233
+ context "for the user not being a descendant of the object" do
1234
+ subject { @user.member_of? @page }
1235
+ it "should be false" do
1236
+ @page.descendants.should_not include @user
1237
+ subject.should == false
1238
+ end
1239
+ end
1240
+ context "for the user being a member of the group object" do
1241
+ subject { @user.member_of? @group }
1242
+ it { should == true }
1243
+ end
1244
+ context "for the argument being not able to having children, e.g. a user or another object" do
1245
+ # this is a bug fix test
1246
+ before do
1247
+ @another_user = create( :user )
1248
+ @another_object = "This is a String."
1249
+ end
1250
+ it "should be simply false and not raise an error" do
1251
+ @user.member_of?( @another_user ).should == false
1252
+ @user.member_of?( @another_object ).should == false
1253
+ end
1254
+ end
1255
+ context "for the user being a former member of the group" do
1256
+ before { @group.unassign_user @user, at: 2.minutes.ago }
1257
+ subject { @user.member_of? @group }
1258
+ it { should == false }
1259
+ end
1260
+ context "for the user being a former indirect member of the group" do
1261
+ before do
1262
+ @ancestor_group = @group.ancestor_groups.create
1263
+ @group.unassign_user @user, at: 2.minutes.ago
1264
+ end
1265
+ subject { @user.member_of? @ancestor_group }
1266
+ it { should == false }
1267
+ end
1268
+ end
1269
+
1270
+
1271
+ # Admins
1272
+ # ------------------------------------------------------------------------------------------
1273
+
1274
+ describe "#admin_of" do
1275
+ before do
1276
+ @group = create( :group, name: "Directly Administrated Group" )
1277
+ @group.find_or_create_admins_parent_group
1278
+ @group.admins_parent.child_users << @user
1279
+ end
1280
+ subject { @user.admin_of }
1281
+ it { should == @user.administrated_objects }
1282
+ end
1283
+
1284
+ describe "#admin_of?" do
1285
+ before do
1286
+ @group = create( :group, name: "Directly Administrated Group" )
1287
+ @sub_group = create( :group, name: "Indirectly Administrated Group" )
1288
+ @sub_group.parent_groups << @group
1289
+ end
1290
+ context "for the user being admin" do
1291
+ before do
1292
+ @group.find_or_create_admins_parent_group
1293
+ @group.admins_parent.child_users << @user # the @user is direct admin of @group
1294
+ end
1295
+ context "for directly administrated objects" do
1296
+ subject { @user.admin_of? @group }
1297
+ it "should state that the user is admin" do
1298
+ subject.should == true
1299
+ end
1300
+ end
1301
+ context "for indirectly administrated objects" do
1302
+ subject { @user.admin_of? @sub_group }
1303
+ it "should state that the user is admin" do
1304
+ subject.should == true
1305
+ end
1306
+ end
1307
+ end
1308
+ context "for the user being main admin" do
1309
+ before do
1310
+ @group.create_main_admins_parent_group
1311
+ @group.main_admins_parent.child_users << @user
1312
+ end
1313
+ subject { @user.admin_of? @group }
1314
+ it { should == true }
1315
+ end
1316
+ context "for some object the user is no admin of" do
1317
+ before { @other_object = Page.create }
1318
+ subject { @user.admin_of? @other_object }
1319
+ it { should == false }
1320
+ end
1321
+ end
1322
+
1323
+ describe "#directly_administrated_objects" do
1324
+ before do
1325
+ @group = create( :group, name: "Directly Administrated Group" )
1326
+ @group.find_or_create_admins_parent_group
1327
+ end
1328
+ subject { @user.directly_administrated_objects }
1329
+ it { should be_kind_of Array }
1330
+ context "for the user being admin of objects" do
1331
+ before { @group.admins_parent.child_users << @user }
1332
+ it "should list the objects the user is directly admin of" do
1333
+ subject.should include @group
1334
+ end
1335
+ end
1336
+ end
1337
+
1338
+ describe "#administrated_objects" do
1339
+ before do
1340
+ @group = create( :group, name: "Administrated Group" )
1341
+ @group.find_or_create_admins_parent_group
1342
+ end
1343
+ subject { @user.administrated_objects }
1344
+ it { should be_kind_of Array }
1345
+ context "for the user being admin of an object" do
1346
+ before { @group.admins_parent.child_users << @user }
1347
+ it "should list all objects administrated by the user" do
1348
+ @group.admins_parent.should be_kind_of Group
1349
+ @group.admins_parent.child_users.should include @user
1350
+ subject.should include @group
1351
+ end
1352
+ end
1353
+ context "for the user being an indirect admin of an object" do
1354
+ before do
1355
+ @sub_group = create( :group, name: "Indirectly Administrated Group" )
1356
+ @sub_group.parent_groups << @group
1357
+ @group.admins_parent.child_users << @user
1358
+ end
1359
+ it "should list directly and indirectly administrated objects" do
1360
+ subject.should include( @group, @sub_group )
1361
+ end
1362
+ end
1363
+ end
1364
+
1365
+ # Main Admins
1366
+ # ------------------------------------------------------------------------------------------
1367
+
1368
+ describe "#main_admin_of?" do
1369
+ before do
1370
+ @page = create( :page )
1371
+ end
1372
+ subject { @user.main_admin_of? @page }
1373
+ context "for the main_admins_parent_group existing" do
1374
+ before { @page.create_main_admins_parent_group }
1375
+ context "for the user being a main admin of the object" do
1376
+ before { @page.main_admins << @user }
1377
+ it { should == true }
1378
+ end
1379
+ context "for the user being just a regular admin of the object" do
1380
+ before { @page.admins << @user }
1381
+ it { should == false }
1382
+ end
1383
+ context "for the user being just a regular member of the object" do
1384
+ before do
1385
+ @group = create( :group )
1386
+ @group.child_users << @user
1387
+ @page.child_groups << @group
1388
+ end
1389
+ it "should be false" do
1390
+ @user.member_of?( @page ).should be_true # just to make sure
1391
+ subject.should == false
1392
+ end
1393
+ end
1394
+ end
1395
+ end
1396
+
1397
+
1398
+ # Guest Status
1399
+ # ==========================================================================================
1400
+
1401
+ describe "#guest_of?" do
1402
+ before { @group = create( :group ) }
1403
+ subject { @user.guest_of? @group }
1404
+ context "for the user being not a guest of the given group" do
1405
+ it { should == false }
1406
+ end
1407
+ context "for the user being a guest of the given group" do
1408
+ before do
1409
+ @group.find_or_create_guests_parent_group
1410
+ @group.guests << @user
1411
+ end
1412
+ it { should == true }
1413
+ end
1414
+ end
1415
+
1416
+
1417
+ # Developers
1418
+ # ==========================================================================================
1419
+
1420
+ describe "#developer?" do
1421
+ subject { @user.developer? }
1422
+ describe "for no developers group existing" do
1423
+ it { should == false }
1424
+ end
1425
+ describe "for the user being no member of the developers group" do
1426
+ before { Group.create_developers_group }
1427
+ it { should == false }
1428
+ end
1429
+ describe "for the user being member of the developers group" do
1430
+ before { Group.create_developers_group.assign_user @user }
1431
+ it { should == true }
1432
+ end
1433
+ end
1434
+ describe "#developer = " do
1435
+ describe "true" do
1436
+ subject { @user.developer = true }
1437
+ it "should assign the user to the developers group" do
1438
+ @user.should_not be_member_of Group.developers
1439
+ subject
1440
+ @user.should be_member_of Group.developers
1441
+ end
1442
+ end
1443
+ describe "false" do
1444
+ before { @user.developer = true }
1445
+ subject { @user.developer = false; time_travel 2.seconds }
1446
+ it "should un-assign the user from the developers group" do
1447
+ @user.should be_member_of Group.developers
1448
+ subject
1449
+ @user.should_not be_member_of Group.developers
1450
+ end
1451
+ end
1452
+ end
1453
+
1454
+
1455
+ # Hidden Users
1456
+ # ==========================================================================================
1457
+
1458
+ describe '#hidden?' do
1459
+ subject { @user.hidden? }
1460
+ end
1461
+
1462
+ describe '#cached(:hidden)' do
1463
+ subject { @user.cached(:hidden) }
1464
+ describe 'for the user not being hidden' do
1465
+ before do
1466
+ @user.cached(:hidden)
1467
+ wait_for_cache
1468
+
1469
+ @user.hidden = true
1470
+ @user.reload
1471
+ end
1472
+ it { should == @user.hidden }
1473
+ end
1474
+ describe 'for the user being hidden' do
1475
+ before do
1476
+ @user.hidden = true
1477
+ @user.cached(:hidden)
1478
+ @user.hidden = false
1479
+ end
1480
+ it { should == @user.hidden }
1481
+ end
1482
+ end
1483
+
1484
+ describe '#hidden=' do
1485
+ describe 'true' do
1486
+ subject { @user.hidden = true }
1487
+ describe 'for the user being hidden' do
1488
+ before { @user.hidden = true }
1489
+ it 'should make sure user is in the hidden_users group' do
1490
+ @user.should be_member_of Group.hidden_users
1491
+ subject
1492
+ @user.should be_member_of Group.hidden_users
1493
+ end
1494
+ end
1495
+ describe 'for the user not being hidden' do
1496
+ it 'should assign the user to the hidden_users group' do
1497
+ @user.should_not be_member_of Group.hidden_users
1498
+ subject
1499
+ @user.should be_member_of Group.hidden_users
1500
+ end
1501
+ end
1502
+ end
1503
+ describe 'false' do
1504
+ subject { @user.hidden = false; time_travel 2.seconds }
1505
+ describe 'for the user being hidden' do
1506
+ before { @user.hidden = true }
1507
+ it 'should remove the user from the hidden_users group' do
1508
+ @user.should be_member_of Group.hidden_users
1509
+ subject
1510
+ @user.should_not be_member_of Group.hidden_users
1511
+ end
1512
+ end
1513
+ describe 'for the user not being hidden' do
1514
+ it 'should make sure the user is not in the hidden_users group' do
1515
+ @user.should_not be_member_of Group.hidden_users
1516
+ subject
1517
+ @user.should_not be_member_of Group.hidden_users
1518
+ end
1519
+ end
1520
+ end
1521
+ end
1522
+
1523
+
1524
+ # Group Flags
1525
+ # ==========================================================================================
1526
+
1527
+ describe "#group_flags" do
1528
+ before { @user = create(:user) }
1529
+ subject { @user.group_flags }
1530
+ describe "for the user being hidden" do
1531
+ before { @user.hidden = true }
1532
+ it { should include 'hidden_users' }
1533
+ end
1534
+ describe "for the user not being hidden" do
1535
+ it { should_not include 'hidden_users' }
1536
+ end
1537
+ end
1538
+
1539
+
1540
+ # User Creation
1541
+ # ==========================================================================================
1542
+
1543
+ describe ".create" do
1544
+ before { @params = {first_name: "Johnny", last_name: "Doe"} }
1545
+ subject { @user = User.create(@params) }
1546
+ describe "when #add_to_corporation is set to a corporation" do
1547
+ before do
1548
+ @corporation = create(:corporation_with_status_groups)
1549
+ @params.merge!({:add_to_corporation => @corporation})
1550
+ end
1551
+ it "should add the user to the first status group of this corporation" do
1552
+ subject
1553
+ @corporation.status_groups.first.members.should include @user
1554
+ end
1555
+ end
1556
+ describe "when #add_to_corporation is set to a corporation id" do
1557
+ before do
1558
+ @corporation = create(:corporation_with_status_groups)
1559
+ @params.merge!({:add_to_corporation => @corporation.id})
1560
+ end
1561
+ it "should add the user to the first status group of this corporation" do
1562
+ subject
1563
+ @corporation.status_groups.first.members.should include @user
1564
+ end
1565
+ end
1566
+ describe "when #add_to_corporation is set to a corporation id which is a String (via html form)" do
1567
+ before do
1568
+ @corporation = create(:corporation_with_status_groups)
1569
+ @params.merge!({:add_to_corporation => @corporation.id.to_s})
1570
+ end
1571
+ it "should add the user to the first status group of this corporation" do
1572
+ subject
1573
+ @corporation.status_groups.first.members.should include @user
1574
+ end
1575
+ end
1576
+ end
1577
+
1578
+
1579
+ # Finder Methods
1580
+ # ==========================================================================================
1581
+
1582
+ describe ".find_all_by_identification_string" do
1583
+ before do
1584
+ @user.first_name = "Some First Name"
1585
+ @user.last_name = "UniqueLastName"
1586
+ @user.email = "unique@example.com"
1587
+ @user.alias = "s.unique"
1588
+ @user.save
1589
+ end
1590
+ describe "for a given alias" do
1591
+ subject { User.find_all_by_identification_string( @user.alias ) }
1592
+ it { should == [ @user ] }
1593
+ end
1594
+ describe "for a given last_name" do
1595
+ subject { User.find_all_by_identification_string( @user.last_name ) }
1596
+ it { should == [ @user ] }
1597
+ end
1598
+ describe "for a given name" do
1599
+ subject { User.find_all_by_identification_string( "#{@user.first_name} #{@user.last_name}" ) }
1600
+ it { should == [ @user ] }
1601
+ end
1602
+ describe "for a given email" do
1603
+ subject { User.find_all_by_identification_string( @user.email ) }
1604
+ it { should == [ @user ] }
1605
+ end
1606
+ describe "for given nonsense" do
1607
+ subject { User.find_all_by_identification_string( "f kas#dfk aoefak!" ) }
1608
+ it { should == [] }
1609
+ end
1610
+ end
1611
+
1612
+ describe ".find_by_title" do
1613
+ before do
1614
+ @user.first_name = "Johnny"
1615
+ @user.last_name = "Doe"
1616
+ @user.save
1617
+ @title = @user.title
1618
+ end
1619
+ specify { @title.should_not be_empty }
1620
+ subject { User.find_by_title( @title ) }
1621
+ it "should find the user by its title" do
1622
+ subject.should == @user
1623
+ end
1624
+ end
1625
+
1626
+ describe ".find_all_by_name" do
1627
+ before do
1628
+ @user = create( :user )
1629
+ end
1630
+ subject { User.find_all_by_name( @user.name ) }
1631
+ it { should include( @user ) }
1632
+ it "should be case-insensitive" do
1633
+ User.find_all_by_name( @user.name.upcase ).should include( @user )
1634
+ User.find_all_by_name( @user.name.downcase ).should include( @user )
1635
+ end
1636
+ end
1637
+
1638
+ describe ".find_by_name" do
1639
+ before do
1640
+ @user = create( :user )
1641
+ end
1642
+ subject { User.find_by_name( @user.name ) }
1643
+ it { should == @user }
1644
+ end
1645
+
1646
+ describe ".find_all_by_email" do
1647
+ before do
1648
+ @user = create( :user )
1649
+ end
1650
+ subject { User.find_all_by_email( @user.email ) }
1651
+ it { should include( @user ) }
1652
+ it "should be case-insensitive" do
1653
+ User.find_all_by_email( @user.email.upcase ).should include( @user )
1654
+ User.find_all_by_email( @user.email.downcase ).should include( @user )
1655
+ end
1656
+ end
1657
+
1658
+ describe ".hidden" do
1659
+ before do
1660
+ @hidden_user = create(:user); @hidden_user.hidden = true
1661
+ @visible_user = create(:user)
1662
+ end
1663
+ subject { User.hidden }
1664
+ it { should be_kind_of ActiveRecord::Relation }
1665
+ it { should include @hidden_user }
1666
+ it { should_not include @visible_user }
1667
+ it "should be chainable" do
1668
+ subject.where(id: @hidden_user.id).should == User.where(id: @hidden_user.id).hidden
1669
+ subject.count.should > 0
1670
+ end
1671
+ end
1672
+
1673
+ describe ".deceased" do
1674
+ before do
1675
+ @deceased_user = create(:user); @deceased_user.mark_as_deceased(at: 1.year.ago)
1676
+ @alive_user = create(:user)
1677
+ end
1678
+ subject { User.deceased }
1679
+ it { should be_kind_of ActiveRecord::Relation }
1680
+ it { should include @deceased_user }
1681
+ it { should_not include @alive_user }
1682
+ it "should be chainable" do
1683
+ subject.where(id: @deceased_user.id).to_a.should == User.where(id: @deceased_user.id).deceased.to_a
1684
+ end
1685
+ end
1686
+
1687
+ describe ".alive" do
1688
+ before do
1689
+ @deceased_user = create(:user); @deceased_user.mark_as_deceased(at: 1.year.ago)
1690
+ @alive_user = create(:user)
1691
+ end
1692
+ subject { User.alive }
1693
+ it { should be_kind_of ActiveRecord::Relation }
1694
+ it { should_not include @deceased_user }
1695
+ it { should include @alive_user }
1696
+ it "should be chainable" do
1697
+ subject.where(id: @alive_user.id).to_a.should == User.where(id: @alive_user.id).alive.to_a
1698
+ end
1699
+ specify "there should be no user that is deceased and alive" do
1700
+ User.alive.deceased.should == []
1701
+ User.deceased.alive.should == []
1702
+ end
1703
+ end
1704
+
1705
+ describe ".without_account" do
1706
+ before do
1707
+ @user_with_account = create(:user_with_account)
1708
+ @user_without_account = create(:user)
1709
+ end
1710
+ subject { User.without_account }
1711
+ it { should be_kind_of ActiveRecord::Relation }
1712
+ it { should include @user_without_account }
1713
+ it { should_not include @user_with_account }
1714
+ it "should be chainable" do
1715
+ subject.where(id: @user_without_account.id).to_a.should == User.where(id: @user_without_account.id).without_account.to_a
1716
+ end
1717
+ end
1718
+
1719
+ describe ".with_email" do
1720
+ before do
1721
+ @user_with_email = create(:user)
1722
+ @user_without_email = create(:user)
1723
+ @user_without_email.profile_fields.destroy_all
1724
+ @user_with_empty_email = create(:user)
1725
+ @user_with_empty_email.profile_fields.where(type: 'ProfileFieldTypes::Email').first.update_attributes(:value => nil) # to circumvent validation
1726
+ end
1727
+ subject { User.with_email }
1728
+ specify "prelims" do
1729
+ @user_with_empty_email.email.should == nil
1730
+ end
1731
+ it { should be_kind_of ActiveRecord::Relation }
1732
+ it { should include @user_with_email }
1733
+ it { should_not include @user_without_email }
1734
+ it { should_not include @user_with_empty_email }
1735
+ it "should be chainable" do
1736
+ subject.where(id: @user_with_email.id).to_a.should == User.where(id: @user_with_email.id).with_email.to_a
1737
+ end
1738
+ end
1739
+
1740
+ describe ".applicable_for_new_account" do
1741
+ before do
1742
+ @hidden_user = create(:user); @hidden_user.hidden = true
1743
+ @visible_user = create(:user)
1744
+ @deceased_user = create(:user); @deceased_user.mark_as_deceased(at: 1.year.ago)
1745
+ @alive_user = create(:user)
1746
+ @user_with_account = create(:user_with_account)
1747
+ @user_without_account = create(:user)
1748
+ @user_with_email = create(:user)
1749
+ @user_without_email = create(:user)
1750
+ @user_without_email.profile_fields.destroy_all
1751
+ @user_with_empty_email = create(:user)
1752
+ @user_with_empty_email.profile_fields.where(type: 'ProfileFieldTypes::Email').first.update_attribute(:value, '')
1753
+ end
1754
+ subject { User.applicable_for_new_account }
1755
+ it { should be_kind_of ActiveRecord::Relation }
1756
+ it { should include @hidden_user }
1757
+ it { should include @visible_user }
1758
+ it { should_not include @deceased_user }
1759
+ it { should include @alive_user }
1760
+ it { should_not include @user_with_account }
1761
+ it { should include @user_without_account }
1762
+ it { should include @user_with_email }
1763
+ it { should_not include @user_without_email }
1764
+ it { should_not include @user_with_empty_email }
1765
+ end
1766
+
1767
+ describe "(postal address finder methods)" do
1768
+ before do
1769
+ @user_with_address = create(:user)
1770
+ @user_with_address.profile_fields.create(type: 'ProfileFieldTypes::Address', value: "Pariser Platz 1\n 10117 Berlin")
1771
+ @user_without_address = create(:user)
1772
+ @user_with_empty_address = create(:user)
1773
+ @user_with_empty_address.profile_fields.create(type: 'ProfileFieldTypes::Address', value: "")
1774
+ end
1775
+
1776
+ describe ".with_postal_address" do
1777
+ subject { User.with_postal_address }
1778
+ it { should be_kind_of ActiveRecord::Relation }
1779
+ it { should include @user_with_address }
1780
+ it { should_not include @user_without_address }
1781
+ it { should_not include @user_with_empty_address }
1782
+ end
1783
+
1784
+ describe ".without_postal_address" do
1785
+ subject { User.without_postal_address }
1786
+ it { should be_kind_of ActiveRecord::Relation }
1787
+ it { should include @user_without_address }
1788
+ it { should include @user_with_empty_address }
1789
+ it { should_not include @user_with_address }
1790
+ end
1791
+ end
1792
+
1793
+ end
1794
+