Skip to content

Commit

Permalink
Use tmp dir instead of Dir.mktmpdir to create directory
Browse files Browse the repository at this point in the history
  • Loading branch information
maniSHarma7575 committed Apr 27, 2024
1 parent 41c1a10 commit 2792646
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def setup
end

def test_bad_connection
Dir.mktmpdir do |dir|
File.chmod(0x000, dir)
db_path = File.join(dir, "db/cant-be-created.db")
error = assert_raise ActiveRecord::NoDatabaseError do
connection = SQLite3Adapter.new(adapter: "sqlite3", database: db_path)
connection.drop_table "ex", if_exists: true
end
assert_kind_of ActiveRecord::ConnectionAdapters::NullPool, error.connection_pool
dir = "/tmp/should/_exist/"
FileUtils.mkdir_p dir
File.chmod(0x000, dir)
db_path = File.join(dir, "db/cant-be-created.db")
error = assert_raise ActiveRecord::NoDatabaseError do
connection = SQLite3Adapter.new(adapter: "sqlite3", database: db_path)
connection.drop_table "ex", if_exists: true
end
assert_kind_of ActiveRecord::ConnectionAdapters::NullPool, error.connection_pool
end

def test_database_should_get_created_when_missing_parent_directories_for_database_path
Expand Down

0 comments on commit 2792646

Please sign in to comment.