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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4095b09787b11d959aa9b8fa93b622c00a4ea17
4
- data.tar.gz: 52d6e190c82940c32497ddf56faadea89d726bd4
3
+ metadata.gz: 33ac07bfd36c0394f555e511042e85e56ce2efe7
4
+ data.tar.gz: 692696c513d7c666c4f14cf4ead1dc4d7613dbb6
5
5
  SHA512:
6
- metadata.gz: e0bf2507e1cde35d75cf02ba964dbe46b67e7d203dec4e2ec057d1361f378112dd5bbf2b3c4e68b76f565680ecdf80c62bf96e014ae6839b30a4d00c253a2cea
7
- data.tar.gz: c0b9fcad3f525a0495df22d05f1d81e8112497cc67da4bc8ac7f0f8c40d228811d80940678a86753c2ffbefa77a3d82cbc19f6a60058c2c42f8bcfe3891666fd
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.instance_variable_get('@filters').each do |filter|
156
- next if filter[1].is_a?(Proc) # Custom filter
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[0])
160
+ value = m.send(filter)
163
161
 
164
162
  assert_predicate = -> (predicate) {
165
- get :index, params: {where: predicate}, format: 'json'
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[0].to_s].type
168
+ case model.columns_hash[filter.to_s].type
171
169
  when :jsonb, :json # JSON
172
- assert_predicate.call({ filter[0] => value })
170
+ assert_predicate.call({ filter => value })
173
171
  else
174
172
  case value
175
173
  when Array
176
- assert_predicate.call({ filter[0] => value }) # Overlaps
177
- assert_predicate.call({ filter[0] => value[0] }) # Contains
174
+ assert_predicate.call({ filter => value }) # Overlaps
175
+ assert_predicate.call({ filter => value[0] }) # Contains
178
176
  else
179
- assert_predicate.call({ filter[0] => value }) # Equality
180
- assert_predicate.call({ filter[0] => { gt: value } }) # Greater Than
181
- assert_predicate.call({ filter[0] => { greater_than: value } })
182
- assert_predicate.call({ filter[0] => { lt: value } }) # Less Than
183
- assert_predicate.call({ filter[0] => { less_than: value } })
184
- assert_predicate.call({ filter[0] => { gte: value } }) # Greater Than or Equal To
185
- assert_predicate.call({ filter[0] => { gteq: value } })
186
- assert_predicate.call({ filter[0] => { greater_than_or_equal_to: value } })
187
- assert_predicate.call({ filter[0] => { lte: value } }) # Less Than or Equal To
188
- assert_predicate.call({ filter[0] => { lteq: value } })
189
- assert_predicate.call({ filter[0] => { less_than_or_equal_to: value } })
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
@@ -1,3 +1,3 @@
1
1
  module StandardAPI
2
- VERSION = '5.0.0.14'
2
+ VERSION = '5.0.0.15'
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: 5.0.0.14
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-20 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails