mailsocio_rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a75e8ff2ed1d5344a797f16d0ab268453d890af
4
- data.tar.gz: a07994c2e18aa9e8a1e66ca5b45f351f4b743ec5
3
+ metadata.gz: 62ac0e391ddccb54f35b0cdf6b7840ebf6e412db
4
+ data.tar.gz: a195b1fb7816a2b16357c03dafc338a3b0253400
5
5
  SHA512:
6
- metadata.gz: 0990a84ed8af1d6d7037c2e18288523d0e595092223e18d451a199391a2d80e4f1abf8b337bf21c1ad3928797713414024303a9acb8217b1181454402a254bc7
7
- data.tar.gz: 628cea7c4cef60a12330dedffe86cf15ebfbe9d93aeb89ceed7c83371eb84515c7055f4cf5c4f1753ca0727f10581603f14feaded75515acf6d3e5514752c047
6
+ metadata.gz: 01889521cd0e027b209ed1cc4b0d125719a5c6b564102dd6b35020c06a4385619b1b851f168f6f263bbfdd95cd6a85e673de682aee6a2fa31c6fe1a5fd2f7eff
7
+ data.tar.gz: 17df29c184f737a689ae6aef1868728abb62d7156b9efd77c97d51aeec3215a6427015bbd06e2d7b947e20f8d51c691bd000ba53484627bdd24690913b4563d6
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in mailsocio-action-mailer.gemspec
4
4
  gemspec
5
+
6
+ group :development, :test do
7
+ gem "rspec"
8
+ gem "pry"
9
+ gem "pry-doc"
10
+ end
data/README.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # Mailsocio Rails
2
2
 
3
- ActionMailer plugin to use mailsocio to deliver emails
3
+ Плагин к ActionMailer для использования mailsocio для отправки электронной почты.
4
4
 
5
- ## Installation
5
+ ## Установка
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Строчка в Гемфайл:
8
8
 
9
9
  ```ruby
10
10
  gem 'mailsocio_rails'
11
11
  ```
12
12
 
13
- And then execute `bundle`.
13
+ Ну и выполните `bundle`.
14
14
 
15
- ## Usage
15
+ ## Использование
16
16
 
17
- Configure ActionMailer as follows:
17
+ Сконфигурируйте ActionMailer вот так:
18
18
 
19
19
  ```ruby
20
20
  # config/application.rb
@@ -26,30 +26,4 @@ config.action_mailer.mailsocio_settings = {
26
26
  }
27
27
  ```
28
28
 
29
- You're done!
30
-
31
- ## Customization
32
-
33
- You can also override gem defaults:
34
-
35
- ```ruby
36
- config.action_mailer.mailsocio_settings = {
37
- account_id: '<your account id>',
38
- api_key: '<your account api key>',
39
-
40
- address: 'app.mailarbor.com', # This can be any smtp server
41
- port: 25, # that is capable to
42
- domain: 'localhost.localdomain' # deliver emails.
43
-
44
- mailsocio_recipient: 'submit@app.mailarbor.com', # If you change this,
45
- # bad things can happen.
46
- }
47
- ```
48
-
49
- ## Contributing
50
-
51
- 1. Fork it ( https://github.com/[my-github-username]/mailsocio_rails/fork )
52
- 2. Create your feature branch (`git checkout -b my-new-feature`)
53
- 3. Commit your changes (`git commit -am 'Add some feature'`)
54
- 4. Push to the branch (`git push origin my-new-feature`)
55
- 5. Create a new Pull Request
29
+ Готово!
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -36,8 +36,14 @@ module MailsocioRails
36
36
 
37
37
  def addresses_from(mail, *methods)
38
38
  methods.flat_map { |method|
39
- (mail.send(method) || []).zip(mail[method].try(:display_names) || [])
39
+ (mail.send(method) || []).zip(really_try(mail[method], :display_names) || [])
40
40
  }
41
41
  end
42
+
43
+ def really_try(obj, meth, *args, &block)
44
+ obj.send(meth, *args, &block)
45
+ rescue NameError
46
+ nil
47
+ end
42
48
  end
43
49
  end
@@ -1,3 +1,3 @@
1
1
  module MailsocioRails
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "mailsocio rails main file" do
4
+ it "adds delivery_method" do
5
+ expect(ActionMailer::Base.delivery_methods).to include(mailsocio: MailsocioRails::Delivery)
6
+ end
7
+
8
+ it "adds configuration method" do
9
+ expect(ActionMailer::Base).to respond_to(:mailsocio_settings=)
10
+ end
11
+ end
@@ -0,0 +1,91 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe MailsocioRails::Delivery do
4
+ before(:each) do
5
+ # Reset all defaults back to original state
6
+ Mail.defaults do
7
+ delivery_method MailsocioRails::Delivery, {
8
+ account_id: "some_id",
9
+ api_key: "some_secret"
10
+ }
11
+ end
12
+ MockSMTP.clear_deliveries
13
+ end
14
+
15
+ describe "general usage" do
16
+ it "delivers to mailsocio gateway" do
17
+ mail = Mail.deliver do
18
+ from "roger@moore.com"
19
+ to "marcel@amont.com"
20
+ subject "invalid RFC2822"
21
+ end
22
+
23
+ expect(MockSMTP.deliveries[0].to).to eq [Mail.delivery_method.settings[:mailsocio_recipient]]
24
+ end
25
+
26
+ it "wipes to, cc and bcc" do
27
+ mail = Mail.deliver do
28
+ from "roger@moore.com"
29
+ to "marcel@amont.com"
30
+ cc "moore@amont.com"
31
+ bcc "luke@amont.com"
32
+ subject "invalid RFC2822"
33
+ end
34
+
35
+ expect(MockSMTP.deliveries[0].mail.to).not_to eq ["marcel@amont.com"]
36
+ expect(MockSMTP.deliveries[0].mail.cc).not_to be
37
+ expect(MockSMTP.deliveries[0].mail.bcc).not_to be
38
+ end
39
+
40
+ it "places to and cc to X-To" do
41
+ mail = Mail.deliver do
42
+ from "roger@moore.com"
43
+ to "Dr.Jones <marcel@amont.com>, <unnamed@gmail.com>"
44
+ cc "AnotherGuy <mike@twitter.com>"
45
+ subject "invalid RFC2822"
46
+ end
47
+
48
+ expected_to = {
49
+ "marcel@amont.com" => { "name": "Dr.Jones" },
50
+ "unnamed@gmail.com" => { "name" => nil },
51
+ "mike@twitter.com" => {"name" => "AnotherGuy"}
52
+ }
53
+ expect(MockSMTP.deliveries[0].mail["X-To"].to_s).to eq expected_to.to_json
54
+ end
55
+
56
+ it "places bcc to X-Bcc" do
57
+ mail = Mail.deliver do
58
+ from "roger@moore.com"
59
+ to "marcel@amont.com"
60
+ bcc "luke@amont.com"
61
+ subject "invalid RFC2822"
62
+ end
63
+
64
+ expect(MockSMTP.deliveries[0].mail["X-Bcc"].to_s).to eq "luke@amont.com"
65
+ end
66
+
67
+ it "preserves from and body" do
68
+ mail = Mail.deliver do
69
+ from "roger@moore.com"
70
+ to "marcel@amont.com"
71
+ subject "invalid RFC2822"
72
+ body "Oh come on!"
73
+ end
74
+
75
+ expect(MockSMTP.deliveries[0].from).to eq "roger@moore.com"
76
+ expect(MockSMTP.deliveries[0].mail.body.to_s).to eq "Oh come on!"
77
+ end
78
+
79
+ it "adds account id and api key" do
80
+ mail = Mail.deliver do
81
+ from "roger@moore.com"
82
+ to "marcel@amont.com"
83
+ subject "invalid RFC2822"
84
+ end
85
+
86
+ expect(MockSMTP.deliveries[0].mail["X-Account-Id"].to_s).to eq "some_id"
87
+ expect(MockSMTP.deliveries[0].mail["X-Api-Key"].to_s).to eq "some_secret"
88
+ end
89
+
90
+ end
91
+ end
@@ -0,0 +1,15 @@
1
+ require 'bundler/setup'
2
+
3
+ Bundler.require(:default, :test)
4
+
5
+ require (Pathname.new(__FILE__).dirname + '../lib/mailsocio_rails').expand_path
6
+
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ class Net::SMTP
11
+ def self.new(*args)
12
+ MockSMTP.new
13
+ end
14
+ end
15
+ end
File without changes
@@ -0,0 +1,49 @@
1
+ class MockSMTP
2
+
3
+ def self.deliveries
4
+ @@deliveries
5
+ end
6
+
7
+ def initialize
8
+ @@deliveries = []
9
+ end
10
+
11
+ def sendmail(mail, from, to)
12
+ @@deliveries << OpenStruct.new(raw: mail, from: from, to: to, mail: Mail.read_from_string(mail))
13
+ 'OK'
14
+ end
15
+
16
+ def start(*args)
17
+ if block_given?
18
+ return yield(self)
19
+ else
20
+ return self
21
+ end
22
+ end
23
+
24
+ def finish
25
+ return true
26
+ end
27
+
28
+ def self.clear_deliveries
29
+ @@deliveries = []
30
+ end
31
+
32
+ # in the standard lib: net/smtp.rb line 577
33
+ # a TypeError is thrown unless this arg is a
34
+ # kind of OpenSSL::SSL::SSLContext
35
+ def enable_tls(context = nil)
36
+ if context && context.kind_of?(OpenSSL::SSL::SSLContext)
37
+ true
38
+ elsif context
39
+ raise TypeError,
40
+ "wrong argument (#{context.class})! "+
41
+ "(Expected kind of OpenSSL::SSL::SSLContext)"
42
+ end
43
+ end
44
+
45
+ def enable_starttls_auto(context = :dummy_ssl_context)
46
+ true
47
+ end
48
+
49
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailsocio_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anahoret team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -61,21 +61,21 @@ dependencies:
61
61
  description: |
62
62
  # Mailsocio Rails
63
63
 
64
- ActionMailer plugin to use mailsocio to deliver emails
64
+ Плагин к ActionMailer для использования mailsocio для отправки электронной почты.
65
65
 
66
- ## Installation
66
+ ## Установка
67
67
 
68
- Add this line to your application's Gemfile:
68
+ Строчка в Гемфайл:
69
69
 
70
70
  ```ruby
71
71
  gem 'mailsocio_rails'
72
72
  ```
73
73
 
74
- And then execute `bundle`.
74
+ Ну и выполните `bundle`.
75
75
 
76
- ## Usage
76
+ ## Использование
77
77
 
78
- Configure ActionMailer as follows:
78
+ Сконфигурируйте ActionMailer вот так:
79
79
 
80
80
  ```ruby
81
81
  # config/application.rb
@@ -87,33 +87,7 @@ description: |
87
87
  }
88
88
  ```
89
89
 
90
- You're done!
91
-
92
- ## Customization
93
-
94
- You can also override gem defaults:
95
-
96
- ```ruby
97
- config.action_mailer.mailsocio_settings = {
98
- account_id: '<your account id>',
99
- api_key: '<your account api key>',
100
-
101
- address: 'app.mailarbor.com', # This can be any smtp server
102
- port: 25, # that is capable to
103
- domain: 'localhost.localdomain' # deliver emails.
104
-
105
- mailsocio_recipient: 'submit@app.mailarbor.com', # If you change this,
106
- # bad things can happen.
107
- }
108
- ```
109
-
110
- ## Contributing
111
-
112
- 1. Fork it ( https://github.com/[my-github-username]/mailsocio_rails/fork )
113
- 2. Create your feature branch (`git checkout -b my-new-feature`)
114
- 3. Commit your changes (`git commit -am 'Add some feature'`)
115
- 4. Push to the branch (`git push origin my-new-feature`)
116
- 5. Create a new Pull Request
90
+ Готово!
117
91
  email:
118
92
  - dmitriy.kiriyenko@anahoret.com
119
93
  executables: []
@@ -121,6 +95,7 @@ extensions: []
121
95
  extra_rdoc_files: []
122
96
  files:
123
97
  - ".gitignore"
98
+ - ".rspec"
124
99
  - Gemfile
125
100
  - LICENSE.txt
126
101
  - README.md
@@ -129,6 +104,11 @@ files:
129
104
  - lib/mailsocio_rails/delivery.rb
130
105
  - lib/mailsocio_rails/version.rb
131
106
  - mailsocio_rails.gemspec
107
+ - spec/lib/mailsocio_rails.rb
108
+ - spec/lib/mailsocio_rails/delivery_spec.rb
109
+ - spec/spec_helper.rb
110
+ - spec/support/.keep
111
+ - spec/support/mock_smtp.rb
132
112
  homepage: http://app.mailarbor.com
133
113
  licenses:
134
114
  - MIT
@@ -153,4 +133,10 @@ rubygems_version: 2.4.5
153
133
  signing_key:
154
134
  specification_version: 4
155
135
  summary: ActionMailer plugin to use mailsocio to deliver emails
156
- test_files: []
136
+ test_files:
137
+ - spec/lib/mailsocio_rails.rb
138
+ - spec/lib/mailsocio_rails/delivery_spec.rb
139
+ - spec/spec_helper.rb
140
+ - spec/support/.keep
141
+ - spec/support/mock_smtp.rb
142
+ has_rdoc: