Sha256: 44c5b13a7283dd6eee10477e8278e3775923b033fc2e755f48415faa1803f09d

Contents?: true

Size: 1.53 KB

Versions: 13

Compression:

Stored size: 1.53 KB

Contents

describe 'Gratan::Client#apply' do
  before(:each) do
    mysql do |cli|
      drop_database(cli)
      create_database(cli)
      create_function(cli, :my_func)
      create_procedure(cli, :my_prcd)
    end
  end

  context 'when func -> prcd' do
    subject { client }

    before do
      apply(subject) {
        <<-RUBY
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "FUNCTION #{TEST_DATABASE}.my_func" do
    grant "EXECUTE"
  end
end
        RUBY
      }

    end

    it do
      apply(subject) {
        <<-RUBY
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "PROCEDURE #{TEST_DATABASE}.my_prcd" do
    grant "EXECUTE"
  end
end
        RUBY
      }

      expect(show_grants).to match_array [
        "GRANT USAGE ON *.* TO 'scott'@'%'",
        "GRANT EXECUTE ON PROCEDURE `#{TEST_DATABASE}`.`my_prcd` TO 'scott'@'%'"
      ]
    end
  end

  context 'when prcd -> func' do
    subject { client }

    before do
      apply(subject) {
        <<-RUBY
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "PROCEDURE #{TEST_DATABASE}.my_prcd" do
    grant "EXECUTE"
  end
end
        RUBY
      }

    end

    it do
      apply(subject) {
        <<-RUBY
user "scott", "%" do
  on "*.*" do
    grant "USAGE"
  end

  on "FUNCTION #{TEST_DATABASE}.my_func" do
    grant "EXECUTE"
  end
end
        RUBY
      }

      expect(show_grants).to match_array [
        "GRANT USAGE ON *.* TO 'scott'@'%'",
        "GRANT EXECUTE ON FUNCTION `#{TEST_DATABASE}`.`my_func` TO 'scott'@'%'"
      ]
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gratan-0.3.2 spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.1 spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.1.beta4 spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.1.beta3 spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.1.beta2 spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.1.beta spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.0 spec/change/change_grants_func_prcd_spec.rb
gratan-0.3.0.beta spec/change/change_grants_func_prcd_spec.rb
gratan-0.2.9 spec/change/change_grants_func_prcd_spec.rb
gratan-0.2.9.beta3 spec/change/change_grants_func_prcd_spec.rb
gratan-0.2.9.beta2 spec/change/change_grants_func_prcd_spec.rb
gratan-0.2.9.beta spec/change/change_grants_func_prcd_spec.rb
gratan-0.2.8 spec/change/change_grants_func_prcd_spec.rb