aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-02 09:41:52 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-02 09:41:52 -0300
commit5c87b5c5248154cf8aa76cce9a24a88769de022d (patch)
treeb726e91020591423c307bc539c03902256f2b4e3 /railties/test
parent4cb4e87b938da13125c57a005cc6924052b76b17 (diff)
downloadrails-5c87b5c5248154cf8aa76cce9a24a88769de022d.tar.gz
rails-5c87b5c5248154cf8aa76cce9a24a88769de022d.tar.bz2
rails-5c87b5c5248154cf8aa76cce9a24a88769de022d.zip
Revert "Merge pull request #15394 from morgoth/fix-automatic-maintaining-test-schema-for-sql-format"
This reverts commit 46139d33c06715e74ad450428ece3ee84da98579, reversing changes made to 8f247871bb18b2e3036a05df5f62cbfe3b402586. Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/test_test.rb91
1 files changed, 1 insertions, 90 deletions
diff --git a/railties/test/application/test_test.rb b/railties/test/application/test_test.rb
index c724c867ec..a223180169 100644
--- a/railties/test/application/test_test.rb
+++ b/railties/test/application/test_test.rb
@@ -67,7 +67,7 @@ module ApplicationTests
assert_match %r{/app/test/unit/failing_test\.rb}, output
end
- test "ruby schema migrations" do
+ test "migrations" do
output = script('generate model user name:string')
version = output.match(/(\d+)_create_users\.rb/)[1]
@@ -104,95 +104,6 @@ module ApplicationTests
assert !result.include?("create_table(:users)")
end
- test "sql structure migrations" do
- output = script('generate model user name:string')
- version = output.match(/(\d+)_create_users\.rb/)[1]
-
- app_file 'test/models/user_test.rb', <<-RUBY
- require 'test_helper'
-
- class UserTest < ActiveSupport::TestCase
- test "user" do
- User.create! name: "Jon"
- end
- end
- RUBY
-
- app_file 'db/structure.sql', ''
- app_file 'config/initializers/enable_sql_schema_format.rb', <<-RUBY
- Rails.application.config.active_record.schema_format = :sql
- RUBY
-
- assert_unsuccessful_run "models/user_test.rb", "Migrations are pending"
-
- app_file 'db/structure.sql', <<-SQL
- CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
- CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
- CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));
- INSERT INTO schema_migrations (version) VALUES ('#{version}');
- SQL
-
- app_file 'config/initializers/disable_maintain_test_schema.rb', <<-RUBY
- Rails.application.config.active_record.maintain_test_schema = false
- RUBY
-
- assert_unsuccessful_run "models/user_test.rb", "Could not find table 'users'"
-
- File.delete "#{app_path}/config/initializers/disable_maintain_test_schema.rb"
-
- assert_successful_test_run('models/user_test.rb')
- end
-
- test "sql structure migrations when adding column to existing table" do
- output_1 = script('generate model user name:string')
- version_1 = output_1.match(/(\d+)_create_users\.rb/)[1]
-
- app_file 'test/models/user_test.rb', <<-RUBY
- require 'test_helper'
- class UserTest < ActiveSupport::TestCase
- test "user" do
- User.create! name: "Jon"
- end
- end
- RUBY
-
- app_file 'config/initializers/enable_sql_schema_format.rb', <<-RUBY
- Rails.application.config.active_record.schema_format = :sql
- RUBY
-
- app_file 'db/structure.sql', <<-SQL
- CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
- CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
- CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));
- INSERT INTO schema_migrations (version) VALUES ('#{version_1}');
- SQL
-
- assert_successful_test_run('models/user_test.rb')
-
- output_2 = script('generate migration add_email_to_users')
- version_2 = output_2.match(/(\d+)_add_email_to_users\.rb/)[1]
-
- app_file 'test/models/user_test.rb', <<-RUBY
- require 'test_helper'
-
- class UserTest < ActiveSupport::TestCase
- test "user" do
- User.create! name: "Jon", email: "jon@doe.com"
- end
- end
- RUBY
-
- app_file 'db/structure.sql', <<-SQL
- CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL);
- CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version");
- CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "email" varchar(255));
- INSERT INTO schema_migrations (version) VALUES ('#{version_1}');
- INSERT INTO schema_migrations (version) VALUES ('#{version_2}');
- SQL
-
- assert_successful_test_run('models/user_test.rb')
- end
-
private
def assert_unsuccessful_run(name, message)
result = run_test_file(name)