mercurius 0.1.4 → 0.1.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: a54e5187f1735963b3bb20d693ac7727b615eebf
4
- data.tar.gz: 1ea72290aa7391f2514078ceb940779180b25b2e
3
+ metadata.gz: c9d092e2bac4a62f415675ab2377d5bbef233fda
4
+ data.tar.gz: 39e988fb569e75e8053352d00fee748cfa6b9028
5
5
  SHA512:
6
- metadata.gz: 1353ad68cbbebaf2fd1465a7def0ae3398f15e333f9b32acf8c875294129f035ba1fcdfe4c1c96c5572f6d2cfe112d3fb581254edfc7cc7fa60a3a2295afb759
7
- data.tar.gz: fe321d6a12ab874e635dcd8d7384fd5d353836cb07abb2e2fa54a48a0aa3675152152d63f9110c883f64486dc4dbede7c5213683673113925e2f3334ad43e85e
6
+ metadata.gz: fbe5d38205bde19ef187af2287c029a30a2d348e874b10c4da3b24c9dd77a92bfb04edf58ee5854e38e7f8d1aa90bb3b87b4c47cdd89789d769c45103ec68fe2
7
+ data.tar.gz: a868cdc0297e17c69e72fbec34c4d615e4570d3d59169de4acb89d59f2230d8c9f7a73ee6ee802e9a83a16cb1b3129a6c7584552a279888ce32d77bed641b297
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  NEW_README.md
19
+ *.sublime-*
@@ -3,7 +3,7 @@ module GCM
3
3
  include ActiveModel::Model
4
4
 
5
5
  def self.special_attrs
6
- [:collapse_key, :time_to_live, :delay_while_idle, :dry_run]
6
+ [:collapse_key, :time_to_live, :delay_while_idle, :dry_run, :notification]
7
7
  end
8
8
 
9
9
  attr_accessor :data
@@ -18,6 +18,7 @@ module GCM
18
18
 
19
19
  def to_h
20
20
  hash = {
21
+ notification: notification,
21
22
  data: data,
22
23
  collapse_key: collapse_key,
23
24
  time_to_live: time_to_live,
@@ -31,6 +32,5 @@ module GCM
31
32
  def ==(that)
32
33
  attributes == that.attributes
33
34
  end
34
-
35
35
  end
36
36
  end
@@ -26,6 +26,12 @@ module GCM
26
26
  result
27
27
  end
28
28
 
29
+ def deliver_topic(notification, topic)
30
+ GCM::Result.new(notification).tap do |result|
31
+ result.process_response connection.write(notification.to_h.merge(to: topic)), [topic]
32
+ end
33
+ end
34
+
29
35
  private
30
36
 
31
37
  def too_many_retries?
@@ -7,6 +7,11 @@ module Mercurius
7
7
  Mercurius::Testing::Result.new notification
8
8
  end
9
9
 
10
+ def deliver_topic(notification, topic)
11
+ Mercurius::Testing::Base.deliveries << Mercurius::Testing::Delivery.new(notification, [topic])
12
+ Mercurius::Testing::Result.new notification
13
+ end
14
+
10
15
  end
11
16
  end
12
17
  end
@@ -1,3 +1,3 @@
1
1
  module Mercurius
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -7,7 +7,7 @@ describe GCM::Service do
7
7
  expect(service.key).to eq GCM.key
8
8
  end
9
9
 
10
- describe '#send' do
10
+ describe '#deliver' do
11
11
  before { stub_request :post, %r[android.googleapis.com/gcm/send] }
12
12
 
13
13
  it 'sends a single message' do
@@ -38,6 +38,17 @@ describe GCM::Service do
38
38
  end
39
39
  end
40
40
 
41
+ describe '#deliver_topic' do
42
+ before { stub_request :post, %r[android.googleapis.com/gcm/send] }
43
+ let(:message) { { notification: { title: 'hello', body: 'world' } } }
44
+
45
+ it 'sends a notification to a topic' do
46
+ service.deliver_topic message, '/topics/global'
47
+ expect(WebMock).to have_requested(:post, %r[android.googleapis.com/gcm/send]).
48
+ with(body: message.merge(to: '/topics/global'))
49
+ end
50
+ end
51
+
41
52
  describe 'response' do
42
53
  context 'success' do
43
54
  before { stub_request :post, %r[android.googleapis.com/gcm/send] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercurius
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Beck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json