Commit b2e48f27 authored by Valery Sizov's avatar Valery Sizov

added some specs for gitlab_access class

parent c9470f5c
......@@ -124,4 +124,48 @@ describe Gitlab::GitAccess do
end
end
end
describe "pass_git_hooks?" do
describe "author email check" do
it 'returns true' do
access.pass_git_hooks?(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').should be_true
end
it 'returns false' do
project.create_git_hook
project.git_hook.update(commit_message_regex: "@only.com")
access.pass_git_hooks?(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').should be_false
end
end
describe "member_check" do
before do
project.create_git_hook
project.git_hook.update(member_check: true)
end
it 'returns false for non-member user' do
access.pass_git_hooks?(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').should be_false
end
it 'returns true if committer is a gitlab member' do
create(:user, email: 'dmitriy.zaporozhets@gmail.com')
access.pass_git_hooks?(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').should be_true
end
end
describe "file names check" do
it 'returns false when filename is prohibited' do
project.create_git_hook
project.git_hook.update(file_name_regex: "jpg$")
access.pass_git_hooks?(user, project, 'refs/heads/master', '913c66a37', '33f3729a4').should be_false
end
it 'returns true if file name is allowed' do
project.create_git_hook
project.git_hook.update(file_name_regex: "exe$")
access.pass_git_hooks?(user, project, 'refs/heads/master', '913c66a37', '33f3729a4').should be_true
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment