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 +4 -4
- data/.gitignore +1 -0
- data/lib/mercurius/gcm/notification.rb +2 -2
- data/lib/mercurius/gcm/service.rb +6 -0
- data/lib/mercurius/testing/service.rb +5 -0
- data/lib/mercurius/version.rb +1 -1
- data/spec/lib/gcm_service_spec.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9d092e2bac4a62f415675ab2377d5bbef233fda
|
4
|
+
data.tar.gz: 39e988fb569e75e8053352d00fee748cfa6b9028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbe5d38205bde19ef187af2287c029a30a2d348e874b10c4da3b24c9dd77a92bfb04edf58ee5854e38e7f8d1aa90bb3b87b4c47cdd89789d769c45103ec68fe2
|
7
|
+
data.tar.gz: a868cdc0297e17c69e72fbec34c4d615e4570d3d59169de4acb89d59f2230d8c9f7a73ee6ee802e9a83a16cb1b3129a6c7584552a279888ce32d77bed641b297
|
data/.gitignore
CHANGED
@@ -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
|
data/lib/mercurius/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe GCM::Service do
|
|
7
7
|
expect(service.key).to eq GCM.key
|
8
8
|
end
|
9
9
|
|
10
|
-
describe '#
|
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
|
+
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-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|