patient_zero 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/patient_zero/errors.rb +1 -0
- data/lib/patient_zero/source.rb +7 -0
- data/lib/patient_zero/version.rb +1 -1
- data/spec/patient_zero/source_spec.rb +23 -0
- 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: 153ec2b306afb2cb3246ae44af572dfaf4b3a339
|
4
|
+
data.tar.gz: 37465e5232e2e0e79ad005134f381eb50ab56110
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c20cff52a8871e886ccaa192393b1c8b34675332ae4cad426bde9dbf19e15c3c613748215af0943503fd72e627ea8dbcbc598b734a2318f255e2dfa305b83ba
|
7
|
+
data.tar.gz: 41be55eb469a678708668864f8509d695d876a75ed5776596cc06ca1d81935b6a6ade0882ae2d7ef7fa03498217e5c4c808245673fbf05eddc32c5ce1edcbfb3
|
data/lib/patient_zero/errors.rb
CHANGED
data/lib/patient_zero/source.rb
CHANGED
@@ -28,6 +28,13 @@ module PatientZero
|
|
28
28
|
raise NotFoundError, e
|
29
29
|
end
|
30
30
|
|
31
|
+
def self.creation_url platform, token=Authorization.token, reference_id=nil
|
32
|
+
response = connection.get("/mobile/api/v1/sources/#{platform}/authenticate", client_token: token, reference_id: reference_id)
|
33
|
+
creation_url = response.headers.fetch :location
|
34
|
+
raise InvalidPlatformError, creation_url.split('error=').last if creation_url.include? 'error'
|
35
|
+
creation_url
|
36
|
+
end
|
37
|
+
|
31
38
|
def platform_id
|
32
39
|
id.split('#').last
|
33
40
|
end
|
data/lib/patient_zero/version.rb
CHANGED
@@ -65,6 +65,29 @@ module PatientZero
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
describe '.creation_url' do
|
69
|
+
let(:platform) { 'facebook' }
|
70
|
+
let(:url) { 'http://something-something.dangerzone.com' }
|
71
|
+
let(:creation_url_response) { double :creation_url_response, headers: { location: url } }
|
72
|
+
before{ allow(Source.connection).to receive(:get).with("/mobile/api/v1/sources/#{platform}/authenticate", anything).and_return creation_url_response }
|
73
|
+
it 'calls the sources authentication api' do
|
74
|
+
expect(Source.connection).to receive(:get).with("/mobile/api/v1/sources/#{platform}/authenticate", anything)
|
75
|
+
Source.creation_url platform, token, 678
|
76
|
+
end
|
77
|
+
context 'when using a valid platform name' do
|
78
|
+
it 'returns the valid url' do
|
79
|
+
expect(Source.creation_url platform, token, 678).to eq url
|
80
|
+
end
|
81
|
+
end
|
82
|
+
context 'when using an invalid platform name' do
|
83
|
+
let(:platform) { 'myspace' }
|
84
|
+
let(:url) { '"https://app.viralheat.com?error=Invalid platform Myspace"' }
|
85
|
+
it 'raises an InvalidPlatformError' do
|
86
|
+
expect{Source.creation_url platform, token, 678}.to raise_error InvalidPlatformError
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
68
91
|
describe '#platform_id' do
|
69
92
|
it 'returns the number at the end of the id' do
|
70
93
|
expect(source.platform_id).to eq '1234567890'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patient_zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Zaninovich
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|