mail_manager 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +5 -0
  3. data/.rspec +1 -0
  4. data/.ruby-version +1 -1
  5. data/Gemfile +27 -10
  6. data/LICENSE.txt +2 -2
  7. data/MIT-LICENSE +1 -1
  8. data/README.md +97 -15
  9. data/{features/bounce_management.feature → app/assets/images/mail_manager/.gitkeep} +0 -0
  10. data/app/assets/images/mail_manager/BottomRight.gif +0 -0
  11. data/app/assets/images/mail_manager/MidRight.gif +0 -0
  12. data/app/assets/images/mail_manager/TopCenter.gif +0 -0
  13. data/app/assets/images/mail_manager/TopRight.gif +0 -0
  14. data/app/assets/images/mail_manager/calendar_date_select/calendar.gif +0 -0
  15. data/app/assets/images/mail_manager/iReach_logo.gif +0 -0
  16. data/app/assets/images/mail_manager/spacer.gif +0 -0
  17. data/app/assets/images/mail_manager/topMid.gif +0 -0
  18. data/app/assets/javascripts/mail_manager/application.js +19 -1
  19. data/app/assets/javascripts/mail_manager/jquery-ui-timepicker-addon.js +2134 -0
  20. data/app/assets/stylesheets/mail_manager/admin.css +261 -0
  21. data/app/assets/stylesheets/mail_manager/application.css +3 -1
  22. data/app/assets/stylesheets/mail_manager/nav.css +68 -0
  23. data/app/assets/stylesheets/mail_manager/timepicker.css +11 -0
  24. data/app/controllers/mail_manager/application_controller.rb +7 -2
  25. data/app/controllers/mail_manager/bounces_controller.rb +5 -10
  26. data/app/controllers/mail_manager/contacts_controller.rb +42 -20
  27. data/app/controllers/mail_manager/mailing_lists_controller.rb +5 -12
  28. data/app/controllers/mail_manager/mailings_controller.rb +18 -18
  29. data/app/controllers/mail_manager/messages_controller.rb +3 -10
  30. data/app/controllers/mail_manager/subscriptions_controller.rb +16 -75
  31. data/app/helpers/mail_manager/layout_helper.rb +43 -0
  32. data/app/models/mail_manager/bounce.rb +16 -5
  33. data/app/models/mail_manager/contact.rb +64 -1
  34. data/app/models/mail_manager/mailable.rb +14 -0
  35. data/app/models/mail_manager/mailer.rb +48 -81
  36. data/app/models/mail_manager/mailing.rb +23 -42
  37. data/app/models/mail_manager/message.rb +52 -8
  38. data/app/models/mail_manager/subscription.rb +9 -3
  39. data/app/models/status_history.rb +3 -2
  40. data/app/views/layouts/mail_manager/application.html.erb +33 -5
  41. data/app/views/layouts/mail_manager/layout.html.erb +15 -0
  42. data/app/views/mail_manager/bounces/index.html.erb +6 -4
  43. data/app/views/mail_manager/bounces/show.html.erb +3 -3
  44. data/app/views/mail_manager/contacts/_form.html.erb +7 -23
  45. data/app/views/mail_manager/contacts/edit.html.erb +3 -3
  46. data/app/views/mail_manager/contacts/index.html.erb +14 -28
  47. data/app/views/mail_manager/contacts/new.html.erb +2 -2
  48. data/app/views/mail_manager/contacts/show.html.erb +5 -5
  49. data/app/views/mail_manager/contacts/subscribe.html.erb +1 -1
  50. data/app/views/mail_manager/mailer/double_opt_in.erb +1 -1
  51. data/app/views/mail_manager/mailer/double_opt_in.html.erb +6 -0
  52. data/app/views/mail_manager/mailer/unsubscribed.erb +1 -1
  53. data/app/views/mail_manager/mailer/unsubscribed.html.erb +1 -1
  54. data/app/views/mail_manager/mailing_lists/_form.html.erb +8 -17
  55. data/app/views/mail_manager/mailing_lists/edit.html.erb +4 -4
  56. data/app/views/mail_manager/mailing_lists/index.html.erb +6 -5
  57. data/app/views/mail_manager/mailing_lists/new.html.erb +3 -3
  58. data/app/views/mail_manager/mailings/_form.html.erb +22 -44
  59. data/app/views/mail_manager/mailings/edit.html.erb +3 -3
  60. data/app/views/mail_manager/mailings/index.html.erb +23 -27
  61. data/app/views/mail_manager/mailings/new.html.erb +2 -2
  62. data/app/views/mail_manager/mailings/test.html.erb +3 -3
  63. data/app/views/mail_manager/messages/index.html.erb +2 -2
  64. data/app/views/mail_manager/subscriptions/_form.html.erb +1 -1
  65. data/app/views/mail_manager/subscriptions/_subscriptions.html.erb +2 -2
  66. data/app/views/mail_manager/subscriptions/edit.html.erb +2 -2
  67. data/app/views/mail_manager/subscriptions/index.html.erb +3 -3
  68. data/app/views/mail_manager/subscriptions/new.html.erb +1 -1
  69. data/app/views/mail_manager/subscriptions/unsubscribe.html.erb +1 -1
  70. data/app/views/mail_manager/subscriptions/unsubscribe_by_email_address.html.erb +3 -3
  71. data/config/locales/en.yml +13 -0
  72. data/config/locales/mailings.en.yml +52 -0
  73. data/config/routes.rb +21 -19
  74. data/db/migrate/008_add_bounces_count_to_mailings.rb +14 -0
  75. data/db/migrate/009_add_messages_count_to_mailings.rb +14 -0
  76. data/db/migrate/010_add_login_token_to_contact.rb +11 -0
  77. data/db/migrate/011_add_deleted_at_to_mailing.rb +11 -0
  78. data/lib/delayed/mailer.rb +9 -5
  79. data/lib/delayed/status.rb +6 -2
  80. data/lib/delayed_overrides/worker.rb +21 -0
  81. data/lib/deleteable.rb +13 -14
  82. data/lib/mail_manager/config.rb +3 -3
  83. data/lib/mail_manager/engine.rb +136 -7
  84. data/lib/mail_manager/lock.rb +1 -0
  85. data/lib/mail_manager/version.rb +1 -1
  86. data/lib/tasks/mail_manager.rake +92 -56
  87. data/mail_manager.gemspec +4 -0
  88. data/spec/rails_helper.rb +50 -0
  89. data/spec/spec_helper.rb +87 -48
  90. data/spec/test_app/.env.development +3 -0
  91. data/spec/test_app/.env.test +2 -0
  92. data/spec/test_app/.rspec +1 -0
  93. data/spec/test_app/Procfile +3 -0
  94. data/spec/test_app/app/controllers/application_controller.rb +4 -0
  95. data/spec/test_app/app/models/ability.rb +7 -0
  96. data/spec/test_app/app/models/user.rb +8 -2
  97. data/spec/test_app/app/models/user_with_role.rb +22 -0
  98. data/spec/test_app/config/database.postgres.yml +21 -0
  99. data/spec/test_app/config/database.sqlite.yml +2 -2
  100. data/spec/test_app/config/environment.rb +2 -2
  101. data/spec/test_app/config/environments/test.rb +13 -0
  102. data/spec/test_app/config/mail_manager.yml +66 -2
  103. data/spec/test_app/config/routes.rb +0 -1
  104. data/spec/test_app/db/migrate/20150420163235_add_bounces_count_to_mailings.rb +14 -0
  105. data/spec/test_app/db/migrate/20150420163804_add_messages_count_to_mailings.rb +14 -0
  106. data/spec/test_app/db/migrate/20150421151457_add_login_token_to_contact.rb +11 -0
  107. data/spec/test_app/db/migrate/20150423143754_add_deleted_at_to_mailing.rb +11 -0
  108. data/spec/test_app/db/schema.rb +10 -5
  109. data/spec/test_app/db/structure.sql +150 -15
  110. data/spec/test_app/features/bounce_management.feature +11 -0
  111. data/spec/test_app/features/contact_management.feature +91 -0
  112. data/{features → spec/test_app/features}/mailable.feature +3 -1
  113. data/spec/test_app/features/mailing_list_management.feature +39 -0
  114. data/spec/test_app/features/mailing_management.feature +60 -0
  115. data/{features → spec/test_app/features}/message.feature +4 -4
  116. data/spec/test_app/features/message_management.feature +22 -0
  117. data/spec/test_app/features/step_definitions/bounce_steps.rb +4 -0
  118. data/spec/test_app/features/step_definitions/contact_steps.rb +63 -0
  119. data/spec/test_app/features/step_definitions/debugging_steps.rb +3 -0
  120. data/spec/test_app/features/step_definitions/email_steps.rb +6 -0
  121. data/spec/test_app/features/step_definitions/job_steps.rb +25 -0
  122. data/spec/test_app/features/step_definitions/login_steps.rb +4 -0
  123. data/spec/test_app/features/step_definitions/mailing_list.rb +17 -0
  124. data/spec/test_app/features/step_definitions/mailing_steps.rb +51 -0
  125. data/spec/test_app/features/step_definitions/subscription_steps.rb +26 -0
  126. data/{features → spec/test_app/features}/step_definitions/webrat_steps.rb +10 -6
  127. data/spec/test_app/features/subscription_management.feature +62 -0
  128. data/spec/test_app/features/support/env.rb +37 -0
  129. data/spec/test_app/features/support/paths.rb +36 -0
  130. data/spec/test_app/lib/debugging.rb +61 -0
  131. data/spec/test_app/lib/post_office_manager.rb +71 -0
  132. data/spec/test_app/public/subscribe.html +40 -0
  133. data/spec/test_app/script/full_suite +50 -0
  134. data/spec/test_app/script/post_office +25 -0
  135. data/spec/test_app/script/rails +20 -0
  136. data/spec/test_app/script/rspec_multi_db +34 -0
  137. data/spec/test_app/spec/controllers/mail_manager/bounces_controller_spec.rb +59 -0
  138. data/spec/test_app/spec/controllers/mail_manager/contacts_controller_spec.rb +178 -0
  139. data/spec/test_app/spec/controllers/mail_manager/mailing_lists_controller_spec.rb +164 -0
  140. data/spec/test_app/spec/controllers/mail_manager/mailings_controller_spec.rb +184 -0
  141. data/spec/test_app/spec/controllers/users_controller_spec.rb +47 -46
  142. data/spec/test_app/spec/factories/_functions.rb +27 -0
  143. data/spec/test_app/spec/factories/contacts.rb +7 -0
  144. data/spec/test_app/spec/factories/mail_manager_bounces.rb +13 -0
  145. data/spec/test_app/spec/factories/mailable.rb +8 -0
  146. data/spec/test_app/spec/factories/mailings.rb +7 -1
  147. data/spec/test_app/spec/factories/message.rb +7 -0
  148. data/spec/test_app/spec/factories/users.rb +19 -7
  149. data/spec/test_app/spec/features/mail_manager/bounce_spec.rb +73 -0
  150. data/spec/test_app/spec/features/mail_manager/double_opt_in_spec.rb +62 -0
  151. data/spec/test_app/spec/features/mail_manager/mailing_spec.rb +46 -0
  152. data/spec/test_app/spec/features/navigation_spec.rb +9 -0
  153. data/spec/test_app/spec/helpers/mail_manager/layout_helper_spec.rb +41 -0
  154. data/spec/test_app/spec/helpers/mail_manager/subscriptions_helper_spec.rb +14 -0
  155. data/spec/test_app/spec/models/delayed/mailer_spec.rb +27 -0
  156. data/spec/test_app/spec/models/delayed/status_job_spec.rb +13 -0
  157. data/spec/test_app/spec/models/delayed/status_spec.rb +37 -0
  158. data/spec/test_app/spec/models/mail_manager/bounce_spec.rb +23 -3
  159. data/spec/test_app/spec/models/mail_manager/engine_spec.rb +79 -0
  160. data/spec/test_app/spec/models/mail_manager/mailable_spec.rb +10 -0
  161. data/spec/test_app/spec/models/mail_manager/mailer_spec.rb +35 -3
  162. data/spec/test_app/spec/models/mail_manager/mailing_list_spec.rb +5 -5
  163. data/spec/test_app/spec/models/mail_manager/mailing_spec.rb +58 -0
  164. data/spec/test_app/spec/models/mail_manager/message_spec.rb +112 -0
  165. data/spec/test_app/spec/models/user_spec.rb +10 -8
  166. data/spec/test_app/spec/rails_helper.rb +86 -0
  167. data/spec/test_app/spec/requests/users_spec.rb +3 -3
  168. data/spec/test_app/spec/routing/mail_manager/bounces_routing_spec.rb +27 -0
  169. data/spec/test_app/spec/routing/mail_manager/contacts_routing_spec.rb +36 -0
  170. data/spec/test_app/spec/routing/mail_manager/mailing_lists_routing_spec.rb +36 -0
  171. data/spec/test_app/spec/routing/mail_manager/mailings_routing_spec.rb +36 -0
  172. data/spec/test_app/spec/spec_helper.rb +82 -32
  173. data/spec/test_app/spec/support/continuance.rb +18 -0
  174. data/spec/test_app/spec/support/custom_matchers.rb +17 -0
  175. data/spec/test_app/spec/support/database_cleaner.rb +10 -1
  176. data/spec/test_app/spec/views/mail_manager/bounces/index.html.erb_spec.rb +32 -0
  177. data/spec/test_app/spec/views/mail_manager/bounces/show.html.erb_spec.rb +12 -0
  178. data/spec/test_app/spec/views/users/edit.html.erb_spec.rb +8 -5
  179. data/spec/test_app/spec/views/users/index.html.erb_spec.rb +10 -19
  180. data/spec/test_app/spec/views/users/new.html.erb_spec.rb +9 -6
  181. data/spec/test_app/spec/views/users/show.html.erb_spec.rb +8 -9
  182. metadata +231 -75
  183. data/.DS_Store +0 -0
  184. data/README.rdoc +0 -3
  185. data/app/.DS_Store +0 -0
  186. data/app/controllers/mail_manager/base_controller.rb +0 -22
  187. data/app/models/.DS_Store +0 -0
  188. data/features/contact_management.feature +0 -24
  189. data/features/mailing_management.feature +0 -78
  190. data/features/step_definitions/email_steps.rb +0 -50
  191. data/features/step_definitions/mlm_steps.rb +0 -11
  192. data/features/step_definitions/pickle_steps.rb +0 -41
  193. data/features/subscription_management.feature +0 -17
  194. data/features/support/env.rb +0 -11
  195. data/features/support/paths.rb +0 -44
  196. data/lib/tasks/mail_manager_tasks.rake +0 -4
  197. data/lib/tasks/rspec.rake +0 -165
  198. data/spec/test_app/bin/cucumber +0 -7
  199. data/spec/test_app/bin/rails +0 -10
  200. data/spec/test_app/bin/rake +0 -7
  201. data/spec/test_app/bin/rspec +0 -7
  202. data/spec/test_app/bin/spring +0 -18
  203. data/spec/test_app/spec/routing/users_routing_spec.rb +0 -35
  204. data/spec/test_app/spec/support/post_office.rb +0 -13
@@ -38,4 +38,5 @@ if ActiveRecord::Base.connection.adapter_name =~ /mysql/i
38
38
  else
39
39
  require 'with_lock'
40
40
  MailManager::Lock = WithLock::Client
41
+ MailManager::LockException = WithLock::LockException
41
42
  end
@@ -1,3 +1,3 @@
1
1
  module MailManager
2
- VERSION = "3.0.0"
2
+ VERSION = "3.2.0"
3
3
  end
@@ -4,48 +4,15 @@ require File.join(Rails.root,'config','environment')
4
4
  initializer = File.join(MailManager::PLUGIN_ROOT,'config','initializers','delayed_job.rb')
5
5
  load initializer
6
6
 
7
- namespace :mail_manager do
8
- desc "Create mlm LSI Auth Menus"
9
- task :create_auth_menus, :parent_menu do |t,args|
10
- Rails.logger.warn "Creating mlm LSI Auth Menus"
11
- parent_menu = args.parent_menu
12
- AdminMenu.create_or_find(
13
- :description=>'Mailings',
14
- :path=>'admin/mail_manager/mailings',
15
- :admin_menu_id=>AdminMenu.find_by_description(parent_menu).id,
16
- :menu_order=>15,
17
- :is_visible=>1,
18
- :auth_all=>1)
19
- AdminMenu.create_or_find(
20
- :description=>'Mailing Lists',
21
- :path=>'admin/mail_manager/mailing_lists',
22
- :admin_menu_id=>AdminMenu.find_by_description(parent_menu).id,
23
- :menu_order=>20,
24
- :is_visible=>1,
25
- :auth_all=>1)
26
- AdminMenu.create_or_find(
27
- :description=>'Bounces',
28
- :path=>'admin/mail_manager/bounces',
29
- :admin_menu_id=>AdminMenu.find_by_description(parent_menu).id,
30
- :menu_order=>30,
31
- :is_visible=>1,
32
- :auth_all=>1)
33
- AdminMenu.create_or_find(
34
- :description=>'Contacts',
35
- :path=>'admin/mail_manager/contacts',
36
- :admin_menu_id=>AdminMenu.find_by_description('Newsletter').id,
37
- :menu_order=>10,
38
- :is_visible=>1,
39
- :auth_all=>1)
40
- AdminMenu.create_or_find(
41
- :description=>'MLM General Auth',
42
- :path=>'admin/mail_manager',
43
- :admin_menu_id=>nil,
44
- :menu_order=>0,
45
- :is_visible=>0,
46
- :auth_all=>1)
7
+ def get_config(env,filename='config/mail_manager.yml')
8
+ begin
9
+ app_config = YAML.load_file('config/mail_manager.yml')
10
+ rescue => e
11
+ app_config = Hash.new
47
12
  end
13
+ end
48
14
 
15
+ namespace :mail_manager do
49
16
  desc "Add mlm defaults to config/mail_manager.yml"
50
17
  task :default_app_config, :table_prefix do |t,args|
51
18
  Rails.logger.warn "Adding defaults to config/mail_manager.yml"
@@ -55,26 +22,95 @@ namespace :mail_manager do
55
22
  app_config = Hash.new
56
23
  end
57
24
  File.open('config/mail_manager.yml','w') do |file|
25
+ table_prefix = args.table_prefix || 'mail_manager_'
26
+ file.write <<EOT
27
+ # this file is used to configure the mail_manager gem
28
+ # it works like an older gem called AppConfig
29
+ # all environments start with settings from the 'common' section
30
+ # and are overridden by the section that matches the environment's name
31
+ # also .. if you create a 'config/mail_manager.local.yml' it will override
32
+ # what is in 'config/mail_manager.yml' such that you can keep a version
33
+ # for local settings and not overwrite one that you include in your source control
34
+ # also ... these files allow the use of erb syntax to set variables with ruby thus
35
+ # allowing ENV variables and such to be used
36
+ # here are the valid settings and what they are for:
37
+ # site_url: used in various places to get the url of the site (such as in mailings templates)
38
+ # public_layout: layout used for public facing pages like unsubscribing and opt-in pages
39
+ # layout: layout used for mail manager administratin pages
40
+ # site_path: used in case your rails site is at a sub-path of the site url
41
+ # exception_notification: (grouping for who gets notified of exceptions)
42
+ # to_addresses: an array of recipients for exceptions
43
+ # from_address: who the exception appears to be from
44
+ # requires_authentication: whether the mail manager app requires login
45
+ # authorized_roles: array of role names that can administer the mail manager
46
+ # roles_method: the method that your "current_user" object defines its role names(returns a list of strings)
47
+ # unsubscribe_path: public url for unsubscribing ... this is a prefix and is followed by a message 'guid', defaults to '/listmgr' and routes as '/listmgr/:guid'
48
+ # dont_include_images_domains: a list of domains that won't include images in the email, whether or not the mailing is set to include them
49
+ # sleep_time_between_messages: a timeout between messages to slow the output of emails to your email server; you should probably limit with your mail server itself if possible
50
+ # path_prefix: a prefix to the mail manager routes(defaults to /admin)
51
+ # table_prefix: prefixes all mail manager tables with a string to avoid collisions with your app - should be set BEFORE running migrations
52
+ # default_from_email_address: where any public messages from the app default to for the "FROM:" header
53
+ # secret: a secret for encrypting tokens and guids
54
+ # bounce: (a grouping for 'POP' settings for bounce messages and the RETURN_PATH: header)
55
+ # email_address: the account for POPing bounces and RETURN_PATH
56
+ # login: login for account for POPing
57
+ # password: password for account for POPing
58
+ # pop_server: POP server
59
+ # port: PORT of pop server
60
+ # ssl: true/false whether you want to enable ssl for pop
61
+ # subscribe_path: public path for double-opt-in 'subscribe' step which sends the email
62
+ # honey_pot_field: used to set a field name which will ignore submissions to the subscribe action if filled
63
+ # double_opt_in_path: path to route the double-opt-in confirmation action to
64
+ # signup_email_address: email address for the FROM: of a double opt in/subscribe email
65
+ #
66
+ # The following 2 might be deprecated soon
67
+ # show_title: can be used in templates/layouts to see whether you should show a title
68
+ # use_show_for_resources: whether to have links to "show" actions - we don't use them really in this app..
69
+ # and the 'show' actions aren't really currently supported
70
+ #
71
+ EOT
58
72
  file.write YAML.dump({
59
73
  'common' => {
60
74
  'site_url' => 'http://example.com',
61
- 'mail_manager' => {
62
- 'unsubscribe_path' => '/listmgr',
63
- 'dont_include_images_domains' => [
64
- 'yahoo.com', 'google.com', 'hotmail.com'
65
- ],
66
- 'sleep_time_between_messages' => 0.3,
67
- 'path_prefix' => '/admin',
68
- 'table_prefix' => args.table_prefix,
69
- 'default_from_email_address' => 'Contact <contact@example.com>',
70
- 'secret' => SecureRandom.hex(15).to_s,
71
- 'bounce' => {
72
- 'email_address' => 'bounces@example.com',
73
- 'login' => 'test',
74
- 'password' => 'secret',
75
- 'pop_server' => 'pop.example.com'
76
- }
75
+ 'public_layout' => 'layout',
76
+ 'site_path' => '/',
77
+ 'use_show_for_resources' => false,
78
+ 'exception_notification' => {
79
+ 'to_addresses' => ['bobo@example.com'],
80
+ 'from_address' => 'Mail Manager Exception <admin@example.com>'
81
+ },
82
+ 'requires_authentication' => false,
83
+ 'roles_method' => nil,
84
+ 'authorized_roles' => [],
85
+ 'unsubscribe_path' => '/listmgr',
86
+ 'subscribe_path' => '/listmgr/subscribe',
87
+ 'subscribe_thank_you_path' => '/listmgr/subscribe_thank_you',
88
+ 'double_opt_in_path' => '/listmgr/confirm',
89
+ 'honey_pot_field' => 'company_name',
90
+ 'signup_email_address' => 'Register <signup@example.com>',
91
+ 'dont_include_images_domains' => [
92
+ 'yahoo.com', 'google.com', 'hotmail.com', 'aol.com', 'gmail.com',
93
+ 'outlook.com'
94
+ ],
95
+ 'sleep_time_between_messages' => 0.3,
96
+ 'path_prefix' => '/admin',
97
+ 'table_prefix' => table_prefix,
98
+ 'default_from_email_address' => 'Contact <contact@example.com>',
99
+ 'secret' => SecureRandom.hex(15).to_s,
100
+ 'bounce' => {
101
+ 'email_address' => 'bounces@example.com',
102
+ 'login' => 'test',
103
+ 'password' => 'secret',
104
+ 'pop_server' => 'pop.example.com'
77
105
  }
106
+ },
107
+ 'development' => {
108
+ 'site_url' => 'http://example.dev',
109
+ 'secret' => SecureRandom.hex(15).to_s
110
+ },
111
+ 'test' => {
112
+ 'site_url' => 'http://example.lvh.me:4000',
113
+ 'secret' => SecureRandom.hex(15).to_s
78
114
  }
79
115
  }.deep_merge(app_config))
80
116
  end
data/mail_manager.gemspec CHANGED
@@ -8,11 +8,15 @@ Gem::Specification.new do |gem|
8
8
  gem.version = MailManager::VERSION
9
9
  gem.authors = ["Lone Star Internet"]
10
10
  gem.email = ["biz@lone-star.net"]
11
+ gem.licenses = ["MIT"]
11
12
  gem.description = %q{Manages the delivery of mailable items. Handles bounces, unsubscribe, opt-in, etc.}
12
13
  gem.summary = %q{Mailing list management tool}
13
14
  gem.homepage = "http://ireach.com"
14
15
 
15
16
  gem.add_dependency "rails", "~>3.2"
17
+ gem.add_dependency 'jquery-rails', "~>3.1"
18
+ gem.add_dependency 'jquery-ui-rails', "~>5.0"
19
+ gem.add_dependency 'jquery-ui-themes', "~>0.0"
16
20
  gem.add_dependency "daemons", "~>1.1"
17
21
  gem.add_dependency "with_lock", "~>0.1"
18
22
  gem.add_dependency "mini_magick", "~>4.1"
@@ -0,0 +1,50 @@
1
+ ## This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ #ENV['RAILS_ENV'] ||= 'test'
3
+ #require 'spec_helper'
4
+ #require File.expand_path('../../config/environment', __FILE__)
5
+ #require 'rspec/rails'
6
+ #require 'capybara/rails'
7
+ #require 'factory_girl_rails'
8
+ #FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)]
9
+ #FactoryGirl.find_definitions
10
+ ## Add additional requires below this line. Rails is not loaded until this point!
11
+ #
12
+ ## Requires supporting ruby files with custom matchers and macros, etc, in
13
+ ## spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
14
+ ## run as spec files by default. This means that files in spec/support that end
15
+ ## in _spec.rb will both be required and run as specs, causing the specs to be
16
+ ## run twice. It is recommended that you do not name files matching this glob to
17
+ ## end with _spec.rb. You can configure this pattern with the --pattern
18
+ ## option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
19
+ ##
20
+ ## The following line is provided for convenience purposes. It has the downside
21
+ ## of increasing the boot-up time by auto-requiring all files in the support
22
+ ## directory. Alternatively, in the individual `*_spec.rb` files, manually
23
+ ## require only the support files necessary.
24
+ ##
25
+ ## Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
26
+ #
27
+ #RSpec.configure do |config|
28
+ # # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
29
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
30
+ #
31
+ # # If you're not using ActiveRecord, or you'd prefer not to run each of your
32
+ # # examples within a transaction, remove the following line or assign false
33
+ # # instead of true.
34
+ # config.use_transactional_fixtures = true
35
+ #
36
+ # # RSpec Rails can automatically mix in different behaviours to your tests
37
+ # # based on their file location, for example enabling you to call `get` and
38
+ # # `post` in specs under `spec/controllers`.
39
+ # #
40
+ # # You can disable this behaviour by removing the line below, and instead
41
+ # # explicitly tag your specs with their type, e.g.:
42
+ # #
43
+ # # RSpec.describe UsersController, :type => :controller do
44
+ # # # ...
45
+ # # end
46
+ # #
47
+ # # The different available types are documented in the features, such as in
48
+ # # https://relishapp.com/rspec/rspec-rails/docs
49
+ # config.infer_spec_type_from_file_location!
50
+ #end
data/spec/spec_helper.rb CHANGED
@@ -1,48 +1,87 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
3
-
4
- require File.expand_path("../../spec/test_app/config/environment", __FILE__)
5
-
6
- require 'database_cleaner'
7
- require 'rspec/rails'
8
- # require 'rspec/autorun'
9
- `rake db:schema:load`
10
- # Requires supporting ruby files with custom matchers and macros, etc,
11
- # in spec/support/ and its subdirectories.
12
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
13
-
14
- RSpec.configure do |config|
15
- # ## Mock Framework
16
- #
17
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
18
- #
19
- # config.mock_with :mocha
20
- # config.mock_with :flexmock
21
- # config.mock_with :rr
22
-
23
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
24
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
25
-
26
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
27
- # examples within a transaction, remove the following line or assign false
28
- # instead of true.
29
- config.use_transactional_fixtures = true
30
-
31
- # If true, the base class of anonymous controllers will be inferred
32
- # automatically. This will be the default behavior in future versions of
33
- # rspec-rails.
34
- config.infer_base_class_for_anonymous_controllers = false
35
-
36
- # Run specs in random order to surface order dependencies. If you find an
37
- # order dependency and want to debug it, you can fix the order by providing
38
- # the seed, which is printed after each run.
39
- # --seed 1234
40
- config.order = "random"
41
- # Use color in STDOUT
42
- config.color_enabled = true
43
-
44
- # Use color not only in STDOUT but also in pagers and files
45
- #config.tty = true
46
-
47
- #config.formatter = :documentation # :progress, :html, :textmate
48
- end
1
+ ## This file was generated by the `rails generate rspec:install` command. Conventionally, all
2
+ ## specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ ## The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ ## this file to always be loaded, without a need to explicitly require it in any
5
+ ## files.
6
+ ##
7
+ ## Given that it is always loaded, you are encouraged to keep this file as
8
+ ## light-weight as possible. Requiring heavyweight dependencies from this file
9
+ ## will add to the boot time of your test suite on EVERY test run, even for an
10
+ ## individual file that may not need all of that loaded. Instead, consider making
11
+ ## a separate helper file that requires the additional dependencies and performs
12
+ ## the additional setup, and require it from the spec files that actually need
13
+ ## it.
14
+ ##
15
+ ## The `.rspec` file also contains a few flags that are not defaults but that
16
+ ## users commonly want.
17
+ ##
18
+ ## See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ #RSpec.configure do |config|
20
+ # # rspec-expectations config goes here. You can use an alternate
21
+ # # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # # assertions if you prefer.
23
+ # config.expect_with :rspec do |expectations|
24
+ # # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # # and `failure_message` of custom matchers include text for helper methods
26
+ # # defined using `chain`, e.g.:
27
+ # # be_bigger_than(2).and_smaller_than(4).description
28
+ # # # => "be bigger than 2 and smaller than 4"
29
+ # # ...rather than:
30
+ # # # => "be bigger than 2"
31
+ # expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ # end
33
+ #
34
+ # # rspec-mocks config goes here. You can use an alternate test double
35
+ # # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ # config.mock_with :rspec do |mocks|
37
+ # # Prevents you from mocking or stubbing a method that does not exist on
38
+ # # a real object. This is generally recommended, and will default to
39
+ # # `true` in RSpec 4.
40
+ # mocks.verify_partial_doubles = true
41
+ # end
42
+ #
43
+ ## The settings below are suggested to provide a good initial experience
44
+ ## with RSpec, but feel free to customize to your heart's content.
45
+ #=begin
46
+ # # These two settings work together to allow you to limit a spec run
47
+ # # to individual examples or groups you care about by tagging them with
48
+ # # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # # get run.
50
+ # config.filter_run :focus
51
+ # config.run_all_when_everything_filtered = true
52
+ #
53
+ # # Limits the available syntax to the non-monkey patched syntax that is
54
+ # # recommended. For more details, see:
55
+ # # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ # config.disable_monkey_patching!
59
+ #
60
+ # # Many RSpec users commonly either run the entire suite or an individual
61
+ # # file, and it's useful to allow more verbose output when running an
62
+ # # individual spec file.
63
+ # if config.files_to_run.one?
64
+ # # Use the documentation formatter for detailed output,
65
+ # # unless a formatter has already been configured
66
+ # # (e.g. via a command-line flag).
67
+ # config.default_formatter = 'doc'
68
+ # end
69
+ #
70
+ # # Print the 10 slowest examples and example groups at the
71
+ # # end of the spec run, to help surface which specs are running
72
+ # # particularly slow.
73
+ # config.profile_examples = 10
74
+ #
75
+ # # Run specs in random order to surface order dependencies. If you find an
76
+ # # order dependency and want to debug it, you can fix the order by providing
77
+ # # the seed, which is printed after each run.
78
+ # # --seed 1234
79
+ # config.order = :random
80
+ #
81
+ # # Seed global randomization in this process using the `--seed` CLI option.
82
+ # # Setting this allows you to use `--seed` to deterministically reproduce
83
+ # # test failures related to randomization by passing the same `--seed` value
84
+ # # as the one that triggered the failure.
85
+ # Kernel.srand config.seed
86
+ #=end
87
+ #end
@@ -0,0 +1,3 @@
1
+ export POST_OFFICE_SMTP_PORT=25001
2
+ export POST_OFFICE_POP_PORT=11011
3
+ export SERVER_PORT=3010
@@ -0,0 +1,2 @@
1
+ export POST_OFFICE_SMTP_PORT=25000
2
+ export POST_OFFICE_POP_PORT=11000
data/spec/test_app/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format documentation
3
+ --require spec_helper
@@ -0,0 +1,3 @@
1
+ post_office: bundle exec script/post_office run
2
+ delayed_job: bundle exec script/delayed_job run
3
+ web: spring rails s WEBrick
@@ -1,3 +1,7 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+ helper_method :current_user
4
+ def current_user
5
+ @current_user ||= User.first
6
+ end
3
7
  end
@@ -0,0 +1,7 @@
1
+ class Ability
2
+ include CanCan::Ability
3
+
4
+ def initialize(user)
5
+ eval MailManager.abilities
6
+ end
7
+ end
@@ -3,11 +3,17 @@ class User < ActiveRecord::Base
3
3
 
4
4
  validates :email, uniqueness: true, presence: true
5
5
 
6
+ def roles
7
+ return ['admin'] if last_name.include?('admin')
8
+ ['user']
9
+ end
10
+
6
11
  include MailManager::ContactableRegistry::Contactable
7
12
  end
8
13
 
9
14
  MailManager::ContactableRegistry.register_contactable("User",{
10
15
  first_name: :first_name,
11
16
  last_name: :last_name,
12
- email_address: :email
13
- })
17
+ email_address: :email,
18
+ phone: :phone
19
+ })
@@ -0,0 +1,22 @@
1
+ class UserWithRole < ActiveRecord::Base
2
+ self.table_name = :users
3
+
4
+ def role
5
+ return 'admin' if last_name.include?('admin')
6
+ return 'user' if last_name.include?('user')
7
+ nil
8
+ end
9
+
10
+ attr_accessible :email, :first_name, :last_name, :phone
11
+
12
+ validates :email, uniqueness: true, presence: true
13
+
14
+ include MailManager::ContactableRegistry::Contactable
15
+ end
16
+
17
+ MailManager::ContactableRegistry.register_contactable("User",{
18
+ first_name: :first_name,
19
+ last_name: :last_name,
20
+ email_address: :email,
21
+ phone: :phone
22
+ })