frodo 0.10.4 → 0.10.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/frodo/entity.rb +9 -1
- data/lib/frodo/version.rb +1 -1
- data/spec/frodo/concerns/api_spec.rb +10 -0
- data/spec/frodo/entity_set_spec.rb +11 -0
- data/spec/frodo/entity_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d625c77ac93f7c66bfe21f5e5080cf00458cc76e
|
4
|
+
data.tar.gz: 67cd17ce735175b4670382677c0c200313f20bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08d6bba647323abc803c11123adedd0d56ee0630b4eb74037b630a43980cc55099aa06a3f75e4dad24fa66568557eb9ed182154d9c882c4d79c41c8f6b4e9fd6'
|
7
|
+
data.tar.gz: 2b66c975a180d4824d08c7d8358cf7db4182ee714a80a1cd32c62fe013c249561f857ebdec95e476655e4188e7ec0d9297096d488a598739e45793a02bc3671d
|
data/lib/frodo/entity.rb
CHANGED
@@ -88,6 +88,12 @@ module Frodo
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
# strip inline annotations from property names and return separately
|
92
|
+
def parse_annotations_from_property_name(property_name)
|
93
|
+
prop_name, annotation = property_name.to_s.split('@', 2)
|
94
|
+
return prop_name, annotation
|
95
|
+
end
|
96
|
+
|
91
97
|
def property_names
|
92
98
|
[
|
93
99
|
@properties_xml_value.andand.keys,
|
@@ -131,7 +137,9 @@ module Frodo
|
|
131
137
|
end
|
132
138
|
|
133
139
|
new_properties.each do |property_name, property_value|
|
134
|
-
|
140
|
+
prop_name, annotation = parse_annotations_from_property_name(property_name)
|
141
|
+
# TODO: Do something with the annotation?
|
142
|
+
self[prop_name] = property_value
|
135
143
|
end
|
136
144
|
end
|
137
145
|
entity
|
data/lib/frodo/version.rb
CHANGED
@@ -201,6 +201,16 @@ describe Frodo::Concerns::API do
|
|
201
201
|
expect{ subject }.to raise_error(ArgumentError)
|
202
202
|
end
|
203
203
|
end
|
204
|
+
|
205
|
+
context 'with @odata.bind properties' do
|
206
|
+
let(:attributes) {{
|
207
|
+
'ownerid@odata.bind': '/systemusers(12345)'
|
208
|
+
}}
|
209
|
+
it 'calls .update! with unmodified attributes' do
|
210
|
+
expect(client).to receive(:update!).with(entity_type, attributes).and_return(true)
|
211
|
+
expect(subject).to be(true)
|
212
|
+
end
|
213
|
+
end
|
204
214
|
end
|
205
215
|
|
206
216
|
describe '.destroy' do
|
@@ -90,6 +90,17 @@ describe Frodo::EntitySet, vcr: {cassette_name: 'entity_set_specs'} do
|
|
90
90
|
it { expect(new_entity['DiscontinuedDate']).to be_nil }
|
91
91
|
it { expect(new_entity['Rating']).to eq(4) }
|
92
92
|
it { expect(new_entity['Price']).to eq(3.5) }
|
93
|
+
|
94
|
+
context 'with @odata.bind properties' do
|
95
|
+
let(:properties) { super().merge({
|
96
|
+
'Supplier@odata.bind': '/systemusers(12345)'
|
97
|
+
})}
|
98
|
+
it 'creates entity without annotations' do
|
99
|
+
expect(new_entity.entity_set).to eq(subject)
|
100
|
+
expect(new_entity['Supplier']).to eq('/systemusers(12345)')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
93
104
|
end
|
94
105
|
|
95
106
|
# describe '#[]' do
|
data/spec/frodo/entity_spec.rb
CHANGED
@@ -59,8 +59,8 @@ describe Frodo::Entity, vcr: false do
|
|
59
59
|
let(:properties) { {
|
60
60
|
"firstname" => "Christoph",
|
61
61
|
"lastname" => "Wagner",
|
62
|
-
"ownerid" => "
|
63
|
-
"parentcustomerid_account" => "
|
62
|
+
"ownerid@odata.bind" => "/systemusers(95B9F1A8-3D5A-E911-A956-000D3A3B9CD8)",
|
63
|
+
"parentcustomerid_account@odata.bind" => "/accounts(60fb3f1c-b766-e911-a955-000d3a3b9316)",
|
64
64
|
} }
|
65
65
|
let(:entity_set) {
|
66
66
|
Frodo::EntitySet.new(
|
@@ -89,8 +89,8 @@ describe Frodo::Entity, vcr: false do
|
|
89
89
|
expect(subject.id).to eq('contacts()')
|
90
90
|
expect(subject['firstname']).to eq('Christoph')
|
91
91
|
expect(subject['lastname']).to eq('Wagner')
|
92
|
-
expect(subject['ownerid']).to eq('
|
93
|
-
expect(subject['parentcustomerid_account']).to eq('
|
92
|
+
expect(subject['ownerid']).to eq('/systemusers(95B9F1A8-3D5A-E911-A956-000D3A3B9CD8)')
|
93
|
+
expect(subject['parentcustomerid_account']).to eq('/accounts(60fb3f1c-b766-e911-a955-000d3a3b9316)')
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|