Business intelligence made simple
Use filename option
Andrew Kaneed29b90a2d74
diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rbindex 5435a819..1bd814c7 100644--- a/app/controllers/blazer/queries_controller.rb+++ b/app/controllers/blazer/queries_controller.rb@@ -293,7 +293,7 @@ module Blazer# not ideal, but useful for testingraise Error, @error if @error && Rails.env.test?- send_data csv_data(@columns, @rows, @data_source), type: "text/csv; charset=utf-8; header=present", disposition: "attachment; filename=\"#{@query.try(:name).try(:parameterize).presence || 'query'}.csv\""+ send_data csv_data(@columns, @rows, @data_source), type: "text/csv; charset=utf-8", disposition: "attachment", filename: "#{@query.try(:name).try(:parameterize).presence || 'query'}.csv"endendenddiff --git a/test/queries_test.rb b/test/queries_test.rbindex a7cae210..3a8d427f 100644--- a/test/queries_test.rb+++ b/test/queries_test.rb@@ -118,7 +118,7 @@ class QueriesTest < ActionDispatch::IntegrationTestdef test_csvrun_query("SELECT 1 AS id, 'Chicago' AS city", format: "csv")assert_equal "id,city\n1,Chicago\n", response.body- assert_equal "attachment; filename=\"query.csv\"", response.headers["Content-Disposition"]+ assert_equal "attachment; filename=\"query.csv\"; filename*=UTF-8''query.csv", response.headers["Content-Disposition"]assert_equal "text/csv; charset=utf-8", response.headers["Content-Type"]end