Skip to content

Business intelligence made simple

Improved query tests [skip ci]

Andrew Kanecfa5342f055f
diff --git a/test/queries_test.rb b/test/queries_test.rb
index 8a5ea6ee..af09676e 100644
--- a/test/queries_test.rb
+++ b/test/queries_test.rb
@@ -40,10 +40,10 @@ class QueriesTest < ActionDispatch::IntegrationTest
end
def test_new_upload_id
- upload = Blazer::Upload.create!(table: "orders")
+ upload = Blazer::Upload.create!(table: "line_items")
get blazer.new_query_path(upload_id: upload.id)
assert_response :success
- assert_match "SELECT * FROM &quot;uploads&quot;.&quot;orders&quot; LIMIT 10", response.body
+ assert_match "SELECT * FROM &quot;uploads&quot;.&quot;line_items&quot; LIMIT 10", response.body
end
def test_create
@@ -68,6 +68,34 @@ class QueriesTest < ActionDispatch::IntegrationTest
assert_match(/Statement can(&#39;|’)t be blank/, response.body)
end
+ def test_show
+ query = create_query
+ get blazer.query_path(query)
+ assert_response :success
+ assert_match "Test", response.body
+ end
+
+ def test_edit
+ query = create_query
+ get blazer.edit_query_path(query)
+ assert_response :success
+ assert_match "Test", response.body
+ end
+
+ def test_refresh
+ query = create_query
+ post blazer.refresh_query_path(query)
+ assert_redirected_to blazer.query_path(query)
+ end
+
+ def test_update
+ query = create_query
+ patch blazer.query_path(query, params: {query: {name: "Updated"}})
+ query.reload
+ assert_redirected_to blazer.query_path(query)
+ assert_equal "Updated", query.name
+ end
+
def test_destroy
query = create_query
delete blazer.query_path(query)
@@ -104,12 +132,6 @@ class QueriesTest < ActionDispatch::IntegrationTest
assert_match "Docs: main", response.body
end
- def test_refresh
- query = create_query
- post blazer.refresh_query_path(query)
- assert_redirected_to blazer.query_path(query)
- end
-
def test_variables_time
query = create_query(statement: "SELECT {created_at}")
get blazer.query_path(query)