frodo 0.12.7 → 0.12.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/frodo/concerns/api.rb +1 -1
- data/lib/frodo/service.rb +4 -4
- data/lib/frodo/version.rb +1 -1
- data/spec/frodo/client_spec.rb +26 -2
- data/spec/frodo/service_spec.rb +17 -1
- 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: 5a388c9e2e7916ae2e41438e5880a185e8669d24a3e69305e5feba9dcffe6969
|
4
|
+
data.tar.gz: 1e454f5b727aa91d5c8953771a55d46470fcc07f3ba915109ba482d8191749ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba148923cea7fe4537475e6f0b2667079730b02a949b3a8fbc77bffe18399b351000542d49bebec118455d833b39c20210360dcc4445b9d01901a9914f1f96d7
|
7
|
+
data.tar.gz: da0d8abbf0c24dfaf42c2bddf8cb9ad06bc69e8000b29d975691df32a149cfb01ddab4d6189f4b3da897615958655610d9738c62960c9d14a326b69f2186465d
|
data/lib/frodo/concerns/api.rb
CHANGED
@@ -41,7 +41,7 @@ module Frodo
|
|
41
41
|
|
42
42
|
def metadata_on_init
|
43
43
|
# Creating Metadata using a different client than the one that is stored
|
44
|
-
Frodo::Client.new(@options).api_get("$metadata").body
|
44
|
+
Frodo::Client.new(@options).api_get("$metadata").body if @options[:with_metadata]
|
45
45
|
end
|
46
46
|
|
47
47
|
# Public: Execute a query and returns the result.
|
data/lib/frodo/service.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Frodo
|
3
2
|
# Encapsulates the basic details and functionality needed to interact with an
|
4
3
|
# Frodo service.
|
@@ -21,7 +20,7 @@ module Frodo
|
|
21
20
|
@service_url = service_url
|
22
21
|
|
23
22
|
Frodo::ServiceRegistry.add(self)
|
24
|
-
register_custom_types
|
23
|
+
register_custom_types if @options[:with_metadata]
|
25
24
|
end
|
26
25
|
|
27
26
|
# Returns user supplied name for service, or its URL
|
@@ -173,14 +172,15 @@ module Frodo
|
|
173
172
|
end
|
174
173
|
|
175
174
|
def with_metadata?
|
176
|
-
|
175
|
+
!@options.key?(:with_metadata) || @options[:with_metadata]
|
177
176
|
end
|
178
177
|
|
179
178
|
private
|
180
179
|
|
181
180
|
def default_options
|
182
181
|
{
|
183
|
-
strict: true # strict property validation
|
182
|
+
strict: true, # strict property validation
|
183
|
+
with_metadata: true
|
184
184
|
}
|
185
185
|
end
|
186
186
|
|
data/lib/frodo/version.rb
CHANGED
data/spec/frodo/client_spec.rb
CHANGED
@@ -14,7 +14,8 @@ describe Frodo::Client do
|
|
14
14
|
instance_url: instance_url,
|
15
15
|
base_path: base_path,
|
16
16
|
client_id: 'client_id',
|
17
|
-
client_secret: 'secret'
|
17
|
+
client_secret: 'secret',
|
18
|
+
with_metadata: true
|
18
19
|
)
|
19
20
|
|
20
21
|
expect(client.options[:client_id]).to eql("client_id")
|
@@ -26,13 +27,36 @@ describe Frodo::Client do
|
|
26
27
|
to_return(body: File.new('spec/fixtures/files/metadata.xml'), status: 200)
|
27
28
|
|
28
29
|
service = client.service
|
29
|
-
|
30
|
+
expect(service.with_metadata?).to be_truthy
|
30
31
|
|
31
32
|
expect(service['Products']).to_not be_nil
|
32
33
|
expect(service['Products'].name).to eql('Products')
|
33
34
|
expect(service['Products'].type).to eql('ODataDemo.Product')
|
34
35
|
end
|
35
36
|
|
37
|
+
it "creates a client without metadata" do
|
38
|
+
client = subject.new(
|
39
|
+
instance_url: instance_url,
|
40
|
+
base_path: base_path,
|
41
|
+
client_id: 'client_id',
|
42
|
+
client_secret: 'secret',
|
43
|
+
with_metadata: false
|
44
|
+
)
|
45
|
+
|
46
|
+
expect(client.options[:client_id]).to eql("client_id")
|
47
|
+
expect(client.options[:client_secret]).to eql("secret")
|
48
|
+
expect(client.options[:instance_url]).to eql(instance_url)
|
49
|
+
expect(client.options[:base_path]).to eql("/api")
|
50
|
+
|
51
|
+
expect_any_instance_of(Frodo::Client).to_not receive(:api_get)
|
52
|
+
service = client.service
|
53
|
+
expect(service.with_metadata?).to be_falsey
|
54
|
+
|
55
|
+
expect(service['Products']).to_not be_nil
|
56
|
+
expect(service['Products'].name).to eql('Products')
|
57
|
+
expect(service['Products'].type).to eql(nil) #because we init new EntitySet only with name
|
58
|
+
end
|
59
|
+
|
36
60
|
it "creates a client and inject a service instead of pulling the configured one" do
|
37
61
|
service = Frodo::Service.new(service_url, name: 'Demo', metadata_file: 'spec/fixtures/files/metadata.xml')
|
38
62
|
client = subject.new(
|
data/spec/frodo/service_spec.rb
CHANGED
@@ -3,7 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Frodo::Service do
|
4
4
|
let(:service_url) { 'http://services.odata.org/V4/OData/OData.svc' }
|
5
5
|
let(:metadata_file) { 'spec/fixtures/files/metadata.xml' }
|
6
|
-
let(:
|
6
|
+
let(:options){{name: 'ODataDemo', metadata_file: metadata_file }}
|
7
|
+
let(:subject) { Frodo::Service.new(service_url, options) }
|
7
8
|
|
8
9
|
describe '.new' do
|
9
10
|
it 'adds itself to Frodo::ServiceRegistry on creation' do
|
@@ -34,6 +35,21 @@ describe Frodo::Service do
|
|
34
35
|
expect(Frodo::PropertyRegistry['mscrm.BooleanManagedProperty']).to be_a(Class)
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
39
|
+
context "with 'with_metadata' option" do
|
40
|
+
it "call 'register_custom_types'" do
|
41
|
+
expect_any_instance_of(Frodo::Service).to receive(:register_custom_types)
|
42
|
+
subject
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "without 'with_metadata' option" do
|
47
|
+
let(:options){{name: 'ODataDemo', with_metadata:false, metadata_file: metadata_file }}
|
48
|
+
it "call 'register_custom_types'" do
|
49
|
+
expect_any_instance_of(Frodo::Service).to_not receive(:register_custom_types)
|
50
|
+
subject
|
51
|
+
end
|
52
|
+
end
|
37
53
|
end
|
38
54
|
|
39
55
|
describe '#logger' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frodo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Pinault
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|