diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-07-03 02:38:12 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-07-03 02:45:54 +0900 |
commit | 324f6fa20779433578f8c0cbaf4ff9343817dd4b (patch) | |
tree | 2e11ecce100ea5a787da9cd53992ec0c36a5a8d4 /activerecord/test/cases | |
parent | 02aac286a6bd8db0eeb606d639c7a7e78ac01453 (diff) | |
parent | bf1024de5500f3c8d2c3b1876894feb02ba26ea7 (diff) | |
download | rails-324f6fa20779433578f8c0cbaf4ff9343817dd4b.tar.gz rails-324f6fa20779433578f8c0cbaf4ff9343817dd4b.tar.bz2 rails-324f6fa20779433578f8c0cbaf4ff9343817dd4b.zip |
Merge pull request #33242 from brasic/sqlite-readonly
Support readonly option in SQLite3Adapter
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb index ad155c7492..d1d4d545a3 100644 --- a/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +++ b/activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb @@ -504,6 +504,39 @@ module ActiveRecord assert_deprecated { @conn.valid_alter_table_type?(:string) } end + def test_db_is_not_readonly_when_readonly_option_is_false + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3", + readonly: false + + assert_not_predicate conn.raw_connection, :readonly? + end + + def test_db_is_not_readonly_when_readonly_option_is_unspecified + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3" + + assert_not_predicate conn.raw_connection, :readonly? + end + + def test_db_is_readonly_when_readonly_option_is_true + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3", + readonly: true + + assert_predicate conn.raw_connection, :readonly? + end + + def test_writes_are_not_permitted_to_readonly_databases + conn = Base.sqlite3_connection database: ":memory:", + adapter: "sqlite3", + readonly: true + + assert_raises(ActiveRecord::StatementInvalid, /SQLite3::ReadOnlyException/) do + conn.execute("CREATE TABLE test(id integer)") + end + end + private def assert_logged(logs) |