spec/lib/gumboot/strap_spec.rb in aaf-gumboot-2.1.3 vs spec/lib/gumboot/strap_spec.rb in aaf-gumboot-2.1.4

- old
+ new

@@ -71,15 +71,21 @@ subject.ensure_activerecord_databases(db_configs.keys) end it 'sets permissions for database users' do expect(client).to receive(:query) - .with("GRANT ALL PRIVILEGES ON `one_db`.* TO 'one_user'@'localhost' " \ - "IDENTIFIED BY 'one_password'").once + .with("CREATE USER IF NOT EXISTS 'one_user'@'localhost' " \ + "IDENTIFIED BY 'one_password';").once expect(client).to receive(:query) - .with("GRANT ALL PRIVILEGES ON `two_db`.* TO 'two_user'@'localhost' " \ - "IDENTIFIED BY 'two_password'").once + .with("GRANT ALL PRIVILEGES ON `one_db`.* TO 'one_user'@'localhost'") + .once + expect(client).to receive(:query) + .with("CREATE USER IF NOT EXISTS 'two_user'@'localhost' " \ + "IDENTIFIED BY 'two_password';").once + expect(client).to receive(:query) + .with("GRANT ALL PRIVILEGES ON `two_db`.* TO 'two_user'@'localhost'") + .once allow(client).to receive(:query).with(match(/^CREATE DATABASE.*/)) subject.ensure_activerecord_databases(db_configs.keys) end @@ -106,11 +112,14 @@ 'username' => 'test_user', 'password' => 'test_password' } end it 'sets permission for the database user' do expect(client).to receive(:query) + .with("CREATE USER IF NOT EXISTS 'test_user'@'localhost' " \ + "IDENTIFIED BY 'test_password';").once + expect(client).to receive(:query) .with('GRANT ALL PRIVILEGES ON `test_db`.* TO ' \ - "'test_user'@'localhost' IDENTIFIED BY 'test_password'").once + "'test_user'@'localhost'").once subject.ensure_database_user(opts) end it 'fails when adapter is not mysql2' do