praxis 2.0.pre.15 → 2.0.pre.16

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: 9391f2cd6fb2c5a605a4b4c9f492371ef1d7f01849e94a9d17fdc51b95c211a9
4
- data.tar.gz: 70c9f00cd12c7b3e99cebd10f86a98ac913433b8b96a41b658893b63ddc4b31b
3
+ metadata.gz: 2fe1ba3515514e34ad80775b6b68b4fe046fd1806c40d2345c4fa945d34ed92a
4
+ data.tar.gz: 11934130d0c527d1bc52020f393f2a5167ba3f88c876e81deaf7eaa05c518eff
5
5
  SHA512:
6
- metadata.gz: edfc42021b347aea6bd7b84853ebd901f55e4963612da2a6870e00b956b3352e51efd8cd3c360123625af48f89553bff6fa0ad7766e076bc164ba8ccf770ba7b
7
- data.tar.gz: da2df887a849f03be390f7218f931807670a58addc8eb3d101b293e0827a522680ca1824f47bafcff2c3f26bfb45bd13e8ad0c6f02577edad12c5c8cfca60904
6
+ metadata.gz: a32c98bd77159e59c5192390c2eb683b62930cb3f4b30cbe680b63db5b0c076199b0fb63e5a0a55abb772a92cadef19a8f05d7cedf7eb8218f585ce8b7a01acf
7
+ data.tar.gz: 2a086210825ac166730d63b9ea7e5baa2420cdeb1772e434028b95de356ce69778d983fededb1125825f5b036bc0a0c13fc9b61536d77a31cc63cd87f6a48c02
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## next
4
4
 
5
+ ## 2.0.pre.16
6
+
7
+ * Updated `Resource.property` signature to only accept known named arguments (`dependencies` and `though` at this time) to spare anyone else from going insane wondering why their `depednencies` aren't working.
8
+ * Fixed issue with Filtering Params, that occurred with using the ! or !! operators on String-typed fields.
9
+
5
10
  ## 2.0.pre.14
6
11
 
7
12
  * More encoding/decoding robustness for filters.
@@ -222,8 +222,7 @@ module Praxis
222
222
  value_type = attr_filters[:value_type]
223
223
  next unless value_type == Attributor::String
224
224
 
225
- value = item[:value]
226
- unless value.empty?
225
+ if item[:value].presence
227
226
  fuzzy_match = attr_filters[:fuzzy_match]
228
227
  if item[:fuzzy] && !item[:fuzzy].empty? && !fuzzy_match
229
228
  errors << "Fuzzy matching for #{attr_name} is not allowed (yet '*' was found in the value)"
@@ -46,8 +46,8 @@ module Praxis::Mapper
46
46
  end
47
47
  end
48
48
 
49
- def self.property(name, **options)
50
- self.properties[name] = options
49
+ def self.property(name, dependencies: nil, through: nil)
50
+ self.properties[name] = {dependencies: dependencies, through: through}
51
51
  end
52
52
 
53
53
  def self._finalize!
@@ -1,3 +1,3 @@
1
1
  module Praxis
2
- VERSION = '2.0.pre.15'
2
+ VERSION = '2.0.pre.16'
3
3
  end
@@ -161,9 +161,9 @@ describe Praxis::Extensions::AttributeFiltering::FilteringParams do
161
161
  # construct it propertly by applying the block. Seems easier than creating the type alone, and
162
162
  # then manually apply the block
163
163
  Attributor::Attribute.new(described_class.for(Post)) do
164
- filter 'id', using: ['=', '!=']
164
+ filter 'id', using: ['=', '!=', '!']
165
165
  filter 'title', using: ['=', '!='], fuzzy: true
166
- filter 'content', using: ['=', '!=']
166
+ filter 'content', using: ['=', '!=', '!']
167
167
  end.type
168
168
  end
169
169
  let(:loaded_params) { filtering_params_type.load(filters_string) }
@@ -194,6 +194,21 @@ describe Praxis::Extensions::AttributeFiltering::FilteringParams do
194
194
  end
195
195
  end
196
196
  end
197
+
198
+ context 'non-valued operators' do
199
+ context 'for string typed fields' do
200
+ let(:filters_string) { 'content!'}
201
+ it 'validates properly' do
202
+ expect(subject).to be_empty
203
+ end
204
+ end
205
+ context 'for non-string typed fields' do
206
+ let(:filters_string) { 'id!'}
207
+ it 'validates properly' do
208
+ expect(subject).to be_empty
209
+ end
210
+ end
211
+ end
197
212
  context 'fuzzy matches' do
198
213
  context 'when allowed' do
199
214
  context 'given a fuzzy string' do
@@ -14,15 +14,15 @@ describe Praxis::Mapper::Resource do
14
14
  subject(:properties) { resource.properties }
15
15
 
16
16
  it 'includes directly-set properties' do
17
- expect(properties[:other_resource]).to eq(dependencies: [:other_model])
17
+ expect(properties[:other_resource]).to eq(dependencies: [:other_model], through: nil)
18
18
  end
19
19
 
20
20
  it 'inherits from a superclass' do
21
- expect(properties[:href]).to eq(dependencies: [:id])
21
+ expect(properties[:href]).to eq(dependencies: [:id], through: nil)
22
22
  end
23
23
 
24
24
  it 'properly overrides a property from the parent' do
25
- expect(properties[:name]).to eq(dependencies: [:simple_name])
25
+ expect(properties[:name]).to eq(dependencies: [:simple_name], through: nil)
26
26
  end
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: praxis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.pre.15
4
+ version: 2.0.pre.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Blanquer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-04-28 00:00:00.000000000 Z
12
+ date: 2021-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack