unidom-standard 1.4.1 → 1.4.2

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: 05c558e6dc0b25a2d495c0f5da157597399fe7a3
4
- data.tar.gz: fe2ab5890489f62da6e0a66094bdcdd7759e8f4e
3
+ metadata.gz: 2e4fdcb805d5792897f09e58c523dddcff3e415a
4
+ data.tar.gz: 304ba3dc1ed7df222f1d30d3b9b56b6727408a9a
5
5
  SHA512:
6
- metadata.gz: d1d7ca3c30626e958be11cfd72a21205e4d329cb1afd192867e7db5ef397458655a7f4a9cb8b2fbffd9c4201e30ea2e9162beb57bd52c1eb57ec4a8e2756bf2d
7
- data.tar.gz: b7dd1593a614430e5409fe44581893f5a880aeaf88160cdd394bbd774c0856e56b8d566884e92f88c947d09c6d0db25468544c9083470cd37ab75a1f3353c958
6
+ metadata.gz: 6bab4fb0ef02424ca5a111c5da147a70895854d01f62b62dafed4f46188666175e5538cb92dd5140e3c3986a1c5a11a74f0d90e2c505534eb8f2121508334bd4
7
+ data.tar.gz: 62a74d1a714d6c9949b375fe0edabe1c049128e34aa803a727baaa883967d2505634db8eac5d4feabd95f1fb33fd515b1667533cb79112cd771726d335af99a1
@@ -8,12 +8,12 @@ class Unidom::Standard::StandardAssociating < Unidom::Standard::ApplicationRecor
8
8
 
9
9
  include Unidom::Common::Concerns::ModelExtension
10
10
 
11
- scope :source_is, ->(source) { where source_id: (source.respond_to?(:id) ? source.id : source) }
12
- scope :target_is, ->(target) { where target_id: (target.respond_to?(:id) ? target.id : target) }
13
-
14
11
  belongs_to :source, class_name: 'Unidom::Standard::Standard', foreign_key: :source_id
15
12
  belongs_to :target, class_name: 'Unidom::Standard::Standard', foreign_key: :target_id
16
13
 
14
+ scope :source_is, ->(source) { where source_id: (source.respond_to?(:id) ? source.id : source) }
15
+ scope :target_is, ->(target) { where target_id: (target.respond_to?(:id) ? target.id : target) }
16
+
17
17
  def self.associate!(source, with: target, due_to: 'REVS', at: Time.now)
18
18
  create! source_id: to_id(source), target_id: to_id(with), association_code: due_to, opened_at: at
19
19
  end
@@ -16,6 +16,18 @@ describe Unidom::Standard::StandardAssociating, type: :model do
16
16
 
17
17
  it_behaves_like 'Unidom::Common::Concerns::ModelExtension', model_attributes
18
18
 
19
+ it_behaves_like 'scope', :source_is, [
20
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:source_id] ] },
21
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ Unidom::Standard::Standard.new(id: model_attributes[:source_id]) ] },
22
+ { attributes_collection: [ model_attributes.merge(source_id: SecureRandom.uuid) ], count_diff: 0, args: [ model_attributes[:source_id] ] },
23
+ { attributes_collection: [ model_attributes.merge(source_id: SecureRandom.uuid) ], count_diff: 0, args: [ Unidom::Standard::Standard.new(id: model_attributes[:source_id]) ] } ]
24
+
25
+ it_behaves_like 'scope', :target_is, [
26
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:target_id] ] },
27
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ Unidom::Standard::Standard.new(id: model_attributes[:target_id]) ] },
28
+ { attributes_collection: [ model_attributes.merge(target_id: SecureRandom.uuid) ], count_diff: 0, args: [ model_attributes[:target_id] ] },
29
+ { attributes_collection: [ model_attributes.merge(target_id: SecureRandom.uuid) ], count_diff: 0, args: [ Unidom::Standard::Standard.new(id: model_attributes[:target_id]) ] } ]
30
+
19
31
  end
20
32
 
21
33
  end
@@ -44,6 +44,12 @@ describe Unidom::Standard::Standard, type: :model do
44
44
  { number: 'A'*name_max_length } => 0,
45
45
  { number: 'A'*(name_max_length+1) } => 1
46
46
 
47
+ it_behaves_like 'scope', :number_is, [
48
+ { attributes_collection: [ model_attributes ], count_diff: 1, args: [ model_attributes[:number] ] },
49
+ { attributes_collection: [ model_attributes ], count_diff: 0, args: [ "#{model_attributes[:number]}0" ] },
50
+ { attributes_collection: [ model_attributes.merge(number: "#{model_attributes[:number]}0") ], count_diff: 0, args: [ model_attributes[:number] ] },
51
+ { attributes_collection: [ model_attributes.merge(number: "#{model_attributes[:number]}0") ], count_diff: 1, args: [ "#{model_attributes[:number]}0" ] } ]
52
+
47
53
  end
48
54
 
49
55
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Standard
3
- VERSION = '1.4.1'.freeze
3
+ VERSION = '1.4.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
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-02-16 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common