Sha256: 3744b3d4c28b259f10ef8a0c36a802a74293939d07366c55962b2b88a97eaea4

Contents?: true

Size: 1.88 KB

Versions: 30

Compression:

Stored size: 1.88 KB

Contents

describe 'Gratan::Client#apply' do
  context 'when create user' do
    subject { client(dry_run: true) }

    it do
      result = apply(subject) {
        <<-RUBY
user 'scott', 'localhost', identified: 'tiger' do
  on '*.*' do
    grant 'SELECT'
    grant 'INSERT'
    grant 'UPDATE'
    grant 'DELETE'
  end

  on 'test.*' do
    grant 'SELECT'
    grant 'INSERT'
    grant 'UPDATE'
    grant 'DELETE'
  end
end
        RUBY
      }

      expect(result).to be_falsey
      expect(show_grants).to match_array []
    end
  end

  context 'when add user' do
    before do
      apply {
        <<-RUBY
user 'bob', '%', required: 'SSL' do
  on '*.*' do
    grant 'ALL PRIVILEGES'
  end

  on 'test.*' do
    grant 'SELECT'
  end
end
        RUBY
      }
    end

    subject { client(dry_run: true) }

    it do
      apply(subject) {
        <<-RUBY
user 'bob', '%', required: 'SSL' do
  on '*.*' do
    grant 'ALL PRIVILEGES'
  end

  on 'test.*' do
    grant 'SELECT'
  end
end

user 'scott', 'localhost', identified: 'tiger' do
  on '*.*' do
    grant 'SELECT'
    grant 'INSERT'
    grant 'UPDATE'
    grant 'DELETE'
  end

  on 'test.*' do
    grant 'SELECT'
    grant 'INSERT'
    grant 'UPDATE'
    grant 'DELETE'
  end
end
        RUBY
      }

      expect(show_grants).to match_array [
        "GRANT ALL PRIVILEGES ON *.* TO 'bob'@'%' REQUIRE SSL",
        "GRANT SELECT ON `test`.* TO 'bob'@'%'",
      ]
    end
  end

  context 'when create user with grant option' do
    subject { client(dry_run: true) }

    it do
      apply(subject) {
        <<-RUBY
user 'scott', 'localhost', identified: 'tiger' do
  on '*.*', with: 'grant option' do
    grant 'SELECT'
    grant 'INSERT'
    grant 'UPDATE'
    grant 'DELETE'
  end

  on 'test.*' do
    grant 'SELECT'
    grant 'INSERT'
    grant 'UPDATE'
    grant 'DELETE'
  end
end
        RUBY
      }

      expect(show_grants).to match_array []
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gratan-0.3.1.beta2 spec/create/create_user_3_spec.rb
gratan-0.3.1.beta spec/create/create_user_3_spec.rb
gratan-0.3.0 spec/create/create_user_3_spec.rb
gratan-0.3.0.beta spec/create/create_user_3_spec.rb
gratan-0.2.9 spec/create/create_user_3_spec.rb
gratan-0.2.9.beta3 spec/create/create_user_3_spec.rb
gratan-0.2.9.beta2 spec/create/create_user_3_spec.rb
gratan-0.2.9.beta spec/create/create_user_3_spec.rb
gratan-0.2.8 spec/create/create_user_3_spec.rb
gratan-0.2.8.beta3 spec/create/create_user_3_spec.rb
gratan-0.2.8.beta2 spec/create/create_user_3_spec.rb
gratan-0.2.8.beta spec/create/create_user_3_spec.rb
gratan-0.2.7 spec/create/create_user_3_spec.rb
gratan-0.2.6 spec/create/create_user_3_spec.rb
gratan-0.2.5 spec/create/create_user_3_spec.rb
gratan-0.2.4 spec/create/create_user_3_spec.rb
gratan-0.2.3 spec/create/create_user_3_spec.rb
gratan-0.2.2 spec/create/create_user_3_spec.rb
gratan-0.2.1 spec/create/create_user_3_spec.rb
gratan-0.2.0 spec/create/create_user_3_spec.rb