ruby_odata 0.1.0 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +7 -2
- data/.simplecov +10 -0
- data/.travis.yml +10 -4
- data/.yardopts +6 -0
- data/CHANGELOG.md +157 -0
- data/Guardfile +14 -0
- data/LICENSE +20 -22
- data/README.md +289 -0
- data/Rakefile +19 -9
- data/features/basic_auth.feature +3 -2
- data/features/batch_request.feature +7 -6
- data/features/cassettes/basic_auth_protected_resource.yml +57 -0
- data/features/cassettes/batch_request_additions.yml +69 -0
- data/features/cassettes/batch_request_deletes.yml +69 -0
- data/features/cassettes/batch_request_updates.yml +69 -0
- data/features/cassettes/clean_database_for_testing.yml +46 -0
- data/features/cassettes/cucumber_tags/basic_auth.yml +297 -0
- data/features/cassettes/cucumber_tags/batch_request.yml +1459 -0
- data/features/cassettes/cucumber_tags/complex_types.yml +326 -0
- data/features/cassettes/cucumber_tags/error_handling.yml +64 -0
- data/features/cassettes/cucumber_tags/query_builder.yml +2025 -0
- data/features/cassettes/cucumber_tags/service.yml +234 -0
- data/features/cassettes/cucumber_tags/service_manage.yml +937 -0
- data/features/cassettes/cucumber_tags/service_methods.yml +647 -0
- data/features/cassettes/cucumber_tags/ssl.yml +203 -0
- data/features/cassettes/cucumber_tags/type_conversion.yml +337 -0
- data/features/cassettes/service_manage_additions.yml +65 -0
- data/features/cassettes/service_manage_deletions.yml +58 -0
- data/features/cassettes/service_manage_deletions_2.yml +58 -0
- data/features/cassettes/unsecured_metadata.yml +89 -0
- data/features/complex_types.feature +4 -3
- data/features/error_handling.feature +13 -0
- data/features/query_builder.feature +30 -9
- data/features/service.feature +4 -3
- data/features/service_manage.feature +6 -5
- data/features/service_methods.feature +3 -2
- data/features/ssl.feature +8 -8
- data/features/step_definitions/service_steps.rb +32 -74
- data/features/support/env.rb +6 -3
- data/features/support/hooks.rb +3 -2
- data/features/support/pickle.rb +29 -18
- data/features/support/vcr.rb +24 -0
- data/features/type_conversion.feature +16 -17
- data/gemfiles/Gemfile.ruby187 +6 -0
- data/lib/ruby_odata.rb +20 -18
- data/lib/ruby_odata/association.rb +7 -6
- data/lib/ruby_odata/class_builder.rb +31 -14
- data/lib/ruby_odata/exceptions.rb +11 -0
- data/lib/ruby_odata/helpers.rb +17 -0
- data/lib/ruby_odata/operation.rb +5 -6
- data/lib/ruby_odata/property_metadata.rb +9 -7
- data/lib/ruby_odata/query_builder.rb +127 -63
- data/lib/ruby_odata/service.rb +265 -147
- data/lib/ruby_odata/version.rb +3 -1
- data/ruby_odata.gemspec +22 -13
- data/spec/fixtures/error_without_message.xml +5 -0
- data/spec/fixtures/int64_ids/edmx_boat_service.xml +19 -0
- data/spec/fixtures/int64_ids/edmx_car_service.xml +21 -0
- data/spec/fixtures/int64_ids/result_boats.xml +26 -0
- data/spec/fixtures/int64_ids/result_cars.xml +28 -0
- data/spec/fixtures/ms_system_center/edmx_ms_system_center.xml +1645 -0
- data/spec/fixtures/ms_system_center/edmx_ms_system_center_v2.xml +2120 -0
- data/spec/fixtures/ms_system_center/hardware_profiles.xml +61 -0
- data/spec/fixtures/ms_system_center/virtual_machines.xml +175 -0
- data/spec/fixtures/ms_system_center/vm_templates.xml +1193 -0
- data/spec/fixtures/nested_expands/edmx_northwind.xml +557 -0
- data/spec/fixtures/nested_expands/northwind_products_category_expands.xml +774 -0
- data/spec/fixtures/sample_service/result_select_categories_expand.xml +268 -0
- data/spec/fixtures/sample_service/result_select_categories_no_property.xml +6 -0
- data/spec/fixtures/sample_service/result_select_categories_travsing_no_expand.xml +6 -0
- data/spec/fixtures/sample_service/result_select_products_name_price.xml +92 -0
- data/spec/property_metadata_spec.rb +10 -10
- data/spec/query_builder_spec.rb +153 -14
- data/spec/revised_service_spec.rb +111 -6
- data/spec/service_spec.rb +389 -85
- data/spec/spec_helper.rb +3 -0
- data/spec/support/sample_service_matcher.rb +15 -0
- data/test/RubyODataService/RubyODataService/App_Data/.gitkeep +0 -0
- data/test/blueprints.rb +15 -9
- data/test/usage_samples/querying.rb +5 -1
- data/test/usage_samples/sample_data.rb +1 -3
- metadata +276 -76
- data/CHANGELOG.rdoc +0 -88
- data/README.rdoc +0 -259
@@ -0,0 +1,268 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<feed xml:base="http://win7dev:8989/SampleService/RubyOData.svc/"
|
3
|
+
xmlns="http://www.w3.org/2005/Atom"
|
4
|
+
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
|
5
|
+
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
|
6
|
+
xmlns:georss="http://www.georss.org/georss"
|
7
|
+
xmlns:gml="http://www.opengis.net/gml">
|
8
|
+
<id>http://win7dev:8989/SampleService/RubyOdata.svc/Categories</id>
|
9
|
+
<title type="text">Categories</title>
|
10
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
11
|
+
<link rel="self" title="Categories" href="Categories" />
|
12
|
+
<entry>
|
13
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(1)</id>
|
14
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
15
|
+
<link rel="edit" title="Category" href="Categories(1)" />
|
16
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(1)/Products">
|
17
|
+
<m:inline>
|
18
|
+
<feed>
|
19
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(1)/Products</id>
|
20
|
+
<title type="text">Products</title>
|
21
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
22
|
+
<link rel="self" title="Products" href="Categories(1)/Products" />
|
23
|
+
<entry>
|
24
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(1)</id>
|
25
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
26
|
+
<link rel="edit" title="Product" href="Products(1)" />
|
27
|
+
<title />
|
28
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
29
|
+
<author>
|
30
|
+
<name />
|
31
|
+
</author>
|
32
|
+
<content type="application/xml">
|
33
|
+
<m:properties>
|
34
|
+
<d:Name>Widget 0001</d:Name>
|
35
|
+
</m:properties>
|
36
|
+
</content>
|
37
|
+
</entry>
|
38
|
+
</feed>
|
39
|
+
</m:inline>
|
40
|
+
</link>
|
41
|
+
<title />
|
42
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
43
|
+
<author>
|
44
|
+
<name />
|
45
|
+
</author>
|
46
|
+
<content type="application/xml">
|
47
|
+
<m:properties>
|
48
|
+
<d:Name>Category 0001</d:Name>
|
49
|
+
</m:properties>
|
50
|
+
</content>
|
51
|
+
</entry>
|
52
|
+
<entry>
|
53
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(2)</id>
|
54
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
55
|
+
<link rel="edit" title="Category" href="Categories(2)" />
|
56
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(2)/Products">
|
57
|
+
<m:inline>
|
58
|
+
<feed>
|
59
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(2)/Products</id>
|
60
|
+
<title type="text">Products</title>
|
61
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
62
|
+
<link rel="self" title="Products" href="Categories(2)/Products" />
|
63
|
+
<entry>
|
64
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(2)</id>
|
65
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
66
|
+
<link rel="edit" title="Product" href="Products(2)" />
|
67
|
+
<title />
|
68
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
69
|
+
<author>
|
70
|
+
<name />
|
71
|
+
</author>
|
72
|
+
<content type="application/xml">
|
73
|
+
<m:properties>
|
74
|
+
<d:Name>Widget 0002</d:Name>
|
75
|
+
</m:properties>
|
76
|
+
</content>
|
77
|
+
</entry>
|
78
|
+
</feed>
|
79
|
+
</m:inline>
|
80
|
+
</link>
|
81
|
+
<title />
|
82
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
83
|
+
<author>
|
84
|
+
<name />
|
85
|
+
</author>
|
86
|
+
<content type="application/xml">
|
87
|
+
<m:properties>
|
88
|
+
<d:Name>Category 0001</d:Name>
|
89
|
+
</m:properties>
|
90
|
+
</content>
|
91
|
+
</entry>
|
92
|
+
<entry>
|
93
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(3)</id>
|
94
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
95
|
+
<link rel="edit" title="Category" href="Categories(3)" />
|
96
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(3)/Products">
|
97
|
+
<m:inline>
|
98
|
+
<feed>
|
99
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(3)/Products</id>
|
100
|
+
<title type="text">Products</title>
|
101
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
102
|
+
<link rel="self" title="Products" href="Categories(3)/Products" />
|
103
|
+
<entry>
|
104
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(3)</id>
|
105
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
106
|
+
<link rel="edit" title="Product" href="Products(3)" />
|
107
|
+
<title />
|
108
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
109
|
+
<author>
|
110
|
+
<name />
|
111
|
+
</author>
|
112
|
+
<content type="application/xml">
|
113
|
+
<m:properties>
|
114
|
+
<d:Name>Widget 0003</d:Name>
|
115
|
+
</m:properties>
|
116
|
+
</content>
|
117
|
+
</entry>
|
118
|
+
</feed>
|
119
|
+
</m:inline>
|
120
|
+
</link>
|
121
|
+
<title />
|
122
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
123
|
+
<author>
|
124
|
+
<name />
|
125
|
+
</author>
|
126
|
+
<content type="application/xml">
|
127
|
+
<m:properties>
|
128
|
+
<d:Name>Category 0002</d:Name>
|
129
|
+
</m:properties>
|
130
|
+
</content>
|
131
|
+
</entry>
|
132
|
+
<entry>
|
133
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(4)</id>
|
134
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
135
|
+
<link rel="edit" title="Category" href="Categories(4)" />
|
136
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(4)/Products">
|
137
|
+
<m:inline>
|
138
|
+
<feed>
|
139
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(4)/Products</id>
|
140
|
+
<title type="text">Products</title>
|
141
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
142
|
+
<link rel="self" title="Products" href="Categories(4)/Products" />
|
143
|
+
<entry>
|
144
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(4)</id>
|
145
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
146
|
+
<link rel="edit" title="Product" href="Products(4)" />
|
147
|
+
<title />
|
148
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
149
|
+
<author>
|
150
|
+
<name />
|
151
|
+
</author>
|
152
|
+
<content type="application/xml">
|
153
|
+
<m:properties>
|
154
|
+
<d:Name>Widget 0004</d:Name>
|
155
|
+
</m:properties>
|
156
|
+
</content>
|
157
|
+
</entry>
|
158
|
+
</feed>
|
159
|
+
</m:inline>
|
160
|
+
</link>
|
161
|
+
<title />
|
162
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
163
|
+
<author>
|
164
|
+
<name />
|
165
|
+
</author>
|
166
|
+
<content type="application/xml">
|
167
|
+
<m:properties>
|
168
|
+
<d:Name>Category 0002</d:Name>
|
169
|
+
</m:properties>
|
170
|
+
</content>
|
171
|
+
</entry>
|
172
|
+
<entry>
|
173
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(5)</id>
|
174
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
175
|
+
<link rel="edit" title="Category" href="Categories(5)" />
|
176
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(5)/Products">
|
177
|
+
<m:inline>
|
178
|
+
<feed>
|
179
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(5)/Products</id>
|
180
|
+
<title type="text">Products</title>
|
181
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
182
|
+
<link rel="self" title="Products" href="Categories(5)/Products" />
|
183
|
+
<entry>
|
184
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(5)</id>
|
185
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
186
|
+
<link rel="edit" title="Product" href="Products(5)" />
|
187
|
+
<title />
|
188
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
189
|
+
<author>
|
190
|
+
<name />
|
191
|
+
</author>
|
192
|
+
<content type="application/xml">
|
193
|
+
<m:properties>
|
194
|
+
<d:Name>Widget 0005</d:Name>
|
195
|
+
</m:properties>
|
196
|
+
</content>
|
197
|
+
</entry>
|
198
|
+
</feed>
|
199
|
+
</m:inline>
|
200
|
+
</link>
|
201
|
+
<title />
|
202
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
203
|
+
<author>
|
204
|
+
<name />
|
205
|
+
</author>
|
206
|
+
<content type="application/xml">
|
207
|
+
<m:properties>
|
208
|
+
<d:Name>Category 0002</d:Name>
|
209
|
+
</m:properties>
|
210
|
+
</content>
|
211
|
+
</entry>
|
212
|
+
<entry>
|
213
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(6)</id>
|
214
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
215
|
+
<link rel="edit" title="Category" href="Categories(6)" />
|
216
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(6)/Products">
|
217
|
+
<m:inline>
|
218
|
+
<feed>
|
219
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(6)/Products</id>
|
220
|
+
<title type="text">Products</title>
|
221
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
222
|
+
<link rel="self" title="Products" href="Categories(6)/Products" />
|
223
|
+
<author>
|
224
|
+
<name />
|
225
|
+
</author>
|
226
|
+
</feed>
|
227
|
+
</m:inline>
|
228
|
+
</link>
|
229
|
+
<title />
|
230
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
231
|
+
<author>
|
232
|
+
<name />
|
233
|
+
</author>
|
234
|
+
<content type="application/xml">
|
235
|
+
<m:properties>
|
236
|
+
<d:Name>Category 0001</d:Name>
|
237
|
+
</m:properties>
|
238
|
+
</content>
|
239
|
+
</entry>
|
240
|
+
<entry>
|
241
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(7)</id>
|
242
|
+
<category term="RubyODataService.Category" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
243
|
+
<link rel="edit" title="Category" href="Categories(7)" />
|
244
|
+
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Products" type="application/atom+xml;type=feed" title="Products" href="Categories(7)/Products">
|
245
|
+
<m:inline>
|
246
|
+
<feed>
|
247
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Categories(7)/Products</id>
|
248
|
+
<title type="text">Products</title>
|
249
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
250
|
+
<link rel="self" title="Products" href="Categories(7)/Products" />
|
251
|
+
<author>
|
252
|
+
<name />
|
253
|
+
</author>
|
254
|
+
</feed>
|
255
|
+
</m:inline>
|
256
|
+
</link>
|
257
|
+
<title />
|
258
|
+
<updated>2013-07-22T14:54:47Z</updated>
|
259
|
+
<author>
|
260
|
+
<name />
|
261
|
+
</author>
|
262
|
+
<content type="application/xml">
|
263
|
+
<m:properties>
|
264
|
+
<d:Name>Category 0002</d:Name>
|
265
|
+
</m:properties>
|
266
|
+
</content>
|
267
|
+
</entry>
|
268
|
+
</feed>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
2
|
+
<error
|
3
|
+
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
|
4
|
+
<code></code>
|
5
|
+
<message xml:lang="en-US">Type 'RubyODataService.Category' does not have a property named 'Price' or there is no type with 'Price' name.</message>
|
6
|
+
</error>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
2
|
+
<error
|
3
|
+
xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
|
4
|
+
<code></code>
|
5
|
+
<message xml:lang="en-US">Only properties specified in $expand can be traversed in $select query options. Property .</message>
|
6
|
+
</error>
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<feed xml:base="http://win7dev:8989/SampleService/RubyOData.svc/"
|
3
|
+
xmlns="http://www.w3.org/2005/Atom"
|
4
|
+
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
|
5
|
+
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
|
6
|
+
xmlns:georss="http://www.georss.org/georss"
|
7
|
+
xmlns:gml="http://www.opengis.net/gml">
|
8
|
+
<id>http://win7dev:8989/SampleService/RubyOdata.svc/Products</id>
|
9
|
+
<title type="text">Products</title>
|
10
|
+
<updated>2013-07-19T12:29:11Z</updated>
|
11
|
+
<link rel="self" title="Products" href="Products" />
|
12
|
+
<entry>
|
13
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(1)</id>
|
14
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
15
|
+
<link rel="edit" title="Product" href="Products(1)" />
|
16
|
+
<title />
|
17
|
+
<updated>2013-07-19T12:29:11Z</updated>
|
18
|
+
<author>
|
19
|
+
<name />
|
20
|
+
</author>
|
21
|
+
<content type="application/xml">
|
22
|
+
<m:properties>
|
23
|
+
<d:Name>Widget 0001</d:Name>
|
24
|
+
<d:Price m:type="Edm.Decimal">75.50</d:Price>
|
25
|
+
</m:properties>
|
26
|
+
</content>
|
27
|
+
</entry>
|
28
|
+
<entry>
|
29
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(2)</id>
|
30
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
31
|
+
<link rel="edit" title="Product" href="Products(2)" />
|
32
|
+
<title />
|
33
|
+
<updated>2013-07-19T12:29:11Z</updated>
|
34
|
+
<author>
|
35
|
+
<name />
|
36
|
+
</author>
|
37
|
+
<content type="application/xml">
|
38
|
+
<m:properties>
|
39
|
+
<d:Name>Widget 0002</d:Name>
|
40
|
+
<d:Price m:type="Edm.Decimal">100.00</d:Price>
|
41
|
+
</m:properties>
|
42
|
+
</content>
|
43
|
+
</entry>
|
44
|
+
<entry>
|
45
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(3)</id>
|
46
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
47
|
+
<link rel="edit" title="Product" href="Products(3)" />
|
48
|
+
<title />
|
49
|
+
<updated>2013-07-19T12:29:11Z</updated>
|
50
|
+
<author>
|
51
|
+
<name />
|
52
|
+
</author>
|
53
|
+
<content type="application/xml">
|
54
|
+
<m:properties>
|
55
|
+
<d:Name>Widget 0003</d:Name>
|
56
|
+
<d:Price m:type="Edm.Decimal">10.25</d:Price>
|
57
|
+
</m:properties>
|
58
|
+
</content>
|
59
|
+
</entry>
|
60
|
+
<entry>
|
61
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(4)</id>
|
62
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
63
|
+
<link rel="edit" title="Product" href="Products(4)" />
|
64
|
+
<title />
|
65
|
+
<updated>2013-07-19T12:29:11Z</updated>
|
66
|
+
<author>
|
67
|
+
<name />
|
68
|
+
</author>
|
69
|
+
<content type="application/xml">
|
70
|
+
<m:properties>
|
71
|
+
<d:Name>Widget 0004</d:Name>
|
72
|
+
<d:Price m:type="Edm.Decimal">100.00</d:Price>
|
73
|
+
</m:properties>
|
74
|
+
</content>
|
75
|
+
</entry>
|
76
|
+
<entry>
|
77
|
+
<id>http://win7dev:8989/SampleService/RubyOData.svc/Products(5)</id>
|
78
|
+
<category term="RubyODataService.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
|
79
|
+
<link rel="edit" title="Product" href="Products(5)" />
|
80
|
+
<title />
|
81
|
+
<updated>2013-07-19T12:29:11Z</updated>
|
82
|
+
<author>
|
83
|
+
<name />
|
84
|
+
</author>
|
85
|
+
<content type="application/xml">
|
86
|
+
<m:properties>
|
87
|
+
<d:Name>Widget 0005</d:Name>
|
88
|
+
<d:Price m:type="Edm.Decimal">75.50</d:Price>
|
89
|
+
</m:properties>
|
90
|
+
</content>
|
91
|
+
</entry>
|
92
|
+
</feed>
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module OData
|
4
4
|
describe PropertyMetadata do
|
5
5
|
describe "#initialize" do
|
6
|
-
it "parses an EDMX property with the essentials (name, type, nullable, nav_prop)" do
|
6
|
+
it "parses an EDMX property with the essentials (name, type, nullable, nav_prop)" do
|
7
7
|
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property Name="Id" Type="Edm.String" Nullable="false" />')
|
8
8
|
property_metadata = PropertyMetadata.new property_element
|
9
9
|
property_metadata.name.should eq "Id"
|
@@ -15,30 +15,30 @@ module OData
|
|
15
15
|
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property Name="Id" Type="Edm.String" Nullable="true" />')
|
16
16
|
property_metadata = PropertyMetadata.new property_element
|
17
17
|
property_metadata.nullable.should eq true
|
18
|
-
end
|
19
|
-
it "parses an EDMX property with nil for missing attributes" do
|
18
|
+
end
|
19
|
+
it "parses an EDMX property with nil for missing attributes" do
|
20
20
|
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property Name="Id" Type="Edm.String" Nullable="false" />')
|
21
21
|
property_metadata = PropertyMetadata.new property_element
|
22
22
|
property_metadata.fc_target_path.should be_nil
|
23
23
|
property_metadata.fc_keep_in_content.should be_nil
|
24
24
|
end
|
25
|
-
it "parses an EDMX property with false for missing Nullable attribute" do
|
25
|
+
it "parses an EDMX property with false for missing Nullable attribute" do
|
26
26
|
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property Name="Id" Type="Edm.String" />')
|
27
27
|
property_metadata = PropertyMetadata.new property_element
|
28
28
|
property_metadata.nullable.should eq false
|
29
|
-
end
|
30
|
-
it "parses an EDMX property with the fc_target_path and fc_keep_in_content attribute" do
|
31
|
-
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property Name="Title" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="false" />')
|
29
|
+
end
|
30
|
+
it "parses an EDMX property with the fc_target_path and fc_keep_in_content attribute" do
|
31
|
+
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" Name="Title" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="false" />')
|
32
32
|
property_metadata = PropertyMetadata.new property_element
|
33
33
|
property_metadata.fc_target_path.should eq "SyndicationTitle"
|
34
34
|
property_metadata.fc_keep_in_content.should eq false
|
35
35
|
end
|
36
|
-
it "parses an EDMX property where fc_keep_in_content is true" do
|
37
|
-
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property Name="Title" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" />')
|
36
|
+
it "parses an EDMX property where fc_keep_in_content is true" do
|
37
|
+
property_element = RSpecSupport::ElementHelpers.string_to_element('<Property xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" Name="Title" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="true" />')
|
38
38
|
property_metadata = PropertyMetadata.new property_element
|
39
39
|
property_metadata.fc_keep_in_content.should eq true
|
40
40
|
end
|
41
|
-
it "parses an EDMX navigation property with the name and the nav_prop set to true" do
|
41
|
+
it "parses an EDMX navigation property with the name and the nav_prop set to true" do
|
42
42
|
property_element = RSpecSupport::ElementHelpers.string_to_element('<NavigationProperty Name="Category" Relationship="Model.CategoryProduct" FromRole="Product" ToRole="Category" />')
|
43
43
|
property_metadata = PropertyMetadata.new property_element
|
44
44
|
property_metadata.name.should eq "Category"
|
data/spec/query_builder_spec.rb
CHANGED
@@ -1,34 +1,173 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
module OData
|
4
4
|
describe QueryBuilder do
|
5
5
|
describe "#initialize" do
|
6
|
-
it "handles additional parameters" do
|
7
|
-
builder = QueryBuilder.new
|
6
|
+
it "handles additional parameters" do
|
7
|
+
builder = QueryBuilder.new "Products", { :x=>1, :y=>2 }
|
8
8
|
builder.query.should eq "Products?x=1&y=2"
|
9
9
|
end
|
10
|
-
it "handles empty additional parameters" do
|
11
|
-
builder = QueryBuilder.new
|
10
|
+
it "handles empty additional parameters" do
|
11
|
+
builder = QueryBuilder.new "Products"
|
12
12
|
builder.query.should eq "Products"
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
it "should append additional parameters to the end" do
|
17
|
-
builder = QueryBuilder.new 'Products', { :x=>1, :y=>2 }
|
13
|
+
end
|
14
|
+
it "should append additional parameters to the end of the query" do
|
15
|
+
builder = QueryBuilder.new "Products", { :x=>1, :y=>2 }
|
18
16
|
builder.top(10)
|
19
17
|
builder.query.should eq "Products?$top=10&x=1&y=2"
|
20
18
|
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#links" do
|
21
22
|
it "should properly handle queries for links" do
|
22
|
-
builder = QueryBuilder.new
|
23
|
-
builder.links(
|
23
|
+
builder = QueryBuilder.new "Categories(1)"
|
24
|
+
builder.links("Products")
|
24
25
|
builder.query.should eq "Categories(1)/$links/Products"
|
25
26
|
end
|
26
27
|
it "should properly handle queries for links with additional operations" do
|
27
|
-
builder = QueryBuilder.new
|
28
|
-
builder.links(
|
28
|
+
builder = QueryBuilder.new "Categories(1)"
|
29
|
+
builder.links("Products")
|
29
30
|
builder.top(5)
|
30
31
|
builder.query.should eq "Categories(1)/$links/Products?$top=5"
|
31
32
|
end
|
33
|
+
it "should throw an exception if count was already called on the builder" do
|
34
|
+
builder = QueryBuilder.new "Categories(1)"
|
35
|
+
builder.count
|
36
|
+
lambda { builder.links("Products") }.should raise_error(OData::NotSupportedError, "You cannot call both the `links` method and the `count` method in the same query.")
|
37
|
+
end
|
38
|
+
it "should throw an exception if select was already called on the builder" do
|
39
|
+
builder = QueryBuilder.new "Products"
|
40
|
+
builder.select "Price"
|
41
|
+
lambda { builder.links("Products") }.should raise_error(OData::NotSupportedError, "You cannot call both the `links` method and the `select` method in the same query.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#count" do
|
46
|
+
it "should accept the count method" do
|
47
|
+
builder = QueryBuilder.new "Products"
|
48
|
+
lambda { builder.count }.should_not raise_error
|
49
|
+
end
|
50
|
+
it "should properly handle the count method" do
|
51
|
+
builder = QueryBuilder.new "Products"
|
52
|
+
builder.count
|
53
|
+
builder.query.should eq "Products/$count"
|
54
|
+
end
|
55
|
+
it "should properly handle the count method with additional operators" do
|
56
|
+
builder = QueryBuilder.new "Products"
|
57
|
+
builder.filter("Name eq 'Widget 1'")
|
58
|
+
builder.count
|
59
|
+
builder.query.should eq "Products/$count?$filter=Name+eq+%27Widget+1%27"
|
60
|
+
end
|
61
|
+
it "should throw an exception if links was already called on the builder" do
|
62
|
+
builder = QueryBuilder.new "Categories(1)"
|
63
|
+
builder.links("Products")
|
64
|
+
lambda { builder.count }.should raise_error(OData::NotSupportedError, "You cannot call both the `links` method and the `count` method in the same query.")
|
65
|
+
end
|
66
|
+
it "should throw an exception if select was already called on the builder" do
|
67
|
+
builder = QueryBuilder.new "Products"
|
68
|
+
builder.select("Price")
|
69
|
+
lambda { builder.count }.should raise_error(OData::NotSupportedError, "You cannot call both the `select` method and the `count` method in the same query.")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#select" do
|
74
|
+
it "should accept the select method" do
|
75
|
+
builder = QueryBuilder.new "Products"
|
76
|
+
lambda { builder.select }.should_not raise_error
|
77
|
+
end
|
78
|
+
it "should properly handle the select method" do
|
79
|
+
builder = QueryBuilder.new "Products"
|
80
|
+
builder.select "Price", "Rating"
|
81
|
+
builder.query.should eq "Products?$select=Price,Rating"
|
82
|
+
end
|
83
|
+
it "shouldn't add duplicate properties" do
|
84
|
+
builder = QueryBuilder.new "Products"
|
85
|
+
builder.select "Price", "Rating", "Price"
|
86
|
+
builder.query.should eq "Products?$select=Price,Rating"
|
87
|
+
end
|
88
|
+
it "should properly handle the select method with additional operators" do
|
89
|
+
builder = QueryBuilder.new "Products"
|
90
|
+
builder.filter("Name eq 'Widget 1'")
|
91
|
+
builder.select("Price", "Rating")
|
92
|
+
builder.query.should eq "Products?$select=Price,Rating&$filter=Name+eq+%27Widget+1%27"
|
93
|
+
end
|
94
|
+
it "should throw an exception if links was already called on the builder" do
|
95
|
+
builder = QueryBuilder.new "Categories(1)"
|
96
|
+
builder.links("Products")
|
97
|
+
lambda { builder.select("Price") }.should raise_error(OData::NotSupportedError, "You cannot call both the `links` method and the `select` method in the same query.")
|
98
|
+
end
|
99
|
+
it "should throw an exception if count was already called on the builder" do
|
100
|
+
builder = QueryBuilder.new "Products"
|
101
|
+
builder.count
|
102
|
+
lambda { builder.select("Price") }.should raise_error(OData::NotSupportedError, "You cannot call both the `count` method and the `select` method in the same query.")
|
103
|
+
end
|
104
|
+
it "should return itself" do
|
105
|
+
builder = QueryBuilder.new "Products"
|
106
|
+
result = builder.select("Price", "Rating")
|
107
|
+
result.should be_a(QueryBuilder)
|
108
|
+
end
|
109
|
+
it "should automatically add $expand for nested selects" do
|
110
|
+
builder = QueryBuilder.new "Categories"
|
111
|
+
result = builder.select "Name", "Products/Name"
|
112
|
+
result.query.should eq "Categories?$select=Name,Products/Name&$expand=Products"
|
113
|
+
end
|
114
|
+
it "should automatically add $expand for deeply nested selects" do
|
115
|
+
builder = QueryBuilder.new "Products"
|
116
|
+
result = builder.select "ProductName", "Order_Details/OrderID", "Order_Details/Order/Customer/CompanyName"
|
117
|
+
result.query.should eq "Products?$select=ProductName,Order_Details/OrderID,Order_Details/Order/Customer/CompanyName&$expand=Order_Details,Order_Details/Order/Customer"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "#navigate" do
|
122
|
+
it "should allow a user to drill down into a navigaion property on an initial query" do
|
123
|
+
builder = QueryBuilder.new "Genres('Horror Movies')"
|
124
|
+
builder.navigate("Titles")
|
125
|
+
builder.filter("Name eq 'Halloween'")
|
126
|
+
builder.query.should eq "Genres('Horror%20Movies')/Titles?$filter=Name+eq+%27Halloween%27"
|
127
|
+
end
|
128
|
+
it "should allow for multiple levels of drill down" do
|
129
|
+
builder = QueryBuilder.new "Genres('Horror Movies')"
|
130
|
+
builder.navigate("Titles('6aBu')")
|
131
|
+
builder.navigate("Awards")
|
132
|
+
builder.filter("Type eq 'Afi'")
|
133
|
+
builder.query.should eq "Genres('Horror%20Movies')/Titles('6aBu')/Awards?$filter=Type+eq+%27Afi%27"
|
134
|
+
end
|
135
|
+
it "should allow for a drill down plus links" do
|
136
|
+
builder = QueryBuilder.new "Genres('Horror Movies')"
|
137
|
+
builder.navigate("Titles('6aBu')")
|
138
|
+
builder.links("Awards")
|
139
|
+
builder.query.should eq "Genres('Horror%20Movies')/Titles('6aBu')/$links/Awards"
|
140
|
+
end
|
141
|
+
it "should allow for a drill down plus count" do
|
142
|
+
builder = QueryBuilder.new "Genres('Horror Movies')"
|
143
|
+
builder.navigate("Titles")
|
144
|
+
builder.count
|
145
|
+
builder.query.should eq "Genres('Horror%20Movies')/Titles/$count"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "additional_parameters" do
|
150
|
+
it "should be able to be added at any time" do
|
151
|
+
builder = QueryBuilder.new "PollingLocations"
|
152
|
+
builder.filter("Address/Zip eq 45693")
|
153
|
+
builder.expand("Election")
|
154
|
+
builder.additional_params[:foo] = "bar"
|
155
|
+
builder.query.should eq "PollingLocations?$expand=Election&$filter=Address%2FZip+eq+45693&foo=bar"
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should not overwrite what is already there" do
|
159
|
+
builder = QueryBuilder.new "Products", { :x=>1, :y=>2 }
|
160
|
+
builder.top(10)
|
161
|
+
builder.additional_params[:foo] = "bar"
|
162
|
+
builder.query.should eq "Products?$top=10&foo=bar&x=1&y=2"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "#query" do
|
167
|
+
it "should encode spaces in IDs" do
|
168
|
+
builder = QueryBuilder.new "Categories('Cool Stuff')"
|
169
|
+
builder.query.should eq "Categories('Cool%20Stuff')"
|
170
|
+
end
|
32
171
|
end
|
33
172
|
end
|
34
173
|
end
|