2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-18 08:26:23 -04:00
|
|
|
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
|
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
it 'returns false when the user can not create and/or execute a trigger' do
|
2017-11-06 12:50:38 -05:00
|
|
|
# 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)
|
2017-08-18 08:26:23 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|