namely 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +125 -0
- data/Rakefile +16 -0
- data/lib/namely.rb +114 -0
- data/lib/namely/authenticator.rb +164 -0
- data/lib/namely/country.rb +9 -0
- data/lib/namely/currency_type.rb +9 -0
- data/lib/namely/event.rb +9 -0
- data/lib/namely/exceptions.rb +13 -0
- data/lib/namely/field.rb +9 -0
- data/lib/namely/job_tier.rb +9 -0
- data/lib/namely/profile.rb +13 -0
- data/lib/namely/report.rb +9 -0
- data/lib/namely/resource_gateway.rb +81 -0
- data/lib/namely/restful_model.rb +150 -0
- data/lib/namely/version.rb +3 -0
- data/namely.gemspec +30 -0
- data/spec/fixtures/vcr_cassettes/country_head.yml +51 -0
- data/spec/fixtures/vcr_cassettes/country_head_missing.yml +50 -0
- data/spec/fixtures/vcr_cassettes/country_index.yml +121 -0
- data/spec/fixtures/vcr_cassettes/country_show.yml +68 -0
- data/spec/fixtures/vcr_cassettes/country_show_missing.yml +54 -0
- data/spec/fixtures/vcr_cassettes/currencytype_index.yml +64 -0
- data/spec/fixtures/vcr_cassettes/event_head.yml +51 -0
- data/spec/fixtures/vcr_cassettes/event_head_missing.yml +50 -0
- data/spec/fixtures/vcr_cassettes/event_index.yml +88 -0
- data/spec/fixtures/vcr_cassettes/event_show.yml +62 -0
- data/spec/fixtures/vcr_cassettes/event_show_missing.yml +54 -0
- data/spec/fixtures/vcr_cassettes/field_index.yml +207 -0
- data/spec/fixtures/vcr_cassettes/jobtier_index.yml +103 -0
- data/spec/fixtures/vcr_cassettes/profile_create.yml +85 -0
- data/spec/fixtures/vcr_cassettes/profile_create_failed.yml +54 -0
- data/spec/fixtures/vcr_cassettes/profile_head.yml +51 -0
- data/spec/fixtures/vcr_cassettes/profile_head_missing.yml +50 -0
- data/spec/fixtures/vcr_cassettes/profile_index.yml +979 -0
- data/spec/fixtures/vcr_cassettes/profile_show.yml +91 -0
- data/spec/fixtures/vcr_cassettes/profile_show_missing.yml +54 -0
- data/spec/fixtures/vcr_cassettes/profile_show_updated.yml +91 -0
- data/spec/fixtures/vcr_cassettes/profile_update.yml +95 -0
- data/spec/fixtures/vcr_cassettes/profile_update_revert.yml +95 -0
- data/spec/fixtures/vcr_cassettes/report_head.yml +51 -0
- data/spec/fixtures/vcr_cassettes/report_head_missing.yml +50 -0
- data/spec/fixtures/vcr_cassettes/report_show.yml +185 -0
- data/spec/fixtures/vcr_cassettes/report_show_missing.yml +54 -0
- data/spec/fixtures/vcr_cassettes/token.yml +57 -0
- data/spec/fixtures/vcr_cassettes/token_refresh.yml +57 -0
- data/spec/namely/authenticator_spec.rb +143 -0
- data/spec/namely/configuration_spec.rb +33 -0
- data/spec/namely/country_spec.rb +11 -0
- data/spec/namely/currency_type_spec.rb +5 -0
- data/spec/namely/event_spec.rb +11 -0
- data/spec/namely/field_spec.rb +5 -0
- data/spec/namely/job_tier_spec.rb +5 -0
- data/spec/namely/profile_spec.rb +25 -0
- data/spec/namely/report_spec.rb +8 -0
- data/spec/namely/resource_gateway_spec.rb +93 -0
- data/spec/shared_examples/a_model_with_a_create_action.rb +24 -0
- data/spec/shared_examples/a_model_with_a_show_action.rb +38 -0
- data/spec/shared_examples/a_model_with_an_index_action.rb +17 -0
- data/spec/shared_examples/a_model_with_an_update_action.rb +37 -0
- data/spec/spec_helper.rb +49 -0
- metadata +280 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: head
|
5
|
+
uri: https://<TEST_SUBDOMAIN>.namely.com/api/v1/reports/this-is-almost-certainly-not-the-id-of-any-model?access_token=<TEST_ACCESS_TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 404
|
19
|
+
message: Not Found
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache
|
23
|
+
Content-Encoding:
|
24
|
+
- gzip
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Date:
|
28
|
+
- Tue, 04 Nov 2014 16:34:50 GMT
|
29
|
+
Server:
|
30
|
+
- nginx/1.6.2
|
31
|
+
Status:
|
32
|
+
- 404 Not Found
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=31536000
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
X-Rack-Cache:
|
38
|
+
- miss
|
39
|
+
X-Request-Id:
|
40
|
+
- d7d37c67-ed05-4344-a6ff-cdfdf35552cc
|
41
|
+
X-Runtime:
|
42
|
+
- '0.024991'
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: ''
|
48
|
+
http_version:
|
49
|
+
recorded_at: Tue, 04 Nov 2014 16:34:50 GMT
|
50
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,185 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<TEST_SUBDOMAIN>.namely.com/api/v1/reports/bbf089f6-90c5-473c-8928-058014a462c9?access_token=<TEST_ACCESS_TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- max-age=0, private, must-revalidate
|
23
|
+
Content-Encoding:
|
24
|
+
- gzip
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Date:
|
28
|
+
- Tue, 04 Nov 2014 16:34:49 GMT
|
29
|
+
Server:
|
30
|
+
- nginx
|
31
|
+
Status:
|
32
|
+
- 200 OK
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=31536000
|
35
|
+
- max-age=31536000; includeSubDomains;
|
36
|
+
Vary:
|
37
|
+
- Accept-Encoding
|
38
|
+
X-Rack-Cache:
|
39
|
+
- miss
|
40
|
+
X-Request-Id:
|
41
|
+
- 977b6e70-4437-4f03-b138-0dc56ceafea1
|
42
|
+
X-Runtime:
|
43
|
+
- '0.114426'
|
44
|
+
Content-Length:
|
45
|
+
- '5918'
|
46
|
+
Connection:
|
47
|
+
- keep-alive
|
48
|
+
body:
|
49
|
+
encoding: ASCII-8BIT
|
50
|
+
string: !binary |-
|
51
|
+
H4sIAAAAAAAAA7VdXXPbttL+Kx7f5Kb2SPKX1BvXH4kdx0p8JDeettPJgCRE
|
52
|
+
wiIJlR9W5E7/+9ldAJQSA/W+r04uTmM+oJYgsNh9drHg+Xu3kgtdNfXuz3/8
|
53
|
+
vauS3Z93o2jWG45mx3ujXny0d3hyEO8NR4PhXu9o2OsfisPjQTza/Wm3WS0k
|
54
|
+
3L2o9EzlEoBY521RGkGlKDYa6y8zVdXNF0K7XzbyawNXuYhkDpfv8JYduuWf
|
55
|
+
n15KyMVrAm7Fv/1eFkLlwd++pVbf7+pGVM2XRDQbD7ZX7sdTvGWHQP+TF7le
|
56
|
+
SfmFfh3ugblr5x6bfXLaWlbYnaatg1J+hXt2puaef/7EOSkbWTYwJ3/sflR1
|
57
|
+
JmUCd/8uqmeRy0e9M4aeqxLFybopzQ3PrrWgxl/kVwF9k/uxLuDGAegAqMJe
|
58
|
+
rw8X79o837lXNClncaOe5I57j90/f/pj955+clG1q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+H8/
|
182
|
+
U0igsPD3Bmz+hCAdb/kvtPocsn5oAAA=
|
183
|
+
http_version:
|
184
|
+
recorded_at: Tue, 04 Nov 2014 16:34:49 GMT
|
185
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<TEST_SUBDOMAIN>.namely.com/api/v1/reports/this-is-almost-certainly-not-the-id-of-any-model?access_token=<TEST_ACCESS_TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 404
|
19
|
+
message: Not Found
|
20
|
+
headers:
|
21
|
+
Cache-Control:
|
22
|
+
- no-cache
|
23
|
+
Content-Encoding:
|
24
|
+
- gzip
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Date:
|
28
|
+
- Tue, 04 Nov 2014 16:34:49 GMT
|
29
|
+
Server:
|
30
|
+
- nginx/1.6.2
|
31
|
+
Status:
|
32
|
+
- 404 Not Found
|
33
|
+
Strict-Transport-Security:
|
34
|
+
- max-age=31536000
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
X-Rack-Cache:
|
38
|
+
- miss
|
39
|
+
X-Request-Id:
|
40
|
+
- 52e1e643-65de-487a-8b28-2be8291d2f1b
|
41
|
+
X-Runtime:
|
42
|
+
- '0.025837'
|
43
|
+
Content-Length:
|
44
|
+
- '64'
|
45
|
+
Connection:
|
46
|
+
- keep-alive
|
47
|
+
body:
|
48
|
+
encoding: ASCII-8BIT
|
49
|
+
string: !binary |-
|
50
|
+
H4sIAAAAAAAAA6tWyk0tLk5MT1WyUgpKLcgvKlHIyy9RSMsvzUtR0lFKLSrK
|
51
|
+
LypWssorzcmpBQBUHrxBLAAAAA==
|
52
|
+
http_version:
|
53
|
+
recorded_at: Tue, 04 Nov 2014 16:34:49 GMT
|
54
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<TEST_SUBDOMAIN>.namely.com/api/v1/oauth2/token?redirect_uri=<CLIENT_REDIRECT_URI>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: grant_type=authorization_code&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&code=<AUTH_CODE>
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*; q=0.5, application/xml"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Content-Length:
|
15
|
+
- '189'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- no-store
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Date:
|
30
|
+
- Tue, 04 Nov 2014 16:38:10 GMT
|
31
|
+
Etag:
|
32
|
+
- '"fc3490b779796351d40312ba491c69c2"'
|
33
|
+
Pragma:
|
34
|
+
- no-cache
|
35
|
+
Server:
|
36
|
+
- nginx
|
37
|
+
Status:
|
38
|
+
- 200 OK
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=31536000
|
41
|
+
- max-age=31536000; includeSubDomains;
|
42
|
+
X-Rack-Cache:
|
43
|
+
- invalidate, pass
|
44
|
+
X-Request-Id:
|
45
|
+
- 386d8523-f838-4023-a096-f74bc6c6291e
|
46
|
+
X-Runtime:
|
47
|
+
- '0.059499'
|
48
|
+
Content-Length:
|
49
|
+
- '141'
|
50
|
+
Connection:
|
51
|
+
- keep-alive
|
52
|
+
body:
|
53
|
+
encoding: UTF-8
|
54
|
+
string: '{"access_token":"<%= access_token %>","refresh_token":"<%= refresh_token %>","token_type":"bearer","expires_in":899}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Tue, 04 Nov 2014 16:38:11 GMT
|
57
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<TEST_SUBDOMAIN>.namely.com/api/v1/oauth2/token?redirect_uri=<CLIENT_REDIRECT_URI>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: grant_type=refresh_token&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&refresh_token=<TEST_REFRESH_TOKEN>
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*; q=0.5, application/xml"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
Content-Length:
|
15
|
+
- '193'
|
16
|
+
Content-Type:
|
17
|
+
- application/x-www-form-urlencoded
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Cache-Control:
|
26
|
+
- no-store
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Date:
|
30
|
+
- Tue, 04 Nov 2014 17:06:29 GMT
|
31
|
+
Etag:
|
32
|
+
- '"c4566dc1eddea53969e88a3bc69cdfb3"'
|
33
|
+
Pragma:
|
34
|
+
- no-cache
|
35
|
+
Server:
|
36
|
+
- nginx/1.6.2
|
37
|
+
Status:
|
38
|
+
- 200 OK
|
39
|
+
Strict-Transport-Security:
|
40
|
+
- max-age=31536000
|
41
|
+
- max-age=31536000; includeSubDomains;
|
42
|
+
X-Rack-Cache:
|
43
|
+
- invalidate, pass
|
44
|
+
X-Request-Id:
|
45
|
+
- e2d5a360-d44d-4198-8528-ceb6ad91bd6c
|
46
|
+
X-Runtime:
|
47
|
+
- '0.045489'
|
48
|
+
Content-Length:
|
49
|
+
- '90'
|
50
|
+
Connection:
|
51
|
+
- keep-alive
|
52
|
+
body:
|
53
|
+
encoding: UTF-8
|
54
|
+
string: '{"access_token":"<%= access_token %>","token_type":"bearer","expires_in":899}'
|
55
|
+
http_version:
|
56
|
+
recorded_at: Tue, 04 Nov 2014 17:06:29 GMT
|
57
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "cgi"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
describe Namely::Authenticator do
|
6
|
+
describe "#auth_code_url" do
|
7
|
+
it "returns a URL to begin the authorization code URL flow" do
|
8
|
+
authenticator = described_class.new(
|
9
|
+
client_id: "MY_CLIENT_ID",
|
10
|
+
client_secret: "MY_CLIENT_SECRET",
|
11
|
+
)
|
12
|
+
|
13
|
+
authorization_code_url = authenticator.authorization_code_url(
|
14
|
+
subdomain: "ellingsonmineral",
|
15
|
+
redirect_uri: "http://www.example.com/authenticated",
|
16
|
+
)
|
17
|
+
|
18
|
+
parsed_uri = URI(authorization_code_url)
|
19
|
+
parsed_query = CGI.parse(parsed_uri.query)
|
20
|
+
expect(parsed_uri.scheme).to eq "https"
|
21
|
+
expect(parsed_uri.host).to eq "ellingsonmineral.namely.com"
|
22
|
+
expect(parsed_uri.path).to eq "/api/v1/oauth2/authorize"
|
23
|
+
expect(parsed_query).to eq(
|
24
|
+
"response_type" => ["code"],
|
25
|
+
"approve" => ["true"],
|
26
|
+
"client_id" => ["MY_CLIENT_ID"],
|
27
|
+
"redirect_uri" => ["http://www.example.com/authenticated"],
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "allows the redirect_uri to be omitted" do
|
32
|
+
authenticator = described_class.new(
|
33
|
+
client_id: "MY_CLIENT_ID",
|
34
|
+
client_secret: "MY_CLIENT_SECRET",
|
35
|
+
)
|
36
|
+
|
37
|
+
authorization_code_url = authenticator.authorization_code_url(
|
38
|
+
subdomain: "ellingsonmineral",
|
39
|
+
)
|
40
|
+
|
41
|
+
parsed_uri = URI(authorization_code_url)
|
42
|
+
parsed_query = CGI.parse(parsed_uri.query)
|
43
|
+
expect(parsed_query).to eq(
|
44
|
+
"response_type" => ["code"],
|
45
|
+
"approve" => ["true"],
|
46
|
+
"client_id" => ["MY_CLIENT_ID"],
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "escapes reserved characters in query parameters" do
|
51
|
+
authenticator = described_class.new(
|
52
|
+
client_id: "MY_CLIENT_ID",
|
53
|
+
client_secret: "MY_CLIENT_SECRET",
|
54
|
+
)
|
55
|
+
redirect_uri = "http://example.com/?auth=true&provider=namely"
|
56
|
+
|
57
|
+
authorization_code_url = authenticator.authorization_code_url(
|
58
|
+
subdomain: "ellingsonmineral",
|
59
|
+
redirect_uri: redirect_uri,
|
60
|
+
)
|
61
|
+
|
62
|
+
parsed_uri = URI(authorization_code_url)
|
63
|
+
parsed_query = CGI.parse(parsed_uri.query)
|
64
|
+
expect(parsed_query["redirect_uri"]).to eq [redirect_uri]
|
65
|
+
end
|
66
|
+
|
67
|
+
it "allows the host and protocol to be overridden" do
|
68
|
+
authenticator = described_class.new(
|
69
|
+
client_id: "MY_CLIENT_ID",
|
70
|
+
client_secret: "MY_CLIENT_SECRET",
|
71
|
+
)
|
72
|
+
|
73
|
+
authorization_code_url = authenticator.authorization_code_url(
|
74
|
+
protocol: "http",
|
75
|
+
host: "testing.example.com",
|
76
|
+
)
|
77
|
+
|
78
|
+
parsed_uri = URI(authorization_code_url)
|
79
|
+
expect(parsed_uri.scheme).to eq "http"
|
80
|
+
expect(parsed_uri.host).to eq "testing.example.com"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#retrieve_tokens" do
|
85
|
+
it "exchanges an authorization code for access and refresh tokens" do
|
86
|
+
erb_settings = {
|
87
|
+
erb: {
|
88
|
+
access_token: "MY_ACCESS_TOKEN",
|
89
|
+
refresh_token: "MY_REFRESH_TOKEN",
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
VCR.use_cassette("token", erb_settings) do
|
94
|
+
authenticator = described_class.new(
|
95
|
+
client_id: ENV.fetch("CLIENT_ID"),
|
96
|
+
client_secret: ENV.fetch("CLIENT_SECRET"),
|
97
|
+
)
|
98
|
+
|
99
|
+
tokens = authenticator.retrieve_tokens(
|
100
|
+
subdomain: ENV.fetch("TEST_SUBDOMAIN"),
|
101
|
+
code: ENV.fetch("AUTH_CODE"),
|
102
|
+
redirect_uri: ENV.fetch("CLIENT_REDIRECT_URI"),
|
103
|
+
)
|
104
|
+
|
105
|
+
expect(tokens).to eq(
|
106
|
+
"access_token" => "MY_ACCESS_TOKEN",
|
107
|
+
"refresh_token" => "MY_REFRESH_TOKEN",
|
108
|
+
"expires_in" => 899,
|
109
|
+
"token_type" => "bearer",
|
110
|
+
)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#refresh_access_token" do
|
116
|
+
it "uses a refresh token to retrieve a new access token" do
|
117
|
+
erb_settings = {
|
118
|
+
erb: {
|
119
|
+
access_token: "MY_ACCESS_TOKEN",
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
VCR.use_cassette("token_refresh", erb_settings) do
|
124
|
+
authenticator = described_class.new(
|
125
|
+
client_id: ENV.fetch("CLIENT_ID"),
|
126
|
+
client_secret: ENV.fetch("CLIENT_SECRET"),
|
127
|
+
)
|
128
|
+
|
129
|
+
tokens = authenticator.refresh_access_token(
|
130
|
+
subdomain: ENV.fetch("TEST_SUBDOMAIN"),
|
131
|
+
refresh_token: ENV.fetch("TEST_REFRESH_TOKEN"),
|
132
|
+
redirect_uri: ENV.fetch("CLIENT_REDIRECT_URI"),
|
133
|
+
)
|
134
|
+
|
135
|
+
expect(tokens).to eq(
|
136
|
+
"access_token" => "MY_ACCESS_TOKEN",
|
137
|
+
"expires_in" => 899,
|
138
|
+
"token_type" => "bearer",
|
139
|
+
)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|