unidom-category 1.6.2 → 1.6.3

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: c5c7dcc861783a84dd34141a3adca54ac7d13048
4
- data.tar.gz: 4c5e1bcfc43aa3cd3940bfcab897952b6eff5ede
3
+ metadata.gz: 8423dbd1e7303708f375a0e58a93cc98543b5c7a
4
+ data.tar.gz: a4da60fec09dc2008e9a64f03ee17f65496b67f0
5
5
  SHA512:
6
- metadata.gz: 2c233281115ca22cb267b7b22814d70d534d1eb31e4f7106cd39b095f130e430a05e03bbd391545c3b9710b581cd09b81970a6d6ad99e450812e3d891f79de4e
7
- data.tar.gz: e118354ada928dcbfdfd8a0bcdc217eb41ac9e4f6b0e28b28615a525c67dd77b4ff9650b352391afd916268b6c169b648e1a44ff27a466e12df496391660786c
6
+ metadata.gz: 59479915cc29a05a2ae89fb12b1c065da0cefd8142318bc5cba087f4172fe6e2c1c8934c33d375a234fdca770dc322e0ccd8e61ed1f09f7554ed8ffdd1cd69be
7
+ data.tar.gz: c4e6032865e7f79ad8d0760003b3e3e34360043f50200dcf71fab50007f47a7289f2eb91fcfe087a419ecbf70faad5083ab74ef216f8f157505d545dc5c813b8
@@ -15,7 +15,7 @@ class Unidom::Category::Category < Unidom::Category::ApplicationRecord
15
15
 
16
16
  belongs_to :scheme, class_name: 'Unidom::Category::CategoryScheme', foreign_key: :scheme_id
17
17
 
18
- scope :scheme_is, ->(scheme) { where scheme_id: (scheme.respond_to?(:id) ? scheme.id : scheme ) }
18
+ scope :scheme_is, ->(scheme) { where scheme_id: to_id(scheme) }
19
19
  scope :code_length_is, ->(length) { where 'LENGTH(code) = :code_length', code_length: length }
20
20
  scope :code_starting_with, ->(prefix) { where 'code LIKE :prefix_expression', prefix_expression: prefix+'%' }
21
21
 
@@ -62,6 +62,26 @@ describe Unidom::Category::Category, type: :model do
62
62
 
63
63
  it_behaves_like 'belongs_to', model_attributes, :scheme, Unidom::Category::CategoryScheme, scheme_attributes
64
64
 
65
+ it_behaves_like 'monomorphic scope', model_attributes, :scheme_is, :scheme
66
+
67
+ it_behaves_like 'scope', :code_length_is, [
68
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ 1 ] },
69
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ 2 ] },
70
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ 3 ] },
71
+ { attributes_collection: [ model_attributes.merge(code: 'XCX') ], count_diff: 0, args: [ 2 ] },
72
+ { attributes_collection: [ model_attributes.merge(code: 'XCX') ], count_diff: 1, args: [ 3 ] },
73
+ { attributes_collection: [ model_attributes.merge(code: 'XCX') ], count_diff: 0, args: [ 4 ] }
74
+ ]
75
+
76
+ it_behaves_like 'scope', :code_starting_with, [
77
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ 'C' ] },
78
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ 'X' ] },
79
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ 'A' ] },
80
+ { attributes_collection: [ model_attributes.merge(code: 'CX') ], count_diff: 1, args: [ 'C' ] },
81
+ { attributes_collection: [ model_attributes.merge(code: 'CX') ], count_diff: 0, args: [ 'X' ] },
82
+ { attributes_collection: [ model_attributes.merge(code: 'CX') ], count_diff: 0, args: [ 'A' ] }
83
+ ]
84
+
65
85
  end
66
86
 
67
87
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Category
3
- VERSION = '1.6.2'.freeze
3
+ VERSION = '1.6.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-category
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-02 00:00:00.000000000 Z
11
+ date: 2017-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common