aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/tasks/mysql_rake_test.rb
diff options
context:
space:
mode:
authorSeamus Abshere <seamus@abshere.net>2012-09-04 18:46:05 -0500
committerSeamus Abshere <seamus@abshere.net>2012-09-05 11:10:15 -0500
commitece23b5fa01301ec006aa42f8b59ec938c35427b (patch)
treefa9a82de517e103481ab5133eaef1be5cb25298d /activerecord/test/cases/tasks/mysql_rake_test.rb
parenta497bed1130427b3bcf717c29ca3b6edf07a5c04 (diff)
downloadrails-ece23b5fa01301ec006aa42f8b59ec938c35427b.tar.gz
rails-ece23b5fa01301ec006aa42f8b59ec938c35427b.tar.bz2
rails-ece23b5fa01301ec006aa42f8b59ec938c35427b.zip
Use the 'mysql' binary for 'rake db:structure:load'.
The previous implementation had the strange requirement that db/structure.sql contain only CREATE TABLE sql statements, one per table, separated by double newlines. SQLite3 and PostgreSQL database tasks, on the other hand, simply spawn 'sqlite3' and 'psql' binaries to load the file directly. The new implementation follows this and attempts to respect all current MySQL configuration settings.
Diffstat (limited to 'activerecord/test/cases/tasks/mysql_rake_test.rb')
-rw-r--r--activerecord/test/cases/tasks/mysql_rake_test.rb7
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/test/cases/tasks/mysql_rake_test.rb b/activerecord/test/cases/tasks/mysql_rake_test.rb
index b49561d858..be591da8d6 100644
--- a/activerecord/test/cases/tasks/mysql_rake_test.rb
+++ b/activerecord/test/cases/tasks/mysql_rake_test.rb
@@ -251,17 +251,14 @@ module ActiveRecord
ActiveRecord::Base.stubs(:connection).returns(@connection)
ActiveRecord::Base.stubs(:establish_connection).returns(true)
+ Kernel.stubs(:system)
end
def test_structure_load
filename = "awesome-file.sql"
- ActiveRecord::Base.expects(:establish_connection).with(@configuration)
- @connection.expects(:execute).twice
+ Kernel.expects(:system).with('mysql', '--database', 'test-db', '--execute', %{SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1})
- open(filename, 'w') { |f| f.puts("SELECT CURDATE();") }
ActiveRecord::Tasks::DatabaseTasks.structure_load(@configuration, filename)
- ensure
- FileUtils.rm(filename)
end
end