Skip to content

Business intelligence made simple

Added test for CSV name

Andrew Kane77c7385318ee
diff --git a/test/queries_test.rb b/test/queries_test.rb
index 3a8d427f..5375c0b0 100644
--- a/test/queries_test.rb
+++ b/test/queries_test.rb
@@ -122,6 +122,14 @@ class QueriesTest < ActionDispatch::IntegrationTest
assert_equal "text/csv; charset=utf-8", response.headers["Content-Type"]
end
+ def test_csv_query
+ query = create_query(name: "All Cities")
+ run_query("SELECT 1 AS id, 'Chicago' AS city", format: "csv", query_id: query.id)
+ assert_equal "id,city\n1,Chicago\n", response.body
+ assert_equal "attachment; filename=\"all-cities.csv\"; filename*=UTF-8''all-cities.csv", response.headers["Content-Disposition"]
+ assert_equal "text/csv; charset=utf-8", response.headers["Content-Type"]
+ end
+
def test_url
run_query "SELECT 'http://localhost:3000/'"
assert_match %{<a target="_blank" href="http://localhost:3000/">http://localhost:3000/</a>}, response.body