Sha256: 81ebceed2e75c2186009dce4f9bf966cca64c19fd9de2c284fb1053d90ebcca5
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require "spec_helper" class Search < ActiveRecord::Base; end describe Scenic::SchemaDumper, :db do it "dumps a create_view for a view in the database" do view_definition = "SELECT 'needle'::text AS haystack" Search.connection.create_view :searches, sql_definition: view_definition stream = StringIO.new ActiveRecord::SchemaDumper.dump(Search.connection, stream) output = stream.string expect(output).to include "create_view :searches" expect(output).to include view_definition Search.connection.drop_view :searches silence_stream(STDOUT) { eval(output) } expect(Search.first.haystack).to eq "needle" end context "with views in non public schemas" do it "dumps a create_view including namespace for a view in the database" do view_definition = "SELECT 'needle'::text AS haystack" Search.connection.execute "CREATE SCHEMA scenic; SET search_path TO scenic, public" Search.connection.create_view :"scenic.searches", sql_definition: view_definition stream = StringIO.new ActiveRecord::SchemaDumper.dump(Search.connection, stream) output = stream.string expect(output).to include "create_view :'scenic.searches'," Search.connection.drop_view :'scenic.searches' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scenic-1.3.0 | spec/scenic/schema_dumper_spec.rb |