diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8514b82..da75eb9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,7 +8,9 @@ require_relative "support/active_record/models" require_relative "support/active_record/schema" -Dotenv.load! +Dotenv.load! if File.exists?(".env") + +# Establish a connection for testing ActiveRecord::Base.establish_connection(ENV['PG_URI_TEST']) Timescaledb.establish_connection(ENV['PG_URI_TEST']) diff --git a/spec/support/active_record/models.rb b/spec/support/active_record/models.rb index 534389c..fbf9527 100644 --- a/spec/support/active_record/models.rb +++ b/spec/support/active_record/models.rb @@ -1,3 +1,5 @@ +ActiveRecord::Base.extend Timescaledb::ActsAsHypertable + class Event < ActiveRecord::Base self.primary_key = "identifier" diff --git a/spec/timescaledb/schema_dumper_spec.rb b/spec/timescaledb/schema_dumper_spec.rb index 0bf72b6..7de4f96 100644 --- a/spec/timescaledb/schema_dumper_spec.rb +++ b/spec/timescaledb/schema_dumper_spec.rb @@ -10,8 +10,7 @@ Event .from("event_counts") .select("time_bucket('1d', time) as time, - identifier as label, - sum(value) as value").group("1,2") + sum(value) as value").group("1") end context "schema" do @@ -78,6 +77,7 @@ end it "dumps a create_continuous_aggregate for a view in the database" do + con.execute("DROP MATERIALIZED VIEW IF EXISTS event_daily_counts") con.execute("DROP MATERIALIZED VIEW IF EXISTS event_counts") con.create_continuous_aggregate(:event_counts, query, materialized_only: true, finalized: true) con.create_continuous_aggregate(:event_daily_counts, query_daily, materialized_only: true, finalized: true)