From 179d194fb2590e957093e48d826da06eb6b93c0a Mon Sep 17 00:00:00 2001 From: lukemelia Date: Mon, 2 Apr 2007 04:29:48 +0000 Subject: [PATCH] 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 --- tracks/app/controllers/data_controller.rb | 4 +++- tracks/test/functional/data_controller_test.rb | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tracks/app/controllers/data_controller.rb b/tracks/app/controllers/data_controller.rb index 7e911b28..c5e1541d 100644 --- a/tracks/app/controllers/data_controller.rb +++ b/tracks/app/controllers/data_controller.rb @@ -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, diff --git a/tracks/test/functional/data_controller_test.rb b/tracks/test/functional/data_controller_test.rb index 408edff0..2a1e4239 100644 --- a/tracks/test/functional/data_controller_test.rb +++ b/tracks/test/functional/data_controller_test.rb @@ -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