stackone_migration 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: daa32597a9e8c833693f8b94f572af6fee65310b673ede6e67a99f6772ee0d87
4
- data.tar.gz: fc23f733389cce570bb07754170e84f59d7f065f6b69931e8ddb941b25002fad
3
+ metadata.gz: cadc4aeca4df2a3e2fb255bf8707c2a2d367ec91fef4f37730f4721200eb280d
4
+ data.tar.gz: 721ca5cd0cd33b92cfbaba84f39b15261804846b19abc3a247a945f001fa9581
5
5
  SHA512:
6
- metadata.gz: 149a32da85baab2c457cda99adb372a5bdb520927f8f28768f1c9a365a9cd878d9817029313f710f4e908ad49860db43ec9ec17f981ecf0d259664a52ea40124
7
- data.tar.gz: 1598674e96bb4bd3724e087382cc5ad53c183c83ad3826d7d224ca56c0764d0da49b3f1f13bb46ff3d96112acdf108a8f10960ba434deb0d4ca958d19ce44421
6
+ metadata.gz: bfed002c6274ece9c15edd5e63ad44a7e1043f1e0057813cc42a969bd1b550dd2c92d6923c13eaa3bda9f924824c9eb0aba6d64a6edb04f606d561d55fddd5df
7
+ data.tar.gz: 6a16939ca863b8e00c3d769322f56caca5e3a253efcb61152c34505326539d75d566906e19c89cf3511b1c871f1d860e0f35a141b0e34bb33231d4b6be099c00
data/Gemfile CHANGED
@@ -11,4 +11,4 @@ group :development, :test do
11
11
  end
12
12
 
13
13
  gem 'merge_hris_client', '~> 3.0'
14
- gem 'stackone_hris_client', '~> 1.4.0'
14
+ gem 'stackone_hris_client', '~> 1.5.1'
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackone_migration (1.3.0)
4
+ stackone_migration (1.4.1)
5
5
  merge_hris_client (~> 3.0)
6
- stackone_hris_client (~> 1.4.0)
6
+ stackone_hris_client (~> 1.5.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -58,7 +58,7 @@ GEM
58
58
  rubocop-ast (1.27.0)
59
59
  parser (>= 3.2.1.0)
60
60
  ruby-progressbar (1.13.0)
61
- stackone_hris_client (1.4.0)
61
+ stackone_hris_client (1.5.1)
62
62
  typhoeus (~> 1.0, >= 1.0.1)
63
63
  typhoeus (1.4.0)
64
64
  ethon (>= 0.9.0)
@@ -73,7 +73,7 @@ DEPENDENCIES
73
73
  rake (~> 13.0.1)
74
74
  rspec (~> 3.6, >= 3.6.0)
75
75
  rubocop (~> 1.48.0)
76
- stackone_hris_client (~> 1.4.0)
76
+ stackone_hris_client (~> 1.5.1)
77
77
  stackone_migration!
78
78
 
79
79
  BUNDLED WITH
@@ -100,8 +100,8 @@ module StackOneMigration
100
100
  :avatar => employee.avatar_url,
101
101
  :personal_email => employee.personal_email,
102
102
  :work_email => employee.work_email,
103
- :mobile_phone_number => employee.personal_phone_number,
104
- :gender => MergeHRISClient::GenderEnum.build_from_hash(map_enum(gender_enum_hash,employee.gender)),
103
+ :mobile_phone_number => employee.personal_phone_number || employee.work_phone_number,
104
+ :gender => MergeHRISClient::GenderEnum.build_from_hash(map_enum(gender_enum_hash, employee.gender)),
105
105
  :date_of_birth => employee.date_of_birth,
106
106
  :start_date => employee.start_date,
107
107
  :manager => employee.manager_id,
@@ -129,7 +129,7 @@ module StackOneMigration
129
129
  :city => location.city,
130
130
  :state => location.state,
131
131
  :zip_code => location.zip_code,
132
- :country => MergeHRISClient::CountryEnum.build_from_hash(location.country),
132
+ :country => map_country_enum(location.country),
133
133
  :location_type => MergeHRISClient::LocationTypeEnum.build_from_hash(map_enum(location_type_enum_hash, location.location_type)),
134
134
  )
135
135
  end
@@ -196,5 +196,13 @@ module StackOneMigration
196
196
 
197
197
  enum.source_value
198
198
  end
199
+
200
+ def self.map_country_enum(enum)
201
+ return nil if enum.nil? || enum.value.nil?
202
+
203
+ enum_value = enum.value != 'unmapped_value' ? enum.value : enum.source_value
204
+
205
+ MergeHRISClient::CountryEnum.build_from_hash(enum_value)
206
+ end
199
207
  end
200
208
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StackOneMigration
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.1'
5
5
  end
@@ -32,7 +32,7 @@ describe StackOneMigration::EmployeesMapper do
32
32
  :city => "San Francisco",
33
33
  :state => "CA",
34
34
  :zip_code => "94105",
35
- :country => "US",
35
+ :country => StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States'),
36
36
  :location_type => StackOneHRIS::LocationTypeEnum.new(value: 'home', source_value: 'home'),
37
37
  ),
38
38
  :work_location => nil,
@@ -59,7 +59,6 @@ describe StackOneMigration::EmployeesMapper do
59
59
  :avatar_url => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
60
60
  :personal_email => 'ija@egje.wf',
61
61
  :work_email => 'kota@efpiphi.kw',
62
- :personal_phone_number => '(715) 658-9486',
63
62
  :gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
64
63
  :date_of_birth => '1990-01-01',
65
64
  :start_date => '2018-01-01',
@@ -69,6 +68,43 @@ describe StackOneMigration::EmployeesMapper do
69
68
  :department => 'Human Resources',
70
69
  )
71
70
  }
71
+ let(:another_sample_employee) {
72
+ StackOneHRIS::Employee.new(
73
+ :id => '456',
74
+ :first_name => 'Allie',
75
+ :last_name => 'Shaw',
76
+ :display_name => 'Allie Shaw',
77
+ :name => 'Allie Jennifer Shaw',
78
+ :avatar_url => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
79
+ :personal_email => 'ija@egje.wf',
80
+ :work_email => 'kota@efpiphi.kw',
81
+ :gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
82
+ :date_of_birth => '1990-01-01',
83
+ :start_date => '2018-01-01',
84
+ :manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
85
+ :personal_phone_number => '(715) 658-9486',
86
+ :job_title => 'Manager',
87
+ :department => 'Human Resources',
88
+ )
89
+ }
90
+ let(:employee_with_no_phone_number) {
91
+ StackOneHRIS::Employee.new(
92
+ :id => '456',
93
+ :first_name => 'Allie',
94
+ :last_name => 'Shaw',
95
+ :display_name => 'Allie Shaw',
96
+ :name => 'Allie Jennifer Shaw',
97
+ :avatar_url => 'https://www.gravatar.com/avatar/0c1c0c1c0c1c0c1c0c1c0c1c0c1c0c1c?d=mm&s=200',
98
+ :personal_email => 'ija@egje.wf',
99
+ :work_email => 'kota@efpiphi.kw',
100
+ :gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
101
+ :date_of_birth => '1990-01-01',
102
+ :start_date => '2018-01-01',
103
+ :manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
104
+ :job_title => 'Manager',
105
+ :department => 'Human Resources',
106
+ )
107
+ }
72
108
 
73
109
  context '.map_to_employee_model' do
74
110
  it 'maps the employee to the target employee class' do
@@ -102,6 +138,38 @@ describe StackOneMigration::EmployeesMapper do
102
138
  expect(target_model.employment_status).to have_attributes(:value => 'INACTIVE')
103
139
  end
104
140
 
141
+ context 'when the employee record has both personal and work phone number' do
142
+ it 'fills the mobile phone number with personal phone number' do
143
+ target_model = described_class.map_to_employee_model(sample_employee)
144
+
145
+ expect(target_model.mobile_phone_number).to eq('(715) 658-9486')
146
+ end
147
+ end
148
+
149
+ context 'when the employee record only has personal phone number' do
150
+ it 'fills the mobile phone number with personal phone number' do
151
+ target_model = described_class.map_to_employee_model(another_sample_employee)
152
+
153
+ expect(target_model.mobile_phone_number).to eq('(715) 658-9486')
154
+ end
155
+ end
156
+
157
+ context 'when the employee record only has work phone number' do
158
+ it 'fills the mobile phone number with work phone number' do
159
+ target_model = described_class.map_to_employee_model(other_sample_employee)
160
+
161
+ expect(target_model.mobile_phone_number).to eq('(456) 787-3508')
162
+ end
163
+ end
164
+
165
+ context 'when the employee record does not have phone numbers' do
166
+ it 'fills the mobile phone number with nil' do
167
+ target_model = described_class.map_to_employee_model(employee_with_no_phone_number)
168
+
169
+ expect(target_model.mobile_phone_number).to be_nil
170
+ end
171
+ end
172
+
105
173
  context 'when the employee record to map is nil' do
106
174
  it 'returns nil' do
107
175
  target_model = described_class.map_to_employee_model(nil)
@@ -120,7 +188,7 @@ describe StackOneMigration::EmployeesMapper do
120
188
  :city => "San Francisco",
121
189
  :state => "CA",
122
190
  :zip_code => "94105",
123
- :country => "US"
191
+ :country => StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States'),
124
192
  )
125
193
 
126
194
  target_model = described_class.map_to_location_model(sample_location)
@@ -138,7 +206,7 @@ describe StackOneMigration::EmployeesMapper do
138
206
  :city => "San Francisco",
139
207
  :state => "CA",
140
208
  :zip_code => "94105",
141
- :country => "US",
209
+ :country => StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States'),
142
210
  :location_type => StackOneHRIS::LocationTypeEnum.new(value: 'home', source_value: 'home'),
143
211
  )
144
212
 
@@ -153,11 +221,39 @@ describe StackOneMigration::EmployeesMapper do
153
221
  expect(target_model.city).to eq("San Francisco")
154
222
  expect(target_model.state).to eq("CA")
155
223
  expect(target_model.zip_code).to eq("94105")
156
- expect(target_model.country).to have_attributes(:raw_value => 'US')
224
+ expect(target_model.country).to have_attributes(:value => 'US')
157
225
  expect(target_model.location_type).to have_attributes(:value => 'HOME')
158
226
  end
159
227
  end
160
228
 
229
+ context '.map_country_enum' do
230
+ it 'maps a country to correct class' do
231
+ sample_country = StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States')
232
+
233
+ target_model = described_class.map_country_enum(sample_country)
234
+
235
+ expect(target_model).to be_a(MergeHRISClient::CountryEnum)
236
+ end
237
+
238
+ it 'maps to a country with the right attributes' do
239
+ sample_country = StackOneHRIS::CountryCodeEnum.new(value: 'US', source_value: 'United States')
240
+
241
+ target_model = described_class.map_country_enum(sample_country)
242
+
243
+ expect(target_model).to have_attributes(:value => 'US', :raw_value => 'US')
244
+ end
245
+
246
+ context 'when the original enum is an unmapped value' do
247
+ it 'maps to a country with non standard value' do
248
+ sample_country = StackOneHRIS::CountryCodeEnum.new(value: 'unmapped_value', source_value: 'United States')
249
+
250
+ target_model = described_class.map_country_enum(sample_country)
251
+
252
+ expect(target_model).to have_attributes(:value => 'MERGE_NONSTANDARD_VALUE', :raw_value => 'United States')
253
+ end
254
+ end
255
+ end
256
+
161
257
  context '.map_to_employment_model' do
162
258
  it 'maps a employeement to correct class' do
163
259
  sample_employment = StackOneHRIS::Employment.new(
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.required_ruby_version = '>= 2.7'
17
17
 
18
18
  s.add_runtime_dependency 'merge_hris_client', '~> 3.0'
19
- s.add_runtime_dependency 'stackone_hris_client', '~> 1.4.0'
19
+ s.add_runtime_dependency 'stackone_hris_client', '~> 1.5.1'
20
20
 
21
21
  s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
22
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackone_migration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - StackOne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-04 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: merge_hris_client
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.4.0
33
+ version: 1.5.1
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: 1.4.0
40
+ version: 1.5.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement