Fixes #3689 - FreshDesk Import brings in all users as inactive.

This commit is contained in:
Dominik Klein 2021-08-03 17:03:22 +02:00 committed by Thorsten Eckel
parent 0b522cfe17
commit 6a89d716be
4 changed files with 58 additions and 19 deletions

View file

@ -20,7 +20,7 @@ class Sequencer
firstname: contact['name'],
email: contact['email'],
phone: contact['phone'],
active: contact['active'],
active: !contact['deleted'],
group_ids: group_ids,
password: password,
last_login: contact['last_login_at'],

View file

@ -14,7 +14,7 @@ class Sequencer
provide_mapped do
{
firstname: resource['name'],
active: resource['active'],
active: !resource['deleted'],
organization_id: organization_id,
email: resource['email'],
mobile: resource['mobile'],

View file

@ -22,7 +22,7 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Agent, sequencer: :sequ
'available_since' => nil,
'type' => 'support_agent',
'contact' => {
'active' => true,
'active' => false,
'email' => 'freshdesk@example.com',
'job_title' => nil,
'language' => 'en',
@ -59,16 +59,24 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Agent, sequencer: :sequ
}
end
it 'imports user correctly' do # rubocop:disable RSpec/MultipleExpectations, RSpec/ExampleLength
expect { process(process_payload) }.to change(User, :count).by(1)
expect(User.last).to have_attributes(
let(:imported_user) do
{
firstname: 'John',
lastname: 'Doe',
login: 'freshdesk@example.com',
email: 'freshdesk@example.com',
active: true,
last_login: DateTime.parse('2021-05-10T07:52:58Z'),
)
}
end
it 'imports user correctly (increased user count)' do
expect { process(process_payload) }.to change(User, :count).by(1)
end
it 'imports user data correctly' do
process(process_payload)
expect(User.last).to have_attributes(imported_user)
end
it 'sets user roles correctly for admin user' do
@ -87,5 +95,16 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Agent, sequencer: :sequ
expect(User.last.groups_access('full').sort).to eq groups
end
context 'with deleted flag in resource' do
before do
resource['contact']['deleted'] = true
imported_user[:active] = false
end
it 'imports user data correctly' do
process(process_payload)
expect(User.last).to have_attributes(imported_user)
end
end
end
end

View file

@ -62,6 +62,20 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Contact, sequencer: :se
}
end
let(:imported_user) do
{
firstname: 'Sam',
lastname: 'Osborne',
login: 'sam.ozzy@freshdesk.com',
email: 'sam.ozzy@freshdesk.com',
active: true,
cf_custom_dropdown: 'key_2',
cf_custom_integer: 999,
cf_test_checkbox: true,
cf_custom_decimal: '1.1',
}
end
before do
create :object_manager_attribute_select, object_name: 'User', name: 'cf_custom_dropdown'
create :object_manager_attribute_integer, object_name: 'User', name: 'cf_custom_integer'
@ -70,19 +84,25 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Contact, sequencer: :se
ObjectManager::Attribute.migration_execute
end
it 'imports customers correctly' do # rubocop:disable RSpec/MultipleExpectations, RSpec/ExampleLength
it 'imports customer correctly (increased user count)' do
expect { process(process_payload) }.to change(User, :count).by(1)
expect(User.last).to have_attributes(
firstname: 'Sam',
lastname: 'Osborne',
login: 'sam.ozzy@freshdesk.com',
email: 'sam.ozzy@freshdesk.com',
active: false,
cf_custom_dropdown: 'key_2',
cf_custom_integer: 999,
cf_test_checkbox: true,
cf_custom_decimal: '1.1',
)
end
it 'imports customer data correctly' do
process(process_payload)
expect(User.last).to have_attributes(imported_user)
end
context 'with deleted flag in resource' do
before do
resource['deleted'] = true
imported_user[:active] = false
end
it 'imports customer data correctly' do
process(process_payload)
expect(User.last).to have_attributes(imported_user)
end
end
end
end