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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8423dbd1e7303708f375a0e58a93cc98543b5c7a
|
4
|
+
data.tar.gz: a4da60fec09dc2008e9a64f03ee17f65496b67f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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.
|
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-
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|