standardapi 6.0.0.12 → 6.0.0.14
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/calculate_tests.rb +24 -6
- data/lib/standard_api/version.rb +1 -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: 57e9eb8d2b72416e613c4231e25fb67709bd38ec93607e12dab2705fdf2e05b2
|
4
|
+
data.tar.gz: a5d03ecbbdc3529f6aec1546a933c8353f6f6a1b5cc2aefc7cc0dda1b55fb52c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03aa6f252f8fed9a81cfce311cc5596798505f0b683bfb4a5a8c5cc55232c73cd8ed1ee1fa78aa642a5e6ba01bd4e5ee1e142e3d197104b7248e06cc64a91499
|
7
|
+
data.tar.gz: 2f47d3025a871845b0b9e50ac3ff014c94cfecb8ebf2d216d7fb171b5ff37aa3b980432a73498ef31b658768e52a646fe2547d5e80b3bbbf4a394bdd4c19a561
|
@@ -3,26 +3,44 @@ module StandardAPI
|
|
3
3
|
module CalculateTests
|
4
4
|
extend ActiveSupport::Testing::Declarative
|
5
5
|
|
6
|
-
CALCULATE_COLUMN_TYPES = [
|
6
|
+
CALCULATE_COLUMN_TYPES = [
|
7
|
+
"smallint", "int", "integer", "bigint", "real", "double precision",
|
8
|
+
"numeric", "interval"
|
9
|
+
]
|
7
10
|
|
8
11
|
test '#calculate.json' do
|
9
12
|
create_model
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
math_column = model.columns.find { |x| CALCULATE_COLUMN_TYPES.include?(x.sql_type) }
|
15
|
+
|
16
|
+
if math_column
|
17
|
+
column = math_column
|
18
|
+
selects = [{ count: column.name}, { maximum: column.name }, { minimum: column.name }, { average: column.name }]
|
19
|
+
else
|
20
|
+
column = model.columns.sample
|
21
|
+
selects = [{ count: column.name}]
|
22
|
+
end
|
13
23
|
|
14
24
|
get resource_path(:calculate, select: selects, format: :json)
|
15
25
|
assert_response :ok
|
16
26
|
calculations = @controller.instance_variable_get('@calculations')
|
17
|
-
assert_equal [[model.count(column), model.maximum(column), model.minimum(column), model.average(column).to_f]], calculations
|
27
|
+
assert_equal [[model.count(column.name), model.maximum(column.name), model.minimum(column.name), model.average(column.name).to_f]], calculations
|
18
28
|
end
|
19
29
|
|
20
30
|
test '#calculate.json params[:where]' do
|
21
31
|
m1 = create_model
|
22
32
|
create_model
|
23
33
|
|
24
|
-
|
25
|
-
|
34
|
+
math_column = model.columns.find { |x| CALCULATE_COLUMN_TYPES.include?(x.sql_type) }
|
35
|
+
|
36
|
+
if math_column
|
37
|
+
column = math_column
|
38
|
+
selects = [{ count: column.name}, { maximum: column.name }, { minimum: column.name }, { average: column.name }]
|
39
|
+
else
|
40
|
+
column = model.columns.sample
|
41
|
+
selects = [{ count: column.name}]
|
42
|
+
end
|
43
|
+
|
26
44
|
predicate = { id: { gt: m1.id } }
|
27
45
|
|
28
46
|
get resource_path(:calculate, where: predicate, select: selects, format: :json)
|
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: 6.0.0.
|
4
|
+
version: 6.0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|