Allow Cucumber tests to run with PostgreSQL with a non-root user.
This commit is contained in:
parent
86e52b0799
commit
b6288f841b
1 changed files with 21 additions and 1 deletions
|
|
@ -2,6 +2,26 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
# disable_referential_integrity doesn't work when using PostgreSQL
|
||||||
|
# with a non-root user.
|
||||||
|
# See http://kopongo.com/2008/7/25/postgres-ri_constrainttrigger-error
|
||||||
|
module ActiveRecord
|
||||||
|
module ConnectionAdapters
|
||||||
|
class PostgreSQLAdapter < AbstractAdapter
|
||||||
|
def disable_referential_integrity(&block)
|
||||||
|
transaction {
|
||||||
|
begin
|
||||||
|
execute "SET CONSTRAINTS ALL DEFERRED"
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
execute "SET CONSTRAINTS ALL IMMEDIATE"
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
DatabaseCleaner::ActiveRecord::Truncation.class_eval do
|
DatabaseCleaner::ActiveRecord::Truncation.class_eval do
|
||||||
# You could argue that this technically isn't truncation. You'd be right.
|
# You could argue that this technically isn't truncation. You'd be right.
|
||||||
# But something in the MySQL adapter segfaults (!) on actual truncation, and we
|
# But something in the MySQL adapter segfaults (!) on actual truncation, and we
|
||||||
|
|
@ -13,4 +33,4 @@ DatabaseCleaner::ActiveRecord::Truncation.class_eval do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue