mailboxer 0.12.5 → 0.13.0

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: 4d3dc85202d707157141672e526db6f126cd6969
4
- data.tar.gz: dcfd20e099d3355a6c3f0ccc8cc7817ff05262b4
3
+ metadata.gz: 76560ca95f622b27cb610d4e333f5f07da0145f0
4
+ data.tar.gz: 5865f0a7a71a57403bc459cae32aba44b2a3ca4e
5
5
  SHA512:
6
- metadata.gz: 339eb28db3520ce5fd59ba8898358aecd98afbd98d644dfeb1f09e4f9f0a7052e6168e5cf492e79c7ffb1bd9849daaaec68faf3a35cbcdfa36ff6f3b15862d8d
7
- data.tar.gz: d8dabb5d52bc1a7f108e96d00e7eb4ee2f62b1d93b630660f8461d733ec384591fa853277d0810efccd3763e5466533377fc1c3d1bb5bd21d33bf501f1a68ed7
6
+ metadata.gz: 39519d696f2bc2240d62c3e79738d195148d817cf105cf47a75a74d717c70c58823787bd3c9e0fe6f16977ab731ee858524535b22a5f5755ad5b033d3ad53dd8
7
+ data.tar.gz: 87c71b2d1e53a05dc3d27842b7dd25577610d28e1016dc3b61e2d190f653e0fcb5bd25cb613e83c6a71df92eb20a66a78759ecb89251db76378ed81d6620f187
data/README.md CHANGED
@@ -25,7 +25,7 @@ Mailboxer was born from the great, but outdated, code from [lpsergi /
25
25
  acts*as*messageable](https://github.com/psergi/acts_as_messageable).
26
26
 
27
27
  We are now working to make exhaustive documentation and some wiki
28
- pages in order to make it even easier to use the gem to its full potencial.
28
+ pages in order to make it even easier to use the gem to its full potential.
29
29
  Please, give us some time if you find something missing or [ask for
30
30
  it](https://github.com/ging/mailboxer/issues). You can also find us on the [Gitter room for this repo](https://gitter.im/mailboxer/mailboxer). Join us there to talk.
31
31
 
@@ -82,7 +82,7 @@ $ rake db:migrate
82
82
 
83
83
  ### Emails
84
84
 
85
- We are now adding support for sending emails when a Notification or a Message is sent to one or more recipients. You should modify the mailboxer initializer (/config/initializer/mailboxer.rb) to edit these settings.
85
+ We are now adding support for sending emails when a Notification or a Message is sent to one or more recipients. You should modify the mailboxer initializer (/config/initializer/mailboxer.rb) to edit these settings:
86
86
 
87
87
  ```ruby
88
88
  Mailboxer.setup do |config|
@@ -94,7 +94,7 @@ Mailboxer.setup do |config|
94
94
  end
95
95
  ```
96
96
 
97
- You can change the way in which emails are delivered by specifying a custom implementation of notification and message mailers
97
+ You can change the way in which emails are delivered by specifying a custom implementation of notification and message mailers:
98
98
 
99
99
  ```ruby
100
100
  Mailboxer.setup do |config|
@@ -142,7 +142,7 @@ end
142
142
  You may change whatever you want or need. For example:
143
143
 
144
144
  ```ruby
145
- config.email_method = :notifications_email
145
+ config.email_method = :notification_email
146
146
  config.name_method = :display_name
147
147
  ```
148
148
 
@@ -160,7 +160,7 @@ class User < ActiveRecord::Base
160
160
  end
161
161
  ```
162
162
 
163
- You are not limited to the User model. You can use Mailboxer in any other model and use it in serveral different models. If you have ducks and cylons in your application and you want to exchange messages as if they were the same, just add `acts_as_messageable` to each one and you will be able to send duck-duck, duck-cylon, cylon-duck and cylon-cylon messages. Of course, you can extend it for as many classes as you need.
163
+ You are not limited to the User model. You can use Mailboxer in any other model and use it in several different models. If you have ducks and cylons in your application and you want to exchange messages as if they were the same, just add `acts_as_messageable` to each one and you will be able to send duck-duck, duck-cylon, cylon-duck and cylon-cylon messages. Of course, you can extend it for as many classes as you need.
164
164
 
165
165
  Example:
166
166
 
@@ -314,4 +314,4 @@ If you need a GUI you should take a look a these links:
314
314
  * [fabianoalmeida](https://github.com/ging/mailboxer/commits/master?author=fabianoalmeida) (Fabiano Almeida)
315
315
  * [supremebeing7](https://github.com/ging/mailboxer/commits/master?author=supremebeing7) (Mark J. Lehman)
316
316
  * [searsaw](https://github.com/mailboxer/mailboxer/commits/master?author=searsaw) (Alex Sears)
317
- * [joshblour](https://github.com/mailboxer/mailboxer/commits/master?author=joshblour) (Yonah Forst)
317
+ * [joshblour](https://github.com/mailboxer/mailboxer/commits/master?author=joshblour) (Yonah Forst)
@@ -33,13 +33,14 @@ class Mailboxer::Notification < ActiveRecord::Base
33
33
 
34
34
  class << self
35
35
  #Sends a Notification to all the recipients
36
- def notify_all(recipients, subject, body, obj = nil, sanitize_text = true, notification_code=nil, send_mail=true)
36
+ def notify_all(recipients, subject, body, obj = nil, sanitize_text = true, notification_code=nil, send_mail=true, sender=nil)
37
37
  notification = Mailboxer::NotificationBuilder.new({
38
38
  :recipients => recipients,
39
39
  :subject => subject,
40
40
  :body => body,
41
41
  :notified_object => obj,
42
- :notification_code => notification_code
42
+ :notification_code => notification_code,
43
+ :sender => sender
43
44
  }).build
44
45
 
45
46
  notification.deliver sanitize_text, send_mail
@@ -1,5 +1,5 @@
1
1
  # Database foreign keys
2
- require 'foreigner'
2
+ require 'foreigner' if Rails.version < "4.2.0"
3
3
  require 'carrierwave'
4
4
  begin
5
5
  require 'sunspot_rails'
@@ -56,8 +56,8 @@ module Mailboxer
56
56
  end
57
57
 
58
58
  #Sends a notification to the messageable
59
- def notify(subject,body,obj = nil,sanitize_text=true,notification_code=nil,send_mail=true)
60
- Mailboxer::Notification.notify_all([self],subject,body,obj,sanitize_text,notification_code,send_mail)
59
+ def notify(subject,body,obj = nil,sanitize_text=true,notification_code=nil,send_mail=true,sender=nil)
60
+ Mailboxer::Notification.notify_all([self],subject,body,obj,sanitize_text,notification_code,send_mail,sender)
61
61
  end
62
62
 
63
63
  #Sends a messages, starting a new conversation, with the messageable
@@ -1,3 +1,3 @@
1
1
  module Mailboxer
2
- VERSION = "0.12.5"
2
+ VERSION = "0.13.0"
3
3
  end
@@ -46,6 +46,13 @@ describe Mailboxer::Notification do
46
46
  expect(notification).to be_is_read(@entity1)
47
47
  end
48
48
 
49
+ it "should be able to specify a sender for a notification" do
50
+ @entity1.notify("Subject", "Body", nil, true, nil, true, @entity3)
51
+ expect(@entity1.mailbox.receipts.size).to eq 1
52
+ notification = @entity1.mailbox.receipts.first.notification
53
+ expect(notification.sender).to eq(@entity3)
54
+ end
55
+
49
56
  it "should notify several users" do
50
57
  recipients = [@entity1,@entity2,@entity3]
51
58
  Mailboxer::Notification.notify_all(recipients,"Subject","Body")
@@ -99,6 +106,25 @@ describe Mailboxer::Notification do
99
106
  expect(notification.body).to eq "Body"
100
107
  end
101
108
 
109
+ it "should be able to specify a sender for a notification" do
110
+ Mailboxer::Notification.notify_all(@entity1,"Subject","Body", nil, true, nil, false, @entity3)
111
+
112
+ #Check getting ALL receipts
113
+ expect(@entity1.mailbox.receipts.size).to eq 1
114
+ receipt = @entity1.mailbox.receipts.first
115
+ notification = receipt.notification
116
+ expect(notification.subject).to eq "Subject"
117
+ expect(notification.body).to eq "Body"
118
+ expect(notification.sender).to eq @entity3
119
+
120
+ #Check getting NOTIFICATION receipts only
121
+ expect(@entity1.mailbox.notifications.size).to eq 1
122
+ notification = @entity1.mailbox.notifications.first
123
+ expect(notification.subject).to eq "Subject"
124
+ expect(notification.body).to eq "Body"
125
+ expect(notification.sender).to eq @entity3
126
+ end
127
+
102
128
  describe "scopes" do
103
129
  let(:scope_user) { FactoryGirl.create(:user) }
104
130
  let!(:notification) { scope_user.notify("Body", "Subject").notification }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailboxer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Casanova Cuesta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreigner
@@ -320,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
320
320
  version: '0'
321
321
  requirements: []
322
322
  rubyforge_project:
323
- rubygems_version: 2.2.2
323
+ rubygems_version: 2.4.8
324
324
  signing_key:
325
325
  specification_version: 4
326
326
  summary: Messaging system for rails apps.