stackone_migration 1.2.2 → 1.3.0

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: 7ed058e52bc6531d4776c4309fa4a63c1f17c050cf7a3a79cbdd5cdb126314a2
4
- data.tar.gz: dc2432ab2547c52815d94de47f2e837937e47035b0ec582f723a547c00050596
3
+ metadata.gz: daa32597a9e8c833693f8b94f572af6fee65310b673ede6e67a99f6772ee0d87
4
+ data.tar.gz: fc23f733389cce570bb07754170e84f59d7f065f6b69931e8ddb941b25002fad
5
5
  SHA512:
6
- metadata.gz: bd971a17ee5e0ae0788e75ed6203ec7cf0907988c3e8c6ffab34bd29c1dde4487184a7161a68b3a1c7e1bbea3cf1a8f55a62a9b80a1b0d7816897752881bbce6
7
- data.tar.gz: 799d35be2943ac5678d2bdf1c4e2ce09269c09fe736bc89480fa62d981318eec8a2ac7bf02f464145961188b868dda0a969ddf3b3aa8cc8634ecbdce2c297aa6
6
+ metadata.gz: 149a32da85baab2c457cda99adb372a5bdb520927f8f28768f1c9a365a9cd878d9817029313f710f4e908ad49860db43ec9ec17f981ecf0d259664a52ea40124
7
+ data.tar.gz: 1598674e96bb4bd3724e087382cc5ad53c183c83ad3826d7d224ca56c0764d0da49b3f1f13bb46ff3d96112acdf108a8f10960ba434deb0d4ca958d19ce44421
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.3.2'
14
+ gem 'stackone_hris_client', '~> 1.4.0'
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackone_migration (1.2.2)
4
+ stackone_migration (1.3.0)
5
5
  merge_hris_client (~> 3.0)
6
- stackone_hris_client (~> 1.3.2)
6
+ stackone_hris_client (~> 1.4.0)
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.3.2)
61
+ stackone_hris_client (1.4.0)
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.3.2)
76
+ stackone_hris_client (~> 1.4.0)
77
77
  stackone_migration!
78
78
 
79
79
  BUNDLED WITH
@@ -101,14 +101,14 @@ module StackOneMigration
101
101
  :personal_email => employee.personal_email,
102
102
  :work_email => employee.work_email,
103
103
  :mobile_phone_number => employee.personal_phone_number,
104
- :gender => MergeHRISClient::GenderEnum.build_from_hash(gender_enum_hash[employee.gender&.to_sym]),
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,
108
- :ethnicity => MergeHRISClient::EthnicityEnum.build_from_hash(ethnicity_enum_hash[employee.ethnicity&.to_sym]),
109
- :marital_status => MergeHRISClient::MaritalStatusEnum.build_from_hash(marital_status_enum_hash[employee.marital_status&.to_sym]),
108
+ :ethnicity => MergeHRISClient::EthnicityEnum.build_from_hash(map_enum(ethnicity_enum_hash, employee.ethnicity)),
109
+ :marital_status => MergeHRISClient::MaritalStatusEnum.build_from_hash(map_enum(marital_status_enum_hash, employee.marital_status)),
110
110
  :hire_date => employee.hire_date,
111
- :employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(employment_status_enum_hash[employee.employment_status&.to_sym]),
111
+ :employment_status => MergeHRISClient::EmploymentStatusEnum.build_from_hash(map_enum(employment_status_enum_hash, employee.employment_status)),
112
112
  :termination_date => employee.termination_date,
113
113
  :home_location => map_to_location_model(employee.home_location),
114
114
  :work_location => map_to_location_model(employee.work_location),
@@ -130,7 +130,7 @@ module StackOneMigration
130
130
  :state => location.state,
131
131
  :zip_code => location.zip_code,
132
132
  :country => MergeHRISClient::CountryEnum.build_from_hash(location.country),
133
- :location_type => MergeHRISClient::LocationTypeEnum.build_from_hash(location_type_enum_hash[location.location_type&.to_sym]),
133
+ :location_type => MergeHRISClient::LocationTypeEnum.build_from_hash(map_enum(location_type_enum_hash, location.location_type)),
134
134
  )
135
135
  end
136
136
 
@@ -140,11 +140,11 @@ module StackOneMigration
140
140
  MergeHRISClient::Employment.new(
141
141
  :job_title => employment.job_title,
142
142
  :pay_rate => employment.pay_rate,
143
- :pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(pay_period_enum_hash[employment.pay_period&.to_sym]),
144
- :pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(pay_frequency_enum_hash[employment.pay_frequency&.to_sym]),
143
+ :pay_period => MergeHRISClient::PayPeriodEnum.build_from_hash(map_enum(pay_period_enum_hash, employment.pay_period)),
144
+ :pay_frequency => MergeHRISClient::PayFrequencyEnum.build_from_hash(map_enum(pay_frequency_enum_hash, employment.pay_frequency)),
145
145
  :pay_currency => MergeHRISClient::PayCurrencyEnum.build_from_hash(employment.pay_currency&.to_s&.upcase),
146
146
  :effective_date => employment.effective_date,
147
- :employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(employment_type_enum_hash[employment.employment_type&.to_sym]),
147
+ :employment_type => MergeHRISClient::EmploymentTypeEnum.build_from_hash(map_enum(employment_type_enum_hash, employment.employment_type)),
148
148
  )
149
149
  end
150
150
 
@@ -187,5 +187,14 @@ module StackOneMigration
187
187
  :previous => nil
188
188
  )
189
189
  end
190
+
191
+ def self.map_enum(enum_hash, enum)
192
+ return nil if enum.nil? || enum.value.nil?
193
+
194
+ mapped_enum = enum_hash[enum&.value&.to_sym]
195
+ return mapped_enum unless mapped_enum.nil? || mapped_enum == 'MERGE_NONSTANDARD_VALUE'
196
+
197
+ enum.source_value
198
+ end
190
199
  end
191
200
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StackOneMigration
4
- VERSION = '1.2.2'
4
+ VERSION = '1.3.0'
5
5
  end
@@ -14,13 +14,13 @@ describe StackOneMigration::EmployeesMapper do
14
14
  :personal_email => 'ija@egje.wf',
15
15
  :work_email => 'kota@efpiphi.kw',
16
16
  :personal_phone_number => '(715) 658-9486',
17
- :gender => 'female',
17
+ :gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
18
18
  :date_of_birth => '1990-01-01',
19
19
  :start_date => '2018-01-01',
20
20
  :manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
21
- :ethnicity => 'white',
22
- :marital_status => 'married',
23
- :employment_status => 'terminated',
21
+ :ethnicity => StackOneHRIS::EthnicityEnum.new(value: 'white', source_value: 'white'),
22
+ :marital_status => StackOneHRIS::MaritalStatusEnum.new(value: 'married', source_value: 'married'),
23
+ :employment_status => StackOneHRIS::EmploymentStatusEnum.new(value: 'terminated', source_value: 'terminated'),
24
24
  :work_phone_number => '(456) 787-3508',
25
25
  :job_title => 'Manager',
26
26
  :department => 'Human Resources',
@@ -32,18 +32,19 @@ describe StackOneMigration::EmployeesMapper do
32
32
  :city => "San Francisco",
33
33
  :state => "CA",
34
34
  :zip_code => "94105",
35
- :country => "US"
35
+ :country => "US",
36
+ :location_type => StackOneHRIS::LocationTypeEnum.new(value: 'home', source_value: 'home'),
36
37
  ),
37
38
  :work_location => nil,
38
39
  :employments => [
39
40
  StackOneHRIS::Employment.new(
40
41
  :job_title => 'Manager',
41
42
  :pay_rate => 100000,
42
- :pay_period => 'year',
43
- :pay_frequency => 'weekly',
43
+ :pay_period => StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year'),
44
+ :pay_frequency => StackOneHRIS::PayFrequencyEnum.new(value: 'weekly', source_value: 'weekly'),
44
45
  :pay_currency => 'USD',
45
46
  :effective_date => '2018-01-01',
46
- :employment_type => 'full_time',
47
+ :employment_type => StackOneHRIS::EmploymentTypeEnum.new(value: 'full_time', source_value: 'full_time'),
47
48
  )
48
49
  ]
49
50
  )
@@ -59,7 +60,7 @@ describe StackOneMigration::EmployeesMapper do
59
60
  :personal_email => 'ija@egje.wf',
60
61
  :work_email => 'kota@efpiphi.kw',
61
62
  :personal_phone_number => '(715) 658-9486',
62
- :gender => 'female',
63
+ :gender => StackOneHRIS::GenderEnum.new(value: 'female', source_value: 'female'),
63
64
  :date_of_birth => '1990-01-01',
64
65
  :start_date => '2018-01-01',
65
66
  :manager_id => '417b5e62-e011-5e69-a906-0aefade9ded1',
@@ -138,7 +139,7 @@ describe StackOneMigration::EmployeesMapper do
138
139
  :state => "CA",
139
140
  :zip_code => "94105",
140
141
  :country => "US",
141
- :location_type => 'home'
142
+ :location_type => StackOneHRIS::LocationTypeEnum.new(value: 'home', source_value: 'home'),
142
143
  )
143
144
 
144
145
  target_model = described_class.map_to_location_model(sample_location)
@@ -162,11 +163,11 @@ describe StackOneMigration::EmployeesMapper do
162
163
  sample_employment = StackOneHRIS::Employment.new(
163
164
  :job_title => 'Manager',
164
165
  :pay_rate => 100000,
165
- :pay_period => 'year',
166
- :pay_frequency => 'weekly',
166
+ :pay_period => StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year'),
167
+ :pay_frequency => StackOneHRIS::PayFrequencyEnum.new(value: 'weekly', source_value: 'weekly'),
167
168
  :pay_currency => 'USD',
168
169
  :effective_date => '2018-01-01',
169
- :employment_type => 'full_time',
170
+ :employment_type => StackOneHRIS::EmploymentTypeEnum.new(value: 'full_time', source_value: 'full_time'),
170
171
  )
171
172
 
172
173
  target_model = described_class.map_to_employment_model(sample_employment)
@@ -178,11 +179,11 @@ describe StackOneMigration::EmployeesMapper do
178
179
  sample_employment = StackOneHRIS::Employment.new(
179
180
  :job_title => 'Manager',
180
181
  :pay_rate => 100000,
181
- :pay_period => 'year',
182
- :pay_frequency => 'weekly',
182
+ :pay_period => StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year'),
183
+ :pay_frequency => StackOneHRIS::PayFrequencyEnum.new(value: 'weekly', source_value: 'weekly'),
183
184
  :pay_currency => 'USD',
184
185
  :effective_date => '2018-01-01',
185
- :employment_type => 'full_time',
186
+ :employment_type => StackOneHRIS::EmploymentTypeEnum.new(value: 'full_time', source_value: 'full_time'),
186
187
  )
187
188
 
188
189
  target_model = described_class.map_to_employment_model(sample_employment)
@@ -266,4 +267,59 @@ describe StackOneMigration::EmployeesMapper do
266
267
  end
267
268
  end
268
269
  end
270
+
271
+ context '.map_enum' do
272
+ it 'returns the mapped enum' do
273
+ target_value = described_class.map_enum(
274
+ described_class.pay_period_enum_hash,
275
+ StackOneHRIS::PayPeriodEnum.new(value: 'year', source_value: 'year')
276
+ )
277
+
278
+ expect(target_value).to eq('YEAR')
279
+ end
280
+
281
+ context 'when the enum is nil' do
282
+ it 'returns nil' do
283
+ target_value = described_class.map_enum(
284
+ described_class.pay_period_enum_hash,
285
+ nil
286
+ )
287
+
288
+ expect(target_value).to be_nil
289
+ end
290
+ end
291
+
292
+ context 'when the enum value is nil' do
293
+ it 'returns nil' do
294
+ target_value = described_class.map_enum(
295
+ described_class.pay_period_enum_hash,
296
+ StackOneHRIS::PayPeriodEnum.new(value: nil, source_value: 'year')
297
+ )
298
+
299
+ expect(target_value).to be_nil
300
+ end
301
+ end
302
+
303
+ context 'when the enum value is an unmapped value' do
304
+ it 'returns the source value' do
305
+ target_value = described_class.map_enum(
306
+ described_class.pay_period_enum_hash,
307
+ StackOneHRIS::PayPeriodEnum.new(value: 'unmapped_value', source_value: 'year_custom_value')
308
+ )
309
+
310
+ expect(target_value).to eq('year_custom_value')
311
+ end
312
+ end
313
+
314
+ context 'when the enum value maps to a MERGE_NONSTANDARD_VALUE' do
315
+ it 'returns the mapped enum' do
316
+ target_value = described_class.map_enum(
317
+ described_class.marital_status_enum_hash,
318
+ StackOneHRIS::MaritalStatusEnum.new(value: 'other', source_value: 'other_status')
319
+ )
320
+
321
+ expect(target_value).to eq('other_status')
322
+ end
323
+ end
324
+ end
269
325
  end
@@ -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.3.2'
19
+ s.add_runtime_dependency 'stackone_hris_client', '~> 1.4.0'
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.2.2
4
+ version: 1.3.0
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-03 00:00:00.000000000 Z
11
+ date: 2023-05-04 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.3.2
33
+ version: 1.4.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: 1.3.2
40
+ version: 1.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement