mail_safe 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 31c1a2b64eb57573f90a15add88b559edeec9b8e
4
+ data.tar.gz: 2f4bba2d1e5d7176d1b9882be77adc7bc94b89cc
5
+ SHA512:
6
+ metadata.gz: 5e05fe8957e4f3d977e23d7f714219bbd636d4fdd47349f63860d0cbabe96357fb0799119527720fdda9a0d7c37ca5a7b5c9a9c3e955edaad2ab67abdbe92f10
7
+ data.tar.gz: 63a8b3ab0f0ad45ec17f53417225097a4571915c192345da892ad5842d7ebd65c9d91eb7d0cf2686ce620e29e313f7b78c6018fe35179c3dcb39e551713f3f2b
data/.gitignore CHANGED
@@ -3,4 +3,4 @@
3
3
  coverage
4
4
  rdoc
5
5
  pkg
6
- .ginger
6
+ gemfiles/*.lock
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - "2.1.2"
6
+ gemfile:
7
+ - gemfiles/actionmailer_3_2.gemfile
8
+ - gemfiles/actionmailer_4_0.gemfile
9
+ - gemfiles/actionmailer_4_1.gemfile
@@ -0,0 +1,11 @@
1
+ appraise "actionmailer-3_2" do
2
+ gem "actionmailer", "~> 3.2.0"
3
+ end
4
+
5
+ appraise "actionmailer-4_0" do
6
+ gem "actionmailer", "~> 4.0.0"
7
+ end
8
+
9
+ appraise "actionmailer-4_1" do
10
+ gem "actionmailer", "~> 4.1.0"
11
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mail_safe.gemspec
4
+ gemspec
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mail_safe (0.3.2)
5
+ actionmailer (>= 3.0.0)
6
+ coveralls
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.1.5)
12
+ actionpack (= 4.1.5)
13
+ actionview (= 4.1.5)
14
+ mail (~> 2.5.4)
15
+ actionpack (4.1.5)
16
+ actionview (= 4.1.5)
17
+ activesupport (= 4.1.5)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ actionview (4.1.5)
21
+ activesupport (= 4.1.5)
22
+ builder (~> 3.1)
23
+ erubis (~> 2.7.0)
24
+ activesupport (4.1.5)
25
+ i18n (~> 0.6, >= 0.6.9)
26
+ json (~> 1.7, >= 1.7.7)
27
+ minitest (~> 5.1)
28
+ thread_safe (~> 0.1)
29
+ tzinfo (~> 1.1)
30
+ appraisal (1.0.2)
31
+ bundler
32
+ rake
33
+ thor (>= 0.14.0)
34
+ builder (3.2.2)
35
+ coveralls (0.7.1)
36
+ multi_json (~> 1.3)
37
+ rest-client
38
+ simplecov (>= 0.7)
39
+ term-ansicolor
40
+ thor
41
+ diff-lcs (1.2.5)
42
+ docile (1.1.5)
43
+ erubis (2.7.0)
44
+ i18n (0.6.11)
45
+ json (1.8.1)
46
+ mail (2.5.4)
47
+ mime-types (~> 1.16)
48
+ treetop (~> 1.4.8)
49
+ mime-types (1.25.1)
50
+ minitest (5.4.1)
51
+ multi_json (1.10.1)
52
+ polyglot (0.3.5)
53
+ rack (1.5.2)
54
+ rack-test (0.6.2)
55
+ rack (>= 1.0)
56
+ rake (10.3.2)
57
+ rdoc (4.1.0)
58
+ rest-client (1.6.8)
59
+ mime-types (~> 1.16)
60
+ rdoc (>= 2.4.2)
61
+ rspec (3.0.0)
62
+ rspec-core (~> 3.0.0)
63
+ rspec-expectations (~> 3.0.0)
64
+ rspec-mocks (~> 3.0.0)
65
+ rspec-core (3.0.4)
66
+ rspec-support (~> 3.0.0)
67
+ rspec-expectations (3.0.4)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.0.0)
70
+ rspec-mocks (3.0.4)
71
+ rspec-support (~> 3.0.0)
72
+ rspec-support (3.0.4)
73
+ simplecov (0.9.0)
74
+ docile (~> 1.1.0)
75
+ multi_json
76
+ simplecov-html (~> 0.8.0)
77
+ simplecov-html (0.8.0)
78
+ term-ansicolor (1.3.0)
79
+ tins (~> 1.0)
80
+ thor (0.19.1)
81
+ thread_safe (0.3.4)
82
+ tins (1.3.2)
83
+ treetop (1.4.15)
84
+ polyglot
85
+ polyglot (>= 0.3.1)
86
+ tzinfo (1.2.2)
87
+ thread_safe (~> 0.1)
88
+
89
+ PLATFORMS
90
+ ruby
91
+
92
+ DEPENDENCIES
93
+ appraisal
94
+ bundler
95
+ mail_safe!
96
+ rake
97
+ rspec (~> 3.0, >= 3.0.0)
data/LICENSE CHANGED
@@ -1,4 +1,7 @@
1
- Copyright (c) 2009-2010 Myron Marston
1
+ Copyright (c) 2009-2010, Myron Marston, Kashless.org
2
+ Copyright (c) 2014, Watu
3
+
4
+ MIT License
2
5
 
3
6
  Permission is hereby granted, free of charge, to any person obtaining
4
7
  a copy of this software and associated documentation files (the
@@ -1,4 +1,11 @@
1
- = mail_safe
1
+ [![Build Status](https://travis-ci.org/watu/mail_safe.png?branch=master)](https://travis-ci.org/watu/mail_safe)
2
+ [![Coverage Status](https://coveralls.io/repos/watu/mail_safe/badge.png?branch=master)](https://coveralls.io/r/watu/mail_safe?branch=master)
3
+ [![Code Climate](https://codeclimate.com/github/watu/mail_safe.png)](https://codeclimate.com/github/watu/mail_safe)
4
+ [![Inline docs](http://inch-ci.org/github/watu/mail_safe.png)](http://inch-ci.org/github/watu/mail_safe)
5
+ [![Gem Version](https://badge.fury.io/rb/mail_safe.png)](http://badge.fury.io/rb/mail_safe)
6
+
7
+
8
+ # mail_safe
2
9
 
3
10
  Mail safe provides a safety net while you're developing an application that uses ActionMailer.
4
11
  It keeps emails from escaping into the wild.
@@ -8,41 +15,42 @@ emails to external email addresses. Instead, emails that would normally be deli
8
15
  addresses will be sent to an address of your choosing, and the body of the email will be appended
9
16
  with a note stating where the email was originally intended to go.
10
17
 
11
- == Download
18
+ ## Download
12
19
 
13
20
  Github: http://github.com/myronmarston/mail_safe
14
21
 
15
- Gem:
16
- gem install mail_safe
22
+ Gem: `gem install mail_safe`
17
23
 
18
- == Installation
24
+ ## Installation
19
25
 
20
- Load the gem in the appropriate environments using Rails' 2.1+ gem support. For example, I'm loading this in
21
- config/environments/development.rb and config/environments/staging.rb:
26
+ Load the gem in the appropriate environments using Rails' 3.2+ gem support. For example, I'm loading this in Gemfile as:
22
27
 
23
- config.gem 'mail_safe'
28
+ `gem "mail_safe", group: [:development, :staging]`
24
29
 
25
30
  IMPORTANT: Be sure not to load this in your production environment, otherwise, your emails won't be sent to the proper
26
- recipients. In your test environment, you probably won't want this, either--rails ensures that no emails are ever sent in the
31
+ recipients. In your test environment, you probably won't want this either. Rails ensures that no emails are ever sent in the
27
32
  test environment, and tests that check outbound email recipients may fail.
28
33
 
29
- == Configuration
34
+ ## Configuration
30
35
 
31
36
  In many cases, no configuration is necessary. If you have git installed, and you've registered your email address
32
37
  with it (check with "git config user.email" in your shell), mail safe will use this. All emails will be sent to this address.
33
38
 
34
39
  Otherwise, you can configure mail safe's behavior. Create a file at config/initializers/mail_safe.rb, similar to the following:
35
40
 
41
+ ```ruby
36
42
  if defined?(MailSafe::Config)
37
43
  MailSafe::Config.internal_address_definition = /.*@my-domain\.com/i
38
44
  MailSafe::Config.replacement_address = 'me@my-domain.com'
39
45
  end
46
+ ```
40
47
 
41
48
  The internal address definition determines which addresses will be ignored (i.e. sent normally) and which will be replaced. Email
42
49
  being sent to internal addresses will be sent normally; all other email addresses will be replaced by the replacement address.
43
50
 
44
51
  These settings can also take procs if you need something more flexible:
45
52
 
53
+ ```ruby
46
54
  if defined?(MailSafe::Config)
47
55
  MailSafe::Config.internal_address_definition = lambda { |address|
48
56
  address =~ /.*@domain1\.com/i ||
@@ -53,9 +61,11 @@ These settings can also take procs if you need something more flexible:
53
61
  # Useful if your mail server allows + dynamic email addresses like gmail.
54
62
  MailSafe::Config.replacement_address = lambda { |address| "my-address+#{address.gsub(/[\w\-.]/, '_')}@gmail.com" }
55
63
  end
64
+ ```
56
65
 
57
66
  When mail safe replaces an email address, it appends a notice to the bottom of the email body, such as:
58
67
 
68
+ ```
59
69
  **************************************************
60
70
  This email originally had different recipients,
61
71
  but MailSafe has prevented it from being sent to them.
@@ -68,13 +78,15 @@ When mail safe replaces an email address, it appends a notice to the bottom of t
68
78
  - external-address-3@domain.com
69
79
 
70
80
  **************************************************
81
+ ```
82
+ ## Version Compatibility and Continuous Integration
83
+
84
+ Tested with [Travis](https://travis-ci.org/watu/mail_safe) using Ruby 1.9, 2.0 and 2.1 against actionmailer 3.2, 4.0 and 4.1. ![Build Status](https://travis-ci.org/watu/mail_safe.svg?branch=master)
71
85
 
72
- == Version Compatibility and Continuous Integration
73
86
 
74
- Mail safe works on ruby {1.8.6}[http://integrity186.heroku.com/mail-safe], {1.8.7}[http://integrity187.heroku.com/mail-safe] and {1.9.1}[http://integrity191.heroku.com/mail-safe],
75
- and any version of actionmailer since 1.3.6 (the version used by rails 1.2.6), including 3.0.0. The builds (linked to above)
76
- use {ginger}[http://github.com/freelancing-god/ginger] to run the specs against 16 different versions of actionmailer.
87
+ ## Copyright
77
88
 
78
- == Copyright
89
+ Copyright (c) 2009-2010 Myron Marston, Kashless.org.
90
+ Copyright (c) 2014, Watu
79
91
 
80
- Copyright (c) 2009-2010 Myron Marston, Kashless.org. See LICENSE for details.
92
+ See LICENSE for details.
data/Rakefile CHANGED
@@ -1,54 +1,16 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "mail_safe"
8
- gem.summary = %Q{Keep your ActionMailer emails from escaping into the wild during development.}
9
- gem.email = "myron.marston@gmail.com"
10
- gem.homepage = "http://github.com/myronmarston/mail_safe"
11
- gem.authors = ["Myron Marston"]
12
-
13
- gem.add_dependency 'actionmailer', '>= 1.3.6'
14
- gem.add_development_dependency 'rspec', '>= 1.2.9'
15
-
16
- gem.files.exclude 'vendor/ginger'
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
- end
19
- rescue LoadError
20
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
21
- end
22
-
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "bundler/gem_tasks"
23
4
  require "rspec/core/rake_task"
24
- RSpec::Core::RakeTask.new(:spec) do |t|
25
- #t.rspec_opts = %w[--format documentation]
26
- end
27
-
28
- task :spec => :check_dependencies if defined?(Jeweler)
5
+ require 'rdoc/task'
29
6
 
30
- task :default => :ginger
7
+ RSpec::Core::RakeTask.new(:test)
31
8
 
32
- require 'rake/rdoctask'
33
9
  Rake::RDocTask.new do |rdoc|
34
- if File.exist?('VERSION.yml')
35
- require 'yaml' unless defined?(YAML) # seems to be needed for ruby 1.9.1
36
- config = YAML.load(File.read('VERSION.yml'))
37
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
38
- else
39
- version = ""
40
- end
41
-
42
10
  rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "mail_safe #{version}"
11
+ rdoc.title = "mail_safe #{MailSafe::VERSION}"
44
12
  rdoc.rdoc_files.include('README*')
45
13
  rdoc.rdoc_files.include('lib/**/*.rb')
46
14
  end
47
15
 
48
- desc 'Run ginger tests'
49
- task :ginger do
50
- $LOAD_PATH << File.join(*%w[vendor ginger lib])
51
- ARGV.clear
52
- ARGV << 'spec'
53
- load File.join(*%w[vendor ginger bin ginger])
54
- end
16
+ task :default => :test
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionmailer", "~> 3.2.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionmailer", "~> 4.0.0"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "actionmailer", "~> 4.1.0"
6
+
7
+ gemspec :path => "../"
@@ -1,11 +1,7 @@
1
1
  require 'action_mailer'
2
- require 'action_mailer/version'
2
+ require 'active_support/core_ext/class/attribute_accessors' # to be able to use cattr_accessor
3
3
 
4
4
  require 'mail_safe/config'
5
5
  require 'mail_safe/address_replacer'
6
6
 
7
- if ActionMailer::VERSION::MAJOR < 3
8
- require 'mail_safe/rails2_hook'
9
- else
10
- require 'mail_safe/rails3_hook'
11
- end
7
+ require 'mail_safe/rails_hook'
@@ -7,19 +7,18 @@ module MailSafe
7
7
  replaced_addresses = {}
8
8
 
9
9
  ADDRESS_TYPES.each do |address_type|
10
- if addresses = mail.send(address_type)
10
+ if addresses = mail[address_type].try(:value)
11
11
  new_addresses = []
12
12
 
13
- addresses.each do |a|
13
+ Array(addresses).each do |a|
14
14
  new_addresses << if MailSafe::Config.is_internal_address?(a)
15
- a
16
- else
17
- (replaced_addresses[address_type] ||= []) << a
18
- MailSafe::Config.get_replacement_address(a)
19
- end
15
+ a
16
+ else
17
+ (replaced_addresses[address_type] ||= []) << a
18
+ MailSafe::Config.get_replacement_address(a)
19
+ end
20
20
  end
21
-
22
- mail.send("#{address_type}=", new_addresses)
21
+ mail.send("#{address_type}=", new_addresses.uniq)
23
22
  end
24
23
  end
25
24
 
@@ -95,28 +94,9 @@ The original recipients were:
95
94
  add_postscript(part, postscript)
96
95
  end
97
96
 
98
- if ActionMailer::VERSION::MAJOR < 3
99
- include ::ActionMailer::Utils
100
-
101
- def add_postscript(part, postscript)
102
- body = part.body + postscript
103
-
104
- # taken from action mailer:
105
- # http://github.com/rails/rails/blob/05d7409ae5fd423be6f747ad553f659fcecbf548/actionmailer/lib/action_mailer/part.rb#L58-65
106
- case part.content_transfer_encoding.to_s.downcase
107
- when "base64" then
108
- part.body = TMail::Base64.folding_encode(body)
109
- when "quoted-printable"
110
- part.body = [normalize_new_lines(body)].pack("M*")
111
- else
112
- part.body = body
113
- end
114
- end
115
- else
116
- def add_postscript(part, postscript)
117
- postscript = postscript.html_safe if postscript.respond_to?(:html_safe)
118
- part.body = part.body.to_s + postscript
119
- end
97
+ def add_postscript(part, postscript)
98
+ postscript = postscript.html_safe if postscript.respond_to?(:html_safe)
99
+ part.body = part.body.to_s + postscript
120
100
  end
121
101
  end
122
102
  end
@@ -29,13 +29,14 @@ module MailSafe
29
29
  def self.developer_email_address
30
30
  unless defined?(@@developer_email_address)
31
31
  @@developer_email_address = begin
32
- `git config user.email`.chomp
32
+ `git config user.email`.strip
33
33
  rescue
34
34
  nil
35
35
  end
36
+ @@developer_email_address = nil if @@developer_email_address.blank?
36
37
  end
37
38
 
38
39
  @@developer_email_address
39
40
  end
40
41
  end
41
- end
42
+ end
@@ -0,0 +1,11 @@
1
+ require 'mail'
2
+
3
+ module MailSafe
4
+ class MailInterceptor
5
+ def self.delivering_email(message)
6
+ MailSafe::AddressReplacer.replace_external_addresses(message) if message
7
+ end
8
+
9
+ ::Mail.register_interceptor(self)
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module MailSafe
2
+ VERSION = "0.3.2"
3
+ end
@@ -1,66 +1,34 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "mail_safe/version"
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{mail_safe}
8
- s.version = "0.3.1"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mail_safe"
8
+ spec.version = MailSafe::VERSION
9
+ spec.authors = ["Myron Marston", "Juan José Conti"]
10
+ spec.email = ["myron.marston@gmail.com", "jjconti@gmail.com"]
11
+ spec.summary = %q{Keep your ActionMailer emails from escaping into the wild during development.}
12
+ spec.description = %q{Mail safe provides a safety net while you"re developing an application that uses ActionMailer.
13
+ It keeps emails from escaping into the wild.
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Myron Marston"]
12
- s.date = %q{2010-10-14}
13
- s.email = %q{myron.marston@gmail.com}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION.yml",
25
- "autotest/discover.rb",
26
- "ginger_scenarios.rb",
27
- "lib/mail_safe.rb",
28
- "lib/mail_safe/address_replacer.rb",
29
- "lib/mail_safe/config.rb",
30
- "lib/mail_safe/rails2_hook.rb",
31
- "lib/mail_safe/rails3_hook.rb",
32
- "mail_safe.gemspec",
33
- "spec/config_spec.rb",
34
- "spec/mailer_spec.rb",
35
- "spec/mailers/test_mailer.rb",
36
- "spec/spec_helper.rb"
37
- ]
38
- s.homepage = %q{http://github.com/myronmarston/mail_safe}
39
- s.rdoc_options = ["--charset=UTF-8"]
40
- s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.3.7}
42
- s.summary = %q{Keep your ActionMailer emails from escaping into the wild during development.}
43
- s.test_files = [
44
- "spec/config_spec.rb",
45
- "spec/mailer_spec.rb",
46
- "spec/mailers/test_mailer.rb",
47
- "spec/spec_helper.rb"
48
- ]
15
+ Once you"ve installed and configured this gem, you can rest assure that your app won"t send
16
+ emails to external email addresses. Instead, emails that would normally be delivered to external
17
+ addresses will be sent to an address of your choosing, and the body of the email will be appended
18
+ with a note stating where the email was originally intended to go.}
19
+ spec.homepage = "http://github.com/myronmarston/mail_safe"
20
+ spec.license = "MIT"
49
21
 
50
- if s.respond_to? :specification_version then
51
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
- s.specification_version = 3
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
53
26
 
54
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
- s.add_runtime_dependency(%q<actionmailer>, [">= 1.3.6"])
56
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
57
- else
58
- s.add_dependency(%q<actionmailer>, [">= 1.3.6"])
59
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
60
- end
61
- else
62
- s.add_dependency(%q<actionmailer>, [">= 1.3.6"])
63
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
64
- end
65
- end
27
+ spec.add_dependency "actionmailer", ">= 3.0.0"
28
+ spec.add_dependency "coveralls"
66
29
 
30
+ spec.add_development_dependency "bundler"
31
+ spec.add_development_dependency "rake"
32
+ spec.add_development_dependency "rspec", "~> 3.0", ">= 3.0.0"
33
+ spec.add_development_dependency "appraisal"
34
+ end
@@ -11,29 +11,29 @@ describe MailSafe::Config do
11
11
 
12
12
  context 'when git is installed' do
13
13
  before(:each) do
14
- MailSafe::Config.should_receive(:`).with('git config user.email').once.and_return("developer@domain.com\n")
14
+ expect(MailSafe::Config).to receive(:`).with('git config user.email').once.and_return("developer@domain.com\n")
15
15
  end
16
16
 
17
17
  it "guesses the developer's email address using git" do
18
- MailSafe::Config.developer_email_address.should == 'developer@domain.com'
18
+ expect(MailSafe::Config.developer_email_address).to eq('developer@domain.com')
19
19
  end
20
20
 
21
21
  it "caches the developer's email address so multiple system calls aren't made" do
22
- MailSafe::Config.developer_email_address.should == MailSafe::Config.developer_email_address
22
+ expect(MailSafe::Config.developer_email_address).to eq(MailSafe::Config.developer_email_address)
23
23
  end
24
24
  end
25
25
 
26
26
  context 'when git is not installed' do
27
27
  before(:each) do
28
- MailSafe::Config.should_receive(:`).with('git config user.email').once.and_return(nil)
28
+ expect(MailSafe::Config).to receive(:`).with('git config user.email').once.and_return(nil)
29
29
  end
30
30
 
31
31
  it "returns nil" do
32
- MailSafe::Config.developer_email_address.should be_nil
32
+ expect(MailSafe::Config.developer_email_address).to be_nil
33
33
  end
34
34
 
35
35
  it "caches the developer's email address so multiple system calls aren't made" do
36
- MailSafe::Config.developer_email_address.should == MailSafe::Config.developer_email_address
36
+ expect(MailSafe::Config.developer_email_address).to eq(MailSafe::Config.developer_email_address)
37
37
  end
38
38
  end
39
39
  end
@@ -47,29 +47,29 @@ describe MailSafe::Config do
47
47
  context 'and #developer_email_address has a value' do
48
48
  before(:each) do
49
49
  @developer_address = 'developer@domain.com'
50
- MailSafe::Config.should_receive(:developer_email_address).at_least(1).and_return(@developer_address)
50
+ expect(MailSafe::Config).to receive(:developer_email_address).at_least(1).and_return(@developer_address)
51
51
  end
52
52
 
53
53
  it 'returns true when passed the developer email address' do
54
- MailSafe::Config.is_internal_address?(@developer_address).should be_true
54
+ expect(MailSafe::Config.is_internal_address?(@developer_address)).to be_truthy
55
55
  end
56
56
 
57
57
  it 'returns true when passed the developer email address with different casing' do
58
- MailSafe::Config.is_internal_address?(@developer_address.upcase).should be_true
58
+ expect(MailSafe::Config.is_internal_address?(@developer_address.upcase)).to be_truthy
59
59
  end
60
60
 
61
61
  it 'returns false when passed another email address' do
62
- MailSafe::Config.is_internal_address?('another-address@domain.com').should be_false
62
+ expect(MailSafe::Config.is_internal_address?('another-address@domain.com')).to be_falsey
63
63
  end
64
64
  end
65
65
 
66
66
  context 'and #developer_email_address has no value' do
67
67
  before(:each) do
68
- MailSafe::Config.should_receive(:developer_email_address).and_return(nil)
68
+ expect(MailSafe::Config).to receive(:developer_email_address).and_return(nil)
69
69
  end
70
70
 
71
71
  it 'raises an error' do
72
- lambda { MailSafe::Config.is_internal_address?('abc@foo.com') }.should raise_error(MailSafe::InvalidConfigSettingError)
72
+ expect { MailSafe::Config.is_internal_address?('abc@foo.com') }.to raise_error(MailSafe::InvalidConfigSettingError)
73
73
  end
74
74
  end
75
75
  end
@@ -80,11 +80,11 @@ describe MailSafe::Config do
80
80
  end
81
81
 
82
82
  it 'returns true if the address matches the regexp' do
83
- MailSafe::Config.is_internal_address?('someone@example.com').should be_true
83
+ expect(MailSafe::Config.is_internal_address?('someone@example.com')).to be_truthy
84
84
  end
85
85
 
86
86
  it 'returns false if the address does not match the regexp' do
87
- MailSafe::Config.is_internal_address?('someone@another-domain.com').should be_false
87
+ expect(MailSafe::Config.is_internal_address?('someone@another-domain.com')).to be_falsey
88
88
  end
89
89
  end
90
90
 
@@ -94,11 +94,11 @@ describe MailSafe::Config do
94
94
  end
95
95
 
96
96
  it 'returns true if the lambda returns true for the given address' do
97
- MailSafe::Config.is_internal_address?('abc@foo.com').should be_true
97
+ expect(MailSafe::Config.is_internal_address?('abc@foo.com')).to be_truthy
98
98
  end
99
99
 
100
100
  it 'returns false if the lambda returns false for the given address' do
101
- MailSafe::Config.is_internal_address?('a-long-address@example.com').should be_false
101
+ expect(MailSafe::Config.is_internal_address?('a-long-address@example.com')).to be_falsey
102
102
  end
103
103
  end
104
104
  end
@@ -110,7 +110,7 @@ describe MailSafe::Config do
110
110
  end
111
111
 
112
112
  it 'returns the configured replacement address' do
113
- MailSafe::Config.get_replacement_address('you@example.com').should == 'me@mydomain.com'
113
+ expect(MailSafe::Config.get_replacement_address('you@example.com')).to eq('me@mydomain.com')
114
114
  end
115
115
  end
116
116
 
@@ -120,7 +120,7 @@ describe MailSafe::Config do
120
120
  end
121
121
 
122
122
  it 'returns the configured replacement address' do
123
- MailSafe::Config.get_replacement_address('you@example.com').should == 'me+you@mydomain.com'
123
+ expect(MailSafe::Config.get_replacement_address('you@example.com')).to eq('me+you@mydomain.com')
124
124
  end
125
125
  end
126
126
 
@@ -132,21 +132,21 @@ describe MailSafe::Config do
132
132
  context 'and #developer_email_address has a value' do
133
133
  before(:each) do
134
134
  @developer_address = 'developer@domain.com'
135
- MailSafe::Config.should_receive(:developer_email_address).at_least(1).and_return(@developer_address)
135
+ expect(MailSafe::Config).to receive(:developer_email_address).at_least(1).and_return(@developer_address)
136
136
  end
137
137
 
138
138
  it 'returns the developer address' do
139
- MailSafe::Config.get_replacement_address('you@example.com').should == @developer_address
139
+ expect(MailSafe::Config.get_replacement_address('you@example.com')).to eq(@developer_address)
140
140
  end
141
141
  end
142
142
 
143
143
  context 'and #developer_email_address has no value' do
144
144
  before(:each) do
145
- MailSafe::Config.should_receive(:developer_email_address).and_return(nil)
145
+ expect(MailSafe::Config).to receive(:developer_email_address).and_return(nil)
146
146
  end
147
147
 
148
148
  it 'raises an error' do
149
- lambda { MailSafe::Config.get_replacement_address('you@example.com') }.should raise_error(MailSafe::InvalidConfigSettingError)
149
+ expect { MailSafe::Config.get_replacement_address('you@example.com') }.to raise_error(MailSafe::InvalidConfigSettingError)
150
150
  end
151
151
  end
152
152
  end
@@ -5,11 +5,7 @@ describe MailSafe do
5
5
  HTML_POSTSCRIPT_PHRASE = /<p>\s+The original recipients were:\s+<\/p>/
6
6
 
7
7
  def deliver_message(message_name, *args)
8
- if ActionMailer::VERSION::MAJOR < 3
9
- TestMailer.send("deliver_#{message_name}", *args)
10
- else
11
- TestMailer.send(message_name, *args).deliver
12
- end
8
+ TestMailer.send(message_name, *args).deliver
13
9
  end
14
10
 
15
11
  RSpec::Matchers.define :have_addresses do |*expected|
@@ -18,34 +14,69 @@ describe MailSafe do
18
14
  end
19
15
  end
20
16
 
17
+ describe 'Delivering a plain text email to internal addresses with empty fields' do
18
+ before(:each) do
19
+ allow(MailSafe::Config).to receive(:is_internal_address?).and_return(true)
20
+ @email = deliver_message(:plain_text_message,
21
+ :to => 'internal-to@address.com')
22
+ end
23
+
24
+ it 'sends the email to the original addresses and dont fail' do
25
+ expect(@email[:to].value).to have_addresses('internal-to@address.com')
26
+ end
27
+ end
28
+
21
29
  describe 'Delivering a plain text email to internal addresses' do
22
30
  before(:each) do
23
- MailSafe::Config.stub(:is_internal_address?).and_return(true)
24
- @email = deliver_message(:plain_text_message, :to => 'internal-to@address.com', :bcc => 'internal-bcc@address.com', :cc => 'internal-cc@address.com')
31
+ allow(MailSafe::Config).to receive(:is_internal_address?).and_return(true)
32
+ @email = deliver_message(:plain_text_message,
33
+ :to => 'internal-to@address.com',
34
+ :bcc => 'internal-bcc@address.com',
35
+ :cc => 'internal-cc@address.com')
36
+ end
37
+
38
+ it 'sends the email to the original addresses' do
39
+ expect(@email.to).to have_addresses('internal-to@address.com')
40
+ expect(@email.cc).to have_addresses('internal-cc@address.com')
41
+ expect(@email.bcc).to have_addresses('internal-bcc@address.com')
42
+ end
43
+
44
+ it 'does not add a post script to the body' do
45
+ expect(@email.body.to_s).not_to match(TEXT_POSTSCRIPT_PHRASE)
46
+ end
47
+ end
48
+
49
+ describe 'Delivering a plain text email to internal addresses with names' do
50
+ before(:each) do
51
+ allow(MailSafe::Config).to receive(:is_internal_address?).and_return(true)
52
+ @email = deliver_message(:plain_text_message,
53
+ :to => 'Internal To <internal-to@address.com>',
54
+ :bcc => 'Internal Bcc <internal-bcc@address.com>',
55
+ :cc => 'Internal Cc <internal-cc@address.com>')
25
56
  end
26
57
 
27
58
  it 'sends the email to the original addresses' do
28
- @email.to.should have_addresses('internal-to@address.com')
29
- @email.cc.should have_addresses('internal-cc@address.com')
30
- @email.bcc.should have_addresses('internal-bcc@address.com')
59
+ expect(@email[:to].value).to have_addresses('Internal To <internal-to@address.com>')
60
+ expect(@email[:cc].value).to have_addresses('Internal Cc <internal-cc@address.com>')
61
+ expect(@email[:bcc].value).to have_addresses('Internal Bcc <internal-bcc@address.com>')
31
62
  end
32
63
 
33
64
  it 'does not add a post script to the body' do
34
- @email.body.to_s.should_not =~ TEXT_POSTSCRIPT_PHRASE
65
+ expect(@email.body.to_s).not_to match(TEXT_POSTSCRIPT_PHRASE)
35
66
  end
36
67
  end
37
68
 
38
69
  describe 'Delivering a plain text email to external addresses' do
39
70
  before(:each) do
40
- MailSafe::Config.stub(:is_internal_address?).and_return(false)
41
- MailSafe::Config.stub(:get_replacement_address).and_return('replacement@example.com')
71
+ allow(MailSafe::Config).to receive(:is_internal_address?).and_return(false)
72
+ allow(MailSafe::Config).to receive(:get_replacement_address).and_return('replacement@example.com')
42
73
  @email = deliver_message(:plain_text_message, :to => 'external-to@address.com', :bcc => 'external-bcc@address.com', :cc => 'external-cc@address.com')
43
74
  end
44
75
 
45
76
  it 'sends the email to the replacement address' do
46
- @email.to.should have_addresses('replacement@example.com')
47
- @email.cc.should have_addresses('replacement@example.com')
48
- @email.bcc.should have_addresses('replacement@example.com')
77
+ expect(@email.to).to have_addresses('replacement@example.com')
78
+ expect(@email.cc).to have_addresses('replacement@example.com')
79
+ expect(@email.bcc).to have_addresses('replacement@example.com')
49
80
  end
50
81
  end
51
82
 
@@ -67,13 +98,13 @@ describe MailSafe do
67
98
  end
68
99
 
69
100
  it 'sends the email to the appropriate address' do
70
- @email.to.should have_addresses('internal1@address.com', 'internal@domain.com')
71
- @email.cc.should have_addresses('internal1@address.com', 'internal2@address.com')
72
- @email.bcc.should have_addresses('internal@domain.com', 'internal@domain.com')
101
+ expect(@email.to).to have_addresses('internal1@address.com', 'internal@domain.com')
102
+ expect(@email.cc).to have_addresses('internal1@address.com', 'internal2@address.com')
103
+ expect(@email.bcc).to have_addresses('internal@domain.com')
73
104
  end
74
105
 
75
106
  it 'adds a plain text post script to the body' do
76
- @email.body.to_s.should =~ TEXT_POSTSCRIPT_PHRASE
107
+ expect(@email.body.to_s).to match(TEXT_POSTSCRIPT_PHRASE)
77
108
  end
78
109
  end
79
110
 
@@ -83,7 +114,7 @@ describe MailSafe do
83
114
  end
84
115
 
85
116
  it 'adds an html post script to the body' do
86
- @email.body.to_s.should =~ HTML_POSTSCRIPT_PHRASE
117
+ expect(@email.body.to_s).to match(HTML_POSTSCRIPT_PHRASE)
87
118
  end
88
119
  end
89
120
 
@@ -97,11 +128,11 @@ describe MailSafe do
97
128
  end
98
129
 
99
130
  it 'adds a text post script to the body of the text part' do
100
- part(/text\/plain/).should =~ TEXT_POSTSCRIPT_PHRASE
131
+ expect(part(/text\/plain/)).to match(TEXT_POSTSCRIPT_PHRASE)
101
132
  end
102
133
 
103
134
  it 'adds an html post script to the body of the html part' do
104
- part(/text\/html/).should =~ HTML_POSTSCRIPT_PHRASE
135
+ expect(part(/text\/html/)).to match(HTML_POSTSCRIPT_PHRASE)
105
136
  end
106
137
  end
107
138
  end
@@ -1,45 +1,37 @@
1
1
  class TestMailer < ActionMailer::Base
2
- # template root must be set for multipart emails, or ActionMailer will throw an exception.
3
- if ActionMailer::VERSION::MAJOR == 2
4
- self.template_root = File.dirname(__FILE__)
5
- end
6
2
 
7
3
  def plain_text_message(options)
8
- setup_recipients(options)
9
- from 'test@mailsafe.org'
10
- subject "Plain text Message Test"
11
- body "Here is the message body."
4
+ setup = setup_recipients(options)
5
+ mail({from: 'test@mailsafe.org',
6
+ subject: "Plain text Message Test"}.update(setup)) do |format|
7
+ format.text { render text: "Here is the message body." }
8
+ end
12
9
  end
13
10
 
14
11
  def html_message(options)
15
- setup_recipients(options)
16
- from 'test@mailsafe.org'
17
- subject "Html Message Test"
18
- body "<p>Here is the message body.</p>"
19
- content_type 'text/html'
20
-
21
- body(body.html_safe) if body.respond_to?(:html_safe)
12
+ setup = setup_recipients(options)
13
+ body = "<p>Here is the message body.</p>"
14
+ body = body.html_safe if body.respond_to?(:html_safe)
15
+ mail({from: 'test@mailsafe.org',
16
+ subject: "Html Message Test"}.update(setup)) do |format|
17
+ format.html { render text: body }
18
+ end
22
19
  end
23
20
 
24
21
  def multipart_message(options)
25
- setup_recipients(options)
26
- from 'test@mailsafe.org'
27
- subject "Html Message Test"
28
-
29
- content_type 'multipart/alternative'
30
-
31
- part :content_type => 'text/plain', :body => "Here is the message body."
32
-
22
+ setup = setup_recipients(options)
33
23
  html_body = "<p>Here is the message body.</p>"
34
24
  html_body = html_body.html_safe if html_body.respond_to?(:html_safe)
35
- part :content_type => 'text/html', :body => html_body
25
+ mail({from: 'test@mailsafe.org',
26
+ subject: "Html Message Test"}.update(setup)) do |format|
27
+ format.text { render text: "Here is the message body." }
28
+ format.html { render text: html_body }
29
+ end
36
30
  end
37
31
 
38
32
  protected
39
33
 
40
34
  def setup_recipients(options)
41
- recipients options[:to]
42
- cc options[:cc]
43
- bcc options[:bcc]
35
+ options.select { |k,_| [:to, :cc, :bcc].include? k }
44
36
  end
45
37
  end
@@ -1,7 +1,6 @@
1
- require 'rubygems'
1
+ require "coveralls"
2
+ Coveralls.wear!
2
3
 
3
- $LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. vendor ginger lib])
4
- require 'ginger'
5
4
  require 'mail_safe'
6
5
  require 'mailers/test_mailer'
7
6
 
@@ -9,9 +8,7 @@ ActionMailer::Base.delivery_method = :test
9
8
 
10
9
  require 'rspec'
11
10
  RSpec.configure do |config|
12
- config.color_enabled = true
13
- config.debug = true
11
+ config.color = true
14
12
  config.filter_run :focus => true
15
13
  config.run_all_when_everything_filtered = true
16
14
  end
17
-
metadata CHANGED
@@ -1,118 +1,167 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mail_safe
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Myron Marston
8
+ - Juan José Conti
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-10-14 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2014-09-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: actionmailer
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 3.0.0
21
+ type: :runtime
23
22
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
27
25
  - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 3
33
- - 6
34
- version: 1.3.6
26
+ - !ruby/object:Gem::Version
27
+ version: 3.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: coveralls
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
35
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
38
71
  name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 3.0.0
80
+ type: :development
39
81
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '3.0'
43
87
  - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 13
46
- segments:
47
- - 1
48
- - 2
49
- - 9
50
- version: 1.2.9
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ - !ruby/object:Gem::Dependency
91
+ name: appraisal
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
51
97
  type: :development
52
- version_requirements: *id002
53
- description:
54
- email: myron.marston@gmail.com
55
- executables: []
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ description: |-
105
+ Mail safe provides a safety net while you"re developing an application that uses ActionMailer.
106
+ It keeps emails from escaping into the wild.
56
107
 
108
+ Once you"ve installed and configured this gem, you can rest assure that your app won"t send
109
+ emails to external email addresses. Instead, emails that would normally be delivered to external
110
+ addresses will be sent to an address of your choosing, and the body of the email will be appended
111
+ with a note stating where the email was originally intended to go.
112
+ email:
113
+ - myron.marston@gmail.com
114
+ - jjconti@gmail.com
115
+ executables: []
57
116
  extensions: []
58
-
59
- extra_rdoc_files:
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - Appraisals
122
+ - Gemfile
123
+ - Gemfile.lock
60
124
  - LICENSE
61
- - README.rdoc
62
- files:
63
- - .document
64
- - .gitignore
65
- - LICENSE
66
- - README.rdoc
125
+ - README.md
67
126
  - Rakefile
68
- - VERSION.yml
69
- - autotest/discover.rb
70
- - ginger_scenarios.rb
127
+ - gemfiles/actionmailer_3_2.gemfile
128
+ - gemfiles/actionmailer_4_0.gemfile
129
+ - gemfiles/actionmailer_4_1.gemfile
71
130
  - lib/mail_safe.rb
72
131
  - lib/mail_safe/address_replacer.rb
73
132
  - lib/mail_safe/config.rb
74
- - lib/mail_safe/rails2_hook.rb
75
- - lib/mail_safe/rails3_hook.rb
133
+ - lib/mail_safe/rails_hook.rb
134
+ - lib/mail_safe/version.rb
76
135
  - mail_safe.gemspec
77
136
  - spec/config_spec.rb
78
137
  - spec/mailer_spec.rb
79
138
  - spec/mailers/test_mailer.rb
80
139
  - spec/spec_helper.rb
81
- has_rdoc: true
82
140
  homepage: http://github.com/myronmarston/mail_safe
83
- licenses: []
84
-
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
85
144
  post_install_message:
86
- rdoc_options:
87
- - --charset=UTF-8
88
- require_paths:
145
+ rdoc_options: []
146
+ require_paths:
89
147
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
- requirements:
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
93
150
  - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
- version: "0"
99
- required_rubygems_version: !ruby/object:Gem::Requirement
100
- none: false
101
- requirements:
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
102
155
  - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
108
158
  requirements: []
109
-
110
159
  rubyforge_project:
111
- rubygems_version: 1.3.7
160
+ rubygems_version: 2.2.2
112
161
  signing_key:
113
- specification_version: 3
162
+ specification_version: 4
114
163
  summary: Keep your ActionMailer emails from escaping into the wild during development.
115
- test_files:
164
+ test_files:
116
165
  - spec/config_spec.rb
117
166
  - spec/mailer_spec.rb
118
167
  - spec/mailers/test_mailer.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
@@ -1,5 +0,0 @@
1
- ---
2
- :build:
3
- :major: 0
4
- :minor: 3
5
- :patch: 1
@@ -1 +0,0 @@
1
- Autotest.add_discovery { 'rspec2' }
@@ -1,43 +0,0 @@
1
- require 'ginger'
2
-
3
- def create_scenario(version)
4
- scenario = Ginger::Scenario.new("Rails #{version}")
5
- scenario[/^action_?mailer$/] = version
6
- scenario[/^action_?pack$/] = version
7
- scenario[/^active_?support$/] = version
8
- scenario
9
- end
10
-
11
- Ginger.configure do |config|
12
- config.aliases["action_mailer"] = "actionmailer"
13
- config.aliases["action_pack"] = "actionpack"
14
- config.aliases["active_support"] = "activesupport"
15
-
16
- # Rails 3 doesn't work on Ruby 1.8.6 or 1.9.1 so skip it.
17
- if RUBY_VERSION == '1.8.7'
18
- rails3 = create_scenario('3.0.0')
19
- rails3['mail'] = '2.2.7'
20
- config.scenarios << rails3
21
- end
22
-
23
- %w( 2.3.9 2.3.8 2.3.5 2.3.4 2.3.3 2.3.2 ).each do |version|
24
- config.scenarios << create_scenario(version)
25
- end
26
-
27
- # Rails 2.3 was the first version that ran on ruby 1.9, so don't bother testing older versions.
28
- if RUBY_VERSION =~ /^1\.8/
29
- %w(
30
- 2.2.3 2.2.2
31
- 2.1.2 2.1.1 2.1.0
32
- 2.0.5 2.0.4 2.0.2 2.0.1 2.0.0
33
- ).each do |version|
34
- config.scenarios << create_scenario(version)
35
- end
36
-
37
- rails126 = Ginger::Scenario.new("Rails 1.2.6")
38
- rails126[/^action_?mailer$/] = '1.3.6'
39
- rails126[/^action_?pack$/] = '1.13.6'
40
- rails126[/^active_?support$/] = '1.4.4'
41
- config.scenarios << rails126
42
- end
43
- end
@@ -1,16 +0,0 @@
1
- module MailSafe
2
- module ActionMailer
3
- def self.included(base)
4
- base.class_eval do
5
- alias_method_chain :deliver!, :mail_safe
6
- end
7
- end
8
-
9
- def deliver_with_mail_safe!(mail = @mail)
10
- MailSafe::AddressReplacer.replace_external_addresses(mail) if mail
11
- deliver_without_mail_safe!(mail)
12
- end
13
- end
14
- end
15
-
16
- ActionMailer::Base.send(:include, MailSafe::ActionMailer) unless ActionMailer::Base.ancestors.include?(MailSafe::ActionMailer)
@@ -1,11 +0,0 @@
1
- require 'mail'
2
-
3
- module MailSafe
4
- class MailInterceptor
5
- def self.delivering_email(mail)
6
- MailSafe::AddressReplacer.replace_external_addresses(mail) if mail
7
- end
8
-
9
- ::Mail.register_interceptor(self)
10
- end
11
- end