cartodb-rb-client 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/lib/cartodb-rb-client/cartodb/client/connection/cartodb.rb +1 -1
- data/lib/cartodb-rb-client/cartodb/model/base.rb +1 -1
- data/lib/cartodb-rb-client/cartodb/model/getters.rb +6 -9
- data/lib/cartodb-rb-client/cartodb/model/schema.rb +13 -2
- data/lib/cartodb-rb-client/cartodb/model/setters.rb +5 -9
- data/lib/cartodb-rb-client/version.rb +1 -1
- data/spec/client_spec.rb +3 -3
- data/spec/fixtures/cassettes/CartoDB_client/should_add_and_remove_colums_in_a_previously_created_table.yml +376 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_allow_reserved_words_in_columns_names.yml +121 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_change_a_previously_created_column.yml +174 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_create_a_table_and_get_its_table_definition.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_create_a_table_forcing_the_schema_and_get_its_table_definition.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_create_a_table_from_a_csv_file.yml +1971 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_create_a_table_with_MULTILINESTRING_type_geometry.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_create_a_table_with_MULTIPOLYGON_type_geometry.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_create_a_table_with_POINT_type_geometry.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_delete_a_table_s_row.yml +221 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_drop_a_table.yml +278 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_escape_properly_input_data_in_insert_queries.yml +121 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_execute_a_select_query_and_return_results.yml +615 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_get_a_table_by_its_name.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_import_any_kind_of_data_file.yml +6612 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_insert_a_row_in_a_table.yml +121 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_paginate_records.yml +2624 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_rename_an_existing_table.yml +123 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_return_errors_on_invalid_queries.yml +59 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_return_nil_when_requesting_a_table_which_does_not_exists.yml +68 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_return_user_s_table_list.yml +176 -0
- data/spec/fixtures/cassettes/CartoDB_client/should_update_a_row_in_a_table.yml +170 -0
- data/spec/fixtures/cassettes/CartoDB_model_data_methods/should_destroy_a_previously_created_record.yml +1398 -0
- data/spec/fixtures/cassettes/CartoDB_model_data_methods/should_initialize_attributes_of_the_model_without_persisting_them.yml +223 -0
- data/spec/fixtures/cassettes/CartoDB_model_data_methods/should_persist_into_cartodb_using_the_save_method.yml +1406 -0
- data/spec/fixtures/cassettes/CartoDB_model_data_methods/should_persist_into_cartodb_using_the_static_create_method.yml +1299 -0
- data/spec/fixtures/cassettes/CartoDB_model_data_methods/should_update_an_existing_record.yml +2028 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_add_more_columns_if_the_table_previously_exists.yml +990 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_contain_an_array_of_columns.yml +1443 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_create_a_table_with_custom_name_if_specified.yml +270 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_create_model_with_custom_data_types_columns.yml +421 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_create_model_with_polygon_type_geometry_columns.yml +272 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_create_the_table_in_cartodb_if_it_doesn_t_exists.yml +780 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_have_a_valid_CartoDB_Client_instance_as_a_connection_object.yml +682 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_have_a_valid_table_name.yml +727 -0
- data/spec/fixtures/cassettes/CartoDB_model_metadata_methods/should_return_only_data_columns.yml +829 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_allow_to_select_the_specified_fiels.yml +17953 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_count_all_records.yml +15596 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_find_a_record_by_its_id.yml +15197 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_order_results.yml +16439 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_paginate_results.yml +24501 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_return_all_records_paginated.yml +16488 -0
- data/spec/fixtures/cassettes/CartoDB_model_scopes/should_search_records_by_certain_filters.yml +4950 -0
- data/spec/fixtures/cassettes/cartodb_spec_models.yml +2467 -0
- data/spec/fixtures/cassettes/clean_tables.yml +266 -0
- data/spec/model/data_spec.rb +6 -6
- data/spec/model/metadata_spec.rb +11 -3
- data/spec/model/scopes_spec.rb +2 -2
- data/spec/model_specs_helper.rb +2 -0
- data/spec/spec_helper.rb +18 -5
- data/spec/support/cartodb_factories.rb +3 -3
- data/spec/support/cartodb_helpers.rb +1 -1
- data/spec/support/cartodb_models.rb +26 -19
- metadata +97 -7
- data/spec/support/data/ngos.xlsx +0 -0
@@ -0,0 +1,266 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://cartodb-rb-client.cartodb.com/api/v1/tables?
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- &70347547176260 !ruby/object:MIME::Type
|
12
|
+
content_type: application/json
|
13
|
+
raw_media_type: application
|
14
|
+
raw_sub_type: json
|
15
|
+
simplified: application/json
|
16
|
+
media_type: application
|
17
|
+
sub_type: json
|
18
|
+
extensions:
|
19
|
+
- json
|
20
|
+
encoding: 8bit
|
21
|
+
system: !!null
|
22
|
+
registered: true
|
23
|
+
url:
|
24
|
+
- IANA
|
25
|
+
- RFC4627
|
26
|
+
obsolete: !!null
|
27
|
+
docs: !!null
|
28
|
+
Authorization:
|
29
|
+
- OAuth oauth_consumer_key="0gRpcgKQK8bpcvSzM5ED4NqaSbNQ8ivS4q0pVdJF", oauth_nonce="VEi9jwsh7M68W8emeqcxoZjaBtoeA4wLfNGy8qVj2s",
|
30
|
+
oauth_signature="Cz8LzmTlBslwlfEJ1bm5I7iHTgY%3D", oauth_signature_method="HMAC-SHA1",
|
31
|
+
oauth_timestamp="1337788390", oauth_token="7PalByYmKY8Dzh76fnt05e0YPXRJino0dyqHZYCw",
|
32
|
+
oauth_version="1.0"
|
33
|
+
response:
|
34
|
+
status:
|
35
|
+
code: 200
|
36
|
+
message: OK
|
37
|
+
headers:
|
38
|
+
Server:
|
39
|
+
- nginx
|
40
|
+
Date:
|
41
|
+
- Wed, 23 May 2012 15:53:10 GMT
|
42
|
+
Content-Type:
|
43
|
+
- application/json; charset=utf-8
|
44
|
+
Transfer-Encoding:
|
45
|
+
- chunked
|
46
|
+
Connection:
|
47
|
+
- keep-alive
|
48
|
+
Vary:
|
49
|
+
- Accept-Encoding
|
50
|
+
Status:
|
51
|
+
- 200 OK
|
52
|
+
Etag:
|
53
|
+
- ! '"5822de039c547528e69f48f88b4a5650"'
|
54
|
+
Cache-Control:
|
55
|
+
- max-age=0, private, must-revalidate
|
56
|
+
X-Ua-Compatible:
|
57
|
+
- IE=Edge,chrome=1
|
58
|
+
Set-Cookie:
|
59
|
+
- _cartodb_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlNDlmYjRmODQ0MWFjOTIwNDEyNTI5NmQ0NjU4ZGJiZWJJIiZ3YXJkZW4udXNlci5jYXJ0b2RiLXJiLWNsaWVudC5rZXkGOwBUSSIWY2FydG9kYi1yYi1jbGllbnQGOwBU--999fbd3225bcb2ead656025ec98e41895ea3b674;
|
60
|
+
domain=.cartodb.com; path=/; HttpOnly
|
61
|
+
X-Runtime:
|
62
|
+
- '0.025659'
|
63
|
+
Content-Encoding:
|
64
|
+
- gzip
|
65
|
+
body:
|
66
|
+
encoding: ASCII-8BIT
|
67
|
+
string: ! '{"total_entries":4,"tables":[{"id":4724,"name":"polygon_geometry_model","privacy":"PUBLIC","tags":"","schema":[["cartodb_id","number"],["the_geom","polygon"],["updated_at","date"],["created_at","date"]],"updated_at":"2012-05-23T17:48:49+02:00","rows_counted":0},{"id":4723,"name":"custom_data_type_column_model","privacy":"PUBLIC","tags":"","schema":[["cartodb_id","number"],["the_geom","geometry","geometry","point"],["description","string"],["name","string"],["test","number"],["created_at","date"],["updated_at","date"]],"updated_at":"2012-05-23T17:48:48+02:00","rows_counted":0},{"id":4722,"name":"moto_gp_circuit","privacy":"PUBLIC","tags":"","schema":[["cartodb_id","number"],["the_geom","geometry","geometry","point"],["constructed","date"],["description","string"],["left_corners","number"],["length","string"],["longest_straight","string"],["name","string"],["right_corners","number"],["width","string"],["created_at","date"],["updated_at","date"]],"updated_at":"2012-05-23T17:48:43+02:00","rows_counted":0},{"id":4718,"name":"table_1","privacy":"PUBLIC","tags":"","schema":[["cartodb_id","number"],["the_geom","geometry","geometry","point"],["description","string"],["name","string"],["created_at","date"],["updated_at","date"]],"updated_at":"2012-05-23T17:39:39+02:00","rows_counted":0}]}'
|
68
|
+
http_version: '1.1'
|
69
|
+
recorded_at: Wed, 23 May 2012 15:53:10 GMT
|
70
|
+
- request:
|
71
|
+
method: delete
|
72
|
+
uri: https://cartodb-rb-client.cartodb.com/api/v1/tables/polygon_geometry_model?
|
73
|
+
body:
|
74
|
+
encoding: US-ASCII
|
75
|
+
string: ''
|
76
|
+
headers:
|
77
|
+
Accept:
|
78
|
+
- *70347547176260
|
79
|
+
Authorization:
|
80
|
+
- OAuth oauth_consumer_key="0gRpcgKQK8bpcvSzM5ED4NqaSbNQ8ivS4q0pVdJF", oauth_nonce="ln36GI7sCB4fvICNlnZYyw3QPGDyTsllbbGqgpdzU",
|
81
|
+
oauth_signature="UvNC9nLmY80ddXMUUfXap8EVxww%3D", oauth_signature_method="HMAC-SHA1",
|
82
|
+
oauth_timestamp="1337788390", oauth_token="7PalByYmKY8Dzh76fnt05e0YPXRJino0dyqHZYCw",
|
83
|
+
oauth_version="1.0"
|
84
|
+
response:
|
85
|
+
status:
|
86
|
+
code: 200
|
87
|
+
message: OK
|
88
|
+
headers:
|
89
|
+
Server:
|
90
|
+
- nginx
|
91
|
+
Date:
|
92
|
+
- Wed, 23 May 2012 15:53:10 GMT
|
93
|
+
Content-Type:
|
94
|
+
- application/json; charset=utf-8
|
95
|
+
Transfer-Encoding:
|
96
|
+
- chunked
|
97
|
+
Connection:
|
98
|
+
- keep-alive
|
99
|
+
Vary:
|
100
|
+
- Accept-Encoding
|
101
|
+
Status:
|
102
|
+
- 200 OK
|
103
|
+
Cache-Control:
|
104
|
+
- no-cache
|
105
|
+
X-Ua-Compatible:
|
106
|
+
- IE=Edge,chrome=1
|
107
|
+
Set-Cookie:
|
108
|
+
- _cartodb_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlMDYwY2E4NWE2MGJlZmE5NDI4MjI1YzE2ZjRkMDY3MTZJIiZ3YXJkZW4udXNlci5jYXJ0b2RiLXJiLWNsaWVudC5rZXkGOwBUSSIWY2FydG9kYi1yYi1jbGllbnQGOwBU--91c56a0e50dfa569f02b89ca7a341285a18ad1e5;
|
109
|
+
domain=.cartodb.com; path=/; HttpOnly
|
110
|
+
X-Runtime:
|
111
|
+
- '0.190212'
|
112
|
+
Content-Encoding:
|
113
|
+
- gzip
|
114
|
+
body:
|
115
|
+
encoding: ASCII-8BIT
|
116
|
+
string: ! ' '
|
117
|
+
http_version: '1.1'
|
118
|
+
recorded_at: Wed, 23 May 2012 15:53:10 GMT
|
119
|
+
- request:
|
120
|
+
method: delete
|
121
|
+
uri: https://cartodb-rb-client.cartodb.com/api/v1/tables/custom_data_type_column_model?
|
122
|
+
body:
|
123
|
+
encoding: US-ASCII
|
124
|
+
string: ''
|
125
|
+
headers:
|
126
|
+
Accept:
|
127
|
+
- *70347547176260
|
128
|
+
Authorization:
|
129
|
+
- OAuth oauth_consumer_key="0gRpcgKQK8bpcvSzM5ED4NqaSbNQ8ivS4q0pVdJF", oauth_nonce="rNWAVHzmRIM6RxJTJKfjoAfkB4SNiLsxlSaIAFKdk",
|
130
|
+
oauth_signature="R2S1Q6coDbFdsBItWqu1sv3s9Wg%3D", oauth_signature_method="HMAC-SHA1",
|
131
|
+
oauth_timestamp="1337788390", oauth_token="7PalByYmKY8Dzh76fnt05e0YPXRJino0dyqHZYCw",
|
132
|
+
oauth_version="1.0"
|
133
|
+
response:
|
134
|
+
status:
|
135
|
+
code: 200
|
136
|
+
message: OK
|
137
|
+
headers:
|
138
|
+
Server:
|
139
|
+
- nginx
|
140
|
+
Date:
|
141
|
+
- Wed, 23 May 2012 15:53:11 GMT
|
142
|
+
Content-Type:
|
143
|
+
- application/json; charset=utf-8
|
144
|
+
Transfer-Encoding:
|
145
|
+
- chunked
|
146
|
+
Connection:
|
147
|
+
- keep-alive
|
148
|
+
Vary:
|
149
|
+
- Accept-Encoding
|
150
|
+
Status:
|
151
|
+
- 200 OK
|
152
|
+
Cache-Control:
|
153
|
+
- no-cache
|
154
|
+
X-Ua-Compatible:
|
155
|
+
- IE=Edge,chrome=1
|
156
|
+
Set-Cookie:
|
157
|
+
- _cartodb_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlNDE5Nzg1Y2FjMzZiZjExNTgyODdlZTA0MDE4YTE0MmZJIiZ3YXJkZW4udXNlci5jYXJ0b2RiLXJiLWNsaWVudC5rZXkGOwBUSSIWY2FydG9kYi1yYi1jbGllbnQGOwBU--260748fd515484011639dd2385ea317eb716df32;
|
158
|
+
domain=.cartodb.com; path=/; HttpOnly
|
159
|
+
X-Runtime:
|
160
|
+
- '0.216359'
|
161
|
+
Content-Encoding:
|
162
|
+
- gzip
|
163
|
+
body:
|
164
|
+
encoding: ASCII-8BIT
|
165
|
+
string: ! ' '
|
166
|
+
http_version: '1.1'
|
167
|
+
recorded_at: Wed, 23 May 2012 15:53:11 GMT
|
168
|
+
- request:
|
169
|
+
method: delete
|
170
|
+
uri: https://cartodb-rb-client.cartodb.com/api/v1/tables/moto_gp_circuit?
|
171
|
+
body:
|
172
|
+
encoding: US-ASCII
|
173
|
+
string: ''
|
174
|
+
headers:
|
175
|
+
Accept:
|
176
|
+
- *70347547176260
|
177
|
+
Authorization:
|
178
|
+
- OAuth oauth_consumer_key="0gRpcgKQK8bpcvSzM5ED4NqaSbNQ8ivS4q0pVdJF", oauth_nonce="m6fXY1zPmR8pp3DVhFwDfdw5Bt95gCiJEQVvZk1Y",
|
179
|
+
oauth_signature="K48l97G6kcKiben9SIquhTEs75s%3D", oauth_signature_method="HMAC-SHA1",
|
180
|
+
oauth_timestamp="1337788391", oauth_token="7PalByYmKY8Dzh76fnt05e0YPXRJino0dyqHZYCw",
|
181
|
+
oauth_version="1.0"
|
182
|
+
response:
|
183
|
+
status:
|
184
|
+
code: 200
|
185
|
+
message: OK
|
186
|
+
headers:
|
187
|
+
Server:
|
188
|
+
- nginx
|
189
|
+
Date:
|
190
|
+
- Wed, 23 May 2012 15:53:11 GMT
|
191
|
+
Content-Type:
|
192
|
+
- application/json; charset=utf-8
|
193
|
+
Transfer-Encoding:
|
194
|
+
- chunked
|
195
|
+
Connection:
|
196
|
+
- keep-alive
|
197
|
+
Vary:
|
198
|
+
- Accept-Encoding
|
199
|
+
Status:
|
200
|
+
- 200 OK
|
201
|
+
Cache-Control:
|
202
|
+
- no-cache
|
203
|
+
X-Ua-Compatible:
|
204
|
+
- IE=Edge,chrome=1
|
205
|
+
Set-Cookie:
|
206
|
+
- _cartodb_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlMDAyNmQ4YTcxYzVlNmFkMzlhMTVhZmY4M2U2ZDg4OTFJIiZ3YXJkZW4udXNlci5jYXJ0b2RiLXJiLWNsaWVudC5rZXkGOwBUSSIWY2FydG9kYi1yYi1jbGllbnQGOwBU--f3852a6af7a2cac08662f993c97bb4e5361ce2cf;
|
207
|
+
domain=.cartodb.com; path=/; HttpOnly
|
208
|
+
X-Runtime:
|
209
|
+
- '0.149254'
|
210
|
+
Content-Encoding:
|
211
|
+
- gzip
|
212
|
+
body:
|
213
|
+
encoding: ASCII-8BIT
|
214
|
+
string: ! ' '
|
215
|
+
http_version: '1.1'
|
216
|
+
recorded_at: Wed, 23 May 2012 15:53:11 GMT
|
217
|
+
- request:
|
218
|
+
method: delete
|
219
|
+
uri: https://cartodb-rb-client.cartodb.com/api/v1/tables/table_1?
|
220
|
+
body:
|
221
|
+
encoding: US-ASCII
|
222
|
+
string: ''
|
223
|
+
headers:
|
224
|
+
Accept:
|
225
|
+
- *70347547176260
|
226
|
+
Authorization:
|
227
|
+
- OAuth oauth_consumer_key="0gRpcgKQK8bpcvSzM5ED4NqaSbNQ8ivS4q0pVdJF", oauth_nonce="W9qeZVUT7etENgwtN6zsPZ2IgF1dmug3qyU4qDS6M",
|
228
|
+
oauth_signature="zY9gsWDwRR6fw2otdtxuxHOuhaY%3D", oauth_signature_method="HMAC-SHA1",
|
229
|
+
oauth_timestamp="1337788391", oauth_token="7PalByYmKY8Dzh76fnt05e0YPXRJino0dyqHZYCw",
|
230
|
+
oauth_version="1.0"
|
231
|
+
response:
|
232
|
+
status:
|
233
|
+
code: 200
|
234
|
+
message: OK
|
235
|
+
headers:
|
236
|
+
Server:
|
237
|
+
- nginx
|
238
|
+
Date:
|
239
|
+
- Wed, 23 May 2012 15:53:11 GMT
|
240
|
+
Content-Type:
|
241
|
+
- application/json; charset=utf-8
|
242
|
+
Transfer-Encoding:
|
243
|
+
- chunked
|
244
|
+
Connection:
|
245
|
+
- keep-alive
|
246
|
+
Vary:
|
247
|
+
- Accept-Encoding
|
248
|
+
Status:
|
249
|
+
- 200 OK
|
250
|
+
Cache-Control:
|
251
|
+
- no-cache
|
252
|
+
X-Ua-Compatible:
|
253
|
+
- IE=Edge,chrome=1
|
254
|
+
Set-Cookie:
|
255
|
+
- _cartodb_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiIlN2JkZTQxZDhiYTFiM2IyMDkyYzMxODVhMGMyMGU2YjBJIiZ3YXJkZW4udXNlci5jYXJ0b2RiLXJiLWNsaWVudC5rZXkGOwBUSSIWY2FydG9kYi1yYi1jbGllbnQGOwBU--f0017b0d727604edaeb1a3d0c70d6d12adc50cf4;
|
256
|
+
domain=.cartodb.com; path=/; HttpOnly
|
257
|
+
X-Runtime:
|
258
|
+
- '0.177177'
|
259
|
+
Content-Encoding:
|
260
|
+
- gzip
|
261
|
+
body:
|
262
|
+
encoding: ASCII-8BIT
|
263
|
+
string: ! ' '
|
264
|
+
http_version: '1.1'
|
265
|
+
recorded_at: Wed, 23 May 2012 15:53:11 GMT
|
266
|
+
recorded_with: VCR 2.1.1
|
data/spec/model/data_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'model_specs_helper'
|
2
2
|
|
3
|
-
describe 'CartoDB model data methods' do
|
3
|
+
describe 'CartoDB model data methods', :vcr => true do
|
4
4
|
|
5
|
-
it "should initialize attributes of the model without persisting them
|
5
|
+
it "should initialize attributes of the model without persisting them" do
|
6
6
|
|
7
7
|
losail_circuit = new_circuit
|
8
8
|
|
@@ -31,7 +31,7 @@ describe 'CartoDB model data methods' do
|
|
31
31
|
}.to change{CartoDB::Connection.records('moto_gp_circuit').total_rows}.from(0).to(1)
|
32
32
|
|
33
33
|
record = CartoDB::Connection.row 'moto_gp_circuit', losail_circuit.cartodb_id
|
34
|
-
record.cartodb_id.should
|
34
|
+
record.cartodb_id.should be == 1
|
35
35
|
record.name.should be == 'Losail Circuit'
|
36
36
|
record.description.should match /The fabulous Losail International Circuit lies/
|
37
37
|
record.latitude.should be == 25.488840
|
@@ -41,8 +41,8 @@ describe 'CartoDB model data methods' do
|
|
41
41
|
record.left_corners.should be == 6
|
42
42
|
record.right_corners.should be == 10
|
43
43
|
record.longest_straight.should be == '1068m'
|
44
|
-
record.constructed.should
|
45
|
-
record.modified.should
|
44
|
+
record.constructed.should be == DateTime.new(2004, 1, 1)
|
45
|
+
record.modified.should be == DateTime.new(2004, 1, 1)
|
46
46
|
|
47
47
|
losail_circuit.cartodb_id.should be == 1
|
48
48
|
losail_circuit.name.should be == 'Losail Circuit'
|
data/spec/model/metadata_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'model_specs_helper'
|
2
2
|
|
3
|
-
describe 'CartoDB model metadata methods' do
|
3
|
+
describe 'CartoDB model metadata methods', :vcr => true do
|
4
4
|
|
5
5
|
it "should have a valid CartoDB::Client instance as a connection object" do
|
6
6
|
model = MotoGPCircuit.new
|
@@ -28,6 +28,7 @@ describe 'CartoDB model metadata methods' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should contain an array of columns" do
|
31
|
+
|
31
32
|
model = MotoGPCircuit.new
|
32
33
|
|
33
34
|
model.columns.should_not be_nil
|
@@ -47,7 +48,7 @@ describe 'CartoDB model metadata methods' do
|
|
47
48
|
model.columns.should include({:name => 'modified', :type => 'date'})
|
48
49
|
end
|
49
50
|
|
50
|
-
it "should add more columns if the table previously exists
|
51
|
+
it "should add more columns if the table previously exists" do
|
51
52
|
table = CartoDB::Connection.create_table 'moto_gp_circuit'
|
52
53
|
table.schema.should include(["cartodb_id", "number"])
|
53
54
|
table.schema.should include(["name", "string"])
|
@@ -113,4 +114,11 @@ describe 'CartoDB model metadata methods' do
|
|
113
114
|
columns.should include({:name => 'test', :type => 'number'})
|
114
115
|
end
|
115
116
|
|
117
|
+
it "should create model with polygon type geometry columns" do
|
118
|
+
columns = PolygonGeometryModel.data_columns
|
119
|
+
columns.should have(4).items
|
120
|
+
columns.should include({:name => 'the_geom', :type => 'geometry', :geometry_type => 'multipolygon'})
|
121
|
+
columns.should include({:name => 'another_column', :type => 'string'})
|
122
|
+
end
|
123
|
+
|
116
124
|
end
|
data/spec/model/scopes_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -23,18 +23,31 @@ Spork.prefork do
|
|
23
23
|
|
24
24
|
RgeoFactory = ::RGeo::Geographic.spherical_factory(:srid => 4326)
|
25
25
|
|
26
|
-
#
|
27
|
-
#
|
28
|
-
|
26
|
+
require "#{File.dirname(__FILE__)}/support/cartodb_helpers.rb"
|
27
|
+
require "#{File.dirname(__FILE__)}/support/cartodb_factories.rb"
|
28
|
+
|
29
|
+
require 'vcr'
|
30
|
+
VCR.configure do |c|
|
31
|
+
c.default_cassette_options = { :record => :new_episodes }
|
32
|
+
c.cassette_library_dir = 'spec/fixtures/cassettes'
|
33
|
+
c.hook_into :typhoeus
|
34
|
+
#c.preserve_exact_body_bytes
|
35
|
+
c.configure_rspec_metadata!
|
36
|
+
end
|
29
37
|
|
30
38
|
RSpec.configure do |config|
|
31
39
|
config.before(:each) do
|
32
|
-
|
40
|
+
VCR.use_cassette('clean tables') do
|
41
|
+
drop_all_cartodb_tables
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
config.after(:all) do
|
36
|
-
|
46
|
+
VCR.use_cassette('clean tables') do
|
47
|
+
drop_all_cartodb_tables
|
48
|
+
end
|
37
49
|
end
|
50
|
+
|
38
51
|
end
|
39
52
|
end
|
40
53
|
|
@@ -24,10 +24,10 @@ module Factories
|
|
24
24
|
:left_corners => 6,
|
25
25
|
:right_corners => 10,
|
26
26
|
:longest_straight => '1068m',
|
27
|
-
:constructed =>
|
28
|
-
:modified =>
|
27
|
+
:constructed => DateTime.new(2004, 1, 1),
|
28
|
+
:modified => DateTime.new(2004, 1, 1)
|
29
29
|
}
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
RSpec.configure{ include Factories }
|
33
|
+
RSpec.configure{ include Factories }
|
@@ -1,22 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
VCR.use_cassette('cartodb spec models') do
|
2
|
+
class MotoGPCircuit < CartoDB::Model::Base
|
3
|
+
field :name
|
4
|
+
field :description
|
5
|
+
field :length
|
6
|
+
field :width
|
7
|
+
field :longest_straight
|
8
|
+
field :left_corners, :type => Integer
|
9
|
+
field :right_corners, :type => Integer
|
10
|
+
field :constructed, :type => Date
|
11
|
+
field :modified, :type => Date
|
12
|
+
end
|
12
13
|
|
13
|
-
class StandardModel < CartoDB::Model::Base
|
14
|
-
end
|
14
|
+
class StandardModel < CartoDB::Model::Base
|
15
|
+
end
|
15
16
|
|
16
|
-
class CustomTableName < CartoDB::Model::Base
|
17
|
-
|
18
|
-
end
|
17
|
+
class CustomTableName < CartoDB::Model::Base
|
18
|
+
cartodb_table_name 'my_table_with_custom_name'
|
19
|
+
end
|
19
20
|
|
20
|
-
class CustomDataTypeColumnModel < CartoDB::Model::Base
|
21
|
-
|
22
|
-
end
|
21
|
+
class CustomDataTypeColumnModel < CartoDB::Model::Base
|
22
|
+
field :test, :type => 'integer'
|
23
|
+
end
|
24
|
+
|
25
|
+
class PolygonGeometryModel < CartoDB::Model::Base
|
26
|
+
set_geometry_type :polygon
|
27
|
+
field :another_column
|
28
|
+
end
|
29
|
+
end
|