Business intelligence made simple
Added more tests
Andrew Kane4e6157983f6c
diff --git a/lib/blazer.rb b/lib/blazer.rbindex 0c44ed89..10a69e79 100644--- a/lib/blazer.rb+++ b/lib/blazer.rb@@ -43,6 +43,8 @@ module Blazerautoload :CheckMailer, "blazer/check_mailer"# net/http optionalautoload :SlackNotifier, "blazer/slack_notifier"+ # activejob optional+ autoload :RunStatementJob, "blazer/run_statement_job"class << selfattr_accessor :auditdiff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rbindex 03caa9ac..abf403e2 100644--- a/lib/blazer/engine.rb+++ b/lib/blazer/engine.rb@@ -30,10 +30,6 @@ module BlazerBlazer.anomaly_checks = Blazer.settings["anomaly_checks"] || falseBlazer.forecasting = Blazer.settings["forecasting"] || falseBlazer.async = Blazer.settings["async"] || false- if Blazer.async- require "blazer/run_statement_job"- end-Blazer.images = Blazer.settings["images"] || falseBlazer.override_csp = Blazer.settings["override_csp"] || falseBlazer.slack_oauth_token = Blazer.settings["slack_oauth_token"] || ENV["BLAZER_SLACK_OAUTH_TOKEN"]diff --git a/test/dashboards_test.rb b/test/dashboards_test.rbindex d5cec2db..426de4cf 100644--- a/test/dashboards_test.rb+++ b/test/dashboards_test.rb@@ -1,6 +1,11 @@require_relative "test_helper"class DashboardsTest < ActionDispatch::IntegrationTest+ def setup+ Blazer::Query.delete_all+ Blazer::Dashboard.delete_all+ end+def test_newget blazer.new_dashboard_pathassert_response :success@@ -18,6 +23,13 @@ class DashboardsTest < ActionDispatch::IntegrationTestassert_response :redirectend+ def test_refresh+ dashboard = create_dashboard+ dashboard.queries << create_query+ post blazer.refresh_dashboard_path(dashboard)+ assert_response :redirect+ end+def create_dashboardBlazer::Dashboard.create!(name: "Test")enddiff --git a/test/queries_test.rb b/test/queries_test.rbindex 961b4152..1c51d9e7 100644--- a/test/queries_test.rb+++ b/test/queries_test.rb@@ -56,6 +56,12 @@ class QueriesTest < ActionDispatch::IntegrationTestassert_response :successend+ def test_refresh+ query = create_query+ post blazer.refresh_query_path(query)+ assert_response :redirect+ end+def test_variables_timequery = create_query(statement: "SELECT {created_at}")get blazer.query_path(query)@@ -117,4 +123,13 @@ class QueriesTest < ActionDispatch::IntegrationTestassert_match %{<img referrerpolicy="no-referrer" src="http://localhost:3000/image.png" }, response.bodyendend++ def test_async+ Blazer.stub(:async, true) do+ perform_enqueued_jobs do+ run_query "SELECT 123"+ end+ assert_match "123", response.body+ end+ endenddiff --git a/test/test_helper.rb b/test/test_helper.rbindex 73ab728c..fe78e408 100644--- a/test/test_helper.rb+++ b/test/test_helper.rb@@ -7,9 +7,10 @@ require "minitest/pride"logger = ActiveSupport::Logger.new(ENV["VERBOSE"] ? STDERR : nil)Combustion.path = "test/internal"-Combustion.initialize! :active_record, :action_controller, :action_mailer, :sprockets do+Combustion.initialize! :active_record, :action_controller, :action_mailer, :active_job, :sprockets doconfig.action_controller.logger = loggerconfig.action_mailer.logger = logger+ config.active_job.logger = loggerconfig.active_record.logger = loggerconfig.cache_store = :memory_storeend