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
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe User do
3
+ RSpec.describe User do
4
4
  context "when valid" do
5
5
  before(:each) do
6
6
  @user = FactoryGirl.build(:user)
@@ -8,12 +8,12 @@ describe User do
8
8
  it "should have a uniq email" do
9
9
  @user.save
10
10
  @user2 = FactoryGirl.build(:user, {email: @user.email})
11
- @user2.valid?.should == false
11
+ expect(@user2.valid?).to eq false
12
12
  end
13
13
  it "should have an email" do
14
- @user.valid?.should == true
14
+ expect(@user.valid?).to eq true
15
15
  @user.email = nil
16
- @user.valid?.should == false
16
+ expect(@user.valid?).to eq false
17
17
  end
18
18
  end
19
19
  context "integrated with mail manager" do
@@ -21,17 +21,19 @@ describe User do
21
21
  @user = FactoryGirl.create(:user)
22
22
  end
23
23
  it "should respond to subscriptions" do
24
- @user.respond_to?(:subscriptions).should == true
24
+ expect(@user.respond_to?(:subscriptions)).to eq true
25
25
  end
26
26
  it "should have a contact" do
27
- @user.contact.present?.should == true
27
+ expect(@user.contact.present?).to eq true
28
28
  end
29
29
  it "should have the same email as the contact" do
30
- @user.email.should == @user.contact.email_address
30
+ expect(@user.email).to eq @user.contact.email_address
31
31
  end
32
32
  it "should be able to subscribe to a mailing list" do
33
33
  @mailing_list = FactoryGirl.create(:mailing_list)
34
34
  @user.subscribe(@mailing_list)
35
+ @user.reload
36
+ expect(@user.subscriptions.detect(&:active?).mailing_list).to eq(@mailing_list)
35
37
  end
36
38
  end
37
39
  end
@@ -0,0 +1,86 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require 'simplecov'
4
+ pwd = File.expand_path( File.dirname(__FILE__) )
5
+ SimpleCov.root(File.join(pwd,'..','..','..'))
6
+ SimpleCov.command_name 'rspec-' + ENV['DBADAPTER'].to_s
7
+ SimpleCov.start('rails') do
8
+ adapters.delete(:root_filter)
9
+ add_filter do |src|
10
+ !(src.filename =~ /^#{SimpleCov.root}/)
11
+ end
12
+ add_filter do |src|
13
+ src.filename =~ /test_app/
14
+ end
15
+ end
16
+ require 'spec_helper'
17
+ require File.join(pwd, '..','config','environment')
18
+ require 'rspec/rails'
19
+ require 'capybara/rails'
20
+ require 'database_cleaner'
21
+
22
+ require 'capybara/poltergeist'
23
+ require 'capybara/rspec'
24
+ require 'capybara/rails'
25
+ require File.join(pwd,'..',"lib","debugging")
26
+ #require 'rack_session_access/capybara'
27
+ Capybara.server_port = MailManager.site_url.split(/:/).last
28
+ Capybara.app_host = MailManager.site_url
29
+
30
+ Capybara.default_driver = :rack_test
31
+ Capybara.register_driver :poltergeist do |app|
32
+ options = {
33
+ inspector: 'open',
34
+ debug: false,
35
+ phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'],
36
+ js_errors: false
37
+ }
38
+ Capybara::Poltergeist::Driver.new(app, options)
39
+ end
40
+ Capybara.javascript_driver = :poltergeist
41
+
42
+ require 'factory_girl_rails'
43
+ # Add additional requires below this line. Rails is not loaded until this point!
44
+
45
+ # Requires supporting ruby files with custom matchers and macros, etc, in
46
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
47
+ # run as spec files by default. This means that files in spec/support that end
48
+ # in _spec.rb will both be required and run as specs, causing the specs to be
49
+ # run twice. It is recommended that you do not name files matching this glob to
50
+ # end with _spec.rb. You can configure this pattern with the --pattern
51
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
52
+ #
53
+ # The following line is provided for convenience purposes. It has the downside
54
+ # of increasing the boot-up time by auto-requiring all files in the support
55
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
56
+ # require only the support files necessary.
57
+ #
58
+ # Dir[Rails.root.join('spec/support/*.rb')].each { |f| require f }
59
+ require File.join("support",'database_cleaner')
60
+ require File.join("support",'custom_matchers')
61
+ require File.join("support",'continuance')
62
+
63
+ RSpec.configure do |config|
64
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
65
+ #config.fixture_path = "#{::Rails.root}/spec/fixtures"
66
+
67
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
68
+ # examples within a transaction, remove the following line or assign false
69
+ # instead of true.
70
+ config.use_transactional_fixtures = false
71
+
72
+ # RSpec Rails can automatically mix in different behaviours to your tests
73
+ # based on their file location, for example enabling you to call `get` and
74
+ # `post` in specs under `spec/controllers`.
75
+ #
76
+ # You can disable this behaviour by removing the line below, and instead
77
+ # explicitly tag your specs with their type, e.g.:
78
+ #
79
+ # RSpec.describe UsersController, :type => :controller do
80
+ # # ...
81
+ # end
82
+ #
83
+ # The different available types are documented in the features, such as in
84
+ # https://relishapp.com/rspec/rspec-rails/docs
85
+ config.infer_spec_type_from_file_location!
86
+ end
@@ -1,11 +1,11 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe "Users" do
3
+ RSpec.describe "Users" do
4
4
  describe "GET /users" do
5
5
  it "works! (now write some real specs)" do
6
6
  # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
7
  get users_path
8
- response.status.should be(200)
8
+ expect(response.status).to be(200)
9
9
  end
10
10
  end
11
11
  end
@@ -0,0 +1,27 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe MailManager::BouncesController, :type => :routing do
4
+ # context "routing when mounted" do
5
+ # routes {TestApp::Application.routes.named_routes[:mail_manager].app.routes}
6
+ #
7
+ # it "routes to #index" do
8
+ # binding.pry
9
+ # expect(:get => "/mail_manager/bounces").to route_to("mail_manager/bounces#index")
10
+ # end
11
+
12
+ # it "routes to #show" do
13
+ # expect(:get => "/mail_manager/bounces/1").to route_to("mail_manager/bounces#show", :id => "1")
14
+ # end
15
+ # end
16
+ context "routing within engine" do
17
+ routes {MailManager::Engine.routes}
18
+
19
+ it "routes to #index" do
20
+ expect(:get => "/bounces").to route_to("mail_manager/bounces#index")
21
+ end
22
+
23
+ it "routes to #show" do
24
+ expect(:get => "/bounces/1").to route_to("mail_manager/bounces#show", :id => "1")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe MailManager::ContactsController, :type => :routing do
4
+ routes {MailManager::Engine.routes}
5
+ describe "routing" do
6
+
7
+ it "routes to #index" do
8
+ expect(:get => "/contacts").to route_to("mail_manager/contacts#index")
9
+ end
10
+
11
+ it "routes to #new" do
12
+ expect(:get => "/contacts/new").to route_to("mail_manager/contacts#new")
13
+ end
14
+
15
+ it "routes to #show" do
16
+ expect(:get => "/contacts/1").to route_to("mail_manager/contacts#show", :id => "1")
17
+ end
18
+
19
+ it "routes to #edit" do
20
+ expect(:get => "/contacts/1/edit").to route_to("mail_manager/contacts#edit", :id => "1")
21
+ end
22
+
23
+ it "routes to #create" do
24
+ expect(:post => "/contacts").to route_to("mail_manager/contacts#create")
25
+ end
26
+
27
+ it "routes to #update" do
28
+ expect(:put => "/contacts/1").to route_to("mail_manager/contacts#update", :id => "1")
29
+ end
30
+
31
+ it "routes to #destroy" do
32
+ expect(:delete => "/contacts/1").to route_to("mail_manager/contacts#destroy", :id => "1")
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe MailManager::MailingListsController, :type => :routing do
4
+ routes {MailManager::Engine.routes}
5
+ describe "routing" do
6
+
7
+ it "routes to #index" do
8
+ expect(:get => "/mailing_lists").to route_to("mail_manager/mailing_lists#index")
9
+ end
10
+
11
+ it "routes to #new" do
12
+ expect(:get => "/mailing_lists/new").to route_to("mail_manager/mailing_lists#new")
13
+ end
14
+
15
+ it "routes to #show" do
16
+ expect(:get => "/mailing_lists/1").to route_to("mail_manager/mailing_lists#show", :id => "1")
17
+ end
18
+
19
+ it "routes to #edit" do
20
+ expect(:get => "/mailing_lists/1/edit").to route_to("mail_manager/mailing_lists#edit", :id => "1")
21
+ end
22
+
23
+ it "routes to #create" do
24
+ expect(:post => "/mailing_lists").to route_to("mail_manager/mailing_lists#create")
25
+ end
26
+
27
+ it "routes to #update" do
28
+ expect(:put => "/mailing_lists/1").to route_to("mail_manager/mailing_lists#update", :id => "1")
29
+ end
30
+
31
+ it "routes to #destroy" do
32
+ expect(:delete => "/mailing_lists/1").to route_to("mail_manager/mailing_lists#destroy", :id => "1")
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe MailManager::MailingsController, :type => :routing do
4
+ routes {MailManager::Engine.routes}
5
+ describe "routing" do
6
+
7
+ it "routes to #index" do
8
+ expect(:get => "/mailings").to route_to("mail_manager/mailings#index")
9
+ end
10
+
11
+ it "routes to #new" do
12
+ expect(:get => "/mailings/new").to route_to("mail_manager/mailings#new")
13
+ end
14
+
15
+ it "routes to #show" do
16
+ expect(:get => "/mailings/1").to route_to("mail_manager/mailings#show", :id => "1")
17
+ end
18
+
19
+ it "routes to #edit" do
20
+ expect(:get => "/mailings/1/edit").to route_to("mail_manager/mailings#edit", :id => "1")
21
+ end
22
+
23
+ it "routes to #create" do
24
+ expect(:post => "/mailings").to route_to("mail_manager/mailings#create")
25
+ end
26
+
27
+ it "routes to #update" do
28
+ expect(:put => "/mailings/1").to route_to("mail_manager/mailings#update", :id => "1")
29
+ end
30
+
31
+ it "routes to #destroy" do
32
+ expect(:delete => "/mailings/1").to route_to("mail_manager/mailings#destroy", :id => "1")
33
+ end
34
+
35
+ end
36
+ end
@@ -1,38 +1,88 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
3
- require File.expand_path("../../config/environment", __FILE__)
4
- require 'rspec/rails'
5
- require 'rspec/autorun'
6
-
7
- # Requires supporting ruby files with custom matchers and macros, etc,
8
- # in spec/support/ and its subdirectories.
9
- Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
10
-
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
11
19
  RSpec.configure do |config|
12
- # ## Mock Framework
13
- #
14
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
- #
16
- # config.mock_with :mocha
17
- # config.mock_with :flexmock
18
- # config.mock_with :rr
19
20
 
20
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
21
+ #config.include MailManager::Engine.routes.url_helpers, type: :view
22
22
 
23
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
- # examples within a transaction, remove the following line or assign false
25
- # instead of true.
26
- config.use_transactional_fixtures = false
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
27
36
 
28
- # If true, the base class of anonymous controllers will be inferred
29
- # automatically. This will be the default behavior in future versions of
30
- # rspec-rails.
31
- config.infer_base_class_for_anonymous_controllers = false
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = false
44
+ end
32
45
 
33
- # Run specs in random order to surface order dependencies. If you find an
34
- # order dependency and want to debug it, you can fix the order by providing
35
- # the seed, which is printed after each run.
36
- # --seed 1234
37
- config.order = "random"
46
+ # The settings below are suggested to provide a good initial experience
47
+ # with RSpec, but feel free to customize to your heart's content.
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is
56
+ # recommended. For more details, see:
57
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
58
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
60
+ config.disable_monkey_patching!
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
76
+
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
82
+
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
38
88
  end
@@ -0,0 +1,18 @@
1
+ def by(message)
2
+ if block_given?
3
+ yield
4
+ else
5
+ pending message
6
+ end
7
+ end
8
+
9
+ alias and_by by
10
+
11
+ def and_it(message)
12
+ if block_given?
13
+ $stdout.puts "#{message},"
14
+ yield
15
+ else
16
+ pending message
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ RSpec::Matchers.define :match_attributes do |expected|
2
+ match do |actual|
3
+ success = true
4
+ expected.each_pair do |key,value|
5
+ # check if its a boolean
6
+ success = if !!actual.send(key) == actual.send(key)
7
+ actual.send(key) == (value != 0)
8
+ elsif actual.send(key).is_a?(Time)
9
+ actual.send(key).utc.to_i == value.utc.to_i
10
+ else
11
+ actual.send(key) == value
12
+ end
13
+ break unless success
14
+ end
15
+ success
16
+ end
17
+ end