incline 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/Gemfile +17 -0
  4. data/Gemfile.lock +186 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +208 -0
  7. data/Rakefile +37 -0
  8. data/app/assets/fonts/incline/.keep +0 -0
  9. data/app/assets/images/incline/.keep +0 -0
  10. data/app/assets/images/incline/barcode-B.svg +181 -0
  11. data/app/assets/javascripts/incline/activate_classed_items.js +11 -0
  12. data/app/assets/javascripts/incline/application.js +30 -0
  13. data/app/assets/javascripts/incline/bootstrap-datepicker.js +1800 -0
  14. data/app/assets/javascripts/incline/datatables.js +22193 -0
  15. data/app/assets/javascripts/incline/escapeHtml.js +10 -0
  16. data/app/assets/javascripts/incline/inline_actions.js +479 -0
  17. data/app/assets/javascripts/incline/jquery.doubleScroll.js +112 -0
  18. data/app/assets/javascripts/incline/jquery.number.js +764 -0
  19. data/app/assets/javascripts/incline/regexMask.js +27 -0
  20. data/app/assets/javascripts/incline/select2/i18n/en.js +3 -0
  21. data/app/assets/javascripts/incline/select2/select2.full.js +6436 -0
  22. data/app/assets/stylesheets/incline/application.css +18 -0
  23. data/app/assets/stylesheets/incline/bootstrap-theme.min.css +5 -0
  24. data/app/assets/stylesheets/incline/custom.scss +279 -0
  25. data/app/assets/stylesheets/incline/datatables.css +494 -0
  26. data/app/assets/stylesheets/incline/datepicker3.css +790 -0
  27. data/app/assets/stylesheets/incline/select2.css +484 -0
  28. data/app/controllers/incline/access_groups_controller.rb +127 -0
  29. data/app/controllers/incline/access_test_controller.rb +30 -0
  30. data/app/controllers/incline/account_activations_controller.rb +28 -0
  31. data/app/controllers/incline/application_controller.rb +11 -0
  32. data/app/controllers/incline/contact_controller.rb +34 -0
  33. data/app/controllers/incline/password_resets_controller.rb +113 -0
  34. data/app/controllers/incline/security_controller.rb +100 -0
  35. data/app/controllers/incline/sessions_controller.rb +50 -0
  36. data/app/controllers/incline/users_controller.rb +304 -0
  37. data/app/controllers/incline/welcome_controller.rb +19 -0
  38. data/app/helpers/incline/.keep +0 -0
  39. data/app/mailers/incline/application_mailer_base.rb +11 -0
  40. data/app/mailers/incline/contact_form.rb +19 -0
  41. data/app/mailers/incline/user_mailer.rb +45 -0
  42. data/app/models/incline/access_group.rb +121 -0
  43. data/app/models/incline/access_group_group_member.rb +12 -0
  44. data/app/models/incline/access_group_user_member.rb +10 -0
  45. data/app/models/incline/action_group.rb +12 -0
  46. data/app/models/incline/action_security.rb +222 -0
  47. data/app/models/incline/contact_message.rb +37 -0
  48. data/app/models/incline/disable_info.rb +20 -0
  49. data/app/models/incline/password_reset.rb +14 -0
  50. data/app/models/incline/password_reset_request.rb +14 -0
  51. data/app/models/incline/user.rb +437 -0
  52. data/app/models/incline/user_login_history.rb +30 -0
  53. data/app/views/incline/access_groups/_details.json.jbuilder +10 -0
  54. data/app/views/incline/access_groups/_form.html.erb +19 -0
  55. data/app/views/incline/access_groups/_list.html.erb +60 -0
  56. data/app/views/incline/access_groups/_messages.json.jbuilder +6 -0
  57. data/app/views/incline/access_groups/edit.html.erb +2 -0
  58. data/app/views/incline/access_groups/index.html.erb +6 -0
  59. data/app/views/incline/access_groups/index.json.jbuilder +16 -0
  60. data/app/views/incline/access_groups/new.html.erb +2 -0
  61. data/app/views/incline/access_groups/show.html.erb +9 -0
  62. data/app/views/incline/access_groups/show.json.jbuilder +11 -0
  63. data/app/views/incline/contact/new.html.erb +22 -0
  64. data/app/views/incline/contact_form/contact.html.erb +16 -0
  65. data/app/views/incline/contact_form/contact.text.erb +13 -0
  66. data/app/views/incline/password_resets/edit.html.erb +16 -0
  67. data/app/views/incline/password_resets/new.html.erb +12 -0
  68. data/app/views/incline/security/_details.json.jbuilder +7 -0
  69. data/app/views/incline/security/_form.html.erb +20 -0
  70. data/app/views/incline/security/_list.html.erb +89 -0
  71. data/app/views/incline/security/_messages.json.jbuilder +6 -0
  72. data/app/views/incline/security/edit.html.erb +2 -0
  73. data/app/views/incline/security/index.html.erb +6 -0
  74. data/app/views/incline/security/index.json.jbuilder +16 -0
  75. data/app/views/incline/security/show.html.erb +31 -0
  76. data/app/views/incline/security/show.json.jbuilder +11 -0
  77. data/app/views/incline/sessions/new.html.erb +26 -0
  78. data/app/views/incline/user_mailer/account_activation.html.erb +7 -0
  79. data/app/views/incline/user_mailer/account_activation.text.erb +6 -0
  80. data/app/views/incline/user_mailer/invalid_password_reset.html.erb +3 -0
  81. data/app/views/incline/user_mailer/invalid_password_reset.text.erb +5 -0
  82. data/app/views/incline/user_mailer/password_reset.html.erb +8 -0
  83. data/app/views/incline/user_mailer/password_reset.text.erb +7 -0
  84. data/app/views/incline/users/_details.json.jbuilder +32 -0
  85. data/app/views/incline/users/_form.html.erb +21 -0
  86. data/app/views/incline/users/_list.html.erb +102 -0
  87. data/app/views/incline/users/_messages.json.jbuilder +6 -0
  88. data/app/views/incline/users/disable_confirm.html.erb +19 -0
  89. data/app/views/incline/users/edit.html.erb +5 -0
  90. data/app/views/incline/users/index.html.erb +6 -0
  91. data/app/views/incline/users/index.json.jbuilder +16 -0
  92. data/app/views/incline/users/new.html.erb +5 -0
  93. data/app/views/incline/users/show.html.erb +12 -0
  94. data/app/views/incline/users/show.json.jbuilder +11 -0
  95. data/app/views/incline/welcome/home.html.erb +5 -0
  96. data/app/views/layouts/application.html.erb +1 -0
  97. data/app/views/layouts/incline/_account_menu.html.erb +18 -0
  98. data/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
  99. data/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
  100. data/app/views/layouts/incline/_footer.html.erb +13 -0
  101. data/app/views/layouts/incline/_header.html.erb +21 -0
  102. data/app/views/layouts/incline/_html_mailer.html.erb +5 -0
  103. data/app/views/layouts/incline/_incline_app.html.erb +25 -0
  104. data/app/views/layouts/incline/_messages.html.erb +3 -0
  105. data/app/views/layouts/incline/_shim.html.erb +3 -0
  106. data/app/views/layouts/incline/_text_mailer.text.erb +1 -0
  107. data/app/views/layouts/incline/application.html.erb +1 -0
  108. data/app/views/layouts/mailer.html.erb +2 -0
  109. data/app/views/layouts/mailer.text.erb +2 -0
  110. data/bin/rails +12 -0
  111. data/bin/test_scaffold.sh +10 -0
  112. data/config/routes.rb +61 -0
  113. data/db/migrate/20170511230126_create_incline_users.rb +26 -0
  114. data/db/migrate/20170515003052_create_incline_access_groups.rb +10 -0
  115. data/db/migrate/20170515003221_create_incline_user_login_histories.rb +12 -0
  116. data/db/migrate/20170515150908_create_incline_access_group_user_members.rb +11 -0
  117. data/db/migrate/20170515151058_create_incline_access_group_group_members.rb +11 -0
  118. data/db/migrate/20170517193432_add_comments_to_incline_user.rb +5 -0
  119. data/db/migrate/20170622132700_create_incline_action_securities.rb +16 -0
  120. data/db/migrate/20170622172712_create_incline_action_groups.rb +11 -0
  121. data/db/migrate/20170622195742_add_non_standard_to_action_security.rb +5 -0
  122. data/db/migrate/20170622230422_add_visible_to_action_security.rb +5 -0
  123. data/db/seeds.rb +81 -0
  124. data/exe/new_incline_app +42 -0
  125. data/lib/generators/incline/install_generator.rb +259 -0
  126. data/lib/generators/incline/templates/_app_menu_anon.html.erb +1 -0
  127. data/lib/generators/incline/templates/_app_menu_authenticated.html.erb +1 -0
  128. data/lib/generators/incline/templates/incline_application.css +17 -0
  129. data/lib/generators/incline/templates/incline_application.html.erb +1 -0
  130. data/lib/generators/incline/templates/incline_application.js +12 -0
  131. data/lib/generators/incline/templates/incline_database.yml +25 -0
  132. data/lib/generators/incline/templates/incline_email.yml +20 -0
  133. data/lib/generators/incline/templates/incline_mailer.html.erb +2 -0
  134. data/lib/generators/incline/templates/incline_mailer.text.erb +2 -0
  135. data/lib/generators/incline/templates/incline_users.yml +64 -0
  136. data/lib/generators/incline/templates/incline_version.rb +3 -0
  137. data/lib/incline/auth_engine_base.rb +52 -0
  138. data/lib/incline/data_tables_request.rb +336 -0
  139. data/lib/incline/date_time_formats.rb +6 -0
  140. data/lib/incline/engine.rb +212 -0
  141. data/lib/incline/errors.rb +15 -0
  142. data/lib/incline/extensions/action_controller_base.rb +526 -0
  143. data/lib/incline/extensions/action_mailer_base.rb +66 -0
  144. data/lib/incline/extensions/action_view_base.rb +489 -0
  145. data/lib/incline/extensions/active_record_base.rb +308 -0
  146. data/lib/incline/extensions/application.rb +137 -0
  147. data/lib/incline/extensions/application_configuration.rb +50 -0
  148. data/lib/incline/extensions/connection_adapter.rb +55 -0
  149. data/lib/incline/extensions/date_time_value.rb +123 -0
  150. data/lib/incline/extensions/date_value.rb +77 -0
  151. data/lib/incline/extensions/decimal_value.rb +55 -0
  152. data/lib/incline/extensions/erb_scaffold_generator.rb +31 -0
  153. data/lib/incline/extensions/float_value.rb +59 -0
  154. data/lib/incline/extensions/form_builder.rb +617 -0
  155. data/lib/incline/extensions/integer_value.rb +54 -0
  156. data/lib/incline/extensions/jbuilder_generator.rb +38 -0
  157. data/lib/incline/extensions/jbuilder_template.rb +39 -0
  158. data/lib/incline/extensions/main_app.rb +40 -0
  159. data/lib/incline/extensions/numeric.rb +63 -0
  160. data/lib/incline/extensions/object.rb +31 -0
  161. data/lib/incline/extensions/resource_route_generator.rb +53 -0
  162. data/lib/incline/extensions/session.rb +113 -0
  163. data/lib/incline/extensions/string.rb +50 -0
  164. data/lib/incline/extensions/test_case.rb +764 -0
  165. data/lib/incline/extensions/time_zone_converter.rb +40 -0
  166. data/lib/incline/global_status.rb +236 -0
  167. data/lib/incline/helpers/route_hash_formatter.rb +46 -0
  168. data/lib/incline/json_log_formatter.rb +96 -0
  169. data/lib/incline/json_logger.rb +17 -0
  170. data/lib/incline/log.rb +153 -0
  171. data/lib/incline/number_formats.rb +17 -0
  172. data/lib/incline/recaptcha.rb +346 -0
  173. data/lib/incline/user_manager.rb +212 -0
  174. data/lib/incline/validators/email_validator.rb +45 -0
  175. data/lib/incline/validators/ip_address_validator.rb +32 -0
  176. data/lib/incline/validators/recaptcha_validator.rb +37 -0
  177. data/lib/incline/validators/safe_name_validator.rb +31 -0
  178. data/lib/incline/version.rb +3 -0
  179. data/lib/incline/work_path.rb +75 -0
  180. data/lib/incline.rb +197 -0
  181. data/lib/tasks/incline_tasks.rake +4 -0
  182. data/lib/templates/erb/scaffold/_form.html.erb +43 -0
  183. data/lib/templates/erb/scaffold/_list.html.erb +81 -0
  184. data/lib/templates/erb/scaffold/edit.html.erb +1 -0
  185. data/lib/templates/erb/scaffold/index.html.erb +6 -0
  186. data/lib/templates/erb/scaffold/new.html.erb +1 -0
  187. data/lib/templates/erb/scaffold/show.html.erb +34 -0
  188. data/lib/templates/jbuilder/scaffold/_details.json.jbuilder +20 -0
  189. data/lib/templates/jbuilder/scaffold/index.json.jbuilder +16 -0
  190. data/lib/templates/jbuilder/scaffold/show.json.jbuilder +16 -0
  191. data/lib/templates/rails/scaffold_controller/controller.rb +128 -0
  192. data/test/controllers/incline/access_groups_controller_test.rb +65 -0
  193. data/test/controllers/incline/access_test_controller_test.rb +53 -0
  194. data/test/controllers/incline/contact_controller_test.rb +32 -0
  195. data/test/controllers/incline/security_controller_test.rb +39 -0
  196. data/test/controllers/incline/welcome_controller_test.rb +16 -0
  197. data/test/dummy/README.rdoc +28 -0
  198. data/test/dummy/Rakefile +6 -0
  199. data/test/dummy/app/assets/images/.keep +0 -0
  200. data/test/dummy/app/assets/javascripts/application.js +12 -0
  201. data/test/dummy/app/assets/stylesheets/application.css +17 -0
  202. data/test/dummy/app/controllers/application_controller.rb +5 -0
  203. data/test/dummy/app/controllers/concerns/.keep +0 -0
  204. data/test/dummy/app/helpers/application_helper.rb +2 -0
  205. data/test/dummy/app/mailers/.keep +0 -0
  206. data/test/dummy/app/models/.keep +0 -0
  207. data/test/dummy/app/models/concerns/.keep +0 -0
  208. data/test/dummy/app/views/layouts/application.html.erb +1 -0
  209. data/test/dummy/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
  210. data/test/dummy/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
  211. data/test/dummy/app/views/layouts/mailer.html.erb +2 -0
  212. data/test/dummy/app/views/layouts/mailer.text.erb +2 -0
  213. data/test/dummy/bin/bundle +3 -0
  214. data/test/dummy/bin/rails +4 -0
  215. data/test/dummy/bin/rake +4 -0
  216. data/test/dummy/bin/setup +29 -0
  217. data/test/dummy/config/application.rb +38 -0
  218. data/test/dummy/config/boot.rb +5 -0
  219. data/test/dummy/config/database.yml +34 -0
  220. data/test/dummy/config/email.yml +24 -0
  221. data/test/dummy/config/environment.rb +5 -0
  222. data/test/dummy/config/environments/development.rb +45 -0
  223. data/test/dummy/config/environments/production.rb +85 -0
  224. data/test/dummy/config/environments/test.rb +44 -0
  225. data/test/dummy/config/initializers/assets.rb +11 -0
  226. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  227. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  228. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  229. data/test/dummy/config/initializers/inflections.rb +16 -0
  230. data/test/dummy/config/initializers/mime_types.rb +4 -0
  231. data/test/dummy/config/initializers/session_store.rb +3 -0
  232. data/test/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
  233. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  234. data/test/dummy/config/locales/en.yml +23 -0
  235. data/test/dummy/config/routes.rb +6 -0
  236. data/test/dummy/config.ru +4 -0
  237. data/test/dummy/db/schema.rb +108 -0
  238. data/test/dummy/lib/assets/.keep +0 -0
  239. data/test/dummy/log/.keep +0 -0
  240. data/test/dummy/public/404.html +67 -0
  241. data/test/dummy/public/422.html +67 -0
  242. data/test/dummy/public/500.html +66 -0
  243. data/test/dummy/public/favicon.ico +0 -0
  244. data/test/extensions/action_controller_base_extensions_test.rb +21 -0
  245. data/test/extensions/action_mailer_base_extensions_test.rb +20 -0
  246. data/test/extensions/action_view_base_extensions_test.rb +267 -0
  247. data/test/extensions/active_record_extensions_test.rb +173 -0
  248. data/test/extensions/application_configuration_extensions_test.rb +46 -0
  249. data/test/extensions/application_extensions_test.rb +23 -0
  250. data/test/extensions/connection_adapter_extensions_test.rb +54 -0
  251. data/test/extensions/date_time_value_extensions_test.rb +104 -0
  252. data/test/extensions/date_value_extensions_test.rb +102 -0
  253. data/test/extensions/decimal_value_extensions_test.rb +85 -0
  254. data/test/extensions/erb_scaffold_generator_extensions_test.rb +17 -0
  255. data/test/extensions/float_value_extensions_test.rb +78 -0
  256. data/test/extensions/form_builder_extensions_test.rb +28 -0
  257. data/test/extensions/integer_value_extensions_test.rb +78 -0
  258. data/test/extensions/jbuilder_generator_extensions_test.rb +21 -0
  259. data/test/extensions/jbuilder_template_extensions_test.rb +47 -0
  260. data/test/extensions/main_app_extensions_test.rb +55 -0
  261. data/test/extensions/numeric_extensions_test.rb +76 -0
  262. data/test/extensions/object_extensions_test.rb +104 -0
  263. data/test/extensions/session_extensions_test.rb +69 -0
  264. data/test/extensions/string_extensions_test.rb +32 -0
  265. data/test/extensions/test_case_extensions_test.rb +538 -0
  266. data/test/extensions/time_zone_converter_extensions_test.rb +10 -0
  267. data/test/fixtures/incline/access_group_group_members.yml +1 -0
  268. data/test/fixtures/incline/access_group_user_members.yml +1 -0
  269. data/test/fixtures/incline/access_groups.yml +13 -0
  270. data/test/fixtures/incline/action_groups.yml +6 -0
  271. data/test/fixtures/incline/action_securities.yml +18 -0
  272. data/test/fixtures/incline/user_login_histories.yml +1 -0
  273. data/test/fixtures/incline/users.yml +64 -0
  274. data/test/incline_test.rb +63 -0
  275. data/test/integration/incline/users_edit_test.rb +180 -0
  276. data/test/integration/incline/users_login_test.rb +105 -0
  277. data/test/integration/incline/users_signup_test.rb +147 -0
  278. data/test/integration/navigation_test.rb +11 -0
  279. data/test/lib/data_tables_request_test.rb +245 -0
  280. data/test/lib/date_time_formats_test.rb +111 -0
  281. data/test/lib/global_status_test.rb +89 -0
  282. data/test/lib/json_log_formatter_test.rb +43 -0
  283. data/test/lib/log_test.rb +36 -0
  284. data/test/lib/recaptcha_test.rb +75 -0
  285. data/test/lib/user_manager_test.rb +47 -0
  286. data/test/lib/work_path_test.rb +18 -0
  287. data/test/models/incline/access_group_group_member_test.rb +30 -0
  288. data/test/models/incline/access_group_test.rb +60 -0
  289. data/test/models/incline/access_group_user_member_test.rb +29 -0
  290. data/test/models/incline/action_group_test.rb +27 -0
  291. data/test/models/incline/action_security_test.rb +176 -0
  292. data/test/models/incline/contact_message_test.rb +66 -0
  293. data/test/models/incline/disable_info_test.rb +29 -0
  294. data/test/models/incline/password_reset_request_test.rb +35 -0
  295. data/test/models/incline/password_reset_test.rb +51 -0
  296. data/test/models/incline/user_login_history_test.rb +31 -0
  297. data/test/models/incline/user_test.rb +91 -0
  298. data/test/test_helper.rb +42 -0
  299. data/test/validators/email_validator_test.rb +102 -0
  300. data/test/validators/ip_address_validator_test.rb +107 -0
  301. data/test/validators/recaptcha_validator_test.rb +57 -0
  302. data/test/validators/safe_name_validator_test.rb +101 -0
  303. metadata +584 -0
@@ -0,0 +1,64 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ name: George Jetson
5
+ email: george@example.com
6
+ activated: true
7
+ enabled: true
8
+ system_admin: false
9
+ password_digest: <%= Incline::User::digest 'Password123' %>
10
+ activated_at: <%= 20.days.ago %>
11
+ last_login_at: <%= 5.hours.ago %>
12
+ last_login_ip: 10.20.30.40
13
+
14
+ two:
15
+ name: Fred Flintstone
16
+ email: fred@example.com
17
+ activated: true
18
+ enabled: true
19
+ system_admin: false
20
+ password_digest: <%= Incline::User::digest 'Password123' %>
21
+ activated_at: <%= 9.days.ago %>
22
+ last_login_at: <%= 3.days.ago %>
23
+ last_login_ip: 1:2::3:4
24
+
25
+ admin:
26
+ name: Sys Admin
27
+ email: admin@example.com
28
+ activated: true
29
+ enabled: true
30
+ system_admin: true
31
+ password_digest: <%= Incline::User::digest 'Password123' %>
32
+ activated_at: <%= 30.days.ago %>
33
+
34
+ basic:
35
+ name: Basic User
36
+ email: basic@example.com
37
+ activated: true
38
+ enabled: true
39
+ system_admin: false
40
+ password_digest: <%= Incline::User::digest 'Password123' %>
41
+ activated_at: <%= 10.days.ago %>
42
+
43
+ disabled:
44
+ name: Bad User
45
+ email: bad@example.com
46
+ activated: true
47
+ enabled: false
48
+ system_admin: false
49
+ password_digest: <%= Incline::User::digest 'Password123' %>
50
+ disabled_by: admin@example.com
51
+ disabled_at: <%= 30.days.ago %>
52
+ activated_at: <%= 31.days.ago %>
53
+
54
+ recently_disabled:
55
+ name: Recent User
56
+ email: recent@example.com
57
+ activated: true
58
+ enabled: false
59
+ system_admin: false
60
+ password_digest: <%= Incline::User::digest 'Password123' %>
61
+ disabled_by: admin@example.com
62
+ disabled_at: <%= 1.days.ago %>
63
+ activated_at: <%= 3.days.ago %>
64
+
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+
3
+ class InclineTest < ActiveSupport::TestCase
4
+
5
+ test 'modules and classes loaded' do
6
+ assert Object.const_defined? :Incline
7
+
8
+ assert Incline.const_defined? :NotLoggedIn
9
+ assert Incline.const_defined? :NotAuthorized
10
+ assert Incline.const_defined? :InvalidApiCall
11
+
12
+ assert Incline.const_defined? :VERSION
13
+ assert Incline.const_defined? :Log
14
+ assert Incline.const_defined? :Engine
15
+ assert Incline.const_defined? :WorkPath
16
+ assert Incline.const_defined? :JsonLogFormatter
17
+ assert Incline.const_defined? :JsonLogger
18
+ assert Incline.const_defined? :GlobalStatus
19
+ assert Incline.const_defined? :DataTablesRequest
20
+ assert Incline.const_defined? :DateTimeFormats
21
+ assert Incline.const_defined? :NumberFormats
22
+ assert Incline.const_defined? :AuthEngineBase
23
+ assert Incline.const_defined? :UserManager
24
+ assert Incline.const_defined? :Recaptcha
25
+ assert Incline::Recaptcha.const_defined? :Tag
26
+
27
+ assert Incline.const_defined? :Extensions
28
+ assert Incline::Extensions.const_defined? :Object
29
+ assert Incline::Extensions.const_defined? :Numeric
30
+ assert Incline::Extensions.const_defined? :String
31
+ assert Incline::Extensions.const_defined? :Application
32
+ assert Incline::Extensions.const_defined? :ApplicationConfiguration
33
+ assert Incline::Extensions.const_defined? :ActiveRecordBase
34
+ assert Incline::Extensions.const_defined? :ConnectionAdapter
35
+ assert Incline::Extensions.const_defined? :MainApp
36
+ assert Incline::Extensions.const_defined? :ActionControllerBase
37
+ assert Incline::Extensions.const_defined? :ActionMailerBase
38
+ assert Incline::Extensions.const_defined? :ActionViewBase
39
+ assert Incline::Extensions.const_defined? :Session
40
+ assert Incline::Extensions::Session.const_defined? :Common
41
+ assert Incline::Extensions::Session.const_defined? :Controller
42
+ assert Incline::Extensions.const_defined? :ResourceRouteGenerator
43
+ assert Incline::Extensions.const_defined? :ErbScaffoldGenerator
44
+ assert Incline::Extensions.const_defined? :JbuilderGenerator
45
+ assert Incline::Extensions.const_defined? :JbuilderTemplate
46
+ assert Incline::Extensions.const_defined? :TestCase
47
+ assert Incline::Extensions.const_defined? :IntegerValue
48
+ assert Incline::Extensions.const_defined? :FloatValue
49
+ assert Incline::Extensions.const_defined? :TimeZoneConverter
50
+ assert Incline::Extensions.const_defined? :DateTimeValue
51
+ assert Incline::Extensions.const_defined? :DateValue
52
+ assert Incline::Extensions.const_defined? :DecimalValue
53
+ assert Incline::Extensions.const_defined? :FormBuilder
54
+
55
+ assert Incline.const_defined? :EmailValidator
56
+ assert Incline.const_defined? :SafeNameValidator
57
+ assert Incline.const_defined? :IpAddressValidator
58
+ assert Incline.const_defined? :RecaptchaValidator
59
+
60
+ end
61
+
62
+
63
+ end
@@ -0,0 +1,180 @@
1
+ require 'test_helper'
2
+
3
+ module Incline
4
+ class UsersEditTest < ActionDispatch::IntegrationTest
5
+ def setup
6
+ @user = incline_users(:one)
7
+ @other_user = incline_users(:two)
8
+ @admin = incline_users(:admin)
9
+ @disabled_user = incline_users(:disabled)
10
+ @recent_user = incline_users(:recently_disabled)
11
+ end
12
+
13
+ # only admin can view random users.
14
+ access_tests_for :show,
15
+ controller: 'users',
16
+ url_helper: 'incline.user_path(@user)',
17
+ allow_anon: false,
18
+ allow_any_user: false,
19
+ allow_admin: true
20
+
21
+ # and users can view themselves.
22
+ test 'user should be able to show self' do
23
+ log_in_as @user
24
+ get incline.user_path(@user)
25
+ assert_response :success
26
+ end
27
+
28
+ # only admin can edit random users.
29
+ access_tests_for :edit,
30
+ controller: 'users',
31
+ url_helper: 'incline.edit_user_path(@user)',
32
+ allow_anon: false,
33
+ allow_any_user: false,
34
+ allow_admin: true
35
+
36
+ # and users can edit themselves.
37
+ test 'user can edit self' do
38
+ log_in_as @user
39
+ get incline.edit_user_path(@user)
40
+ assert_template 'incline/users/edit'
41
+ assert_select 'form[action=?]', incline.user_path(@user)
42
+ assert_select '#user_name'
43
+ assert_select '#user_email'
44
+ assert_select '#user_password'
45
+ end
46
+
47
+ # only admin can update random users.
48
+ access_tests_for :update,
49
+ controller: 'users',
50
+ url_helper: 'incline.user_path(@user)',
51
+ allow_anon: false,
52
+ allow_any_user: false,
53
+ allow_admin: true,
54
+ update_params: '{ user: { name: @user.name, email: @user.email } }',
55
+ success: '(system_admin? ? incline.users_path : incline.user_path(@user))'
56
+
57
+ # and users can update themselves.
58
+ test 'user can update self' do
59
+ log_in_as @user
60
+ patch incline.user_path(@user), user: { name: @user.name, email: @user.email }
61
+ assert_redirected_to incline.user_path(@user)
62
+ end
63
+
64
+
65
+ # only admin can destroy users.
66
+ access_tests_for :destroy,
67
+ controller: 'users',
68
+ url_helper: 'incline.user_path(@disabled_user)',
69
+ allow_anon: false,
70
+ allow_any_user: false,
71
+ allow_admin: true,
72
+ success: 'incline.users_path'
73
+
74
+ test 'user count should change when destroyed' do
75
+ log_in_as @admin
76
+ assert_difference 'Incline::User.count', -1 do
77
+ delete incline.user_path(@disabled_user)
78
+ end
79
+ end
80
+
81
+ test 'should not destroy recently disabled users' do
82
+ log_in_as @admin
83
+ assert_no_difference 'Incline::User.count' do
84
+ delete incline.user_path(@recent_user)
85
+ end
86
+ assert_redirected_to incline.users_path
87
+ end
88
+
89
+ test 'should not destroy active users' do
90
+ log_in_as @admin
91
+ assert_no_difference 'Incline::User.count' do
92
+ delete incline.user_path(@user)
93
+ end
94
+ assert_redirected_to incline.users_path
95
+ end
96
+
97
+ # only admin can disable users.
98
+ access_tests_for :disable_confirm,
99
+ controller: 'users',
100
+ url_helper: 'incline.disable_user_path(@user)',
101
+ method: 'get',
102
+ allow_anon: false,
103
+ allow_any_user: false,
104
+ allow_admin: true
105
+
106
+ access_tests_for :disable,
107
+ controller: 'users',
108
+ url_helper: 'incline.disable_user_path(@user)',
109
+ method: 'patch',
110
+ allow_anon: false,
111
+ allow_any_user: false,
112
+ allow_admin: true,
113
+ success: 'incline.users_path',
114
+ disable_params: { disable_info: { reason: 'As a test' } }
115
+
116
+ test 'enabled count should change when disabled' do
117
+ log_in_as @admin
118
+ assert_difference 'Incline::User.enabled.count', -1 do
119
+ patch incline.disable_user_path(@other_user), disable_info: { reason: 'As a test' }
120
+ end
121
+ end
122
+
123
+ access_tests_for :enable,
124
+ controller: 'users',
125
+ url_helper: 'incline.enable_user_path(@recent_user)',
126
+ method: 'patch',
127
+ allow_anon: false,
128
+ allow_any_user: false,
129
+ allow_admin: true,
130
+ success: 'incline.users_path'
131
+
132
+ test 'enabled cound should change when enabled' do
133
+ log_in_as @admin
134
+ assert_difference 'Incline::User.enabled.count', 1 do
135
+ patch incline.enable_user_path(@recent_user)
136
+ end
137
+ end
138
+
139
+
140
+
141
+
142
+ test 'should not allow the admin attribute to be edited via web' do
143
+ log_in_as @other_user
144
+ assert_not @other_user.system_admin?
145
+ patch incline.user_path(@other_user), user: { password: 'password', password_confirmation: 'password', system_admin: '1' }
146
+ assert_not @other_user.reload.system_admin?
147
+ end
148
+
149
+ test 'unsuccessful edit' do
150
+ log_in_as(@user)
151
+ get incline.edit_user_path(@user)
152
+ assert_template 'incline/users/edit'
153
+ patch incline.user_path(@user), user: { name: '', email: 'foo@invalid', password: 'foo', password_confirmation: 'baz' }
154
+ assert_template 'incline/users/edit'
155
+ assert_select 'div#error_explanation'
156
+ end
157
+
158
+ test 'successful edit with friendly forwarding' do
159
+ get incline.edit_user_path(@user)
160
+ assert_redirected_to incline.login_path
161
+ log_in_as(@user)
162
+ assert_redirected_to incline.edit_user_path(@user)
163
+ name = 'Foo Bar'
164
+ email = 'foo@bar.com'
165
+ pwd = ''
166
+ patch incline.user_path(@user), user: { name: name, email: email, password: pwd, password_confirmation: pwd }
167
+ assert_not flash.empty?
168
+ assert_redirected_to @user
169
+ @user.reload
170
+ assert_equal name, @user.name
171
+ assert_equal email, @user.email
172
+ pwd = 'new-password'
173
+ patch incline.user_path(@user), user: { name: name, email: email, password: pwd, password_confirmation: pwd }
174
+ assert_not flash.empty?
175
+ assert_redirected_to @user
176
+ @user.reload
177
+ assert @user.authenticate(pwd)
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,105 @@
1
+ require 'test_helper'
2
+
3
+ module Incline
4
+ class UsersLoginTest < ActionDispatch::IntegrationTest
5
+
6
+ def setup
7
+ @routes = Incline::Engine.routes
8
+ @user = Incline::User.find_by(email: valid_creds[:email])
9
+ end
10
+
11
+ def self.valid_creds
12
+ {
13
+ email: 'george@example.com',
14
+ password: 'Password123'
15
+ }
16
+ end
17
+
18
+ def valid_creds
19
+ self.class.valid_creds
20
+ end
21
+
22
+ # to get the login form, you must not be logged in.
23
+ access_tests_for :new,
24
+ controller: 'sessions',
25
+ url_helper: 'incline.login_path',
26
+ allow_anon: true,
27
+ allow_any_user: false,
28
+ allow_admin: false,
29
+ failure: 'incline.user_path(user)'
30
+
31
+ # to login, you must not be logged in.
32
+ access_tests_for :create,
33
+ controller: 'sessions',
34
+ url_helper: 'incline.login_path',
35
+ allow_anon: true,
36
+ allow_any_user: false,
37
+ allow_admin: false,
38
+ create_params: { session: valid_creds },
39
+ success: 'incline.user_path(@user)', # instance var
40
+ failure: 'incline.user_path(user)' # local var
41
+
42
+ test 'login template' do
43
+ get incline.login_path
44
+ assert_template 'incline/sessions/new'
45
+ assert_select '#session_email'
46
+ assert_select '#session_password'
47
+ assert_select 'a[href=?]', incline.signup_path
48
+ assert_select 'a[href=?]', incline.new_password_reset_path
49
+ end
50
+
51
+ test 'login with invalid information' do
52
+ get incline.login_path
53
+ assert_template 'incline/sessions/new'
54
+ post incline.login_path, session: { email: '', password: '' }
55
+ assert_template 'incline/sessions/new'
56
+ assert_not flash.empty?
57
+ get main_app.root_path
58
+ assert flash.empty?
59
+ assert_select 'a[href=?]', incline.login_path
60
+ assert_select 'a[href=?]', incline.logout_path, count: 0
61
+ end
62
+
63
+ test 'login with valid information followed by logout' do
64
+ get incline.login_path
65
+ post incline.login_path, session: valid_creds
66
+ assert is_logged_in?
67
+ assert_redirected_to @user
68
+ follow_redirect!
69
+ assert_template 'incline/users/show'
70
+ assert_select 'a[href=?]', incline.login_path, count: 0
71
+ assert_select 'a[href=?]', incline.logout_path
72
+ assert_select 'a[href=?]', incline.user_path(@user)
73
+ delete incline.logout_path
74
+ assert_not is_logged_in?
75
+ assert_redirected_to main_app.root_path
76
+ # simulate clicking 'log out' a second time.
77
+ delete incline.logout_path
78
+ assert_redirected_to main_app.root_path
79
+ follow_redirect!
80
+ assert_select 'a[href=?]', incline.login_path
81
+ assert_select 'a[href=?]', incline.logout_path, count: 0
82
+ assert_select 'a[href=?]', incline.user_path(@user), count: 0
83
+ end
84
+
85
+ test 'login with disabled account' do
86
+ @user = incline_users(:disabled)
87
+ get incline.login_path
88
+ post incline.login_path, session: { email: @user.email, password: valid_creds[:password] }
89
+ assert_template 'incline/sessions/new'
90
+ assert_not flash.empty?
91
+ end
92
+
93
+ test 'login with remembering' do
94
+ log_in_as @user, remember_me: '1'
95
+ assert_not_nil cookies[user_token_cookie.to_s]
96
+ assert_equal assigns(:user).remember_token, cookies[user_token_cookie.to_s]
97
+ end
98
+
99
+ test 'login without remembering' do
100
+ log_in_as @user, remember_me: '0'
101
+ assert_nil cookies[user_token_cookie.to_s]
102
+ end
103
+
104
+ end
105
+ end
@@ -0,0 +1,147 @@
1
+ require 'test_helper'
2
+
3
+ module Incline
4
+ class UsersSignupTest < ActionDispatch::IntegrationTest
5
+
6
+ def setup
7
+ @routes = Incline::Engine.routes
8
+ @valid_params = self.class.valid_params
9
+ ActionMailer::Base.deliveries.clear
10
+ end
11
+
12
+ def self.valid_params
13
+ {
14
+ name: 'Valid User',
15
+ email: 'valid@example.com',
16
+ password: 'Password321',
17
+ password_confirmation: 'Password321',
18
+ recaptcha: Incline::Recaptcha::DISABLED
19
+ }
20
+ end
21
+
22
+ # should not allow when logged in (except admins can create other users)
23
+ access_tests_for :new,
24
+ controller: 'users',
25
+ url_helper: 'incline.signup_path',
26
+ allow_anon: true,
27
+ allow_any_user: false,
28
+ allow_admin: true,
29
+ failure: 'incline.user_path(user)'
30
+
31
+ access_tests_for :create,
32
+ controller: 'users',
33
+ url_helper: 'incline.signup_path',
34
+ allow_anon: true,
35
+ allow_any_user: false,
36
+ allow_admin: true,
37
+ success: '(system_admin? ? incline.users_path : main_app.root_path)',
38
+ failure: 'incline.user_path(user)',
39
+ create_params: { user: valid_params }
40
+
41
+ test 'signup template' do
42
+ get incline.signup_path
43
+ assert_template 'incline/users/new'
44
+ assert_select 'form[action=?]', incline.signup_path
45
+ assert_select '#user_name'
46
+ assert_select '#user_email'
47
+ assert_select '#user_password'
48
+ end
49
+
50
+ test 'require name' do
51
+ # no name
52
+ get incline.signup_path
53
+ assert_no_difference 'Incline::User.count' do
54
+ post incline.signup_path, user: @valid_params.merge(name: '')
55
+ end
56
+ assert_template 'incline/users/new'
57
+ assert_select 'div#error_explanation', /Name can't be blank/
58
+ assert_select 'div.field_with_errors input[id=?]', 'user_name'
59
+ end
60
+
61
+ test 'require valid email' do
62
+ # no email
63
+ get incline.signup_path
64
+ assert_no_difference 'Incline::User.count' do
65
+ post incline.signup_path, user: @valid_params.merge(email: '')
66
+ end
67
+ assert_template 'incline/users/new'
68
+ assert_select 'div#error_explanation', /Email can't be blank/
69
+ assert_select 'div.field_with_errors input[id=?]', 'user_email'
70
+
71
+ # invalid email
72
+ assert_no_difference 'Incline::User.count' do
73
+ post incline.signup_path, user: @valid_params.merge(email: 'admin@localhost')
74
+ end
75
+ assert_template 'incline/users/new'
76
+ assert_select 'div#error_explanation', /Email is not a valid email address/
77
+ assert_select 'div.field_with_errors input[id=?]', 'user_email'
78
+ end
79
+
80
+ test 'require password and confirmation' do
81
+ # no password
82
+ get incline.signup_path
83
+ assert_no_difference 'Incline::User.count' do
84
+ post incline.signup_path, user: @valid_params.merge(password: '')
85
+ end
86
+ assert_template 'incline/users/new'
87
+ assert_select 'div#error_explanation', /Password can't be blank/
88
+ assert_select 'div.field_with_errors input[id=?]', 'user_password'
89
+
90
+ # no password confirmation
91
+ assert_no_difference 'Incline::User.count' do
92
+ post incline.signup_path, user: @valid_params.merge(password_confirmation: '')
93
+ end
94
+ assert_template 'incline/users/new'
95
+ assert_select 'div#error_explanation', /Password confirmation doesn't match Password/
96
+ assert_select 'div.field_with_errors input[id=?]', 'user_password_confirmation'
97
+ end
98
+
99
+ test 'require reCAPTCHA' do
100
+ # no reCAPTCHA challenge
101
+ get incline.signup_path
102
+ assert_no_difference 'Incline::User.count' do
103
+ post incline.signup_path, user: @valid_params.merge(recaptcha: '')
104
+ end
105
+ assert_template 'incline/users/new'
106
+ assert_select 'div#error_explanation', /Recaptcha can't be blank/
107
+
108
+ # invalid reCAPTCHA challenge
109
+ assert_no_difference 'Incline::User.count' do
110
+ post incline.signup_path, user: @valid_params.merge(recaptcha: '0.0.0.0')
111
+ end
112
+ assert_template 'incline/users/new'
113
+ assert_select 'div#error_explanation', /Requires reCAPTCHA challenge to be completed/
114
+ end
115
+
116
+ test 'valid signup' do
117
+ # valid signup
118
+ get incline.signup_path
119
+ assert_difference 'Incline::User.count', 1 do
120
+ post incline.signup_path, user: @valid_params
121
+ end
122
+ assert_not is_logged_in?
123
+ assert_equal 1, ActionMailer::Base.deliveries.size
124
+ user = assigns(:user)
125
+ assert_not user.activated?
126
+ token = user.activation_token
127
+ assert_not_nil token
128
+
129
+ # try logging in before activation.
130
+ log_in_as user, password: @valid_params[:password]
131
+ assert_not is_logged_in?
132
+
133
+ # invalid activation token
134
+ get incline.edit_account_activation_url('invalid-token', email: user.email)
135
+ assert_not is_logged_in?
136
+ assert_not user.reload.activated?
137
+
138
+ # valid activation token
139
+ get incline.edit_account_activation_url(token, email: user.email)
140
+ assert user.reload.activated?
141
+ follow_redirect!
142
+ assert_template 'incline/users/show'
143
+ assert is_logged_in?
144
+ end
145
+
146
+ end
147
+ end
@@ -0,0 +1,11 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+
5
+ test 'layout links' do
6
+ get root_path
7
+ assert_select 'a[href=?]', root_path, count: 2
8
+ # TODO: Test more links.
9
+ end
10
+
11
+ end