gitlab-org--gitlab-foss/spec/lib/gitlab/database/grant_spec.rb
Yorick Peterse 60526a5291
Fix TRIGGER checks for MySQL
This ensures we can check if the user has TRIGGER permissions without
querying restricted tables. Thanks to Steve Norman
(https://gitlab.com/stevenorman) for helping out with this merge
request.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/38372
2017-11-06 23:34:07 +01:00

18 lines
783 B
Ruby

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', :postgresql 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