ink_file_picker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ink_file_picker/client.rb +1 -1
- data/lib/ink_file_picker/response.rb +11 -1
- data/lib/ink_file_picker/version.rb +1 -1
- data/spec/ink_file_picker/response_spec.rb +40 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b9c7875362ff6bf4c1184114dcd2c1481ac4620
|
4
|
+
data.tar.gz: 4c58dbe3e7a6677f38bc9149f8240c1352de344b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5e696624475b6c20b69eea7fc335dd6787951c5be8c63160dd641a570fed579bc625ec8154a449ae608204f2a834ea3c457ffaecd5bd96e273486e366c76e5a
|
7
|
+
data.tar.gz: fba1614dea4bf46e59cab2574e0713cc4947d79471c9a364f2fd72d911bf7784684236fbe81490e69c87365587b31bddeecba0a9698f52accb2b808bc91680c8
|
@@ -158,7 +158,7 @@ module InkFilePicker
|
|
158
158
|
|
159
159
|
add_policy_to params, from: policy_attributes, ensure_included: {handle: file_handle.handle, call: options[:call]}
|
160
160
|
|
161
|
-
|
161
|
+
UrlBuilder.new(file_url: file_handle.url, action: options[:url_action], params: params).to_s
|
162
162
|
end
|
163
163
|
|
164
164
|
def add_policy_to(params, options = {})
|
@@ -4,9 +4,19 @@ module InkFilePicker
|
|
4
4
|
# Decorates the response with hash like access to the
|
5
5
|
# parsed body, which is expected to be JSON.
|
6
6
|
class Response
|
7
|
+
DELEGATE_TO_RESPONSE = %w[
|
8
|
+
success? status headers body finished?
|
9
|
+
]
|
10
|
+
|
11
|
+
DELEGATE_TO_PARSED_BODY = %w[
|
12
|
+
to_hash each
|
13
|
+
]
|
14
|
+
|
7
15
|
attr_reader :http_response
|
8
16
|
|
9
|
-
delegate
|
17
|
+
delegate *DELEGATE_TO_RESPONSE, to: :http_response
|
18
|
+
delegate *DELEGATE_TO_PARSED_BODY, to: :parsed_body
|
19
|
+
|
10
20
|
|
11
21
|
def initialize(http_response)
|
12
22
|
@http_response = http_response
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe InkFilePicker::Response do
|
4
|
+
let(:http_response_body) { '{"url": "https://www.filepicker.io/api/file/WmFxB2aSe20SGT2kzSsr", "size": 234, "type": "image/jpeg", "filename": "test.jpg", "key": "WmFxB2aSe20SGT2kzSsr_test.jpg"}' }
|
5
|
+
let(:http_response) do
|
6
|
+
Faraday::Response.new(
|
7
|
+
body: http_response_body,
|
8
|
+
status: 200
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { described_class.new http_response }
|
13
|
+
|
14
|
+
it "has http_response" do
|
15
|
+
expect(subject.http_response).to eq http_response
|
16
|
+
end
|
17
|
+
|
18
|
+
described_class::DELEGATE_TO_RESPONSE.each do |name|
|
19
|
+
it "delegates #{name} to #http_response" do
|
20
|
+
expect(http_response).to receive(name).and_return 'an answer'
|
21
|
+
expect(subject.public_send name).to eq 'an answer'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has parsed_body" do
|
26
|
+
expect(subject.parsed_body).to eq JSON.parse http_response_body
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns parsed_body on to_hash" do
|
30
|
+
expect(subject.to_hash).to eq subject.parsed_body
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
described_class::DELEGATE_TO_PARSED_BODY.each do |name|
|
35
|
+
it "delegates #{name} to #parsed_body" do
|
36
|
+
expect(subject.parsed_body).to receive(name).and_return 'an answer'
|
37
|
+
expect(subject.public_send name).to eq 'an answer'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ink_file_picker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thorbjørn Hermansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- spec/ink_file_picker/configuration_spec.rb
|
115
115
|
- spec/ink_file_picker/file_handle_spec.rb
|
116
116
|
- spec/ink_file_picker/policy_spec.rb
|
117
|
+
- spec/ink_file_picker/response_spec.rb
|
117
118
|
- spec/ink_file_picker_spec.rb
|
118
119
|
- spec/spec_helper.rb
|
119
120
|
homepage: ''
|
@@ -146,5 +147,6 @@ test_files:
|
|
146
147
|
- spec/ink_file_picker/configuration_spec.rb
|
147
148
|
- spec/ink_file_picker/file_handle_spec.rb
|
148
149
|
- spec/ink_file_picker/policy_spec.rb
|
150
|
+
- spec/ink_file_picker/response_spec.rb
|
149
151
|
- spec/ink_file_picker_spec.rb
|
150
152
|
- spec/spec_helper.rb
|