aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorAri Pollak <ajp@aripollak.com>2017-02-24 12:44:11 -0500
committerAri Pollak <ajp@aripollak.com>2017-02-24 12:46:00 -0500
commitdf050484cd3b5e888b50d2e0554a4077407459a8 (patch)
tree7245a326ea2f49a05ec64d4758531f9884bd4990 /activerecord/test
parentaa56dc235a341876762f0219738cac46d181fcd3 (diff)
downloadrails-df050484cd3b5e888b50d2e0554a4077407459a8.tar.gz
rails-df050484cd3b5e888b50d2e0554a4077407459a8.tar.bz2
rails-df050484cd3b5e888b50d2e0554a4077407459a8.zip
Drop comments from structure.sql in postgresql
Fixes #28153.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/tasks/postgresql_rake_test.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/activerecord/test/cases/tasks/postgresql_rake_test.rb b/activerecord/test/cases/tasks/postgresql_rake_test.rb
index a23100c32a..a28217c2e6 100644
--- a/activerecord/test/cases/tasks/postgresql_rake_test.rb
+++ b/activerecord/test/cases/tasks/postgresql_rake_test.rb
@@ -217,17 +217,21 @@ if current_adapter?(:PostgreSQLAdapter)
class PostgreSQLStructureDumpTest < ActiveRecord::TestCase
def setup
- @connection = stub(structure_dump: true)
+ @connection = stub(schema_search_path: nil, structure_dump: true)
@configuration = {
"adapter" => "postgresql",
"database" => "my-app-db"
}
- @filename = "awesome-file.sql"
+ @filename = "/tmp/awesome-file.sql"
+ FileUtils.touch(@filename)
ActiveRecord::Base.stubs(:connection).returns(@connection)
ActiveRecord::Base.stubs(:establish_connection).returns(true)
Kernel.stubs(:system)
- File.stubs(:open)
+ end
+
+ def teardown
+ FileUtils.rm_f(@filename)
end
def test_structure_dump
@@ -236,6 +240,15 @@ if current_adapter?(:PostgreSQLAdapter)
ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename)
end
+ def test_structure_dump_comments_removed
+ Kernel.stubs(:system).returns(true)
+ File.write(@filename, "-- comment\n not comment\n")
+
+ ActiveRecord::Tasks::DatabaseTasks.structure_dump(@configuration, @filename)
+
+ assert_equal " not comment\n", File.readlines(@filename).first
+ end
+
def test_structure_dump_with_extra_flags
expected_command = ["pg_dump", "-s", "-x", "-O", "-f", @filename, "--noop", "my-app-db"]