cru_lib 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/cru_lib.gemspec +7 -4
- data/lib/cru_lib/global_registry_master_person_methods.rb +1 -1
- data/lib/cru_lib/global_registry_methods.rb +2 -2
- data/lib/cru_lib/global_registry_relationship_methods.rb +1 -1
- data/lib/cru_lib/version.rb +1 -1
- data/spec/support/async_commons.rb +19 -0
- data/spec/support/async_spec.rb +90 -0
- metadata +46 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 728c78d6c47945aca14a06d298d49c81980d6dc841dee906fca34d5057765513
|
4
|
+
data.tar.gz: cbc0424afd867582c214f486acea47017c19ea593b4ac2f3bc3144d66646cd02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c7463e6c6df87f0273607c04fe9ffb6fd27353c2fc1617a9610cf95dcc659da78baeb54879f46b9ef32df57ed1985d233154a3e4ba1682ec0f79f034949586
|
7
|
+
data.tar.gz: e1dea8dbc805b803e7889970f7ea1f1d1689e790af86a52ad5278406132403a420ddd7ca6a1ae8e5b1813efd4f06ededc2eabed88139738c6ce70af4633b7801
|
data/cru_lib.gemspec
CHANGED
@@ -23,9 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency 'global_registry', '~> 1.0'
|
25
25
|
|
26
|
-
spec.add_runtime_dependency 'rails', '>=
|
27
|
-
spec.add_runtime_dependency 'activesupport', '>=
|
26
|
+
spec.add_runtime_dependency 'rails', '>= 6.0'
|
27
|
+
spec.add_runtime_dependency 'activesupport', '>= 6.0'
|
28
28
|
|
29
|
-
spec.add_development_dependency 'bundler', '~>
|
30
|
-
spec.add_development_dependency 'rake', '~>
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.3'
|
30
|
+
spec.add_development_dependency 'rake', '~> 13'
|
31
|
+
|
32
|
+
spec.add_development_dependency 'rspec-rails', '~> 5'
|
33
|
+
spec.add_development_dependency 'sidekiq', '~> 6'
|
31
34
|
end
|
@@ -13,13 +13,13 @@ module CruLib
|
|
13
13
|
|
14
14
|
def delete_from_global_registry
|
15
15
|
if global_registry_id
|
16
|
-
Sidekiq::Client.enqueue(self.class, nil,
|
16
|
+
Sidekiq::Client.enqueue(self.class, nil, "async_delete_from_global_registry", global_registry_id)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
# Define default push method
|
21
21
|
def push_to_global_registry
|
22
|
-
async(
|
22
|
+
async("async_push_to_global_registry")
|
23
23
|
end
|
24
24
|
|
25
25
|
def async_push_to_global_registry(parent_id = nil, parent_type = nil, parent = nil)
|
@@ -10,7 +10,7 @@ module CruLib
|
|
10
10
|
# TODO - deleting a relationship is different.
|
11
11
|
def delete_from_global_registry
|
12
12
|
if global_registry_id
|
13
|
-
Sidekiq::Client.enqueue(self.class, nil,
|
13
|
+
Sidekiq::Client.enqueue(self.class, nil, "async_delete_from_global_registry", global_registry_id)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/cru_lib/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
# Mock ActiveRecord::RecordNotFound
|
3
|
+
#
|
4
|
+
module ActiveRecord
|
5
|
+
class RecordNotFound < StandardError
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# ActiveRecord-ish - a mocked ActiveRecord that behaves like a model class with id
|
10
|
+
#
|
11
|
+
class ActiveRecordIsh
|
12
|
+
attr_accessor :id
|
13
|
+
|
14
|
+
def self.find(id)
|
15
|
+
obj = self.new
|
16
|
+
obj.id = id
|
17
|
+
obj
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
|
2
|
+
require 'cru_lib/async'
|
3
|
+
require_relative 'async_commons'
|
4
|
+
|
5
|
+
require 'sidekiq/testing'
|
6
|
+
Sidekiq::Testing.inline!
|
7
|
+
|
8
|
+
# The class includes Sidekiq worker and responds properly to Async calls
|
9
|
+
#
|
10
|
+
class SidekiqAsync < ActiveRecordIsh
|
11
|
+
include Sidekiq::Worker
|
12
|
+
include CruLib::Async
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
describe CruLib::Async do
|
17
|
+
describe 'when there is no id' do
|
18
|
+
before(:each) do
|
19
|
+
@tested = SidekiqAsync.new
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'calls class method when one argument' do
|
23
|
+
param_1 = SecureRandom.uuid
|
24
|
+
|
25
|
+
# Expect class method get called with just one parameter
|
26
|
+
#
|
27
|
+
expect(SidekiqAsync).to receive(:method_1) do |arg_1, *arg_2|
|
28
|
+
expect(arg_1).to eq(param_1)
|
29
|
+
expect(arg_2.length).to eq(0)
|
30
|
+
end
|
31
|
+
|
32
|
+
@tested.async("method_1", param_1)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'calls class method when two arguments' do
|
36
|
+
param_1 = SecureRandom.uuid
|
37
|
+
param_2 = SecureRandom.uuid
|
38
|
+
|
39
|
+
# Expect class method get called with two parameters
|
40
|
+
#
|
41
|
+
expect(SidekiqAsync).to receive(:method_2) do |arg_1, arg_2, *arg_3|
|
42
|
+
expect(arg_1).to eq(param_1)
|
43
|
+
expect(arg_2).to eq(param_2)
|
44
|
+
expect(arg_3.length).to eq(0)
|
45
|
+
end
|
46
|
+
|
47
|
+
@tested.async("method_2", param_1, param_2)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'with id' do
|
52
|
+
before(:each) do
|
53
|
+
@tested = SidekiqAsync.new
|
54
|
+
@id = SecureRandom.random_number(100_000)
|
55
|
+
@tested.id = @id
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'calls instance method properly when one argument' do
|
59
|
+
param_1 = SecureRandom.uuid
|
60
|
+
|
61
|
+
# Expect instance method get called with one parameter
|
62
|
+
# The object's attribute id is properly set
|
63
|
+
#
|
64
|
+
expect_any_instance_of(SidekiqAsync).to receive(:inst_method_1) do |object, arg_1, *arg_2|
|
65
|
+
expect(object.id).to eq(@id)
|
66
|
+
expect(arg_1).to eq(param_1)
|
67
|
+
expect(arg_2.length).to eq(0)
|
68
|
+
end
|
69
|
+
|
70
|
+
@tested.async("inst_method_1", param_1)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'calls instance method properly when two arguments' do
|
74
|
+
param_1 = SecureRandom.uuid
|
75
|
+
param_2 = SecureRandom.uuid
|
76
|
+
|
77
|
+
# Expect instance method get called with two parameters
|
78
|
+
# The object's attribute id is properly set
|
79
|
+
#
|
80
|
+
expect_any_instance_of(SidekiqAsync).to receive(:inst_method_2) do |object, arg_1, arg_2, *arg_3|
|
81
|
+
expect(object.id).to eq(@id)
|
82
|
+
expect(arg_1).to eq(param_1)
|
83
|
+
expect(arg_2).to eq(param_2)
|
84
|
+
expect(arg_3.length).to eq(0)
|
85
|
+
end
|
86
|
+
|
87
|
+
@tested.async("inst_method_2", param_1, param_2)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cru_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Starcher
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: global_registry
|
@@ -30,56 +30,84 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '6.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '6.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '6.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '6.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '13'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '13'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sidekiq
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '6'
|
83
111
|
description: Provides a common interface for mapping ActiveRecord models to Global
|
84
112
|
Registry entities and relationships.
|
85
113
|
email:
|
@@ -102,11 +130,13 @@ files:
|
|
102
130
|
- lib/cru_lib/railtie.rb
|
103
131
|
- lib/cru_lib/version.rb
|
104
132
|
- spec/shared_examples_for_global_registry_models.rb
|
133
|
+
- spec/support/async_commons.rb
|
134
|
+
- spec/support/async_spec.rb
|
105
135
|
homepage: https://github.com/CruGlobal/cru_lib
|
106
136
|
licenses:
|
107
137
|
- MIT
|
108
138
|
metadata: {}
|
109
|
-
post_install_message:
|
139
|
+
post_install_message:
|
110
140
|
rdoc_options: []
|
111
141
|
require_paths:
|
112
142
|
- lib
|
@@ -121,10 +151,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
151
|
- !ruby/object:Gem::Version
|
122
152
|
version: '0'
|
123
153
|
requirements: []
|
124
|
-
|
125
|
-
|
126
|
-
signing_key:
|
154
|
+
rubygems_version: 3.3.0
|
155
|
+
signing_key:
|
127
156
|
specification_version: 4
|
128
157
|
summary: Map ActiveRecord to Global Registry
|
129
158
|
test_files:
|
130
159
|
- spec/shared_examples_for_global_registry_models.rb
|
160
|
+
- spec/support/async_commons.rb
|
161
|
+
- spec/support/async_spec.rb
|