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.
- checksums.yaml +5 -13
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +27 -10
- data/LICENSE.txt +2 -2
- data/MIT-LICENSE +1 -1
- data/README.md +97 -15
- data/{features/bounce_management.feature → app/assets/images/mail_manager/.gitkeep} +0 -0
- data/app/assets/images/mail_manager/BottomRight.gif +0 -0
- data/app/assets/images/mail_manager/MidRight.gif +0 -0
- data/app/assets/images/mail_manager/TopCenter.gif +0 -0
- data/app/assets/images/mail_manager/TopRight.gif +0 -0
- data/app/assets/images/mail_manager/calendar_date_select/calendar.gif +0 -0
- data/app/assets/images/mail_manager/iReach_logo.gif +0 -0
- data/app/assets/images/mail_manager/spacer.gif +0 -0
- data/app/assets/images/mail_manager/topMid.gif +0 -0
- data/app/assets/javascripts/mail_manager/application.js +19 -1
- data/app/assets/javascripts/mail_manager/jquery-ui-timepicker-addon.js +2134 -0
- data/app/assets/stylesheets/mail_manager/admin.css +261 -0
- data/app/assets/stylesheets/mail_manager/application.css +3 -1
- data/app/assets/stylesheets/mail_manager/nav.css +68 -0
- data/app/assets/stylesheets/mail_manager/timepicker.css +11 -0
- data/app/controllers/mail_manager/application_controller.rb +7 -2
- data/app/controllers/mail_manager/bounces_controller.rb +5 -10
- data/app/controllers/mail_manager/contacts_controller.rb +42 -20
- data/app/controllers/mail_manager/mailing_lists_controller.rb +5 -12
- data/app/controllers/mail_manager/mailings_controller.rb +18 -18
- data/app/controllers/mail_manager/messages_controller.rb +3 -10
- data/app/controllers/mail_manager/subscriptions_controller.rb +16 -75
- data/app/helpers/mail_manager/layout_helper.rb +43 -0
- data/app/models/mail_manager/bounce.rb +16 -5
- data/app/models/mail_manager/contact.rb +64 -1
- data/app/models/mail_manager/mailable.rb +14 -0
- data/app/models/mail_manager/mailer.rb +48 -81
- data/app/models/mail_manager/mailing.rb +23 -42
- data/app/models/mail_manager/message.rb +52 -8
- data/app/models/mail_manager/subscription.rb +9 -3
- data/app/models/status_history.rb +3 -2
- data/app/views/layouts/mail_manager/application.html.erb +33 -5
- data/app/views/layouts/mail_manager/layout.html.erb +15 -0
- data/app/views/mail_manager/bounces/index.html.erb +6 -4
- data/app/views/mail_manager/bounces/show.html.erb +3 -3
- data/app/views/mail_manager/contacts/_form.html.erb +7 -23
- data/app/views/mail_manager/contacts/edit.html.erb +3 -3
- data/app/views/mail_manager/contacts/index.html.erb +14 -28
- data/app/views/mail_manager/contacts/new.html.erb +2 -2
- data/app/views/mail_manager/contacts/show.html.erb +5 -5
- data/app/views/mail_manager/contacts/subscribe.html.erb +1 -1
- data/app/views/mail_manager/mailer/double_opt_in.erb +1 -1
- data/app/views/mail_manager/mailer/double_opt_in.html.erb +6 -0
- data/app/views/mail_manager/mailer/unsubscribed.erb +1 -1
- data/app/views/mail_manager/mailer/unsubscribed.html.erb +1 -1
- data/app/views/mail_manager/mailing_lists/_form.html.erb +8 -17
- data/app/views/mail_manager/mailing_lists/edit.html.erb +4 -4
- data/app/views/mail_manager/mailing_lists/index.html.erb +6 -5
- data/app/views/mail_manager/mailing_lists/new.html.erb +3 -3
- data/app/views/mail_manager/mailings/_form.html.erb +22 -44
- data/app/views/mail_manager/mailings/edit.html.erb +3 -3
- data/app/views/mail_manager/mailings/index.html.erb +23 -27
- data/app/views/mail_manager/mailings/new.html.erb +2 -2
- data/app/views/mail_manager/mailings/test.html.erb +3 -3
- data/app/views/mail_manager/messages/index.html.erb +2 -2
- data/app/views/mail_manager/subscriptions/_form.html.erb +1 -1
- data/app/views/mail_manager/subscriptions/_subscriptions.html.erb +2 -2
- data/app/views/mail_manager/subscriptions/edit.html.erb +2 -2
- data/app/views/mail_manager/subscriptions/index.html.erb +3 -3
- data/app/views/mail_manager/subscriptions/new.html.erb +1 -1
- data/app/views/mail_manager/subscriptions/unsubscribe.html.erb +1 -1
- data/app/views/mail_manager/subscriptions/unsubscribe_by_email_address.html.erb +3 -3
- data/config/locales/en.yml +13 -0
- data/config/locales/mailings.en.yml +52 -0
- data/config/routes.rb +21 -19
- data/db/migrate/008_add_bounces_count_to_mailings.rb +14 -0
- data/db/migrate/009_add_messages_count_to_mailings.rb +14 -0
- data/db/migrate/010_add_login_token_to_contact.rb +11 -0
- data/db/migrate/011_add_deleted_at_to_mailing.rb +11 -0
- data/lib/delayed/mailer.rb +9 -5
- data/lib/delayed/status.rb +6 -2
- data/lib/delayed_overrides/worker.rb +21 -0
- data/lib/deleteable.rb +13 -14
- data/lib/mail_manager/config.rb +3 -3
- data/lib/mail_manager/engine.rb +136 -7
- data/lib/mail_manager/lock.rb +1 -0
- data/lib/mail_manager/version.rb +1 -1
- data/lib/tasks/mail_manager.rake +92 -56
- data/mail_manager.gemspec +4 -0
- data/spec/rails_helper.rb +50 -0
- data/spec/spec_helper.rb +87 -48
- data/spec/test_app/.env.development +3 -0
- data/spec/test_app/.env.test +2 -0
- data/spec/test_app/.rspec +1 -0
- data/spec/test_app/Procfile +3 -0
- data/spec/test_app/app/controllers/application_controller.rb +4 -0
- data/spec/test_app/app/models/ability.rb +7 -0
- data/spec/test_app/app/models/user.rb +8 -2
- data/spec/test_app/app/models/user_with_role.rb +22 -0
- data/spec/test_app/config/database.postgres.yml +21 -0
- data/spec/test_app/config/database.sqlite.yml +2 -2
- data/spec/test_app/config/environment.rb +2 -2
- data/spec/test_app/config/environments/test.rb +13 -0
- data/spec/test_app/config/mail_manager.yml +66 -2
- data/spec/test_app/config/routes.rb +0 -1
- data/spec/test_app/db/migrate/20150420163235_add_bounces_count_to_mailings.rb +14 -0
- data/spec/test_app/db/migrate/20150420163804_add_messages_count_to_mailings.rb +14 -0
- data/spec/test_app/db/migrate/20150421151457_add_login_token_to_contact.rb +11 -0
- data/spec/test_app/db/migrate/20150423143754_add_deleted_at_to_mailing.rb +11 -0
- data/spec/test_app/db/schema.rb +10 -5
- data/spec/test_app/db/structure.sql +150 -15
- data/spec/test_app/features/bounce_management.feature +11 -0
- data/spec/test_app/features/contact_management.feature +91 -0
- data/{features → spec/test_app/features}/mailable.feature +3 -1
- data/spec/test_app/features/mailing_list_management.feature +39 -0
- data/spec/test_app/features/mailing_management.feature +60 -0
- data/{features → spec/test_app/features}/message.feature +4 -4
- data/spec/test_app/features/message_management.feature +22 -0
- data/spec/test_app/features/step_definitions/bounce_steps.rb +4 -0
- data/spec/test_app/features/step_definitions/contact_steps.rb +63 -0
- data/spec/test_app/features/step_definitions/debugging_steps.rb +3 -0
- data/spec/test_app/features/step_definitions/email_steps.rb +6 -0
- data/spec/test_app/features/step_definitions/job_steps.rb +25 -0
- data/spec/test_app/features/step_definitions/login_steps.rb +4 -0
- data/spec/test_app/features/step_definitions/mailing_list.rb +17 -0
- data/spec/test_app/features/step_definitions/mailing_steps.rb +51 -0
- data/spec/test_app/features/step_definitions/subscription_steps.rb +26 -0
- data/{features → spec/test_app/features}/step_definitions/webrat_steps.rb +10 -6
- data/spec/test_app/features/subscription_management.feature +62 -0
- data/spec/test_app/features/support/env.rb +37 -0
- data/spec/test_app/features/support/paths.rb +36 -0
- data/spec/test_app/lib/debugging.rb +61 -0
- data/spec/test_app/lib/post_office_manager.rb +71 -0
- data/spec/test_app/public/subscribe.html +40 -0
- data/spec/test_app/script/full_suite +50 -0
- data/spec/test_app/script/post_office +25 -0
- data/spec/test_app/script/rails +20 -0
- data/spec/test_app/script/rspec_multi_db +34 -0
- data/spec/test_app/spec/controllers/mail_manager/bounces_controller_spec.rb +59 -0
- data/spec/test_app/spec/controllers/mail_manager/contacts_controller_spec.rb +178 -0
- data/spec/test_app/spec/controllers/mail_manager/mailing_lists_controller_spec.rb +164 -0
- data/spec/test_app/spec/controllers/mail_manager/mailings_controller_spec.rb +184 -0
- data/spec/test_app/spec/controllers/users_controller_spec.rb +47 -46
- data/spec/test_app/spec/factories/_functions.rb +27 -0
- data/spec/test_app/spec/factories/contacts.rb +7 -0
- data/spec/test_app/spec/factories/mail_manager_bounces.rb +13 -0
- data/spec/test_app/spec/factories/mailable.rb +8 -0
- data/spec/test_app/spec/factories/mailings.rb +7 -1
- data/spec/test_app/spec/factories/message.rb +7 -0
- data/spec/test_app/spec/factories/users.rb +19 -7
- data/spec/test_app/spec/features/mail_manager/bounce_spec.rb +73 -0
- data/spec/test_app/spec/features/mail_manager/double_opt_in_spec.rb +62 -0
- data/spec/test_app/spec/features/mail_manager/mailing_spec.rb +46 -0
- data/spec/test_app/spec/features/navigation_spec.rb +9 -0
- data/spec/test_app/spec/helpers/mail_manager/layout_helper_spec.rb +41 -0
- data/spec/test_app/spec/helpers/mail_manager/subscriptions_helper_spec.rb +14 -0
- data/spec/test_app/spec/models/delayed/mailer_spec.rb +27 -0
- data/spec/test_app/spec/models/delayed/status_job_spec.rb +13 -0
- data/spec/test_app/spec/models/delayed/status_spec.rb +37 -0
- data/spec/test_app/spec/models/mail_manager/bounce_spec.rb +23 -3
- data/spec/test_app/spec/models/mail_manager/engine_spec.rb +79 -0
- data/spec/test_app/spec/models/mail_manager/mailable_spec.rb +10 -0
- data/spec/test_app/spec/models/mail_manager/mailer_spec.rb +35 -3
- data/spec/test_app/spec/models/mail_manager/mailing_list_spec.rb +5 -5
- data/spec/test_app/spec/models/mail_manager/mailing_spec.rb +58 -0
- data/spec/test_app/spec/models/mail_manager/message_spec.rb +112 -0
- data/spec/test_app/spec/models/user_spec.rb +10 -8
- data/spec/test_app/spec/rails_helper.rb +86 -0
- data/spec/test_app/spec/requests/users_spec.rb +3 -3
- data/spec/test_app/spec/routing/mail_manager/bounces_routing_spec.rb +27 -0
- data/spec/test_app/spec/routing/mail_manager/contacts_routing_spec.rb +36 -0
- data/spec/test_app/spec/routing/mail_manager/mailing_lists_routing_spec.rb +36 -0
- data/spec/test_app/spec/routing/mail_manager/mailings_routing_spec.rb +36 -0
- data/spec/test_app/spec/spec_helper.rb +82 -32
- data/spec/test_app/spec/support/continuance.rb +18 -0
- data/spec/test_app/spec/support/custom_matchers.rb +17 -0
- data/spec/test_app/spec/support/database_cleaner.rb +10 -1
- data/spec/test_app/spec/views/mail_manager/bounces/index.html.erb_spec.rb +32 -0
- data/spec/test_app/spec/views/mail_manager/bounces/show.html.erb_spec.rb +12 -0
- data/spec/test_app/spec/views/users/edit.html.erb_spec.rb +8 -5
- data/spec/test_app/spec/views/users/index.html.erb_spec.rb +10 -19
- data/spec/test_app/spec/views/users/new.html.erb_spec.rb +9 -6
- data/spec/test_app/spec/views/users/show.html.erb_spec.rb +8 -9
- metadata +231 -75
- data/.DS_Store +0 -0
- data/README.rdoc +0 -3
- data/app/.DS_Store +0 -0
- data/app/controllers/mail_manager/base_controller.rb +0 -22
- data/app/models/.DS_Store +0 -0
- data/features/contact_management.feature +0 -24
- data/features/mailing_management.feature +0 -78
- data/features/step_definitions/email_steps.rb +0 -50
- data/features/step_definitions/mlm_steps.rb +0 -11
- data/features/step_definitions/pickle_steps.rb +0 -41
- data/features/subscription_management.feature +0 -17
- data/features/support/env.rb +0 -11
- data/features/support/paths.rb +0 -44
- data/lib/tasks/mail_manager_tasks.rake +0 -4
- data/lib/tasks/rspec.rake +0 -165
- data/spec/test_app/bin/cucumber +0 -7
- data/spec/test_app/bin/rails +0 -10
- data/spec/test_app/bin/rake +0 -7
- data/spec/test_app/bin/rspec +0 -7
- data/spec/test_app/bin/spring +0 -18
- data/spec/test_app/spec/routing/users_routing_spec.rb +0 -35
- data/spec/test_app/spec/support/post_office.rb +0 -13
|
@@ -4,7 +4,42 @@
|
|
|
4
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
|
5
5
|
# files.
|
|
6
6
|
|
|
7
|
+
require 'simplecov'
|
|
8
|
+
pwd = File.expand_path( File.dirname(__FILE__) )
|
|
9
|
+
SimpleCov.root(File.join(pwd,'..','..','..','..'))
|
|
10
|
+
SimpleCov.command_name 'cucumber-' + ENV['DBADAPTER'].to_s
|
|
11
|
+
SimpleCov.start('rails') do
|
|
12
|
+
adapters.delete(:root_filter)
|
|
13
|
+
add_filter do |src|
|
|
14
|
+
!(src.filename =~ /^#{SimpleCov.root}/)
|
|
15
|
+
end
|
|
16
|
+
add_filter do |src|
|
|
17
|
+
src.filename =~ /test_app/
|
|
18
|
+
end
|
|
19
|
+
end
|
|
7
20
|
require 'cucumber/rails'
|
|
21
|
+
require 'factory_girl_rails'
|
|
22
|
+
|
|
23
|
+
require 'capybara/poltergeist'
|
|
24
|
+
require 'capybara/rspec'
|
|
25
|
+
require 'capybara/rails'
|
|
26
|
+
require File.join(pwd,'..','..',"lib","debugging")
|
|
27
|
+
#require 'rack_session_access/capybara'
|
|
28
|
+
Capybara.server_port = MailManager.site_url.split(/:/).last
|
|
29
|
+
Capybara.app_host = MailManager.site_url
|
|
30
|
+
|
|
31
|
+
Capybara.default_driver = :rack_test
|
|
32
|
+
Capybara.register_driver :poltergeist do |app|
|
|
33
|
+
options = {
|
|
34
|
+
inspector: 'open',
|
|
35
|
+
debug: false,
|
|
36
|
+
phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'],
|
|
37
|
+
js_errors: false
|
|
38
|
+
}
|
|
39
|
+
Capybara::Poltergeist::Driver.new(app, options)
|
|
40
|
+
end
|
|
41
|
+
Capybara.javascript_driver = :poltergeist
|
|
42
|
+
|
|
8
43
|
|
|
9
44
|
# Capybara defaults to CSS3 selectors rather than XPath.
|
|
10
45
|
# If you'd prefer to use XPath, just uncomment this line and adjust any
|
|
@@ -27,6 +62,8 @@ require 'cucumber/rails'
|
|
|
27
62
|
# recommended as it will mask a lot of errors for you!
|
|
28
63
|
#
|
|
29
64
|
ActionController::Base.allow_rescue = false
|
|
65
|
+
DatabaseCleaner.strategy = :truncation
|
|
66
|
+
DatabaseCleaner.clean
|
|
30
67
|
|
|
31
68
|
# Remove/comment out the lines below if your app doesn't have a database.
|
|
32
69
|
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module NavigationHelpers
|
|
2
|
+
# Maps a name to a path. Used by the
|
|
3
|
+
#
|
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
|
5
|
+
#
|
|
6
|
+
# step definition in webrat_steps.rb
|
|
7
|
+
#
|
|
8
|
+
def path_to(page_name, routing=nil)
|
|
9
|
+
case page_name
|
|
10
|
+
|
|
11
|
+
when /the homepage/
|
|
12
|
+
'/'
|
|
13
|
+
|
|
14
|
+
# Add more mappings here.
|
|
15
|
+
# Here is a more fancy example:
|
|
16
|
+
#
|
|
17
|
+
# when /^(.*)'s profile page$/i
|
|
18
|
+
# user_profile_path(User.find_by_login($1))
|
|
19
|
+
# added by script/generate pickle path
|
|
20
|
+
when /the unsubscribe by email address page/
|
|
21
|
+
'/unsubscribe_by_email_address'
|
|
22
|
+
when /^the (.+?) page$/ # translate to named route
|
|
23
|
+
path_words = $1
|
|
24
|
+
begin
|
|
25
|
+
routing.send("#{path_words.downcase.gsub(' ','_')}_path")
|
|
26
|
+
rescue => e
|
|
27
|
+
mail_manager.send("#{path_words.downcase.gsub(' ','_')}_path")
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
|
31
|
+
"Now, go and add a mapping in #{__FILE__}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
World(NavigationHelpers)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module ::Debugging
|
|
2
|
+
def self.with_pry_remote(timeout=5.minutes)
|
|
3
|
+
return unless block_given?
|
|
4
|
+
begin
|
|
5
|
+
yield
|
|
6
|
+
rescue StandardError, MiniTest::Assertion, Exception, RuntimeError => e
|
|
7
|
+
begin
|
|
8
|
+
Debugging::send_developer_im('chauboldt@bender.lnstar.com', "Error running test - #{e.message}: #{e.backtrace.join("\n")[0..80]} on #{`hostname`.strip} from #{`pwd`}")
|
|
9
|
+
Timeout::timeout(timeout) do
|
|
10
|
+
binding.pry_remote
|
|
11
|
+
end
|
|
12
|
+
rescue Exception, StandardError, RuntimeError => te
|
|
13
|
+
Rails.logger.warn "Uncaught/Unpried exception: #{te.message} #{te.backtrace.join("\n")}"
|
|
14
|
+
raise e
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.send_developer_im(recipient='chauboldt@bender.lnstar.com', message)
|
|
20
|
+
# include Jabber # Makes using it a bit easier as we don't need to prepend Jabber:: to everything
|
|
21
|
+
# def send_xmpp_message(recipient, message)
|
|
22
|
+
# (recipient,message) = ARGV
|
|
23
|
+
|
|
24
|
+
#Account info
|
|
25
|
+
account = 'nagios@bender.lnstar.com'
|
|
26
|
+
password = '10dole01'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Jabber::debug = true # Uncomment this if you want to see what's being sent and received!
|
|
30
|
+
jid = Jabber::JID::new(account)
|
|
31
|
+
client = Jabber::Client::new(jid)
|
|
32
|
+
client.connect
|
|
33
|
+
client.auth(password)
|
|
34
|
+
client.send(Jabber::Message::new(recipient,message))
|
|
35
|
+
# end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.wait_until(timeout=nil, log=false)
|
|
39
|
+
timeout ||= ((Capybara.default_wait_time + 3) rescue 10.seconds)
|
|
40
|
+
require "timeout"
|
|
41
|
+
Timeout.timeout(timeout) do
|
|
42
|
+
Rails.logger.warn "Waiting for something.. timeout: #{timeout}" if log
|
|
43
|
+
sleep(0.1) until value = yield
|
|
44
|
+
value
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.wait_until_success(timeout=nil, log=false)
|
|
49
|
+
timeout ||= ((Capybara.default_wait_time + 3) rescue 10.seconds)
|
|
50
|
+
wait_until(timeout) do
|
|
51
|
+
begin
|
|
52
|
+
Rails.logger.warn "Waiting for something.. trying: #{Kernel.caller[0..5].join("\n")}" if log
|
|
53
|
+
yield
|
|
54
|
+
true
|
|
55
|
+
rescue => e
|
|
56
|
+
Rails.logger.warn "Waiting for something.. failure: #{e.message} #{e.backtrace.join}"
|
|
57
|
+
false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
class PostOfficeManager
|
|
2
|
+
@@post_office_pipe = nil
|
|
3
|
+
@@smtp_port = nil
|
|
4
|
+
@@pop_port = nil
|
|
5
|
+
|
|
6
|
+
def self.smtp_port
|
|
7
|
+
@@smtp_port ||= ENV['POST_OFFICE_SMTP_PORT'] || 25000
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.pop_port
|
|
11
|
+
@@pop_port ||= ENV['POST_OFFICE_POP_PORT'] || 11000
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.post_office_pipe
|
|
15
|
+
@@post_office_pipe
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.start_post_office(smtp=nil, pop=nil, kill_existing=true)
|
|
19
|
+
@@smtp_port = smtp if smtp
|
|
20
|
+
@@pop_port = pop if pop
|
|
21
|
+
stop_post_office if kill_existing && running?
|
|
22
|
+
if(@@post_office_pipe.nil? && !running?)
|
|
23
|
+
@@post_office_pipe = IO.popen("post_office -s #{smtp_port} -p #{pop_port}")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.run_post_office(smtp=nil, pop=nil, kill_existing=true)
|
|
28
|
+
@@smtp_port = smtp if smtp
|
|
29
|
+
@@pop_port = pop if pop
|
|
30
|
+
stop_post_office if kill_existing && running?
|
|
31
|
+
if(@@post_office_pipe.nil? && !running?)
|
|
32
|
+
@@post_office_pipe = IO.popen("post_office -s #{smtp_port} -p #{pop_port}")
|
|
33
|
+
end
|
|
34
|
+
Process.wait(@@post_office_pipe.pid)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.running?
|
|
38
|
+
`lsof -i TCP:#{smtp_port} | grep LISTEN | wc -l`.to_i == 1
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.stop_post_office
|
|
42
|
+
if @@post_office_pipe
|
|
43
|
+
`kill #{@@post_office_pipe.pid}`
|
|
44
|
+
else
|
|
45
|
+
pid = find_post_office_pid
|
|
46
|
+
`kill #{pid}` unless pid.nil?
|
|
47
|
+
end
|
|
48
|
+
@@post_office_pipe = nil
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.find_post_office_pid
|
|
52
|
+
commands = `lsof -i TCP:#{smtp_port} | grep LISTEN`
|
|
53
|
+
pids = []
|
|
54
|
+
commands.split("\n").each do |command|
|
|
55
|
+
pid = command.split(/\s+/)[1]
|
|
56
|
+
pids << pid
|
|
57
|
+
end
|
|
58
|
+
raise "Multiple post office processes(#{pids.join(',')})" if pids.uniq.length > 1
|
|
59
|
+
pids.uniq.first
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
#this didn't seem to just work!
|
|
63
|
+
#RSpec.configure do |config|
|
|
64
|
+
# config.before(:suite) do
|
|
65
|
+
# PostOfficeManager.start_post_office
|
|
66
|
+
# end
|
|
67
|
+
#
|
|
68
|
+
# config.before(:suite) do
|
|
69
|
+
# PostOfficeManager.stop_post_office
|
|
70
|
+
# end
|
|
71
|
+
#end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Subscribe to Newsletter</title>
|
|
4
|
+
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
|
|
5
|
+
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
|
|
6
|
+
<style>
|
|
7
|
+
.error {
|
|
8
|
+
color:red;
|
|
9
|
+
}
|
|
10
|
+
.highlight-important {
|
|
11
|
+
display:none;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
<script src="https://cdn.jsdelivr.net/jquery.validation/1.13.1/jquery.validate.min.js"></script>
|
|
15
|
+
<script type="text/javascript">
|
|
16
|
+
jQuery(document).ready(function(){
|
|
17
|
+
jQuery('#subscribe_form').validate();
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
</head>
|
|
21
|
+
<body>
|
|
22
|
+
<div class="sign_up">
|
|
23
|
+
Join Our Email List!
|
|
24
|
+
<form method='post' action="/subscribe" id="subscribe_form">
|
|
25
|
+
<input id="mailing_list_ids" name="mailing_list_ids[]" type="hidden" value="1" />
|
|
26
|
+
<label for="first_name">First Name</label>
|
|
27
|
+
<input type="text" name="contact[first_name]" id="first_name" class="required" /><br/>
|
|
28
|
+
<label for="last_name">Last Name</label>
|
|
29
|
+
<input type="text" name="contact[last_name]" id="last_name" class="required" /><br/>
|
|
30
|
+
<label for="email_address">Email</label>
|
|
31
|
+
<input type="text" name="contact[email_address]" id="email_address" class="required email" /><br/>
|
|
32
|
+
<div class="highlight-important">
|
|
33
|
+
<label for="company_name">Company</label>
|
|
34
|
+
<input type="text" name="company_name" id="company_name" />
|
|
35
|
+
</div>
|
|
36
|
+
<input type="submit" name="submit" value="Join" />
|
|
37
|
+
</form>
|
|
38
|
+
</div>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export RAILS_ENV=test
|
|
2
|
+
./script/post_office start
|
|
3
|
+
|
|
4
|
+
./script/with_lock start
|
|
5
|
+
# RUN FOR SQLITE
|
|
6
|
+
cp config/database.sqlite.yml config/database.yml
|
|
7
|
+
|
|
8
|
+
bundle exec rake db:schema:load
|
|
9
|
+
|
|
10
|
+
export SQLITE_SUCCESS=0
|
|
11
|
+
export CUC_SQLITE_SUCCESS=0
|
|
12
|
+
|
|
13
|
+
DBADAPTER=sqlite bundle exec rspec spec && export SQLITE_SUCCESS=1
|
|
14
|
+
DBADAPTER=sqlite bundle exec cucumber features && export CUC_SQLITE_SUCCESS=1
|
|
15
|
+
|
|
16
|
+
if [ $POSTGRES -eq 1 ]; then
|
|
17
|
+
#RUN FOR Postgresql
|
|
18
|
+
cp config/database.postgres.local.yml config/database.yml
|
|
19
|
+
|
|
20
|
+
bundle exec rake db:schema:load
|
|
21
|
+
|
|
22
|
+
export PGSQL_SUCCESS=0
|
|
23
|
+
export CUCPGSQL_SUCCESS=0
|
|
24
|
+
|
|
25
|
+
DBADAPTER=pg bundle exec rspec spec && export PGSQL_SUCCESS=1
|
|
26
|
+
DBADAPTER=pg bundle exec cucumber features && export CUC_PGSQL_SUCCESS=1
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
#RUN FOR MYSQL
|
|
30
|
+
cp config/database.mysql.local.yml config/database.yml
|
|
31
|
+
|
|
32
|
+
bundle exec rake db:schema:load
|
|
33
|
+
|
|
34
|
+
export MYSQL_SUCCESS=0
|
|
35
|
+
export CUCMYSQL_SUCCESS=0
|
|
36
|
+
|
|
37
|
+
DBADAPTER=mysql bundle exec rspec spec && export MYSQL_SUCCESS=1
|
|
38
|
+
DBADAPTER=mysql bundle exec cucumber features && export CUC_MYSQL_SUCCESS=1
|
|
39
|
+
|
|
40
|
+
./script/post_office stop
|
|
41
|
+
./script/with_lock stop
|
|
42
|
+
|
|
43
|
+
unset RAILS_ENV
|
|
44
|
+
|
|
45
|
+
if [ $MYSQL_SUCCESS -eq 0 ] ; then echo "Rspec Mysql Failed" && exit 1; fi
|
|
46
|
+
if [ $PGSQL_SUCCESS -eq 0 ] ; then echo "Rspec Pgsql Failed" && exit 1; fi
|
|
47
|
+
if [ $SQLITE_SUCCESS -eq 0 ] ; then echo "Rspec SQLite Failed" && exit 1; fi
|
|
48
|
+
if [ $CUC_MYSQL_SUCCESS -eq 0 ] ; then echo "Cucumber Mysql Failed" && exit 1; fi
|
|
49
|
+
if [ $CUC_PGSQL_SUCCESS -eq 0 ] ; then echo "Cucumber Pgsql Failed" && exit 1; fi
|
|
50
|
+
if [ $CUC_SQLITE_SUCCESS -eq 0 ] ; then echo "Cucumber SQLite Failed" && exit 1; fi
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# -*- encoding: utf-8 -*-
|
|
3
|
+
$:.push File.expand_path(File.join('..','..','lib'), __FILE__)
|
|
4
|
+
|
|
5
|
+
require "rubygems"
|
|
6
|
+
require "bundler"
|
|
7
|
+
Bundler.setup(:post_office)
|
|
8
|
+
require 'post_office_manager'
|
|
9
|
+
require 'dotenv'
|
|
10
|
+
|
|
11
|
+
ENV['RAILS_ENV'] ||= 'development'
|
|
12
|
+
Dotenv.overload(".env.#{ENV['RAILS_ENV']}")
|
|
13
|
+
Dotenv.overload(".env.#{ENV['RAILS_ENV']}.local")
|
|
14
|
+
|
|
15
|
+
FileUtils.mkdir_p('tmp/pids') unless File.exists?('tmp/pids')
|
|
16
|
+
|
|
17
|
+
if ARGV.include?('start')
|
|
18
|
+
puts "Starting Post Office!"
|
|
19
|
+
PostOfficeManager.start_post_office
|
|
20
|
+
elsif ARGV.include?('stop')
|
|
21
|
+
puts "Stopping Post Office!"
|
|
22
|
+
PostOfficeManager.stop_post_office
|
|
23
|
+
elsif ARGV.include?('run')
|
|
24
|
+
PostOfficeManager.run_post_office
|
|
25
|
+
end
|
data/spec/test_app/script/rails
CHANGED
|
@@ -3,4 +3,24 @@
|
|
|
3
3
|
|
|
4
4
|
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
5
|
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
|
|
7
|
+
ENV['RAILS_ENV'] ||= 'development'
|
|
8
|
+
|
|
9
|
+
# THIS IS NEW:
|
|
10
|
+
require "rails/commands/server"
|
|
11
|
+
module Rails
|
|
12
|
+
class Server
|
|
13
|
+
def default_options
|
|
14
|
+
super.merge({
|
|
15
|
+
:Port => (ENV['SERVER_PORT'] || 3000),
|
|
16
|
+
:environment => (ENV['RAILS_ENV'] || "development").dup,
|
|
17
|
+
:daemonize => false,
|
|
18
|
+
:debugger => false,
|
|
19
|
+
:pid => File.expand_path("tmp/pids/server.pid"),
|
|
20
|
+
:config => File.expand_path("config.ru")
|
|
21
|
+
})
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
# END OF CHANGE
|
|
6
26
|
require 'rails/commands'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export RAILS_ENV=test
|
|
2
|
+
./script/post_office start
|
|
3
|
+
|
|
4
|
+
# RUN FOR SQLITE
|
|
5
|
+
|
|
6
|
+
./script/with_lock start
|
|
7
|
+
cp config/database.sqlite.yml config/database.yml
|
|
8
|
+
|
|
9
|
+
rm db/test.sqlite3
|
|
10
|
+
spring rake db:schema:load
|
|
11
|
+
|
|
12
|
+
export SQLITE_SUCCESS=0
|
|
13
|
+
|
|
14
|
+
DBADAPTER=sqlite bundle exec rspec spec && export SQLITE_SUCCESS=1
|
|
15
|
+
|
|
16
|
+
./script/with_lock stop
|
|
17
|
+
|
|
18
|
+
#RUN FOR MYSQL
|
|
19
|
+
cp config/database.local.yml config/database.yml
|
|
20
|
+
|
|
21
|
+
mysqladmin -f drop mail_manager_test
|
|
22
|
+
mysqladmin -f create mail_manager_test
|
|
23
|
+
spring rake db:schema:load
|
|
24
|
+
|
|
25
|
+
export MYSQL_SUCCESS=0
|
|
26
|
+
|
|
27
|
+
DBADAPTER=mysql bundle exec rspec spec && export MYSQL_SUCCESS=1
|
|
28
|
+
|
|
29
|
+
./script/post_office stop
|
|
30
|
+
|
|
31
|
+
unset RAILS_ENV
|
|
32
|
+
|
|
33
|
+
if [ $MYSQL_SUCCESS -eq 0 ] ; then exit 1; fi
|
|
34
|
+
if [ $SQLITE_SUCCESS -eq 0 ] ; then exit 1; fi
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
#
|
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
|
19
|
+
# that an instance is receiving a specific message.
|
|
20
|
+
|
|
21
|
+
RSpec.describe MailManager::BouncesController, :type => :controller do
|
|
22
|
+
render_views
|
|
23
|
+
routes {MailManager::Engine.routes}
|
|
24
|
+
|
|
25
|
+
# This should return the minimal set of attributes required to create a valid
|
|
26
|
+
# MailManager::Bounce. As you add validations to MailManager::Bounce, be sure to
|
|
27
|
+
# adjust the attributes here as well.
|
|
28
|
+
let(:valid_attributes) {
|
|
29
|
+
FactoryGirl.attributes_for(:bounce)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let(:invalid_attributes) {
|
|
33
|
+
FactoryGirl.attributes_for(:bounce, status: "notastatus")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# This should return the minimal set of values that should be in the session
|
|
37
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
38
|
+
# MailManager::BouncesController. Be sure to keep this updated too.
|
|
39
|
+
let(:valid_session) { {} }
|
|
40
|
+
|
|
41
|
+
describe "GET #index" do
|
|
42
|
+
it "assigns all bounces as @bounces" do
|
|
43
|
+
bounce = MailManager::Bounce.create! valid_attributes
|
|
44
|
+
get :index, {}, valid_session
|
|
45
|
+
expect(assigns(:bounces)).to eq([bounce])
|
|
46
|
+
expect(response.body).to match /Listing Bounces/
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "GET #show" do
|
|
51
|
+
it "assigns the requested bounce as @bounce" do
|
|
52
|
+
bounce = MailManager::Bounce.create! valid_attributes
|
|
53
|
+
get :show, {:id => bounce.to_param}, valid_session
|
|
54
|
+
expect(assigns(:bounce)).to eq(bounce)
|
|
55
|
+
expect(response.body).to match /Viewing Bounce/
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|