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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c3b045a67f198699974080c3cffa49b2a15abbee
4
- data.tar.gz: e613a6e4ee99d2e5228c8534a9755f1d5a7f97a3
2
+ SHA256:
3
+ metadata.gz: 728c78d6c47945aca14a06d298d49c81980d6dc841dee906fca34d5057765513
4
+ data.tar.gz: cbc0424afd867582c214f486acea47017c19ea593b4ac2f3bc3144d66646cd02
5
5
  SHA512:
6
- metadata.gz: 7a561ee2fc0cd12f144d3e4124b0f304634658155baa8ea68d246e4bc2947853c120037851b110f675911bf65d3d2e600d08192260af22685961fee37b52ffb3
7
- data.tar.gz: 8b7d3e04a0bae7b0952cf7d4a00679db43ffaae862228f972e9ac7c292740325b57a28b08f5c7328a51e59f413efc899b5ea01ef5ba6496f50d659da5213f051
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', '>= 4.2.0'
27
- spec.add_runtime_dependency 'activesupport', '>= 4.2.0'
26
+ spec.add_runtime_dependency 'rails', '>= 6.0'
27
+ spec.add_runtime_dependency 'activesupport', '>= 6.0'
28
28
 
29
- spec.add_development_dependency 'bundler', '~> 1.11'
30
- spec.add_development_dependency 'rake', '~> 10.0'
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
@@ -9,7 +9,7 @@ module CruLib
9
9
 
10
10
  def retrieve_gr_master_person_id
11
11
  return unless respond_to?(:gr_master_person_id)
12
- async(:async_retrieve_gr_master_person_id)
12
+ async("async_retrieve_gr_master_person_id")
13
13
  end
14
14
 
15
15
  def async_retrieve_gr_master_person_id
@@ -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, :async_delete_from_global_registry, global_registry_id)
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(:async_push_to_global_registry)
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, :async_delete_from_global_registry, global_registry_id)
13
+ Sidekiq::Client.enqueue(self.class, nil, "async_delete_from_global_registry", global_registry_id)
14
14
  end
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module CruLib
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -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.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: 2017-05-11 00:00:00.000000000 Z
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: 4.2.0
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: 4.2.0
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: 4.2.0
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: 4.2.0
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: '1.11'
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: '1.11'
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: '10.0'
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: '10.0'
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
- rubyforge_project:
125
- rubygems_version: 2.6.8
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