mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-01 23:08:49 +01:00
Apply James Kebinger's patch to fix #492 (broken: csv export of notes). Thanks SK for
the bug report and James for the patch! git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@518 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
ba0b52ff1a
commit
179d194fb2
2 changed files with 9 additions and 3 deletions
|
|
@ -55,7 +55,9 @@ class DataController < ApplicationController
|
|||
CSV::Writer.generate(result = "") do |csv|
|
||||
csv << ["ID", "User ID", "Project", "Note",
|
||||
"Created at", "Updated at"]
|
||||
@user.notes.find(:all, :include => [:project]).each do |note|
|
||||
# had to remove project include because it's association order is leaking through
|
||||
# and causing an ambiguous column ref even with_exclusive_scope didn't seem to help -JamesKebinger
|
||||
@user.notes.find(:all,:order=>"notes.created_at").each do |note|
|
||||
# Format dates in ISO format for easy sorting in spreadsheet
|
||||
# Print context and project names for easy viewing
|
||||
csv << [note.id, note.user_id,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ require 'data_controller'
|
|||
class DataController; def rescue_action(e) raise e end; end
|
||||
|
||||
class DataControllerTest < Test::Unit::TestCase
|
||||
fixtures :users, :preferences, :projects, :notes
|
||||
|
||||
def setup
|
||||
@controller = DataController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
|
|
@ -12,7 +14,9 @@ class DataControllerTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
def test_csv_export_completes_without_error
|
||||
@request.session['user_id'] = users(:admin_user).id
|
||||
get :csv_notes
|
||||
puts @response.body
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue