soapy_cake 1.25.1 → 1.25.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/soapy_cake/admin.rb +1 -1
- data/lib/soapy_cake/helper.rb +1 -1
- data/lib/soapy_cake/version.rb +1 -1
- data/spec/integration/soapy_cake/admin_addedit_spec.rb +23 -21
- data/spec/integration/soapy_cake/admin_spec.rb +15 -15
- data/spec/integration/soapy_cake/admin_track_spec.rb +4 -2
- data/spec/lib/soapy_cake/admin_addedit_spec.rb +6 -4
- data/spec/lib/soapy_cake/admin_batched_spec.rb +12 -7
- data/spec/lib/soapy_cake/admin_spec.rb +4 -3
- data/spec/lib/soapy_cake/affiliate_spec.rb +3 -3
- data/spec/lib/soapy_cake/response_spec.rb +6 -6
- data/spec/lib/soapy_cake/time_converter_spec.rb +12 -12
- data/spec/support/admin_method_example.rb +3 -2
- 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: 1321d74f53687f87ede80c9d57c96cd0071243f3
|
4
|
+
data.tar.gz: 2a959b7fe70c1bbac22d7e798cd7c1eb76bc20ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7217c43f14f3b57ac1b104dfd64924e0f45a120147814ab2dfb4f8bf05efc2dca2d0ce709dd3eff418c3588b3d0049ac58458119bdde00a4a1f62b9d1e6b314
|
7
|
+
data.tar.gz: 64d9af5457a4fd531a01c26f7f02311ef73abbb2027fd5cc9dcf3d8204fd01d844cfeb5e27166af65974f6fda62bf993fe5eb7ae888f6d8dff7abd91c0ee2d49
|
data/README.md
CHANGED
data/lib/soapy_cake/admin.rb
CHANGED
@@ -113,7 +113,7 @@ module SoapyCake
|
|
113
113
|
blacklist_date = opts[:blacklist_date].to_date
|
114
114
|
# CAKE applies the blacklisting at 00:00 of the specified day, so add one more day.
|
115
115
|
# Unless it is the current day, then blacklisting should take effect immediately.
|
116
|
-
blacklist_date += 1.day if blacklist_date > Date.
|
116
|
+
blacklist_date += 1.day if blacklist_date > Date.current
|
117
117
|
|
118
118
|
run Request.new(
|
119
119
|
:admin,
|
data/lib/soapy_cake/helper.rb
CHANGED
@@ -54,7 +54,7 @@ module SoapyCake
|
|
54
54
|
# It cannot be *that* far in the future though because it causes a datetime overflow
|
55
55
|
# in the steam powered rusty black box they call a database server.
|
56
56
|
def future_expiration_date
|
57
|
-
Date.
|
57
|
+
Date.current + (365 * 30)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/lib/soapy_cake/version.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
RSpec.describe SoapyCake::AdminAddedit do
|
3
|
+
subject(:admin_addedit) { described_class.new }
|
4
|
+
|
3
5
|
around { |example| Timecop.freeze(Time.utc(2015, 2, 17, 12), &example) }
|
4
6
|
|
5
7
|
let(:affiliate_id) { 1 }
|
@@ -13,7 +15,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
13
15
|
|
14
16
|
describe 'affiliates', :vcr do
|
15
17
|
it 'edits affiliates' do
|
16
|
-
result =
|
18
|
+
result = admin_addedit.edit_affiliate(
|
17
19
|
affiliate_id: 1,
|
18
20
|
vat_tax_required: false
|
19
21
|
)
|
@@ -24,7 +26,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
24
26
|
|
25
27
|
describe 'advertisers', :vcr do
|
26
28
|
it 'creates advertisers' do
|
27
|
-
result =
|
29
|
+
result = admin_addedit.create_advertiser(
|
28
30
|
advertiser_name: 'Foxy Fox',
|
29
31
|
account_status_id: 1
|
30
32
|
)
|
@@ -35,7 +37,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
35
37
|
|
36
38
|
describe 'contacts', :vcr do
|
37
39
|
it 'edits a contact' do
|
38
|
-
result =
|
40
|
+
result = admin_addedit.edit_contact(
|
39
41
|
entity_id: advertiser_id,
|
40
42
|
contact_id: contact_id,
|
41
43
|
contact_email_address: 'fox@rabbit.com'
|
@@ -65,7 +67,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
65
67
|
end
|
66
68
|
|
67
69
|
it 'creates an offer', :vcr do
|
68
|
-
result =
|
70
|
+
result = admin_addedit.add_offer(
|
69
71
|
hidden: false,
|
70
72
|
offer_status_id: :public,
|
71
73
|
offer_type_id: :third_party,
|
@@ -113,20 +115,20 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
113
115
|
end
|
114
116
|
|
115
117
|
it 'updates an offer', :vcr do
|
116
|
-
result =
|
118
|
+
result = admin_addedit.edit_offer(update_params)
|
117
119
|
expect(result).to include(offer_id: offer_id)
|
118
120
|
end
|
119
121
|
|
120
122
|
context 'errors' do
|
121
123
|
it 'fails when not enough params are given' do
|
122
124
|
expect do
|
123
|
-
|
125
|
+
admin_addedit.edit_offer(offer_id: 123)
|
124
126
|
end.to raise_error(SoapyCake::Error, "Parameter 'advertiser_id' missing!")
|
125
127
|
end
|
126
128
|
|
127
129
|
it 'fails when invalid offer_id is given on edit' do
|
128
130
|
expect do
|
129
|
-
|
131
|
+
admin_addedit.edit_offer(offer_id: -1)
|
130
132
|
end.to raise_error(SoapyCake::Error, "Parameter 'offer_id' must be > 0!")
|
131
133
|
end
|
132
134
|
|
@@ -138,7 +140,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
138
140
|
|
139
141
|
it 'fails with error' do
|
140
142
|
expect do
|
141
|
-
|
143
|
+
admin_addedit.edit_offer(update_params)
|
142
144
|
end.to raise_error(SoapyCake::Error, /Writes not enabled/)
|
143
145
|
end
|
144
146
|
end
|
@@ -147,14 +149,14 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
147
149
|
|
148
150
|
describe 'geo targeting' do
|
149
151
|
it 'creates geo targetings', :vcr do
|
150
|
-
result =
|
152
|
+
result = admin_addedit.add_geo_targets(
|
151
153
|
offer_contract_id: offer_contract_id,
|
152
154
|
countries: %w(DE FR),
|
153
155
|
allow_countries: true
|
154
156
|
)
|
155
157
|
expect(result).to include(success: true, row_count: '2')
|
156
158
|
|
157
|
-
result =
|
159
|
+
result = admin_addedit.add_geo_targets(
|
158
160
|
offer_contract_id: offer_contract_id,
|
159
161
|
countries: %w(AT CH),
|
160
162
|
redirects: {
|
@@ -168,7 +170,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
168
170
|
|
169
171
|
it 'fails if it does not get a correct redirect hash' do
|
170
172
|
expect do
|
171
|
-
|
173
|
+
admin_addedit.add_geo_targets(
|
172
174
|
offer_contract_id: offer_contract_id,
|
173
175
|
redirects: {},
|
174
176
|
allow_countries: false
|
@@ -182,7 +184,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
182
184
|
|
183
185
|
describe 'offer contracts' do
|
184
186
|
it 'creates an offer contract', :vcr do
|
185
|
-
result =
|
187
|
+
result = admin_addedit.add_offer_contract(
|
186
188
|
offer_id: offer_id,
|
187
189
|
offer_contract_name: 'Test Contract',
|
188
190
|
price_format_id: :cpa,
|
@@ -200,7 +202,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
200
202
|
end
|
201
203
|
|
202
204
|
it 'updates an offer contract', :vcr do
|
203
|
-
result =
|
205
|
+
result = admin_addedit.edit_offer_contract(
|
204
206
|
offer_id: offer_id,
|
205
207
|
offer_contract_id: offer_contract_id,
|
206
208
|
offer_contract_name: 'Test Contract',
|
@@ -221,13 +223,13 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
221
223
|
context 'errors' do
|
222
224
|
it 'fails when not enough params are given' do
|
223
225
|
expect do
|
224
|
-
|
226
|
+
admin_addedit.edit_offer_contract(offer_contract_id: 123)
|
225
227
|
end.to raise_error(SoapyCake::Error, "Parameter 'offer_id' missing!")
|
226
228
|
end
|
227
229
|
|
228
230
|
it 'fails when invalid offer_id is given on edit' do
|
229
231
|
expect do
|
230
|
-
|
232
|
+
admin_addedit.edit_offer_contract(offer_contract_id: -1)
|
231
233
|
end.to raise_error(SoapyCake::Error, "Parameter 'offer_contract_id' must be > 0!")
|
232
234
|
end
|
233
235
|
end
|
@@ -235,7 +237,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
235
237
|
|
236
238
|
describe 'offer / offer contract caps' do
|
237
239
|
it 'updates a cap for an offer contract', :vcr do
|
238
|
-
result =
|
240
|
+
result = admin_addedit.update_caps(
|
239
241
|
offer_contract_id: offer_contract_id,
|
240
242
|
cap_type_id: :conversion,
|
241
243
|
cap_interval_id: :daily,
|
@@ -247,7 +249,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
247
249
|
end
|
248
250
|
|
249
251
|
it 'removes a cap for an offer contract', :vcr do
|
250
|
-
result =
|
252
|
+
result = admin_addedit.remove_caps(
|
251
253
|
offer_contract_id: offer_contract_id,
|
252
254
|
cap_type_id: :conversion
|
253
255
|
)
|
@@ -258,7 +260,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
258
260
|
|
259
261
|
describe 'offer tiers' do
|
260
262
|
it 'adds an offer tier', :vcr do
|
261
|
-
result =
|
263
|
+
result = admin_addedit.add_offer_tier(
|
262
264
|
offer_id: offer_id,
|
263
265
|
offer_contract_id: offer_contract_id,
|
264
266
|
tier_id: tier_id,
|
@@ -270,7 +272,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
270
272
|
end
|
271
273
|
|
272
274
|
it 'edits an offer tier', :vcr do
|
273
|
-
result =
|
275
|
+
result = admin_addedit.edit_offer_tier(
|
274
276
|
offer_id: offer_id,
|
275
277
|
offer_contract_id: offer_contract_id,
|
276
278
|
tier_id: tier_id,
|
@@ -284,7 +286,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
284
286
|
|
285
287
|
describe 'campaigns' do
|
286
288
|
it 'adds a campaign', :vcr do
|
287
|
-
result =
|
289
|
+
result = admin_addedit.add_campaign(
|
288
290
|
affiliate_id: affiliate_id,
|
289
291
|
offer_id: offer_id,
|
290
292
|
media_type_id: 1,
|
@@ -296,7 +298,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
296
298
|
end
|
297
299
|
|
298
300
|
it 'edits a campaign', :vcr do
|
299
|
-
result =
|
301
|
+
result = admin_addedit.edit_campaign(
|
300
302
|
campaign_id: 123,
|
301
303
|
affiliate_id: affiliate_id,
|
302
304
|
offer_id: offer_id,
|
@@ -5,13 +5,13 @@ RSpec.describe SoapyCake::Admin do
|
|
5
5
|
let(:logger) { instance_double(Logger) }
|
6
6
|
before { allow(logger).to receive(:info) }
|
7
7
|
|
8
|
-
subject { described_class.new(logger: logger) }
|
8
|
+
subject(:admin) { described_class.new(logger: logger) }
|
9
9
|
|
10
10
|
it 'returns an affiliate with correct data types', :vcr do
|
11
11
|
expect(logger).to receive(:info)
|
12
12
|
.with('soapy_cake:request admin:export:affiliates:5 {"affiliate_id":16027}')
|
13
13
|
|
14
|
-
result =
|
14
|
+
result = admin.affiliates(affiliate_id: 16027)
|
15
15
|
expect(result.count).to eq(1)
|
16
16
|
expect(result.first).to include(
|
17
17
|
affiliate_id: 16027,
|
@@ -39,7 +39,7 @@ RSpec.describe SoapyCake::Admin do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns a clicks report with a defined time range', :vcr do
|
42
|
-
result =
|
42
|
+
result = admin.clicks(
|
43
43
|
start_date: Date.new(2014, 6, 30),
|
44
44
|
end_date: Date.new(2014, 7, 1),
|
45
45
|
row_limit: 1
|
@@ -53,7 +53,7 @@ RSpec.describe SoapyCake::Admin do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'does not parse a transaction_id as an integer', :vcr do
|
56
|
-
result =
|
56
|
+
result = admin.conversions(
|
57
57
|
start_date: Date.new(2015, 4, 11),
|
58
58
|
end_date: Date.new(2015, 4, 12),
|
59
59
|
row_limit: 1
|
@@ -65,12 +65,12 @@ RSpec.describe SoapyCake::Admin do
|
|
65
65
|
|
66
66
|
it 'raises if there is an error', :vcr do
|
67
67
|
expect do
|
68
|
-
|
68
|
+
admin.affiliates(affiliate_id: 'bloops')
|
69
69
|
end.to raise_error(SoapyCake::RequestFailed)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'creates an affiliate and returns the ID', :vcr do
|
73
|
-
result =
|
73
|
+
result = admin.affiliate_signup(
|
74
74
|
contact_timezone: 'CET',
|
75
75
|
contact_phone_work: 'n/a',
|
76
76
|
address_country: 'n/a',
|
@@ -85,7 +85,7 @@ RSpec.describe SoapyCake::Admin do
|
|
85
85
|
contact_first_name: 'Foxy',
|
86
86
|
contact_last_name: 'Fox',
|
87
87
|
contact_email_address: 'foxy@forrest.com',
|
88
|
-
date_added: Date.
|
88
|
+
date_added: Date.current
|
89
89
|
)
|
90
90
|
|
91
91
|
expect(result).to eq(
|
@@ -97,7 +97,7 @@ RSpec.describe SoapyCake::Admin do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'returns media types', :vcr do
|
100
|
-
result =
|
100
|
+
result = admin.media_types
|
101
101
|
|
102
102
|
expect(result.first).to eq(
|
103
103
|
media_type_id: 15,
|
@@ -106,17 +106,17 @@ RSpec.describe SoapyCake::Admin do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
context 'XML responses' do
|
109
|
-
subject { described_class.new(xml_response: true) }
|
109
|
+
subject(:admin) { described_class.new(xml_response: true) }
|
110
110
|
|
111
111
|
it 'returns an XML string', :vcr do
|
112
|
-
result =
|
112
|
+
result = admin.media_types
|
113
113
|
|
114
114
|
expect(result.next).to eq(File.read('spec/fixtures/raw_response.xml').strip)
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'fails on error', :vcr do
|
118
118
|
expect do
|
119
|
-
|
119
|
+
admin.affiliates(affiliate_id: -2).next
|
120
120
|
end.to raise_error(SoapyCake::RequestFailed)
|
121
121
|
end
|
122
122
|
end
|
@@ -124,7 +124,7 @@ RSpec.describe SoapyCake::Admin do
|
|
124
124
|
describe '#blacklists' do
|
125
125
|
it 'returns blacklists', :vcr do
|
126
126
|
expect(
|
127
|
-
|
127
|
+
admin.blacklists(
|
128
128
|
advertiser_id: 15882,
|
129
129
|
offer_id: 10551,
|
130
130
|
affiliate_id: 16187,
|
@@ -157,11 +157,11 @@ RSpec.describe SoapyCake::Admin do
|
|
157
157
|
end
|
158
158
|
|
159
159
|
it 'removes blacklists', :vcr do
|
160
|
-
expect(
|
160
|
+
expect(admin.blacklists(blacklist_params).to_a).to be_present
|
161
161
|
|
162
|
-
|
162
|
+
admin.remove_blacklist(blacklist_id: 28)
|
163
163
|
|
164
|
-
expect(
|
164
|
+
expect(admin.blacklists(blacklist_params).to_a).to be_empty
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
@@ -2,9 +2,11 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
RSpec.describe SoapyCake::AdminTrack do
|
5
|
+
subject(:admin_track) { described_class.new }
|
6
|
+
|
5
7
|
describe '#mass_conversion_insert', :vcr do
|
6
8
|
it 'inserts conversions' do
|
7
|
-
result =
|
9
|
+
result = admin_track.mass_conversion_insert(
|
8
10
|
conversion_date: Date.new(2015, 5, 6),
|
9
11
|
affiliate_id: 16059,
|
10
12
|
campaign_id: 13268,
|
@@ -19,7 +21,7 @@ RSpec.describe SoapyCake::AdminTrack do
|
|
19
21
|
|
20
22
|
describe '#update_conversion', :vcr do
|
21
23
|
it 'updates a conversion' do
|
22
|
-
result =
|
24
|
+
result = admin_track.update_conversion(
|
23
25
|
conversion_id: 145211,
|
24
26
|
offer_id: 5032,
|
25
27
|
payout: 0.75,
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
RSpec.describe SoapyCake::AdminAddedit do
|
3
|
+
subject(:admin_addedit) { described_class.new }
|
4
|
+
|
3
5
|
before do
|
4
|
-
allow(
|
6
|
+
allow(admin_addedit).to receive(:run).and_return({})
|
5
7
|
end
|
6
8
|
|
7
9
|
describe '#edit_offer' do
|
@@ -25,7 +27,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
25
27
|
.with(:admin, :addedit, :offer,
|
26
28
|
hash_including(tags: 'new-tag', tags_modification_type: 'add'))
|
27
29
|
|
28
|
-
|
30
|
+
admin_addedit.edit_offer(offer_params)
|
29
31
|
end
|
30
32
|
|
31
33
|
it 'allows replacing tags' do
|
@@ -33,7 +35,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
33
35
|
.with(:admin, :addedit, :offer,
|
34
36
|
hash_including(tags: 'new-tag', tags_modification_type: 'replace'))
|
35
37
|
|
36
|
-
|
38
|
+
admin_addedit.edit_offer(offer_params.merge(tags_replace: true))
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
@@ -77,7 +79,7 @@ RSpec.describe SoapyCake::AdminAddedit do
|
|
77
79
|
.with(:admin, :addedit, :offer,
|
78
80
|
hash_including(tags: 'tag', tags_modification_type: 'add'))
|
79
81
|
|
80
|
-
|
82
|
+
admin_addedit.add_offer(offer_params.merge(tags: 'tag', tags_replace: true))
|
81
83
|
end
|
82
84
|
end
|
83
85
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
RSpec.describe SoapyCake::AdminBatched do
|
3
|
+
subject(:admin_batched) { described_class.new }
|
3
4
|
let(:admin) { instance_double(SoapyCake::Admin, xml_response?: false) }
|
4
5
|
|
5
6
|
before :each do
|
@@ -14,7 +15,7 @@ RSpec.describe SoapyCake::AdminBatched do
|
|
14
15
|
expect(admin).to receive(:offers)
|
15
16
|
.with(advertiser: 1, start_at_row: 3, row_limit: 2).and_return(%i(c).to_enum)
|
16
17
|
|
17
|
-
result =
|
18
|
+
result = admin_batched.offers(advertiser: 1)
|
18
19
|
|
19
20
|
expect(result).to be_a(Enumerator)
|
20
21
|
expect(result.to_a).to eq(%i(a b c))
|
@@ -24,11 +25,11 @@ RSpec.describe SoapyCake::AdminBatched do
|
|
24
25
|
expect(admin).to receive(:offers)
|
25
26
|
.with(advertiser: 1, start_at_row: 1, row_limit: 100).and_return(%i(a b).to_enum)
|
26
27
|
|
27
|
-
expect(
|
28
|
+
expect(admin_batched.offers({ advertiser: 1 }, 100).to_a).to eq(%i(a b))
|
28
29
|
end
|
29
30
|
|
30
31
|
context 'SoapyCake Batched with XMLResponse set' do
|
31
|
-
subject { described_class.new(xml_response: true) }
|
32
|
+
subject(:admin_batched) { described_class.new(xml_response: true) }
|
32
33
|
|
33
34
|
before do
|
34
35
|
allow(admin).to receive(:xml_response?).and_return(true)
|
@@ -42,7 +43,7 @@ RSpec.describe SoapyCake::AdminBatched do
|
|
42
43
|
expect(admin).to receive(:affiliates)
|
43
44
|
.with(start_at_row: 21, row_limit: 10).and_return([].to_enum)
|
44
45
|
|
45
|
-
result =
|
46
|
+
result = admin_batched.affiliates({}, 10)
|
46
47
|
|
47
48
|
expect(result).to be_a(Enumerator)
|
48
49
|
expect(result.to_a).to eq(%i(a b))
|
@@ -51,15 +52,19 @@ RSpec.describe SoapyCake::AdminBatched do
|
|
51
52
|
|
52
53
|
context 'errors' do
|
53
54
|
it 'fails with an invalid method' do
|
54
|
-
expect {
|
55
|
+
expect { admin_batched.something }.to raise_error(NoMethodError)
|
55
56
|
end
|
56
57
|
|
57
58
|
it 'fails when row_limit is set' do
|
58
|
-
expect {
|
59
|
+
expect { admin_batched.offers(row_limit: 123) }.to(
|
60
|
+
raise_error(/Cannot set .* in batched mode/)
|
61
|
+
)
|
59
62
|
end
|
60
63
|
|
61
64
|
it 'fails when start_at_row is set' do
|
62
|
-
expect {
|
65
|
+
expect { admin_batched.offers(start_at_row: 123) }.to(
|
66
|
+
raise_error(/Cannot set .* in batched mode/)
|
67
|
+
)
|
63
68
|
end
|
64
69
|
end
|
65
70
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
RSpec.describe SoapyCake::Admin do
|
3
|
+
subject(:admin) { described_class.new }
|
3
4
|
let(:opts) { nil }
|
4
5
|
let(:cake_opts) { opts }
|
5
6
|
let(:cake_method) { method }
|
@@ -182,7 +183,7 @@ RSpec.describe SoapyCake::Admin do
|
|
182
183
|
let(:opts) { { blacklist_date: date } }
|
183
184
|
|
184
185
|
context 'immediate blacklisting for current date' do
|
185
|
-
let(:date) { Date.
|
186
|
+
let(:date) { Date.current }
|
186
187
|
let(:cake_opts) { { blacklist_date: date } }
|
187
188
|
|
188
189
|
it_behaves_like 'a cake admin method'
|
@@ -212,7 +213,7 @@ RSpec.describe SoapyCake::Admin do
|
|
212
213
|
it_behaves_like 'a cake admin method'
|
213
214
|
|
214
215
|
it 'uses a local response' do
|
215
|
-
expect(
|
216
|
+
expect(admin.media_types(response: File.read('spec/fixtures/raw_response.xml'))).to eq(
|
216
217
|
[
|
217
218
|
{ media_type_id: 15, type_name: 'Adware' },
|
218
219
|
{ media_type_id: 7, type_name: 'Banner' },
|
@@ -253,7 +254,7 @@ RSpec.describe SoapyCake::Admin do
|
|
253
254
|
it_behaves_like 'a cake admin method'
|
254
255
|
|
255
256
|
it 'fails if no blacklist_id is passed' do
|
256
|
-
expect {
|
257
|
+
expect { admin.remove_blacklist }
|
257
258
|
.to raise_error(SoapyCake::Error, "Parameter 'blacklist_id' missing!")
|
258
259
|
end
|
259
260
|
end
|
@@ -4,16 +4,16 @@ RSpec.describe SoapyCake::Affiliate do
|
|
4
4
|
let(:opts) { { a: 1 } }
|
5
5
|
let(:cake_opts) { opts.merge(affiliate_id: affiliate_id) }
|
6
6
|
|
7
|
-
subject { described_class.new(affiliate_id: affiliate_id) }
|
7
|
+
subject(:affiliate) { described_class.new(affiliate_id: affiliate_id) }
|
8
8
|
|
9
9
|
shared_examples_for 'a cake affiliate method' do
|
10
10
|
it 'runs the request' do
|
11
11
|
request = instance_double(SoapyCake::Request)
|
12
12
|
expect(SoapyCake::Request).to receive(:new)
|
13
13
|
.with(:affiliate, service, method, cake_opts).and_return(request)
|
14
|
-
expect(
|
14
|
+
expect(affiliate).to receive(:run).with(request)
|
15
15
|
|
16
|
-
|
16
|
+
affiliate.public_send(method, opts)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -24,16 +24,16 @@ RSpec.describe SoapyCake::Response do
|
|
24
24
|
EOD
|
25
25
|
end
|
26
26
|
|
27
|
-
subject { described_class.new(xml.strip, false, 0) }
|
27
|
+
subject(:response) { described_class.new(xml.strip, false, 0) }
|
28
28
|
|
29
29
|
it 'returns an enumerator' do
|
30
|
-
expect(
|
30
|
+
expect(response.to_enum).to be_a(Enumerator)
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'parses the CAKE XML structure properly' do
|
34
|
-
expect(
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
expect(response.to_enum.to_a).to eq([
|
35
|
+
{ id: '123' },
|
36
|
+
{ id: '312' }
|
37
|
+
])
|
38
38
|
end
|
39
39
|
end
|
@@ -1,38 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
RSpec.describe SoapyCake::TimeConverter do
|
3
|
-
subject { described_class.new('Europe/Berlin') }
|
3
|
+
subject(:time_converter) { described_class.new('Europe/Berlin') }
|
4
4
|
|
5
5
|
describe '#to_cake' do
|
6
6
|
it 'converts a time-like object into a cake timestamp' do
|
7
|
-
expect(
|
8
|
-
expect(
|
9
|
-
expect(
|
7
|
+
expect(time_converter.to_cake(DateTime.new(2015, 1, 2, 12, 30))).to eq('2015-01-02T13:30:00')
|
8
|
+
expect(time_converter.to_cake(Time.utc(2015, 1, 2, 12, 30))).to eq('2015-01-02T13:30:00')
|
9
|
+
expect(time_converter.to_cake(Date.new(2015, 1, 2))).to eq('2015-01-02T01:00:00')
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'respects DST' do
|
13
|
-
expect(
|
14
|
-
expect(
|
13
|
+
expect(time_converter.to_cake(Time.utc(2015, 1, 2, 12, 30))).to eq('2015-01-02T13:30:00')
|
14
|
+
expect(time_converter.to_cake(Time.utc(2015, 6, 2, 12, 30))).to eq('2015-06-02T14:30:00')
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#from_cake' do
|
19
19
|
it 'parses cake dates into the specified time zone (including DST)' do
|
20
|
-
expect(
|
21
|
-
expect(
|
20
|
+
expect(time_converter.from_cake('2015-01-11T14:53:40.000')).to be_a(Time)
|
21
|
+
expect(time_converter.from_cake('2015-01-11T14:53:40.000'))
|
22
22
|
.to eq(Time.utc(2015, 1, 11, 13, 53, 40))
|
23
|
-
expect(
|
23
|
+
expect(time_converter.from_cake('2015-06-11T14:53:40.000'))
|
24
24
|
.to eq(Time.utc(2015, 6, 11, 12, 53, 40))
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
context 'legacy mode / CAKE_TIME_OFFSET' do
|
29
|
-
subject { described_class.new('Europe/Berlin', 5) }
|
29
|
+
subject(:time_converter) { described_class.new('Europe/Berlin', 5) }
|
30
30
|
|
31
31
|
it 'works as before (broken, without DST)' do
|
32
32
|
expect(STDERR).to receive(:puts).with(/Please use time_zone/)
|
33
33
|
|
34
|
-
expect(
|
35
|
-
expect(
|
34
|
+
expect(time_converter.to_cake(DateTime.new(2015, 1, 2, 12, 30))).to eq('2015-01-02T17:30:00')
|
35
|
+
expect(time_converter.to_cake(DateTime.new(2015, 6, 2, 12, 30))).to eq('2015-06-02T17:30:00')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
RSpec.shared_examples_for 'a cake admin method' do
|
3
|
+
subject(:admin) { described_class.new }
|
3
4
|
let(:request) { instance_double(SoapyCake::Request) }
|
4
5
|
|
5
6
|
it 'runs the request' do
|
6
7
|
expect(SoapyCake::Request).to receive(:new)
|
7
8
|
.with(:admin, service, cake_method, cake_opts || {}).and_return(request)
|
8
|
-
expect(
|
9
|
+
expect(admin).to receive(:run).with(request)
|
9
10
|
|
10
|
-
|
11
|
+
admin.public_send(method, *[opts || cake_opts].compact)
|
11
12
|
end
|
12
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soapy_cake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.25.
|
4
|
+
version: 1.25.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ad2games GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|