summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/grant_spec.rb
blob: 02697eb2a1673cc93993f5ff0a3b2f6dd6dfe00d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Database::Grant do
  describe '.create_and_execute_trigger' do
    it 'returns true when the user can create and execute a trigger' do
      # We assume the DB/user is set up correctly so that triggers can be
      # created, which is necessary anyway for other tests to work.
      expect(described_class.create_and_execute_trigger?('users')).to eq(true)
    end

    it 'returns false when the user can not create and/or execute a trigger' do
      # In case of MySQL the user may have SUPER permissions, making it
      # impossible to have `false` returned when running tests; hence we only
      # run these tests on PostgreSQL.
      expect(described_class.create_and_execute_trigger?('foo')).to eq(false)
    end
  end
end