Skip to content

Commit d449940

Browse files
authored
Update CSV export test. (bullet-train-co#682)
1 parent 0a5f6da commit d449940

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/system/action_models_test.rb

+13-2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def setup
159159
@jane.current_team.visitors.create(email: "[email protected]", first_name: "Liam", last_name: "Patel")
160160
@jane.current_team.visitors.create(email: "[email protected]", first_name: "Ava", last_name: "Brown")
161161
@jane.current_team.visitors.create(email: "[email protected]", first_name: "Ethan", last_name: "Kim")
162+
250.times do
163+
@jane.current_team.visitors.create(email: "random+#{SecureRandom.uuid}@example.com", first_name: SecureRandom.hex.first(5), last_name: SecureRandom.hex.first(5))
164+
end
162165

163166
login_as(@jane, scope: :user)
164167
visit account_team_path(@jane.current_team)
@@ -179,10 +182,18 @@ def setup
179182
csv_export_action = Visitors::CsvExportAction.order(:id).last
180183
csv_data = csv_export_action.file.download
181184

182-
assert_match(/id,email,first_name,last_name/, csv_data)
183-
assert_match(/[email protected],Liam,Patel/, csv_data)
185+
# Ensure the header is in the right spot.
186+
assert_match(/id,email,first_name,last_name/, csv_data.lines.first)
187+
188+
# Ensure the first record is where we expect it.
189+
assert_match(/[email protected],Liam,Patel/, csv_data.lines[1])
190+
191+
# Ensure the other records are in the CSV.
184192
assert_match(/[email protected],Ava,Brown/, csv_data)
185193
assert_match(/[email protected],Ethan,Kim/, csv_data)
194+
195+
# Ensure all records and headers were exported.
196+
assert_equal csv_data.lines.count, 254
186197
end
187198
end
188199
end

0 commit comments

Comments
 (0)