action_kit_rest 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/action_kit_rest.gemspec +3 -3
- data/lib/action_kit_rest/api.rb +3 -1
- data/lib/action_kit_rest/version.rb +1 -1
- data/spec/lib/action_kit_rest/user_spec.rb +42 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 317f12658a694714e0daa94fce192f265b89f4e929e952e9a3ca2282564342a0
|
4
|
+
data.tar.gz: 3fa2bf0508101bb095b92fb48f24267f1ccfa2358194fc6c95463a8d8755293a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e305d2038f0d79db110442bda003084f4fc06d064d14a9c25353d072f4785228c8f88da18a6c51ce25db48cc3c1d130c6f354a457340fb5f2658f32c30043b5
|
7
|
+
data.tar.gz: bc614ab72455c91988e262086647207d4925d3e0139a74ec912f5279117e2d639e546a4e3b7f5e93bdba136280c96971f0971a9d8121d8db8a633f91c4872c10
|
data/action_kit_rest.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: action_kit_rest 0.3.
|
5
|
+
# stub: action_kit_rest 0.3.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "action_kit_rest".freeze
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Nathan Woodhull".freeze, "Diego Marcet".freeze, "Jacinda Moore".freeze]
|
14
|
-
s.date = "2018-12-
|
14
|
+
s.date = "2018-12-05"
|
15
15
|
s.description = "Gem for interacting with the ActionKit API".freeze
|
16
16
|
s.email = "systems@controlshiftlabs.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/action_kit_rest/api.rb
CHANGED
@@ -37,7 +37,9 @@ module ActionKitRest
|
|
37
37
|
connection.stack do |builder|
|
38
38
|
builder.use Faraday::Request::Multipart
|
39
39
|
builder.use Faraday::Request::UrlEncoded
|
40
|
-
|
40
|
+
if connection.configuration.authenticated?
|
41
|
+
builder.use Faraday::Request::BasicAuthentication, connection.configuration.username, connection.configuration.password
|
42
|
+
end
|
41
43
|
|
42
44
|
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
43
45
|
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActionKitRest::User do
|
4
|
-
before
|
5
|
-
@actionkit = ActionKitRest.new(host: 'test.com')
|
6
|
-
|
4
|
+
before :each do
|
7
5
|
logger = double
|
8
6
|
logger.stub(:debug).and_return(true)
|
9
7
|
|
@@ -11,45 +9,63 @@ describe ActionKitRest::User do
|
|
11
9
|
Vertebrae::Base.stub(:logger).and_return(logger)
|
12
10
|
end
|
13
11
|
|
12
|
+
subject { ActionKitRest.new(host: 'test.com') }
|
14
13
|
|
15
14
|
describe "retrieval" do
|
16
15
|
let(:request_path) { 'user/1/' }
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
context 'without basic auth' do
|
18
|
+
before(:each) do
|
19
|
+
stub_get(request_path).to_return(:body => body, :status => status,
|
20
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
describe ".get" do
|
24
|
+
let(:status) { 200 }
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
context 'without phones' do
|
27
|
+
let(:body) { fixture('user/object_without_phones.json') }
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
it 'should return a user object' do
|
30
|
+
expect(subject.user.get(1).email).to eq 'walkers@wawd.com'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with phones' do
|
35
|
+
let(:body) { fixture('user/object_with_phones.json') }
|
36
|
+
let(:phone_body) { fixture('phone/object.json') }
|
37
|
+
|
38
|
+
it 'should include phones' do
|
39
|
+
stub_get('phone/?user=1').to_return(:body => phone_body, :status => 200)
|
40
|
+
expect(subject.user.get(1).phones.count).to eq 3
|
41
|
+
expect(subject.user.get(1).phones.map(&:phone)).to match_array(['7755555555', '7755555577', '310-310-3310'])
|
42
|
+
end
|
31
43
|
end
|
32
44
|
end
|
33
45
|
|
34
|
-
|
35
|
-
let(:body) {
|
36
|
-
let(:
|
46
|
+
describe 'user not found' do
|
47
|
+
let(:body) { '' }
|
48
|
+
let(:status) { 404 }
|
37
49
|
|
38
|
-
it
|
39
|
-
|
40
|
-
expect(@actionkit.user.get(1).phones.count).to eq 3
|
41
|
-
expect(@actionkit.user.get(1).phones.map(&:phone)).to match_array(['7755555555', '7755555577', '310-310-3310'])
|
50
|
+
it "should raise an exception" do
|
51
|
+
expect { subject.user.get(1) }.to raise_error(ActionKitRest::Response::NotFound)
|
42
52
|
end
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
46
|
-
|
47
|
-
let(:body) { '' }
|
48
|
-
|
56
|
+
context 'with basic auth' do
|
57
|
+
let(:body) { fixture('user/object_without_phones.json') }
|
58
|
+
|
59
|
+
subject { ActionKitRest.new(host: 'test.com', username: 'alice', password: 'somesecret') }
|
60
|
+
|
61
|
+
before(:each) do
|
62
|
+
stub_get(request_path).with(basic_auth: ['alice', 'somesecret'])
|
63
|
+
.to_return(body: body, status: 200, headers: {content_type: "application/json; charset=utf-8"})
|
64
|
+
end
|
49
65
|
|
50
|
-
it
|
51
|
-
expect
|
66
|
+
it 'should return a user object' do
|
67
|
+
expect(subject.user.get(1).email).to eq 'walkers@wawd.com'
|
52
68
|
end
|
53
69
|
end
|
54
70
|
end
|
55
|
-
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_kit_rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Woodhull
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-12-
|
13
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: vertebrae
|