Skip to content

Commit

Permalink
Fix test failure in adapters/mysql/active_schema_test.rb
Browse files Browse the repository at this point in the history
Follow up to #21601.
  • Loading branch information
kamipo committed Nov 19, 2015
1 parent 6b7861e commit 056d6c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions activerecord/test/cases/adapters/mysql/active_schema_test.rb
Expand Up @@ -16,8 +16,8 @@ def execute(sql, name = nil) return sql end
end

def test_add_index
# add_index calls table_exists? and index_name_exists? which can't work since execute is stubbed
def (ActiveRecord::Base.connection).table_exists?(*); true; end
# add_index calls data_source_exists? and index_name_exists? which can't work since execute is stubbed
def (ActiveRecord::Base.connection).data_source_exists?(*); true; end
def (ActiveRecord::Base.connection).index_name_exists?(*); false; end

expected = "CREATE INDEX `index_people_on_last_name` ON `people` (`last_name`) "
Expand Down Expand Up @@ -60,7 +60,7 @@ def (ActiveRecord::Base.connection).index_name_exists?(*); false; end
end

def test_index_in_create
def (ActiveRecord::Base.connection).table_exists?(*); false; end
def (ActiveRecord::Base.connection).data_source_exists?(*); false; end

%w(SPATIAL FULLTEXT UNIQUE).each do |type|
expected = "CREATE TABLE `people` (#{type} INDEX `index_people_on_last_name` (`last_name`) ) ENGINE=InnoDB"
Expand All @@ -78,7 +78,7 @@ def (ActiveRecord::Base.connection).table_exists?(*); false; end
end

def test_index_in_bulk_change
def (ActiveRecord::Base.connection).table_exists?(*); true; end
def (ActiveRecord::Base.connection).data_source_exists?(*); true; end
def (ActiveRecord::Base.connection).index_name_exists?(*); false; end

%w(SPATIAL FULLTEXT UNIQUE).each do |type|
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_remove_timestamps
end

def test_indexes_in_create
ActiveRecord::Base.connection.stubs(:table_exists?).with(:temp).returns(false)
ActiveRecord::Base.connection.stubs(:data_source_exists?).with(:temp).returns(false)
ActiveRecord::Base.connection.stubs(:index_name_exists?).with(:index_temp_on_zip).returns(false)

expected = "CREATE TEMPORARY TABLE `temp` ( INDEX `index_temp_on_zip` (`zip`) ) ENGINE=InnoDB AS SELECT id, name, zip FROM a_really_complicated_query"
Expand Down
Expand Up @@ -16,7 +16,7 @@ def execute(sql, name = nil) return sql end
end

def test_add_index
# add_index calls table_exists? and index_name_exists? which can't work since execute is stubbed
# add_index calls data_source_exists? and index_name_exists? which can't work since execute is stubbed
def (ActiveRecord::Base.connection).data_source_exists?(*); true; end
def (ActiveRecord::Base.connection).index_name_exists?(*); false; end

Expand Down

0 comments on commit 056d6c3

Please sign in to comment.