summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index cb28a7eca38..1f8133e7ff7 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -160,6 +160,34 @@ describe Project do
end
end
end
+
+ describe :update_merge_requests do
+ let(:project) { Factory :project }
+
+ before do
+ @merge_request = Factory :merge_request,
+ :project => project,
+ :merged => false,
+ :closed => false
+ @key = Factory :key, :user_id => project.owner.id
+ end
+
+ it "should close merge request if last commit from source branch was pushed to target branch" do
+ @merge_request.reloaded_commits
+ @merge_request.last_commit.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
+ project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a", "refs/heads/stable", @key.identifier)
+ @merge_request.reload
+ @merge_request.merged.should be_true
+ @merge_request.closed.should be_true
+ end
+
+ it "should update merge request commits with new one if pushed to source branch" do
+ @merge_request.last_commit.should == nil
+ project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a", "refs/heads/master", @key.identifier)
+ @merge_request.reload
+ @merge_request.last_commit.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
+ end
+ end
end
# == Schema Information
#