Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed leading space in csv column header names #379

Merged
merged 1 commit into from
Nov 28, 2018
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
2 changes: 1 addition & 1 deletion app/views/audio_events/download.csv.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%# <%== does not do html entity escaping %>
<%== @formatted_annotations.columns.join(', ') %>
<%== @formatted_annotations.columns.join(',') %>
<%==
CSV.generate do |csv|
@formatted_annotations.each do |row|
Expand Down
37 changes: 37 additions & 0 deletions spec/requests/audio_events_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
require 'rails_helper'
require 'rspec/mocks'

describe "Audio Events" do

create_entire_hierarchy

# projects update/create actions expect payload from html form as well as json
describe 'Downloading Csv' do

before(:each) do
@env ||= {}
@env['HTTP_AUTHORIZATION'] = admin_token

@download_url = "/audio_recordings/#{audio_recording.id}/audio_events/download"
end

it 'downloads csv file with no leading spaces in headers' do

get @download_url, nil, @env
expect(response).to have_http_status(200)
column_headers = "audio_event_id,audio_recording_id,audio_recording_uuid,audio_recording_start_date_utc_00_00,"+
"audio_recording_start_time_utc_00_00,audio_recording_start_datetime_utc_00_00,event_created_at_date_utc_00_00,"+
"event_created_at_time_utc_00_00,event_created_at_datetime_utc_00_00,projects,site_id,site_name,"+
"event_start_date_utc_00_00,event_start_time_utc_00_00,event_start_datetime_utc_00_00,event_start_seconds,"+
"event_end_seconds,event_duration_seconds,low_frequency_hertz,high_frequency_hertz,is_reference,created_by,"+
"updated_by,common_name_tags,common_name_tag_ids,species_name_tags,species_name_tag_ids,other_tags,"+
"other_tag_ids,listen_url,library_url\n"
expect(response.body).to start_with(column_headers)
end

end

end