Sha256: f4bf8496eebf98ef6b4f64bba0b43396f3c82707ab49a1c2bb13543aba6e1327

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

module Scenic
  module Adapters
    describe Postgres::RefreshDependencies, :db do
      it "refreshes dependecies in the correct order" do
        adapter = Postgres.new

        adapter.create_materialized_view(
          "first",
          "SELECT text 'hi' AS greeting",
        )

        adapter.create_materialized_view(
          "second",
          "SELECT * from first",
        )

        adapter.create_materialized_view(
          "third",
          "SELECT * from first UNION SELECT * from second",
        )

        adapter.create_materialized_view(
          "fourth",
          "SELECT * from third",
        )

        expect(adapter).to receive(:refresh_materialized_view).
          with("public.first").ordered

        expect(adapter).to receive(:refresh_materialized_view).
          with("public.second").ordered

        expect(adapter).to receive(:refresh_materialized_view).
          with("public.third").ordered

        described_class.call(:fourth, adapter, ActiveRecord::Base.connection)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scenic-1.4.1 spec/scenic/adapters/postgres/refresh_dependencies_spec.rb
scenic-1.4.0 spec/scenic/adapters/postgres/refresh_dependencies_spec.rb