notifiable-mpns-nverinaud 0.1.1 → 0.2.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: 6de32f33fe358a05bdd9e9b99c5809d78de94d25
4
- data.tar.gz: af61998ff6a22c8c6d590d38b18d5520a00e2ae2
3
+ metadata.gz: 0f8ed9de33d83bdef31684a88eb5d124447a27db
4
+ data.tar.gz: 4fab56b8f4c50a65c9c95a0f110a1cd01eb6b899
5
5
  SHA512:
6
- metadata.gz: 27ec98f3c368944e0a2a86ab9c9f447060bde7db600383c2cee10aab52e4ba1a068b0af626468637009a357f8f64d59b0986a979b6ae15350d2d448a6c7e9dfb
7
- data.tar.gz: cbee5b7fd1cfbdfcf5a1e60c29a4ef3a160874be599cc41379467a22edddbbe2e02b4a57ef5469298da2fac6f8fe45f46a3f58afc22cd2805324e16445f8bf57
6
+ metadata.gz: 9af490e671a5acc7f8352adc3366afa1f7e847c335bb0c766f42c2771ee4fa29c225daa972d7836270a30f2949451689e5ea4d0acfad459481a12383fcf2dcb7
7
+ data.tar.gz: 10babfb594c69f2aea56e419f8b7d38b4af8619078b05c6f3e5fefbc2ae127cb3eee8c07b9714f67c2bff9b880142f5ee2a3627efa34193becf4505117657faf
@@ -8,9 +8,22 @@ module Notifiable
8
8
 
9
9
  protected
10
10
  def enqueue(notification, device_token)
11
+
12
+ data = {}
11
13
 
12
- options = {content: notification.message}
13
- response = MicrosoftPushNotificationService.send_notification device_token.token, :toast, options
14
+ # title
15
+ title = notification.provider_value(device_token.provider, :title)
16
+ data[:title] = title if title
17
+
18
+ # content
19
+ content = notification.provider_value(device_token.provider, :message)
20
+ data[:content] = content if content
21
+
22
+ # custom attributes
23
+ custom_attributes = notification.provider_value(device_token.provider, :params)
24
+ data.merge!({:params => custom_attributes}) if custom_attributes
25
+
26
+ response = MicrosoftPushNotificationService.send_notification device_token.token, :toast, data
14
27
 
15
28
  case response.code.to_i
16
29
  when 200
@@ -1,7 +1,7 @@
1
1
  module Notifiable
2
2
  module Mpns
3
3
  module Nverinaud
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "notifiable-rails"
21
+ spec.add_dependency "notifiable-rails", ">=0.4.0"
22
22
  spec.add_dependency "ruby-mpns", "~> 1.2.1"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -3,20 +3,53 @@ require 'spec_helper'
3
3
  describe Notifiable::Mpns::Nverinaud::SingleNotifier do
4
4
 
5
5
  let(:m) { Notifiable::Mpns::Nverinaud::SingleNotifier.new }
6
- let(:n) { Notifiable::Notification.create(:message => "Test message") }
7
6
  let(:d) { Notifiable::DeviceToken.create(:token => "http://db3.notify.live.net/throttledthirdparty/01.00/123456789123456798", :provider => :mpns) }
8
7
  let(:u) { User.new(d) }
9
8
 
10
- it "sends a single mpns notification" do
9
+ it "sends an mpns notification with a title" do
10
+ n = Notifiable::Notification.create(:payload => {:mpns => {:title => "A title"}})
11
+
12
+ stub_request(:post, d.token)
13
+
14
+ m.send_notification(n, d)
15
+ m.close
16
+
17
+ Notifiable::NotificationDeviceToken.count.should == 1
18
+ a_request(:post, d.token)
19
+ .with(:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><wp:Notification xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1>A title</wp:Text1><wp:Text2></wp:Text2><wp:Param></wp:Param></wp:Toast></wp:Notification>")
20
+ .should have_been_made.once
21
+ end
22
+
23
+ it "sends a single mpns notification with content" do
24
+ n = Notifiable::Notification.create(:message => "A message")
11
25
  stub_request(:post, d.token)
12
26
 
13
27
  m.send_notification(n, d)
14
28
  m.close
15
29
 
16
30
  Notifiable::NotificationDeviceToken.count.should == 1
31
+ a_request(:post, d.token)
32
+ .with(:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><wp:Notification xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1></wp:Text1><wp:Text2>A message</wp:Text2><wp:Param></wp:Param></wp:Toast></wp:Notification>")
33
+ .should have_been_made.once
34
+ end
35
+
36
+ it "sends custom attributes" do
37
+ n = Notifiable::Notification.create(:payload => {:mpns => {:params => {:an_object_id => 123456}}})
38
+
39
+ stub_request(:post, d.token)
40
+
41
+ m.send_notification(n, d)
42
+ m.close
43
+
44
+ Notifiable::NotificationDeviceToken.count.should == 1
45
+ a_request(:post, d.token)
46
+ .with(:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><wp:Notification xmlns:wp=\"WPNotification\"><wp:Toast><wp:Text1></wp:Text1><wp:Text2></wp:Text2><wp:Param>?an_object_id=123456</wp:Param></wp:Toast></wp:Notification>")
47
+ .should have_been_made.once
17
48
  end
18
49
 
19
- it "de-registers a device on receiving a 404 status from MPNS" do
50
+ it "de-registers a device on receiving a 404 status from MPNS" do
51
+ n = Notifiable::Notification.create(:message => "A message")
52
+
20
53
  stub_request(:post, d.token).to_return(:status => 404)
21
54
 
22
55
  m.send_notification(n, d)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifiable-mpns-nverinaud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: notifiable-rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-mpns
29
29
  requirement: !ruby/object:Gem::Requirement