one_signal 1.0.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +24 -0
- data/.github/workflows/gem-push.yml +30 -0
- data/CHANGELOG.txt +17 -1
- data/LICENSE +158 -668
- data/README.md +32 -10
- data/bin/console +18 -0
- data/bin/setup +18 -0
- data/lib/one_signal/app.rb +16 -14
- data/lib/one_signal/notification.rb +33 -18
- data/lib/one_signal/one_signal.rb +32 -20
- data/lib/one_signal/player.rb +52 -17
- data/lib/one_signal/version.rb +1 -1
- data/one_signal.gemspec +2 -2
- data/test/app_test.rb +47 -6
- data/test/helper.rb +1 -1
- data/test/notification_test.rb +64 -8
- data/test/one_signal_test.rb +17 -14
- data/test/player_test.rb +116 -11
- metadata +10 -8
- data/.travis.yml +0 -5
data/lib/one_signal/version.rb
CHANGED
data/one_signal.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path('lib/one_signal/version')
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.required_ruby_version = '>= 2.
|
5
|
-
s.add_development_dependency 'rake', '~>
|
4
|
+
s.required_ruby_version = '>= 2.0.0'
|
5
|
+
s.add_development_dependency 'rake', '~> 12.0'
|
6
6
|
s.add_development_dependency 'mocha', '~> 1.1'
|
7
7
|
s.add_development_dependency 'dotenv', '~> 2.0'
|
8
8
|
s.add_development_dependency 'minitest', '~> 5.8'
|
data/test/app_test.rb
CHANGED
@@ -15,40 +15,81 @@ class AppTest < MiniTest::Test
|
|
15
15
|
widget: "acme"
|
16
16
|
}
|
17
17
|
|
18
|
-
@user_auth_key = "fake user auth key"
|
19
|
-
|
18
|
+
@user_auth_key = "fake user auth key 123"
|
19
|
+
@user_auth_key_2 = "fake user auth key 456"
|
20
|
+
@opts = {
|
21
|
+
key1: "value1",
|
22
|
+
key2: "vaue2",
|
23
|
+
auth_key: @user_auth_key_2
|
24
|
+
}
|
25
|
+
@default_opts = {
|
26
|
+
auth_key: @user_auth_key
|
27
|
+
}
|
28
|
+
OneSignal::OneSignal.user_auth_key = @user_auth_key
|
20
29
|
end
|
21
30
|
|
22
31
|
def test_all
|
23
32
|
response = mock_response_ok
|
24
33
|
OneSignal::OneSignal.expects(:send_get_request)
|
25
|
-
.with(uri: @all_uri, params: @params)
|
34
|
+
.with(uri: @all_uri, params: @params, opts: @default_opts)
|
26
35
|
.returns(response)
|
27
36
|
assert_equal response, OneSignal::App.all(params: @params)
|
28
37
|
end
|
29
38
|
|
39
|
+
def test_all_with_auth_key
|
40
|
+
response = mock_response_ok
|
41
|
+
OneSignal::OneSignal.expects(:send_get_request)
|
42
|
+
.with(uri: @all_uri, params: @params, opts: @opts)
|
43
|
+
.returns(response)
|
44
|
+
assert_equal response, OneSignal::App.all(params: @params, opts: @opts)
|
45
|
+
end
|
46
|
+
|
30
47
|
def test_get
|
31
48
|
response = mock_response_ok
|
32
49
|
OneSignal::OneSignal.expects(:send_get_request)
|
33
|
-
.with(uri: @get_uri, params: nil)
|
50
|
+
.with(uri: @get_uri, params: nil, opts: @default_opts)
|
34
51
|
.returns(response)
|
35
52
|
assert_equal response, OneSignal::App.get(id: @app_id)
|
36
53
|
end
|
37
54
|
|
55
|
+
def test_get_with_auth_key
|
56
|
+
response = mock_response_ok
|
57
|
+
OneSignal::OneSignal.expects(:send_get_request)
|
58
|
+
.with(uri: @get_uri, params: nil, opts: @opts)
|
59
|
+
.returns(response)
|
60
|
+
assert_equal response, OneSignal::App.get(id: @app_id, opts: @opts)
|
61
|
+
end
|
62
|
+
|
38
63
|
def test_create
|
39
64
|
response = mock_response_ok
|
40
65
|
OneSignal::OneSignal.expects(:send_post_request)
|
41
|
-
.with(uri: @create_uri, body: @params)
|
66
|
+
.with(uri: @create_uri, body: @params, opts: @default_opts)
|
42
67
|
.returns(response)
|
43
68
|
assert_equal response, OneSignal::App.create(params: @params)
|
44
69
|
end
|
45
70
|
|
71
|
+
def test_create_with_auth_key
|
72
|
+
response = mock_response_ok
|
73
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
74
|
+
.with(uri: @create_uri, body: @params, opts: @opts)
|
75
|
+
.returns(response)
|
76
|
+
assert_equal response, OneSignal::App.create(params: @params, opts: @opts)
|
77
|
+
end
|
78
|
+
|
46
79
|
def test_update
|
47
80
|
response = mock_response_ok
|
48
81
|
OneSignal::OneSignal.expects(:send_put_request)
|
49
|
-
.with(uri: @update_uri, body: @params)
|
82
|
+
.with(uri: @update_uri, body: @params, opts: @default_opts)
|
50
83
|
.returns(response)
|
51
84
|
assert_equal response, OneSignal::App.update(id: @app_id, params: @params)
|
52
85
|
end
|
53
86
|
|
87
|
+
def test_update_with_auth_key
|
88
|
+
response = mock_response_ok
|
89
|
+
OneSignal::OneSignal.expects(:send_put_request)
|
90
|
+
.with(uri: @update_uri, body: @params, opts: @opts)
|
91
|
+
.returns(response)
|
92
|
+
assert_equal response, OneSignal::App.update(id: @app_id, params: @params, opts: @opts)
|
93
|
+
end
|
94
|
+
|
54
95
|
end
|
data/test/helper.rb
CHANGED
data/test/notification_test.rb
CHANGED
@@ -10,35 +10,63 @@ class NotificationTest < MiniTest::Test
|
|
10
10
|
@delete_uri = URI.parse(base_url + "/#{@notification_id}")
|
11
11
|
@all_uri = URI.parse(base_url)
|
12
12
|
@get_uri = URI.parse(base_url + "/#{@notification_id}")
|
13
|
+
@api_key = "fake api key 123"
|
14
|
+
@api_key_2 = "fake api key 456"
|
13
15
|
@params = {
|
14
16
|
foo: "bar",
|
15
17
|
widget: "acme"
|
16
18
|
}
|
17
|
-
@
|
19
|
+
@opts = {
|
20
|
+
key1: "value1",
|
21
|
+
key2: "vaue2",
|
22
|
+
auth_key: @api_key_2
|
23
|
+
}
|
24
|
+
@default_opts = {
|
25
|
+
auth_key: @api_key
|
26
|
+
}
|
18
27
|
OneSignal::OneSignal.api_key = @api_key
|
19
28
|
end
|
20
29
|
|
21
30
|
def test_all
|
22
31
|
response = mock_response_ok
|
23
32
|
OneSignal::OneSignal.expects(:send_get_request)
|
24
|
-
.with(uri: @all_uri, params: @params)
|
33
|
+
.with(uri: @all_uri, params: @params, opts: @default_opts)
|
25
34
|
.returns(response)
|
26
35
|
assert_equal response, OneSignal::Notification.all(params: @params)
|
27
36
|
end
|
28
37
|
|
38
|
+
def test_all_with_auth_key
|
39
|
+
response = mock_response_ok
|
40
|
+
OneSignal::OneSignal.expects(:send_get_request)
|
41
|
+
.with(uri: @all_uri, params: @params, opts: @opts)
|
42
|
+
.returns(response)
|
43
|
+
assert_equal response, OneSignal::Notification.all(params: @params,
|
44
|
+
opts: @opts)
|
45
|
+
end
|
46
|
+
|
29
47
|
def test_get
|
30
48
|
response = mock_response_ok
|
31
49
|
OneSignal::OneSignal.expects(:send_get_request)
|
32
|
-
.with(uri: @get_uri, params: @params)
|
50
|
+
.with(uri: @get_uri, params: @params, opts: @default_opts)
|
33
51
|
.returns(response)
|
34
52
|
assert_equal response, OneSignal::Notification.get(id: @notification_id,
|
35
53
|
params: @params)
|
36
54
|
end
|
37
55
|
|
56
|
+
def test_get_with_auth_key
|
57
|
+
response = mock_response_ok
|
58
|
+
OneSignal::OneSignal.expects(:send_get_request)
|
59
|
+
.with(uri: @get_uri, params: @params, opts: @opts)
|
60
|
+
.returns(response)
|
61
|
+
assert_equal response, OneSignal::Notification.get(id: @notification_id,
|
62
|
+
params: @params,
|
63
|
+
opts: @opts)
|
64
|
+
end
|
65
|
+
|
38
66
|
def test_create_raises_onesignal_error
|
39
67
|
response = mock_response_ko
|
40
68
|
OneSignal::OneSignal.expects(:send_post_request)
|
41
|
-
.with(uri: @create_uri, body: @params)
|
69
|
+
.with(uri: @create_uri, body: @params, opts: @default_opts)
|
42
70
|
.returns(response)
|
43
71
|
assert_raises OneSignal::OneSignalError do
|
44
72
|
OneSignal::Notification.create(params: @params)
|
@@ -48,7 +76,7 @@ class NotificationTest < MiniTest::Test
|
|
48
76
|
def test_create_raises_no_recipients_error
|
49
77
|
response = mock_response_no_recipients
|
50
78
|
OneSignal::OneSignal.expects(:send_post_request)
|
51
|
-
.with(uri: @create_uri, body: @params)
|
79
|
+
.with(uri: @create_uri, body: @params, opts: @default_opts)
|
52
80
|
.returns(response)
|
53
81
|
assert_raises OneSignal::NoRecipientsError do
|
54
82
|
OneSignal::Notification.create(params: @params)
|
@@ -58,27 +86,55 @@ class NotificationTest < MiniTest::Test
|
|
58
86
|
def test_create
|
59
87
|
response = mock_response_ok
|
60
88
|
OneSignal::OneSignal.expects(:send_post_request)
|
61
|
-
.with(uri: @create_uri, body: @params)
|
89
|
+
.with(uri: @create_uri, body: @params, opts: @default_opts)
|
62
90
|
.returns(response)
|
63
91
|
assert_equal response, OneSignal::Notification.create(params: @params)
|
64
92
|
end
|
65
93
|
|
94
|
+
def test_create_with_auth_key
|
95
|
+
response = mock_response_ok
|
96
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
97
|
+
.with(uri: @create_uri, body: @params, opts: @opts)
|
98
|
+
.returns(response)
|
99
|
+
assert_equal response, OneSignal::Notification.create(params: @params, opts: @opts)
|
100
|
+
end
|
101
|
+
|
66
102
|
def test_update
|
67
103
|
response = mock_response_ok
|
68
104
|
OneSignal::OneSignal.expects(:send_put_request)
|
69
|
-
.with(uri: @update_uri, body: @params)
|
105
|
+
.with(uri: @update_uri, body: @params, opts: @default_opts)
|
70
106
|
.returns(response)
|
71
107
|
assert_equal response, OneSignal::Notification.update(id: @notification_id,
|
72
108
|
params: @params)
|
73
109
|
end
|
74
110
|
|
111
|
+
def test_update_with_auth_key
|
112
|
+
response = mock_response_ok
|
113
|
+
OneSignal::OneSignal.expects(:send_put_request)
|
114
|
+
.with(uri: @update_uri, body: @params, opts: @opts)
|
115
|
+
.returns(response)
|
116
|
+
assert_equal response, OneSignal::Notification.update(id: @notification_id,
|
117
|
+
params: @params,
|
118
|
+
opts: @opts)
|
119
|
+
end
|
120
|
+
|
75
121
|
def test_delete
|
76
122
|
response = mock_response_ok
|
77
123
|
OneSignal::OneSignal.expects(:send_delete_request)
|
78
|
-
.with(uri: @delete_uri, params: @params)
|
124
|
+
.with(uri: @delete_uri, params: @params, opts: @default_opts)
|
79
125
|
.returns(response)
|
80
126
|
assert_equal response, OneSignal::Notification.delete(id: @notification_id,
|
81
127
|
params: @params)
|
82
128
|
end
|
83
129
|
|
130
|
+
def test_delete_with_auth_key
|
131
|
+
response = mock_response_ok
|
132
|
+
OneSignal::OneSignal.expects(:send_delete_request)
|
133
|
+
.with(uri: @delete_uri, params: @params, opts: @opts)
|
134
|
+
.returns(response)
|
135
|
+
assert_equal response, OneSignal::Notification.delete(id: @notification_id,
|
136
|
+
params: @params,
|
137
|
+
opts: @opts)
|
138
|
+
end
|
139
|
+
|
84
140
|
end
|
data/test/one_signal_test.rb
CHANGED
@@ -6,6 +6,7 @@ class OneSignalTest < MiniTest::Test
|
|
6
6
|
@api_key = "fake_api_123"
|
7
7
|
@body = "fake body"
|
8
8
|
@params = {foo: 'bar', widget: 'acme'}
|
9
|
+
@opts = {auth_key: @api_key}
|
9
10
|
@uri = URI.parse("https://www.example.com/foo/bar")
|
10
11
|
@default_timeout = 30
|
11
12
|
end
|
@@ -16,11 +17,11 @@ class OneSignalTest < MiniTest::Test
|
|
16
17
|
OneSignal::OneSignal.read_timeout = @default_timeout
|
17
18
|
end
|
18
19
|
|
19
|
-
def build_mock_request(body: nil)
|
20
|
+
def build_mock_request(body: nil, auth_key: nil)
|
20
21
|
request = mock()
|
21
22
|
request.expects(:body=).with(body.to_json) unless body.nil?
|
22
23
|
request.expects(:add_field).with("Content-Type", "application/json")
|
23
|
-
request.expects(:add_field).with("Authorization", "Basic #{
|
24
|
+
request.expects(:add_field).with("Authorization", "Basic #{auth_key}")
|
24
25
|
return request
|
25
26
|
end
|
26
27
|
|
@@ -67,7 +68,7 @@ class OneSignalTest < MiniTest::Test
|
|
67
68
|
|
68
69
|
def test_send_post_request
|
69
70
|
# test request creation
|
70
|
-
request = build_mock_request(body: @body)
|
71
|
+
request = build_mock_request(body: @body, auth_key: @api_key)
|
71
72
|
Net::HTTP::Post.expects(:new).with(@uri.request_uri).returns(request)
|
72
73
|
|
73
74
|
# test http object creation
|
@@ -78,8 +79,9 @@ class OneSignalTest < MiniTest::Test
|
|
78
79
|
response = mock()
|
79
80
|
http.expects(:request).with(request).returns(response)
|
80
81
|
|
81
|
-
OneSignal::OneSignal.
|
82
|
-
|
82
|
+
assert_equal response, OneSignal::OneSignal.send_post_request(uri: @uri,
|
83
|
+
body: @body,
|
84
|
+
opts: @opts)
|
83
85
|
end
|
84
86
|
|
85
87
|
def test_send_delete_request
|
@@ -87,7 +89,7 @@ class OneSignalTest < MiniTest::Test
|
|
87
89
|
expected_uri.query = URI.encode_www_form(@params)
|
88
90
|
|
89
91
|
# test request creation
|
90
|
-
request = build_mock_request
|
92
|
+
request = build_mock_request(auth_key: @api_key)
|
91
93
|
Net::HTTP::Delete.expects(:new).with(expected_uri.request_uri).returns(request)
|
92
94
|
|
93
95
|
# test http object creation
|
@@ -98,14 +100,14 @@ class OneSignalTest < MiniTest::Test
|
|
98
100
|
response = mock()
|
99
101
|
http.expects(:request).with(request).returns(response)
|
100
102
|
|
101
|
-
OneSignal::OneSignal.api_key = @api_key
|
102
103
|
assert_equal response, OneSignal::OneSignal.send_delete_request(uri: @uri,
|
103
|
-
|
104
|
+
params: @params,
|
105
|
+
opts: @opts)
|
104
106
|
end
|
105
107
|
|
106
108
|
def test_send_put_request
|
107
109
|
# test request creation
|
108
|
-
request = build_mock_request(body: @body)
|
110
|
+
request = build_mock_request(body: @body, auth_key: @api_key)
|
109
111
|
Net::HTTP::Put.expects(:new).with(@uri.request_uri).returns(request)
|
110
112
|
|
111
113
|
# test http object creation
|
@@ -116,8 +118,9 @@ class OneSignalTest < MiniTest::Test
|
|
116
118
|
response = mock()
|
117
119
|
http.expects(:request).with(request).returns(response)
|
118
120
|
|
119
|
-
OneSignal::OneSignal.
|
120
|
-
|
121
|
+
assert_equal response, OneSignal::OneSignal.send_put_request(uri: @uri,
|
122
|
+
body: @body,
|
123
|
+
opts: @opts)
|
121
124
|
end
|
122
125
|
|
123
126
|
def test_send_get_request
|
@@ -125,7 +128,7 @@ class OneSignalTest < MiniTest::Test
|
|
125
128
|
expected_uri.query = URI.encode_www_form(@params)
|
126
129
|
|
127
130
|
# test request creation
|
128
|
-
request = build_mock_request
|
131
|
+
request = build_mock_request(auth_key: @api_key)
|
129
132
|
Net::HTTP::Get.expects(:new).with(expected_uri.request_uri).returns(request)
|
130
133
|
|
131
134
|
# test http object creation
|
@@ -136,9 +139,9 @@ class OneSignalTest < MiniTest::Test
|
|
136
139
|
response = mock()
|
137
140
|
http.expects(:request).with(request).returns(response)
|
138
141
|
|
139
|
-
OneSignal::OneSignal.api_key = @api_key
|
140
142
|
assert_equal response, OneSignal::OneSignal.send_get_request(uri: @uri,
|
141
|
-
params: @params
|
143
|
+
params: @params,
|
144
|
+
opts: @opts)
|
142
145
|
end
|
143
146
|
|
144
147
|
end
|
data/test/player_test.rb
CHANGED
@@ -10,6 +10,7 @@ class PlayerTest < MiniTest::Test
|
|
10
10
|
@player_id = "fake-id-123"
|
11
11
|
@get_uri = URI.parse(base_url + "/#{@player_id}")
|
12
12
|
@update_uri = URI.parse(base_url + "/#{@player_id}")
|
13
|
+
@delete_uri = URI.parse(base_url + "/#{@player_id}")
|
13
14
|
@create_session_uri = URI.parse(base_url + "/#{@player_id}/on_session")
|
14
15
|
@create_purchase_uri = URI.parse(base_url + "/#{@player_id}/on_purchase")
|
15
16
|
@create_focus_uri = URI.parse(base_url + "/#{@player_id}/on_focus")
|
@@ -18,14 +19,23 @@ class PlayerTest < MiniTest::Test
|
|
18
19
|
foo: "bar",
|
19
20
|
widget: "acme"
|
20
21
|
}
|
21
|
-
@api_key = "fake api key"
|
22
|
+
@api_key = "fake api key 123"
|
23
|
+
@api_key_2 = "fake api key 456"
|
24
|
+
@opts = {
|
25
|
+
key1: "value1",
|
26
|
+
key2: "vaue2",
|
27
|
+
auth_key: @api_key_2
|
28
|
+
}
|
29
|
+
@default_opts = {
|
30
|
+
auth_key: @api_key
|
31
|
+
}
|
22
32
|
OneSignal::OneSignal.api_key = @api_key
|
23
33
|
end
|
24
34
|
|
25
35
|
def test_create_raises_error
|
26
36
|
response = mock_response_ko
|
27
37
|
OneSignal::OneSignal.expects(:send_post_request)
|
28
|
-
.with(uri: @create_uri, body: @params)
|
38
|
+
.with(uri: @create_uri, body: @params, opts: @default_opts)
|
29
39
|
.returns(response)
|
30
40
|
assert_raises OneSignal::OneSignalError do
|
31
41
|
OneSignal::Player.create(params: @params)
|
@@ -35,39 +45,71 @@ class PlayerTest < MiniTest::Test
|
|
35
45
|
def test_csv_export
|
36
46
|
response = mock_response_ok
|
37
47
|
OneSignal::OneSignal.expects(:send_post_request)
|
38
|
-
.with(uri: @csv_export_uri, body: @params)
|
48
|
+
.with(uri: @csv_export_uri, body: @params, opts: @default_opts)
|
39
49
|
.returns(response)
|
40
50
|
assert_equal response, OneSignal::Player.csv_export(params: @params)
|
41
51
|
end
|
42
52
|
|
53
|
+
def test_csv_export_with_auth_key
|
54
|
+
response = mock_response_ok
|
55
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
56
|
+
.with(uri: @csv_export_uri, body: @params, opts: @opts)
|
57
|
+
.returns(response)
|
58
|
+
assert_equal response, OneSignal::Player.csv_export(params: @params, opts: @opts)
|
59
|
+
end
|
60
|
+
|
43
61
|
def test_all
|
44
62
|
response = mock_response_ok
|
45
63
|
OneSignal::OneSignal.expects(:send_get_request)
|
46
|
-
.with(uri: @all_uri, params: @params)
|
64
|
+
.with(uri: @all_uri, params: @params, opts: @default_opts)
|
47
65
|
.returns(response)
|
48
66
|
assert_equal response, OneSignal::Player.all(params: @params)
|
49
67
|
end
|
50
68
|
|
69
|
+
def test_all_with_auth_key
|
70
|
+
response = mock_response_ok
|
71
|
+
OneSignal::OneSignal.expects(:send_get_request)
|
72
|
+
.with(uri: @all_uri, params: @params, opts: @opts)
|
73
|
+
.returns(response)
|
74
|
+
assert_equal response, OneSignal::Player.all(params: @params, opts: @opts)
|
75
|
+
end
|
76
|
+
|
51
77
|
def test_get
|
52
78
|
response = mock_response_ok
|
53
79
|
OneSignal::OneSignal.expects(:send_get_request)
|
54
|
-
.with(uri: @get_uri, params: nil)
|
80
|
+
.with(uri: @get_uri, params: nil, opts: @default_opts)
|
55
81
|
.returns(response)
|
56
82
|
assert_equal response, OneSignal::Player.get(id: @player_id)
|
57
83
|
end
|
58
84
|
|
85
|
+
def test_get_with_auth_key
|
86
|
+
response = mock_response_ok
|
87
|
+
OneSignal::OneSignal.expects(:send_get_request)
|
88
|
+
.with(uri: @get_uri, params: nil, opts: @opts)
|
89
|
+
.returns(response)
|
90
|
+
assert_equal response, OneSignal::Player.get(id: @player_id, opts: @opts)
|
91
|
+
end
|
92
|
+
|
59
93
|
def test_create
|
60
94
|
response = mock_response_ok
|
61
95
|
OneSignal::OneSignal.expects(:send_post_request)
|
62
|
-
.with(uri: @create_uri, body: @params)
|
96
|
+
.with(uri: @create_uri, body: @params, opts: @default_opts)
|
63
97
|
.returns(response)
|
64
98
|
assert_equal response, OneSignal::Player.create(params: @params)
|
65
99
|
end
|
66
100
|
|
101
|
+
def test_create_with_auth_key
|
102
|
+
response = mock_response_ok
|
103
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
104
|
+
.with(uri: @create_uri, body: @params, opts: @opts)
|
105
|
+
.returns(response)
|
106
|
+
assert_equal response, OneSignal::Player.create(params: @params, opts: @opts)
|
107
|
+
end
|
108
|
+
|
67
109
|
def test_update_raises_error
|
68
110
|
response = mock_response_ko
|
69
111
|
OneSignal::OneSignal.expects(:send_put_request)
|
70
|
-
.with(uri: @update_uri, body: @params)
|
112
|
+
.with(uri: @update_uri, body: @params, opts: @default_opts)
|
71
113
|
.returns(response)
|
72
114
|
assert_raises OneSignal::OneSignalError do
|
73
115
|
OneSignal::Player.update(id: @player_id, params: @params)
|
@@ -77,36 +119,99 @@ class PlayerTest < MiniTest::Test
|
|
77
119
|
def test_update
|
78
120
|
response = mock_response_ok
|
79
121
|
OneSignal::OneSignal.expects(:send_put_request)
|
80
|
-
.with(uri: @update_uri, body: @params)
|
122
|
+
.with(uri: @update_uri, body: @params, opts: @default_opts)
|
81
123
|
.returns(response)
|
82
124
|
assert_equal response, OneSignal::Player.update(id: @player_id, params: @params)
|
83
125
|
end
|
84
126
|
|
127
|
+
def test_update_with_auth_key
|
128
|
+
response = mock_response_ok
|
129
|
+
OneSignal::OneSignal.expects(:send_put_request)
|
130
|
+
.with(uri: @update_uri, body: @params, opts: @opts)
|
131
|
+
.returns(response)
|
132
|
+
assert_equal response, OneSignal::Player.update(id: @player_id,
|
133
|
+
params: @params,
|
134
|
+
opts: @opts)
|
135
|
+
end
|
136
|
+
|
85
137
|
def test_create_session
|
86
138
|
response = mock_response_ok
|
87
139
|
OneSignal::OneSignal.expects(:send_post_request)
|
88
|
-
.with(uri: @create_session_uri, body: @params)
|
140
|
+
.with(uri: @create_session_uri, body: @params, opts: @default_opts)
|
89
141
|
.returns(response)
|
90
142
|
assert_equal response, OneSignal::Player.create_session(id: @player_id,
|
91
143
|
params: @params)
|
92
144
|
end
|
93
145
|
|
146
|
+
def test_create_session_with_auth_key
|
147
|
+
response = mock_response_ok
|
148
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
149
|
+
.with(uri: @create_session_uri, body: @params, opts: @opts)
|
150
|
+
.returns(response)
|
151
|
+
assert_equal response, OneSignal::Player.create_session(id: @player_id,
|
152
|
+
params: @params,
|
153
|
+
opts: @opts)
|
154
|
+
end
|
155
|
+
|
94
156
|
def test_create_purchase
|
95
157
|
response = mock_response_ok
|
96
158
|
OneSignal::OneSignal.expects(:send_post_request)
|
97
|
-
.with(uri: @create_purchase_uri,
|
159
|
+
.with(uri: @create_purchase_uri,
|
160
|
+
body: @params,
|
161
|
+
opts: @default_opts)
|
98
162
|
.returns(response)
|
99
163
|
assert_equal response, OneSignal::Player.create_purchase(id: @player_id,
|
100
164
|
params: @params)
|
101
165
|
end
|
102
166
|
|
167
|
+
def test_create_purchase_with_auth_key
|
168
|
+
response = mock_response_ok
|
169
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
170
|
+
.with(uri: @create_purchase_uri,
|
171
|
+
body: @params,
|
172
|
+
opts: @opts)
|
173
|
+
.returns(response)
|
174
|
+
assert_equal response, OneSignal::Player.create_purchase(id: @player_id,
|
175
|
+
params: @params,
|
176
|
+
opts: @opts)
|
177
|
+
end
|
178
|
+
|
103
179
|
def test_create_focus
|
104
180
|
response = mock_response_ok
|
105
181
|
OneSignal::OneSignal.expects(:send_post_request)
|
106
|
-
.with(uri: @create_focus_uri, body: @params)
|
182
|
+
.with(uri: @create_focus_uri, body: @params, opts: @default_opts)
|
107
183
|
.returns(response)
|
108
184
|
assert_equal response, OneSignal::Player.create_focus(id: @player_id,
|
109
185
|
params: @params)
|
110
186
|
end
|
111
187
|
|
188
|
+
def test_create_focus_with_auth_key
|
189
|
+
response = mock_response_ok
|
190
|
+
OneSignal::OneSignal.expects(:send_post_request)
|
191
|
+
.with(uri: @create_focus_uri, body: @params, opts: @opts)
|
192
|
+
.returns(response)
|
193
|
+
assert_equal response, OneSignal::Player.create_focus(id: @player_id,
|
194
|
+
params: @params,
|
195
|
+
opts: @opts)
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_delete
|
199
|
+
response = mock_response_ok
|
200
|
+
OneSignal::OneSignal.expects(:send_delete_request)
|
201
|
+
.with(uri: @delete_uri, params: @params, opts: @default_opts)
|
202
|
+
.returns(response)
|
203
|
+
assert_equal response, OneSignal::Player.delete(id: @player_id,
|
204
|
+
params: @params)
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_delete_with_auth_key
|
208
|
+
response = mock_response_ok
|
209
|
+
OneSignal::OneSignal.expects(:send_delete_request)
|
210
|
+
.with(uri: @delete_uri, params: @params, opts: @opts)
|
211
|
+
.returns(response)
|
212
|
+
assert_equal response, OneSignal::Player.delete(id: @player_id,
|
213
|
+
params: @params,
|
214
|
+
opts: @opts)
|
215
|
+
end
|
216
|
+
|
112
217
|
end
|