Skip to content

Business intelligence made simple

Test forecasting

Andrew Kane56b48c9d7c7b
diff --git a/Gemfile b/Gemfile
index 6e5cef51..a73155cf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,3 +8,4 @@ gem "combustion"
gem "rails"
gem "pg"
gem "sprockets-rails"
+gem "prophet-rb" if ENV["TEST_FORECASTING"]
diff --git a/test/charts_test.rb b/test/charts_test.rb
index ed253f7e..ce9670e1 100644
--- a/test/charts_test.rb
+++ b/test/charts_test.rb
@@ -51,4 +51,12 @@ class ChartsTest < ActionDispatch::IntegrationTest
run_query "SELECT 1 AS user_id, NOW() AS conversion_time /* cohort analysis */", query_id: 1
assert_match "1 cohort", response.body
end
+
+ def test_forecasting
+ skip "Too slow" unless ENV["TEST_FORECASTING"]
+
+ query = Blazer::Query.create!(statement: "SELECT current_date + n AS day, n FROM generate_series(1, 30) n", data_source: "main")
+ run_query query.statement, query_id: query.id, forecast: "t"
+ assert_match %{"name":"forecast"}, response.body
+ end
end
diff --git a/test/internal/config/blazer.yml b/test/internal/config/blazer.yml
index 9400a24f..4406305c 100644
--- a/test/internal/config/blazer.yml
+++ b/test/internal/config/blazer.yml
@@ -67,7 +67,7 @@ check_schedules:
# enable forecasting
# note: with trend, time series are sent to https://trendapi.org
-# forecasting: prophet / trend
+forecasting: prophet
# enable map
mapbox_access_token: token
diff --git a/test/test_helper.rb b/test/test_helper.rb
index c92daccf..5a8fc8a8 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -17,8 +17,8 @@ ActiveSupport.on_load(:active_record) do
end
class ActionDispatch::IntegrationTest
- def run_query(statement, query_id: nil)
- post blazer.run_queries_path, params: {statement: statement, data_source: "main", query_id: query_id}, xhr: true
+ def run_query(statement, **params)
+ post blazer.run_queries_path, params: {statement: statement, data_source: "main"}.merge(params), xhr: true
assert_response :success
end
end