device_cloud 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/device_cloud/push_notification/base_notification.rb +5 -0
- data/lib/device_cloud/push_notification/data_notification.rb +0 -10
- data/lib/device_cloud/version.rb +1 -1
- data/spec/device_cloud/push_notification/base_notification_spec.rb +17 -0
- data/spec/device_cloud/push_notification/data_notification_spec.rb +0 -13
- data/spec/version_spec.rb +1 -1
- metadata +1 -1
@@ -1,15 +1,5 @@
|
|
1
1
|
module DeviceCloud
|
2
2
|
class PushNotification::DataNotification < PushNotification::BaseNotification
|
3
|
-
def initialize(file_data)
|
4
|
-
@file_data = file_data
|
5
|
-
@id = data['id']
|
6
|
-
end
|
7
|
-
|
8
|
-
def file_name
|
9
|
-
return '' unless id
|
10
|
-
id['fdName']
|
11
|
-
end
|
12
|
-
|
13
3
|
def handle!
|
14
4
|
DeviceCloud.data_notification_handler.call(self)
|
15
5
|
end
|
data/lib/device_cloud/version.rb
CHANGED
@@ -29,6 +29,10 @@ describe DeviceCloud::PushNotification::BaseNotification do
|
|
29
29
|
its(:value) { should eq data['value'] }
|
30
30
|
end
|
31
31
|
|
32
|
+
describe "#data" do
|
33
|
+
its(:data) { should eq file_data.data }
|
34
|
+
end
|
35
|
+
|
32
36
|
describe "#handle!" do
|
33
37
|
it "should raise NotImplementedError" do
|
34
38
|
expect{subject.handle!}.to raise_error NotImplementedError
|
@@ -48,4 +52,17 @@ describe DeviceCloud::PushNotification::BaseNotification do
|
|
48
52
|
its(:mac_address) { should eq '' }
|
49
53
|
end
|
50
54
|
end
|
55
|
+
|
56
|
+
describe "#file_name" do
|
57
|
+
context 'when id is present' do
|
58
|
+
its(:file_name) { should eq data['id']['fdName']}
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when id is nil' do
|
62
|
+
before(:each) do
|
63
|
+
data['id'] = nil
|
64
|
+
end
|
65
|
+
its(:file_name) { should eq '' }
|
66
|
+
end
|
67
|
+
end
|
51
68
|
end
|
@@ -27,17 +27,4 @@ describe DeviceCloud::PushNotification::DataNotification do
|
|
27
27
|
expect(handled_data).to eq subject
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
|
-
describe "#file_name" do
|
32
|
-
context 'when id is present' do
|
33
|
-
its(:file_name) { should eq data['id']['fdName']}
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'when id is nil' do
|
37
|
-
before(:each) do
|
38
|
-
data['id'] = nil
|
39
|
-
end
|
40
|
-
its(:file_name) { should eq '' }
|
41
|
-
end
|
42
|
-
end
|
43
30
|
end
|
data/spec/version_spec.rb
CHANGED