diff options
Diffstat (limited to 'spec/models/merge_request_spec.rb')
-rw-r--r-- | spec/models/merge_request_spec.rb | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index a0a43fbb815..cb15d250c12 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -41,15 +41,12 @@ describe MergeRequest do it { should include_module(Issuable) } end - describe "#mr_and_commit_notes" do - - end describe "#mr_and_commit_notes" do let!(:merge_request) { create(:merge_request) } before do - merge_request.stub(:commits) { [merge_request.project.repository.commit] } + merge_request.stub(:commits) { [merge_request.source_project.repository.commit] } create(:note, commit_id: merge_request.commits.first.id, noteable_type: 'Commit') create(:note, noteable: merge_request) end @@ -71,4 +68,39 @@ describe MergeRequest do subject.is_being_reassigned?.should be_false end end + + describe '#for_fork?' do + it 'returns true if the merge request is for a fork' do + subject.source_project = create(:source_project) + subject.target_project = create(:target_project) + + subject.for_fork?.should be_true + end + it 'returns false if is not for a fork' do + subject.source_project = create(:source_project) + subject.target_project = subject.source_project + subject.for_fork?.should be_false + end + end + + + describe '#allow_source_branch_removal?' do + it 'should not allow removal when mr is a fork' do + + subject.disallow_source_branch_removal?.should be_true + end + it 'should not allow removal when the mr is not a fork, but the source branch is the root reference' do + subject.target_project = subject.source_project + subject.source_branch = subject.source_project.repository.root_ref + subject.disallow_source_branch_removal?.should be_true + end + + it 'should not disallow removal when the mr is not a fork, and but source branch is not the root reference' do + subject.target_project = subject.source_project + subject.source_branch = "Something Different #{subject.source_project.repository.root_ref}" + subject.for_fork?.should be_false + subject.disallow_source_branch_removal?.should be_false + end + end + end |