Skip to content
Snippets Groups Projects
Verified Commit b7b76abb authored by Prashanth Chandra's avatar Prashanth Chandra :mountain:
Browse files

Add MR validation spec

parent 43582c71
No related branches found
No related tags found
No related merge requests found
......@@ -221,6 +221,59 @@
expect(subject).to be_valid
end
end
context 'for collaboration' do
let(:project) { create(:project, :public, merge_requests_require_allow_collaboration: true) }
let(:fork) { fork_project(project) }
let(:can_push) { true }
let(:is_protected) { false }
before do
allow(subject).to receive(:can_push_to_source_project?).and_return(can_push)
allow(subject).to receive(:protected_source_branch?).and_return(is_protected)
subject.source_project = source_project
subject.target_project = target_project
end
context 'when source and target project are the same' do
let(:target_project) { project }
let(:source_project) { project }
it { is_expected.to be_valid }
end
context 'when source and target project are different' do
let(:target_project) { project }
let(:source_project) { fork }
it { is_expected.to be_valid }
end
context 'when source branch is protected' do
let(:target_project) { project }
let(:source_project) { fork }
let(:is_protected) { true }
it { is_expected.not_to be_valid }
end
context 'when author cannot push code to source project' do
let(:target_project) { project }
let(:source_project) { fork }
let(:can_push) { false }
it { is_expected.not_to be_valid }
end
context 'when author cannot allow collaboration but project does not require it' do
let(:project) { create(:project, :public) }
let(:target_project) { project }
let(:source_project) { fork }
let(:is_protected) { true }
it { is_expected.to be_valid }
end
end
end
describe 'callbacks' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment