Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/data_pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@ def run(args:, config:)
]
end
elsif config.include_missing?
table << [user.uuid, '[HAS NO PROFILE]', nil, nil, nil, nil, nil, nil]
table << [user.uuid, '[HAS NO PROFILE]', nil, nil, nil, nil, nil, nil, nil]
end
end

if config.include_missing?
(uuids - users.map(&:uuid)).each do |missing_uuid|
table << [missing_uuid, '[UUID NOT FOUND]', nil, nil, nil, nil, nil, nil]
table << [missing_uuid, '[UUID NOT FOUND]', nil, nil, nil, nil, nil, nil, nil]
end
end

Expand Down
158 changes: 82 additions & 76 deletions spec/lib/data_pull_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@
subject(:result) { subtask.run(args:, config:) }

it 'looks up the UUIDs for the given email addresses', aggregate_failures: true do
expect(result.table).to eq(
[
['email', 'uuid'],
*users.map { |u| [u.email_addresses.first.email, u.uuid] },
['missing@example.com', '[NOT FOUND]'],
],
)

expected_table = [
['email', 'uuid'],
*users.map { |u| [u.email_addresses.first.email, u.uuid] },
['missing@example.com', '[NOT FOUND]'],
]

expect(result.table).to eq(expected_table)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably just being dense, but I don't entirely follow how these changes would have caught the previous issue. Shouldn't an equality check have failed?

Copy link
Copy Markdown
Contributor Author

@mitchellhenke mitchellhenke Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, my added check does not address the issue.

Copy link
Copy Markdown
Contributor Author

@mitchellhenke mitchellhenke Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a hopefully clearer and more correct check in 946f8fb

expect_consistent_row_length(result.table)
expect(result.subtask).to eq('uuid-lookup')
expect(result.uuids).to match_array(users.map(&:uuid))
end
Expand Down Expand Up @@ -231,34 +231,34 @@
end

it 'still includes them and marks them as deleted' do
expect(result.table).to eq(
[
['partner_uuid', 'source', 'internal_uuid', 'deleted'],
external_uuids.first.then do |external_uuid|
identity = AgencyIdentity.find_by(uuid: external_uuid)

[
identity.uuid,
identity.agency.name,
identity.user.uuid,
nil,
]
end,
external_uuids.last.then do |external_uuid|
identity = ServiceProviderIdentity.find_by(uuid: external_uuid)

[
identity.uuid,
identity.agency.name,
DeletedUser.find_by(user_id: identity.user_id).uuid,
true,
]
end,
['does-not-exist', '[NOT FOUND]', '[NOT FOUND]', nil],
],
)
expected_table = [
['partner_uuid', 'source', 'internal_uuid', 'deleted'],
external_uuids.first.then do |external_uuid|
identity = AgencyIdentity.find_by(uuid: external_uuid)

[
identity.uuid,
identity.agency.name,
identity.user.uuid,
nil,
]
end,
external_uuids.last.then do |external_uuid|
identity = ServiceProviderIdentity.find_by(uuid: external_uuid)

[
identity.uuid,
identity.agency.name,
DeletedUser.find_by(user_id: identity.user_id).uuid,
true,
]
end,
['does-not-exist', '[NOT FOUND]', '[NOT FOUND]', nil],
]
expect(result.table).to eq(expected_table)

expect(result.subtask).to eq('uuid-convert')
expect_consistent_row_length(result.table)
expect(result.uuids).to match_array(users.map(&:uuid))
end
end
Expand All @@ -277,17 +277,16 @@
subject(:result) { subtask.run(args:, config:) }

it 'loads email addresses for the user', aggregate_failures: true do
expect(result.table).to match(
[
['uuid', 'email', 'confirmed_at'],
*user.email_addresses.sort_by(&:id).map do |e|
[e.user.uuid, e.email, kind_of(Time)]
end,
['does-not-exist', '[NOT FOUND]', nil],
],
)

expected_table = [
['uuid', 'email', 'confirmed_at'],
*user.email_addresses.sort_by(&:id).map do |e|
[e.user.uuid, e.email, kind_of(Time)]
end,
['does-not-exist', '[NOT FOUND]', nil],
]
expect(result.table).to match(expected_table)
expect(result.subtask).to eq('email-lookup')
expect_consistent_row_length(result.table)
expect(result.uuids).to eq([user.uuid])
end
end
Expand Down Expand Up @@ -382,29 +381,29 @@
subject(:result) { subtask.run(args:, config:) }

it 'loads profile summary for the user', aggregate_failures: true do
expect(result.table).to match_array(
[
['uuid', 'profile_id', 'status', 'idv_level', 'activated_timestamp', 'disabled_reason',
'gpo_verification_pending_timestamp', 'fraud_review_pending_timestamp',
'fraud_rejection_timestamp'],
*user.profiles.sort_by(&:id).map do |p|
profile_status = p.active ? 'active' : 'inactive'
[
user.uuid,
p.id,
profile_status,
p.idv_level,
kind_of(Time),
p.deactivation_reason,
nil,
nil,
nil,
]
end,
[user_without_profile.uuid, '[HAS NO PROFILE]', nil, nil, nil, nil, nil, nil],
['uuid-does-not-exist', '[UUID NOT FOUND]', nil, nil, nil, nil, nil, nil],
],
)
expected_result = [
['uuid', 'profile_id', 'status', 'idv_level', 'activated_timestamp', 'disabled_reason',
'gpo_verification_pending_timestamp', 'fraud_review_pending_timestamp',
'fraud_rejection_timestamp'],
*user.profiles.sort_by(&:id).map do |p|
profile_status = p.active ? 'active' : 'inactive'
[
user.uuid,
p.id,
profile_status,
p.idv_level,
kind_of(Time),
p.deactivation_reason,
nil,
nil,
nil,
]
end,
[user_without_profile.uuid, '[HAS NO PROFILE]', nil, nil, nil, nil, nil, nil, nil],
['uuid-does-not-exist', '[UUID NOT FOUND]', nil, nil, nil, nil, nil, nil, nil],
]
expect(result.table).to match_array(expected_result)
expect_consistent_row_length(result.table)

expect(result.subtask).to eq('profile-summary')
expect(result.uuids).to match_array([user.uuid, user_without_profile.uuid])
Expand Down Expand Up @@ -453,6 +452,7 @@
]

expect(result.table).to match_array(expected_table)
expect_consistent_row_length(result.table)
expect(result.subtask).to eq('uuid-export')
expect(result.uuids).to match_array([user1.uuid, user2.uuid])
end
Expand Down Expand Up @@ -512,18 +512,24 @@

describe '#run' do
it 'loads events for the users' do
expect(result.table).to match_array(
[
%w[uuid date events_count],
[user.uuid, Date.new(2023, 1, 2), 5],
[user.uuid, Date.new(2023, 1, 1), 1],
['uuid-does-not-exist', '[UUID NOT FOUND]', nil],
],
)

expected_table = [
%w[uuid date events_count],
[user.uuid, Date.new(2023, 1, 2), 5],
[user.uuid, Date.new(2023, 1, 1), 1],
['uuid-does-not-exist', '[UUID NOT FOUND]', nil],
]
expect(result.table).to match_array(expected_table)
expect(result.subtask).to eq('events-summary')
expect_consistent_row_length(result.table)
expect(result.uuids).to match_array([user.uuid])
end
end
end

# Assert that each row has the same length
def expect_consistent_row_length(table)
first_row_length = table.first.length

expect(table.all? { |row| row.length == first_row_length }).to eq(true)
end
end