standardapi 5.0.0.14 → 5.0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/standard_api/test_case.rb +21 -23
- data/lib/standard_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ac07bfd36c0394f555e511042e85e56ce2efe7
|
4
|
+
data.tar.gz: 692696c513d7c666c4f14cf4ead1dc4d7613dbb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1adac840d149b4b69705cde887df45f70a7bc79e133a1078b0627a3ecb90618daeaaac13a4d11e6df5c289d68d56ed13d448f7cf5f9ba5bf2202c9e91befc1d
|
7
|
+
data.tar.gz: c4356b1cab6d8c995b84661a6cf223398f596eccc05cf07b00f03f22f62703c50e96072f9705a4df901e2429b80be0f39af20be9563e472e7cdfedb9cb15a3ef
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'active_support/test_case'
|
2
|
+
require 'rails-controller-testing'
|
3
|
+
Rails::Controller::Testing.install
|
2
4
|
|
3
5
|
require File.expand_path(File.join(__FILE__, '../test_case/calculate_tests'))
|
4
6
|
require File.expand_path(File.join(__FILE__, '../test_case/create_tests'))
|
@@ -152,41 +154,37 @@ module StandardAPI::TestCase
|
|
152
154
|
end
|
153
155
|
|
154
156
|
def include_filter_tests
|
155
|
-
model.
|
156
|
-
|
157
|
-
next if model.reflect_on_association(filter[0]) # TODO: Relation Filter Tests
|
158
|
-
next if !model.respond_to?(filter[0])
|
159
|
-
|
160
|
-
define_method("test_model_filter_#{filter[0]}") do
|
157
|
+
model.attribute_names.each do |filter|
|
158
|
+
define_method("test_model_filter_#{filter}") do
|
161
159
|
m = create_model
|
162
|
-
value = m.send(filter
|
160
|
+
value = m.send(filter)
|
163
161
|
|
164
162
|
assert_predicate = -> (predicate) {
|
165
|
-
get
|
163
|
+
get "/#{controller_class.controller_path}.json", params: { where: predicate, format: 'json' }
|
166
164
|
assert_equal model.filter(predicate).order('id ASC').to_sql, assigns(plural_name).to_sql
|
167
165
|
}
|
168
166
|
|
169
167
|
# TODO: Test array
|
170
|
-
case model.columns_hash[filter
|
168
|
+
case model.columns_hash[filter.to_s].type
|
171
169
|
when :jsonb, :json # JSON
|
172
|
-
assert_predicate.call({ filter
|
170
|
+
assert_predicate.call({ filter => value })
|
173
171
|
else
|
174
172
|
case value
|
175
173
|
when Array
|
176
|
-
assert_predicate.call({ filter
|
177
|
-
assert_predicate.call({ filter
|
174
|
+
assert_predicate.call({ filter => value }) # Overlaps
|
175
|
+
assert_predicate.call({ filter => value[0] }) # Contains
|
178
176
|
else
|
179
|
-
assert_predicate.call({ filter
|
180
|
-
assert_predicate.call({ filter
|
181
|
-
assert_predicate.call({ filter
|
182
|
-
assert_predicate.call({ filter
|
183
|
-
assert_predicate.call({ filter
|
184
|
-
assert_predicate.call({ filter
|
185
|
-
assert_predicate.call({ filter
|
186
|
-
assert_predicate.call({ filter
|
187
|
-
assert_predicate.call({ filter
|
188
|
-
assert_predicate.call({ filter
|
189
|
-
assert_predicate.call({ filter
|
177
|
+
assert_predicate.call({ filter => value }) # Equality
|
178
|
+
assert_predicate.call({ filter => { gt: value } }) # Greater Than
|
179
|
+
assert_predicate.call({ filter => { greater_than: value } })
|
180
|
+
assert_predicate.call({ filter => { lt: value } }) # Less Than
|
181
|
+
assert_predicate.call({ filter => { less_than: value } })
|
182
|
+
assert_predicate.call({ filter => { gte: value } }) # Greater Than or Equal To
|
183
|
+
assert_predicate.call({ filter => { gteq: value } })
|
184
|
+
assert_predicate.call({ filter => { greater_than_or_equal_to: value } })
|
185
|
+
assert_predicate.call({ filter => { lte: value } }) # Less Than or Equal To
|
186
|
+
assert_predicate.call({ filter => { lteq: value } })
|
187
|
+
assert_predicate.call({ filter => { less_than_or_equal_to: value } })
|
190
188
|
end
|
191
189
|
end
|
192
190
|
end
|
data/lib/standard_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standardapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0.
|
4
|
+
version: 5.0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|