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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dea6fe2070a9d9f2e92b545da5d2f7415568fee783ba45e1be6628822eb49fa7
4
- data.tar.gz: a4b14c21227e9790fe4913b173faadc310b7384d09c39cd1891b864fd98c2ff6
3
+ metadata.gz: 57e9eb8d2b72416e613c4231e25fb67709bd38ec93607e12dab2705fdf2e05b2
4
+ data.tar.gz: a5d03ecbbdc3529f6aec1546a933c8353f6f6a1b5cc2aefc7cc0dda1b55fb52c
5
5
  SHA512:
6
- metadata.gz: 451fbdbd66417b109b33d4bc1631f7a9e2913e345b966074baad332168c4184f5d8c7cda94f4e48afb771ef22bd4eb7d9b38986bbd1bd874ceef251001aeddc9
7
- data.tar.gz: cd109f69f5115e62a66719b1310af3d28a71ce7124d4cc873c139d44b59680edac0ff6330f935a9b1d2ddca2919d18a89fa7d7718d323689bffbed3ec3f04837
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 = ["smallint", "int", "bigint", "real", "double precision", "numeric", "interval"]
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
- column = model.columns.find { |x| CALCULATE_COLUMN_TYPES.include?(x.sql_type) }.name
12
- selects = [{ count: column}, { maximum: column }, { minimum: column }, { average: column }]
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
- column = model.columns.find { |x| CALCULATE_COLUMN_TYPES.include?(x.sql_type) }.name
25
- selects = [{ count: column}, { maximum: column }, { minimum: column }, { average: column }]
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)
@@ -1,3 +1,3 @@
1
1
  module StandardAPI
2
- VERSION = '6.0.0.12'
2
+ VERSION = '6.0.0.14'
3
3
  end
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.12
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-21 00:00:00.000000000 Z
11
+ date: 2019-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails