Commit cfefab85 authored by Douwe Maan's avatar Douwe Maan

Add regression tests

parent d69f699e
......@@ -78,9 +78,10 @@ describe Gitlab::Checks::DiffCheck do
context 'file lock rules' do
let(:project) { create(:project, :repository) }
let(:path_lock) { create(:path_lock, path: 'README', project: project) }
it 'returns an error if the changes update a path locked by another user' do
path_lock = create(:path_lock, path: 'README', project: project)
path_lock
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "The path 'README' is locked by #{path_lock.user.name}")
end
......@@ -90,6 +91,26 @@ describe Gitlab::Checks::DiffCheck do
2.times { subject.validate! }
end
context 'when the branch is being deleted' do
let(:newrev) { Gitlab::Git::BLANK_SHA }
it 'does not run' do
path_lock
expect { subject.validate! }.not_to raise_error
end
end
context 'when there is no valid change' do
let(:changes) { { oldrev: '_any', newrev: nil, ref: nil } }
it 'does not run' do
path_lock
expect { subject.validate! }.not_to raise_error
end
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