action_kit_rest 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca64b1d81e81abcc181f8389df3b0a5a6c6a808a5247095d127c8c259f61d668
|
4
|
+
data.tar.gz: d1446906a1e323bc240ea661517eaba948fce26c34df8e5655359a2df6a85488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1948223a468182d3f5e8b8636a5216be2f98df7c9e936e4b074a2550058cd84e3fd0cd07e8805f26807daf0f713884d2ec961ba7324ad52137253a31979533a5
|
7
|
+
data.tar.gz: e867c075b7d9f25cc943f465b86b2ebd2cd66f7bb9c8310c528f615ef60e664b336dc3e612a7fc0511205a8662d5199b29e5db9fad93f06d937ee59da6897534
|
data/action_kit_rest.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.4.
|
5
|
+
# stub: action_kit_rest 0.4.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "action_kit_rest".freeze
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.2"
|
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]
|
@@ -60,6 +60,7 @@ Gem::Specification.new do |s|
|
|
60
60
|
"lib/action_kit_rest/version.rb",
|
61
61
|
"spec/fixtures/action/event_create_action.json",
|
62
62
|
"spec/fixtures/action/event_signup_action.json",
|
63
|
+
"spec/fixtures/allowed_user_field/get.json",
|
63
64
|
"spec/fixtures/allowed_user_field/list.json",
|
64
65
|
"spec/fixtures/allowed_user_field/list_filtered.json",
|
65
66
|
"spec/fixtures/error.json",
|
@@ -14,7 +14,7 @@ module ActionKitRest
|
|
14
14
|
# We must override this, because the paths for allowed user fields use the name,
|
15
15
|
# not a numerical ID.
|
16
16
|
def extract_id_from_response(resp)
|
17
|
-
location.split('/').last
|
17
|
+
resp.response.headers["location"].split('/').last
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"allow_multiple": false,
|
3
|
+
"always_show": false,
|
4
|
+
"choices": [],
|
5
|
+
"created_at": "2016-10-19T01:39:35",
|
6
|
+
"description": "",
|
7
|
+
"display_name": "Foo",
|
8
|
+
"field_choices": "",
|
9
|
+
"field_default": "",
|
10
|
+
"field_length": null,
|
11
|
+
"field_regex": "",
|
12
|
+
"field_type": "string",
|
13
|
+
"hidden": false,
|
14
|
+
"name": "foo",
|
15
|
+
"order_index": 0,
|
16
|
+
"required": false,
|
17
|
+
"resource_uri": "/rest/v1/alloweduserfield/age/",
|
18
|
+
"updated_at": "2016-10-19T01:39:35"
|
19
|
+
}
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActionKitRest::AllowedUserField do
|
4
4
|
let(:status) { 200 }
|
5
|
+
let(:standard_headers) { {content_type: "application/json; charset=utf-8"} }
|
5
6
|
|
6
7
|
subject { ActionKitRest.new(host: 'test.com', username: 'alice', password: 'somesecret') }
|
7
8
|
|
@@ -11,17 +12,19 @@ describe ActionKitRest::AllowedUserField do
|
|
11
12
|
|
12
13
|
ActionKitRest.stub(:logger).and_return(logger)
|
13
14
|
Vertebrae::Base.stub(:logger).and_return(logger)
|
14
|
-
|
15
|
-
stub_get(request_path).with(basic_auth: ['alice', 'somesecret'])
|
16
|
-
.to_return(body: response_body,
|
17
|
-
status: status,
|
18
|
-
headers: {content_type: "application/json; charset=utf-8"})
|
19
15
|
end
|
20
16
|
|
21
17
|
describe '#list' do
|
22
18
|
let(:request_path) { 'alloweduserfield/' }
|
23
19
|
let(:response_body) { fixture('allowed_user_field/list.json') }
|
24
20
|
|
21
|
+
before :each do
|
22
|
+
stub_get(request_path).with(basic_auth: ['alice', 'somesecret'])
|
23
|
+
.to_return(body: response_body,
|
24
|
+
status: status,
|
25
|
+
headers: standard_headers)
|
26
|
+
end
|
27
|
+
|
25
28
|
it 'should return a list of objects' do
|
26
29
|
fields = subject.allowed_user_field.list
|
27
30
|
fields.each do |field|
|
@@ -34,9 +37,42 @@ describe ActionKitRest::AllowedUserField do
|
|
34
37
|
let(:request_path) { 'alloweduserfield/?name=age' }
|
35
38
|
let(:response_body) { fixture('allowed_user_field/list_filtered.json') }
|
36
39
|
|
40
|
+
before :each do
|
41
|
+
stub_get(request_path).with(basic_auth: ['alice', 'somesecret'])
|
42
|
+
.to_return(body: response_body,
|
43
|
+
status: status,
|
44
|
+
headers: standard_headers)
|
45
|
+
end
|
46
|
+
|
37
47
|
it 'should return a single object' do
|
38
48
|
field = subject.allowed_user_field.find('age')
|
39
49
|
expect(field.field_type).to eq 'integer'
|
40
50
|
end
|
41
51
|
end
|
52
|
+
|
53
|
+
describe '#create' do
|
54
|
+
let(:create_request_path) { 'alloweduserfield/' }
|
55
|
+
let(:create_request_body) { {name: 'foo'}.to_json }
|
56
|
+
let(:create_status) { 201 }
|
57
|
+
let(:created_url) { 'https://test.com/rest/v1/alloweduserfield/foo/' }
|
58
|
+
let(:get_request_path) { 'alloweduserfield/foo/' }
|
59
|
+
let(:get_response_body) { fixture('allowed_user_field/get.json') }
|
60
|
+
|
61
|
+
before :each do
|
62
|
+
stub_post(create_request_path).with(basic_auth: ['alice', 'somesecret'],
|
63
|
+
body: create_request_body)
|
64
|
+
.to_return(status: create_status,
|
65
|
+
headers: standard_headers.merge(Location: created_url))
|
66
|
+
|
67
|
+
stub_get(get_request_path).with(basic_auth: ['alice', 'somesecret'])
|
68
|
+
.to_return(body: get_response_body,
|
69
|
+
status: status,
|
70
|
+
headers: standard_headers)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should POST to the endpoint, then do a GET on the created object' do
|
74
|
+
field = subject.allowed_user_field.create({name: 'foo'})
|
75
|
+
expect(field.display_name).to eq 'Foo'
|
76
|
+
end
|
77
|
+
end
|
42
78
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Woodhull
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- lib/action_kit_rest/version.rb
|
224
224
|
- spec/fixtures/action/event_create_action.json
|
225
225
|
- spec/fixtures/action/event_signup_action.json
|
226
|
+
- spec/fixtures/allowed_user_field/get.json
|
226
227
|
- spec/fixtures/allowed_user_field/list.json
|
227
228
|
- spec/fixtures/allowed_user_field/list_filtered.json
|
228
229
|
- spec/fixtures/error.json
|