Skip to content

Commit

Permalink
Add created_at to registration export csv (#9011)
Browse files Browse the repository at this point in the history
* Add created_at to registration export csv

* Change spec factory and test case for csv registration export

* typo, ooops
  • Loading branch information
AnnikaStein authored Mar 4, 2024
1 parent 6dcb809 commit 62d8d7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion WcaOnRails/app/views/registrations/export.csv.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% require 'csv' %>
<% headers = ["Status", "Name", "Country", "WCA ID", "Birth Date", "Gender" ] + @competition.events.map(&:id) + [ "Email", "Guests", "IP" ] %>
<% headers = ["Status", "Name", "Country", "WCA ID", "Birth Date", "Gender" ] + @competition.events.map(&:id) + [ "Email", "Guests", "IP", "Registration Date Time (UTC)" ] %>
<%= CSV.generate_line(headers).html_safe -%>
<% @registrations.each do |registration| %>
<%= CSV.generate_line([
Expand All @@ -13,5 +13,6 @@
registration.email,
registration.guests,
registration.ip,
registration.created_at,
]).html_safe -%>
<% end %>
1 change: 1 addition & 0 deletions WcaOnRails/spec/factories/registrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
association :user, factory: [:user, :wca_id]
guests { 10 }
comments { "" }
created_at { Time.now }
administrative_notes { "" }
transient do
events { competition.events }
Expand Down
5 changes: 3 additions & 2 deletions WcaOnRails/spec/views/registrations/export.csv.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:registration,
competition: competition,
accepted_at: Time.now,
created_at: Time.utc(2014, 3, 14, 15, 16, 17),
user: user,
competition_events: [competition.competition_events.find_by!(event_id: "333")],
guests: 1,
Expand All @@ -29,7 +30,7 @@
assign(:registrations, competition.registrations)
render

expect(rendered).to eq "Status,Name,Country,WCA ID,Birth Date,Gender,333,333oh,Email,Guests,IP\na,Bob,USA,,1990-01-01,m,1,0,[email protected],1,\"\"\n"
expect(rendered).to eq "Status,Name,Country,WCA ID,Birth Date,Gender,333,333oh,Email,Guests,IP,Registration Date Time (UTC)\na,Bob,USA,,1990-01-01,m,1,0,[email protected],1,\"\",2014-03-14 15:16:17 UTC\n"
end

it "renders null (missing) gender as empty string" do
Expand All @@ -39,6 +40,6 @@
assign(:registrations, competition.registrations)
render

expect(rendered).to eq "Status,Name,Country,WCA ID,Birth Date,Gender,333,333oh,Email,Guests,IP\na,Bob,USA,,1990-01-01,,1,0,[email protected],1,\"\"\n"
expect(rendered).to eq "Status,Name,Country,WCA ID,Birth Date,Gender,333,333oh,Email,Guests,IP,Registration Date Time (UTC)\na,Bob,USA,,1990-01-01,,1,0,[email protected],1,\"\",2014-03-14 15:16:17 UTC\n"
end
end

0 comments on commit 62d8d7e

Please sign in to comment.