Merge branch 'state-machine' of https://github.com/Undev/gitlabhq into Undev-state-machine

Conflicts:
	app/models/issue.rb
	app/models/merge_request.rb
This commit is contained in:
Dmitriy Zaporozhets 2013-02-19 11:01:19 +02:00
commit 155703c613
55 changed files with 521 additions and 428 deletions

View file

@ -54,10 +54,15 @@ FactoryGirl.define do
project
trait :closed do
closed true
state :closed
end
trait :reopened do
state :reopened
end
factory :closed_issue, traits: [:closed]
factory :reopened_issue, traits: [:reopened]
end
factory :merge_request do
@ -67,10 +72,6 @@ FactoryGirl.define do
source_branch "master"
target_branch "stable"
trait :closed do
closed true
end
# pick 3 commits "at random" (from bcf03b5d~3 to bcf03b5d)
trait :with_diffs do
target_branch "master" # pretend bcf03b5d~3
@ -85,7 +86,16 @@ FactoryGirl.define do
end
end
trait :closed do
state :closed
end
trait :reopened do
state :reopened
end
factory :closed_merge_request, traits: [:closed]
factory :reopened_merge_request, traits: [:reopened]
factory :merge_request_with_diffs, traits: [:with_diffs]
end
@ -159,6 +169,12 @@ FactoryGirl.define do
factory :milestone do
title
project
trait :closed do
state :closed
end
factory :closed_milestone, traits: [:closed]
end
factory :system_hook do

View file

@ -15,7 +15,6 @@ describe Issue, "Issuable" do
it { should validate_presence_of(:author) }
it { should validate_presence_of(:title) }
it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) }
it { should ensure_inclusion_of(:closed).in_array([true, false]) }
end
describe "Scope" do

View file

@ -9,7 +9,7 @@
# project_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# closed :boolean default(FALSE), not null
# state :string default(FALSE), not null
# position :integer default(0)
# branch_name :string(255)
# description :text
@ -44,34 +44,15 @@ describe Issue do
end
end
describe '#is_being_closed?' do
it 'returns true if the closed attribute has changed and is now true' do
subject.closed = true
subject.is_being_closed?.should be_true
end
it 'returns false if the closed attribute has changed and is now false' do
issue = create(:closed_issue)
issue.closed = false
issue.is_being_closed?.should be_false
end
it 'returns false if the closed attribute has not changed' do
subject.is_being_closed?.should be_false
end
end
describe '#is_being_reassigned?' do
it 'returnes issues assigned to user' do
user = create :user
2.times do
issue = create :issue, assignee: user
end
describe '#is_being_reopened?' do
it 'returns true if the closed attribute has changed and is now false' do
issue = create(:closed_issue)
issue.closed = false
issue.is_being_reopened?.should be_true
end
it 'returns false if the closed attribute has changed and is now true' do
subject.closed = true
subject.is_being_reopened?.should be_false
end
it 'returns false if the closed attribute has not changed' do
subject.is_being_reopened?.should be_false
Issue.open_for(user).count.should eq 2
end
end
end

View file

@ -15,7 +15,7 @@
# st_commits :text(2147483647)
# st_diffs :text(2147483647)
# merged :boolean default(FALSE), not null
# state :integer default(1), not null
# merge_status :integer default(1), not null
# milestone_id :integer
#
@ -36,6 +36,10 @@ 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) }
@ -62,35 +66,4 @@ describe MergeRequest do
subject.is_being_reassigned?.should be_false
end
end
describe '#is_being_closed?' do
it 'returns true if the closed attribute has changed and is now true' do
subject.closed = true
subject.is_being_closed?.should be_true
end
it 'returns false if the closed attribute has changed and is now false' do
merge_request = create(:closed_merge_request)
merge_request.closed = false
merge_request.is_being_closed?.should be_false
end
it 'returns false if the closed attribute has not changed' do
subject.is_being_closed?.should be_false
end
end
describe '#is_being_reopened?' do
it 'returns true if the closed attribute has changed and is now false' do
merge_request = create(:closed_merge_request)
merge_request.closed = false
merge_request.is_being_reopened?.should be_true
end
it 'returns false if the closed attribute has changed and is now true' do
subject.closed = true
subject.is_being_reopened?.should be_false
end
it 'returns false if the closed attribute has not changed' do
subject.is_being_reopened?.should be_false
end
end
end

View file

@ -7,7 +7,7 @@
# project_id :integer not null
# description :text
# due_date :date
# closed :boolean default(FALSE), not null
# state :string default(FALSE), not null
# created_at :datetime not null
# updated_at :datetime not null
#
@ -27,7 +27,6 @@ describe Milestone do
describe "Validation" do
it { should validate_presence_of(:title) }
it { should validate_presence_of(:project) }
it { should ensure_inclusion_of(:closed).in_array([true, false]) }
end
let(:milestone) { create(:milestone) }
@ -41,7 +40,7 @@ describe Milestone do
it "should count closed issues" do
IssueObserver.current_user = issue.author
issue.update_attributes(closed: true)
issue.close
milestone.issues << issue
milestone.percent_complete.should == 100
end
@ -96,7 +95,7 @@ describe Milestone do
describe :items_count do
before do
milestone.issues << create(:issue)
milestone.issues << create(:issue, closed: true)
milestone.issues << create(:closed_issue)
milestone.merge_requests << create(:merge_request)
end
@ -110,7 +109,35 @@ describe Milestone do
it { milestone.can_be_closed?.should be_true }
end
describe :open? do
it { milestone.open?.should be_true }
describe :is_empty? do
before do
issue = create :closed_issue, milestone: milestone
merge_request = create :merge_request, milestone: milestone
end
it 'Should return total count of issues and merge requests assigned to milestone' do
milestone.total_items_count.should eq 2
end
end
describe :can_be_closed? do
before do
milestone = create :milestone
create :closed_issue, milestone: milestone
issue = create :issue
end
it 'should be true if milestone active and all nestied issues closed' do
milestone.can_be_closed?.should be_true
end
it 'should be false if milestone active and not all nestied issues closed' do
issue.milestone = milestone
issue.save
milestone.can_be_closed?.should be_false
end
end
end

View file

@ -121,10 +121,7 @@ describe Project do
let(:project) { create(:project) }
before do
@merge_request = create(:merge_request,
project: project,
merged: false,
closed: false)
@merge_request = create(:merge_request, project: project)
@key = create(:key, user_id: project.owner.id)
end
@ -133,8 +130,7 @@ describe Project do
@merge_request.last_commit.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a", "refs/heads/stable", @key.user)
@merge_request.reload
@merge_request.merged.should be_true
@merge_request.closed.should be_true
@merge_request.merged?.should be_true
end
it "should update merge request commits with new one if pushed to source branch" do

View file

@ -1,10 +1,15 @@
require 'spec_helper'
describe IssueObserver do
let(:some_user) { double(:user, id: 1) }
let(:assignee) { double(:user, id: 2) }
let(:author) { double(:user, id: 3) }
let(:issue) { double(:issue, id: 42, assignee: assignee, author: author) }
let(:some_user) { create :user }
let(:assignee) { create :user }
let(:author) { create :user }
let(:mock_issue) { double(:issue, id: 42, assignee: assignee, author: author) }
let(:assigned_issue) { create(:issue, assignee: assignee, author: author) }
let(:unassigned_issue) { create(:issue, author: author) }
let(:closed_assigned_issue) { create(:closed_issue, assignee: assignee, author: author) }
let(:closed_unassigned_issue) { create(:closed_issue, author: author) }
before(:each) { subject.stub(:current_user).and_return(some_user) }
@ -21,24 +26,66 @@ describe IssueObserver do
end
it 'sends an email to the assignee' do
Notify.should_receive(:new_issue_email).with(issue.id)
Notify.should_receive(:new_issue_email).with(mock_issue.id)
subject.after_create(issue)
subject.after_create(mock_issue)
end
it 'does not send an email to the assignee if assignee created the issue' do
subject.stub(:current_user).and_return(assignee)
Notify.should_not_receive(:new_issue_email)
subject.after_create(issue)
subject.after_create(mock_issue)
end
end
context '#after_close' do
context 'a status "closed"' do
it 'note is created if the issue is being closed' do
Note.should_receive(:create_status_change_note).with(assigned_issue, some_user, 'closed')
assigned_issue.close
end
it 'notification is delivered if the issue being closed' do
Notify.should_receive(:issue_status_changed_email).twice
assigned_issue.close
end
it 'notification is delivered only to author if the issue being closed' do
Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(unassigned_issue, some_user, 'closed')
unassigned_issue.close
end
end
context 'a status "reopened"' do
it 'note is created if the issue is being reopened' do
Note.should_receive(:create_status_change_note).with(closed_assigned_issue, some_user, 'reopened')
closed_assigned_issue.reopen
end
it 'notification is delivered if the issue being reopened' do
Notify.should_receive(:issue_status_changed_email).twice
closed_assigned_issue.reopen
end
it 'notification is delivered only to author if the issue being reopened' do
Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(closed_unassigned_issue, some_user, 'reopened')
closed_unassigned_issue.reopen
end
end
end
context '#after_update' do
before(:each) do
issue.stub(:is_being_reassigned?).and_return(false)
issue.stub(:is_being_closed?).and_return(false)
issue.stub(:is_being_reopened?).and_return(false)
mock_issue.stub(:is_being_reassigned?).and_return(false)
end
it 'is called when an issue is changed' do
@ -53,105 +100,17 @@ describe IssueObserver do
context 'a reassigned email' do
it 'is sent if the issue is being reassigned' do
issue.should_receive(:is_being_reassigned?).and_return(true)
subject.should_receive(:send_reassigned_email).with(issue)
mock_issue.should_receive(:is_being_reassigned?).and_return(true)
subject.should_receive(:send_reassigned_email).with(mock_issue)
subject.after_update(issue)
subject.after_update(mock_issue)
end
it 'is not sent if the issue is not being reassigned' do
issue.should_receive(:is_being_reassigned?).and_return(false)
mock_issue.should_receive(:is_being_reassigned?).and_return(false)
subject.should_not_receive(:send_reassigned_email)
subject.after_update(issue)
end
end
context 'a status "closed"' do
it 'note is created if the issue is being closed' do
issue.should_receive(:is_being_closed?).and_return(true)
Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
end
it 'note is not created if the issue is not being closed' do
issue.should_receive(:is_being_closed?).and_return(false)
Note.should_not_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
end
it 'notification is delivered if the issue being closed' do
issue.stub(:is_being_closed?).and_return(true)
Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
end
it 'notification is not delivered if the issue not being closed' do
issue.stub(:is_being_closed?).and_return(false)
Notify.should_not_receive(:issue_status_changed_email)
Note.should_not_receive(:create_status_change_note).with(issue, some_user, 'closed')
subject.after_update(issue)
end
it 'notification is delivered only to author if the issue being closed' do
issue_without_assignee = double(:issue, id: 42, author: author, assignee: nil)
issue_without_assignee.stub(:is_being_reassigned?).and_return(false)
issue_without_assignee.stub(:is_being_closed?).and_return(true)
issue_without_assignee.stub(:is_being_reopened?).and_return(false)
Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(issue_without_assignee, some_user, 'closed')
subject.after_update(issue_without_assignee)
end
end
context 'a status "reopened"' do
it 'note is created if the issue is being reopened' do
Notify.should_receive(:issue_status_changed_email).twice
issue.should_receive(:is_being_reopened?).and_return(true)
Note.should_receive(:create_status_change_note).with(issue, some_user, 'reopened')
subject.after_update(issue)
end
it 'note is not created if the issue is not being reopened' do
issue.should_receive(:is_being_reopened?).and_return(false)
Note.should_not_receive(:create_status_change_note).with(issue, some_user, 'reopened')
subject.after_update(issue)
end
it 'notification is delivered if the issue being reopened' do
issue.stub(:is_being_reopened?).and_return(true)
Notify.should_receive(:issue_status_changed_email).twice
Note.should_receive(:create_status_change_note).with(issue, some_user, 'reopened')
subject.after_update(issue)
end
it 'notification is not delivered if the issue not being reopened' do
issue.stub(:is_being_reopened?).and_return(false)
Notify.should_not_receive(:issue_status_changed_email)
Note.should_not_receive(:create_status_change_note).with(issue, some_user, 'reopened')
subject.after_update(issue)
end
it 'notification is delivered only to author if the issue being reopened' do
issue_without_assignee = double(:issue, id: 42, author: author, assignee: nil)
issue_without_assignee.stub(:is_being_reassigned?).and_return(false)
issue_without_assignee.stub(:is_being_closed?).and_return(false)
issue_without_assignee.stub(:is_being_reopened?).and_return(true)
Notify.should_receive(:issue_status_changed_email).once
Note.should_receive(:create_status_change_note).with(issue_without_assignee, some_user, 'reopened')
subject.after_update(issue_without_assignee)
subject.after_update(mock_issue)
end
end
end
@ -160,23 +119,23 @@ describe IssueObserver do
let(:previous_assignee) { double(:user, id: 3) }
before(:each) do
issue.stub(:assignee_id).and_return(assignee.id)
issue.stub(:assignee_id_was).and_return(previous_assignee.id)
mock_issue.stub(:assignee_id).and_return(assignee.id)
mock_issue.stub(:assignee_id_was).and_return(previous_assignee.id)
end
def it_sends_a_reassigned_email_to(recipient)
Notify.should_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id)
Notify.should_receive(:reassigned_issue_email).with(recipient, mock_issue.id, previous_assignee.id)
end
def it_does_not_send_a_reassigned_email_to(recipient)
Notify.should_not_receive(:reassigned_issue_email).with(recipient, issue.id, previous_assignee.id)
Notify.should_not_receive(:reassigned_issue_email).with(recipient, mock_issue.id, previous_assignee.id)
end
it 'sends a reassigned email to the previous and current assignees' do
it_sends_a_reassigned_email_to assignee.id
it_sends_a_reassigned_email_to previous_assignee.id
subject.send(:send_reassigned_email, issue)
subject.send(:send_reassigned_email, mock_issue)
end
context 'does not send an email to the user who made the reassignment' do
@ -185,14 +144,14 @@ describe IssueObserver do
it_sends_a_reassigned_email_to previous_assignee.id
it_does_not_send_a_reassigned_email_to assignee.id
subject.send(:send_reassigned_email, issue)
subject.send(:send_reassigned_email, mock_issue)
end
it 'if the user is the previous assignee' do
subject.stub(:current_user).and_return(previous_assignee)
it_sends_a_reassigned_email_to assignee.id
it_does_not_send_a_reassigned_email_to previous_assignee.id
subject.send(:send_reassigned_email, issue)
subject.send(:send_reassigned_email, mock_issue)
end
end
end

View file

@ -1,10 +1,14 @@
require 'spec_helper'
describe MergeRequestObserver do
let(:some_user) { double(:user, id: 1) }
let(:assignee) { double(:user, id: 2) }
let(:author) { double(:user, id: 3) }
let(:mr) { double(:merge_request, id: 42, assignee: assignee, author: author) }
let(:some_user) { create :user }
let(:assignee) { create :user }
let(:author) { create :user }
let(:mr_mock) { double(:merge_request, id: 42, assignee: assignee, author: author) }
let(:assigned_mr) { create(:merge_request, assignee: assignee, author: author) }
let(:unassigned_mr) { create(:merge_request, author: author) }
let(:closed_assigned_mr) { create(:closed_merge_request, assignee: assignee, author: author) }
let(:closed_unassigned_mr) { create(:closed_merge_request, author: author) }
before(:each) { subject.stub(:current_user).and_return(some_user) }
@ -21,23 +25,21 @@ describe MergeRequestObserver do
end
it 'sends an email to the assignee' do
Notify.should_receive(:new_merge_request_email).with(mr.id)
subject.after_create(mr)
Notify.should_receive(:new_merge_request_email).with(mr_mock.id)
subject.after_create(mr_mock)
end
it 'does not send an email to the assignee if assignee created the merge request' do
subject.stub(:current_user).and_return(assignee)
Notify.should_not_receive(:new_merge_request_email)
subject.after_create(mr)
subject.after_create(mr_mock)
end
end
context '#after_update' do
before(:each) do
mr.stub(:is_being_reassigned?).and_return(false)
mr.stub(:is_being_closed?).and_return(false)
mr.stub(:is_being_reopened?).and_return(false)
mr_mock.stub(:is_being_reassigned?).and_return(false)
end
it 'is called when a merge request is changed' do
@ -52,97 +54,50 @@ describe MergeRequestObserver do
context 'a reassigned email' do
it 'is sent if the merge request is being reassigned' do
mr.should_receive(:is_being_reassigned?).and_return(true)
subject.should_receive(:send_reassigned_email).with(mr)
mr_mock.should_receive(:is_being_reassigned?).and_return(true)
subject.should_receive(:send_reassigned_email).with(mr_mock)
subject.after_update(mr)
subject.after_update(mr_mock)
end
it 'is not sent if the merge request is not being reassigned' do
mr.should_receive(:is_being_reassigned?).and_return(false)
mr_mock.should_receive(:is_being_reassigned?).and_return(false)
subject.should_not_receive(:send_reassigned_email)
subject.after_update(mr)
subject.after_update(mr_mock)
end
end
end
context '#after_close' do
context 'a status "closed"' do
it 'note is created if the merge request is being closed' do
mr.should_receive(:is_being_closed?).and_return(true)
Note.should_receive(:create_status_change_note).with(mr, some_user, 'closed')
Note.should_receive(:create_status_change_note).with(assigned_mr, some_user, 'closed')
subject.after_update(mr)
end
it 'note is not created if the merge request is not being closed' do
mr.should_receive(:is_being_closed?).and_return(false)
Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'closed')
subject.after_update(mr)
end
it 'notification is delivered if the merge request being closed' do
mr.stub(:is_being_closed?).and_return(true)
Note.should_receive(:create_status_change_note).with(mr, some_user, 'closed')
subject.after_update(mr)
end
it 'notification is not delivered if the merge request not being closed' do
mr.stub(:is_being_closed?).and_return(false)
Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'closed')
subject.after_update(mr)
assigned_mr.close
end
it 'notification is delivered only to author if the merge request is being closed' do
mr_without_assignee = double(:merge_request, id: 42, author: author, assignee: nil)
mr_without_assignee.stub(:is_being_reassigned?).and_return(false)
mr_without_assignee.stub(:is_being_closed?).and_return(true)
mr_without_assignee.stub(:is_being_reopened?).and_return(false)
Note.should_receive(:create_status_change_note).with(mr_without_assignee, some_user, 'closed')
Note.should_receive(:create_status_change_note).with(unassigned_mr, some_user, 'closed')
subject.after_update(mr_without_assignee)
unassigned_mr.close
end
end
end
context '#after_reopen' do
context 'a status "reopened"' do
it 'note is created if the merge request is being reopened' do
mr.should_receive(:is_being_reopened?).and_return(true)
Note.should_receive(:create_status_change_note).with(mr, some_user, 'reopened')
Note.should_receive(:create_status_change_note).with(closed_assigned_mr, some_user, 'reopened')
subject.after_update(mr)
end
it 'note is not created if the merge request is not being reopened' do
mr.should_receive(:is_being_reopened?).and_return(false)
Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'reopened')
subject.after_update(mr)
end
it 'notification is delivered if the merge request being reopened' do
mr.stub(:is_being_reopened?).and_return(true)
Note.should_receive(:create_status_change_note).with(mr, some_user, 'reopened')
subject.after_update(mr)
end
it 'notification is not delivered if the merge request is not being reopened' do
mr.stub(:is_being_reopened?).and_return(false)
Note.should_not_receive(:create_status_change_note).with(mr, some_user, 'reopened')
subject.after_update(mr)
closed_assigned_mr.reopen
end
it 'notification is delivered only to author if the merge request is being reopened' do
mr_without_assignee = double(:merge_request, id: 42, author: author, assignee: nil)
mr_without_assignee.stub(:is_being_reassigned?).and_return(false)
mr_without_assignee.stub(:is_being_closed?).and_return(false)
mr_without_assignee.stub(:is_being_reopened?).and_return(true)
Note.should_receive(:create_status_change_note).with(mr_without_assignee, some_user, 'reopened')
Note.should_receive(:create_status_change_note).with(closed_unassigned_mr, some_user, 'reopened')
subject.after_update(mr_without_assignee)
closed_unassigned_mr.reopen
end
end
end
@ -151,23 +106,23 @@ describe MergeRequestObserver do
let(:previous_assignee) { double(:user, id: 3) }
before(:each) do
mr.stub(:assignee_id).and_return(assignee.id)
mr.stub(:assignee_id_was).and_return(previous_assignee.id)
mr_mock.stub(:assignee_id).and_return(assignee.id)
mr_mock.stub(:assignee_id_was).and_return(previous_assignee.id)
end
def it_sends_a_reassigned_email_to(recipient)
Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id)
Notify.should_receive(:reassigned_merge_request_email).with(recipient, mr_mock.id, previous_assignee.id)
end
def it_does_not_send_a_reassigned_email_to(recipient)
Notify.should_not_receive(:reassigned_merge_request_email).with(recipient, mr.id, previous_assignee.id)
Notify.should_not_receive(:reassigned_merge_request_email).with(recipient, mr_mock.id, previous_assignee.id)
end
it 'sends a reassigned email to the previous and current assignees' do
it_sends_a_reassigned_email_to assignee.id
it_sends_a_reassigned_email_to previous_assignee.id
subject.send(:send_reassigned_email, mr)
subject.send(:send_reassigned_email, mr_mock)
end
context 'does not send an email to the user who made the reassignment' do
@ -176,14 +131,14 @@ describe MergeRequestObserver do
it_sends_a_reassigned_email_to previous_assignee.id
it_does_not_send_a_reassigned_email_to assignee.id
subject.send(:send_reassigned_email, mr)
subject.send(:send_reassigned_email, mr_mock)
end
it 'if the user is the previous assignee' do
subject.stub(:current_user).and_return(previous_assignee)
it_sends_a_reassigned_email_to assignee.id
it_does_not_send_a_reassigned_email_to previous_assignee.id
subject.send(:send_reassigned_email, mr)
subject.send(:send_reassigned_email, mr_mock)
end
end
end

View file

@ -54,14 +54,24 @@ describe Gitlab::API do
end
end
describe "PUT /projects/:id/issues/:issue_id" do
describe "PUT /projects/:id/issues/:issue_id to update only title" do
it "should update a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
title: 'updated title', labels: 'label2', closed: 1
title: 'updated title'
response.status.should == 200
json_response['title'].should == 'updated title'
end
end
describe "PUT /projects/:id/issues/:issue_id to update state and label" do
it "should update a project issue" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
labels: 'label2', state_event: "close"
response.status.should == 200
json_response['labels'].should == ['label2']
json_response['closed'].should be_true
json_response['state'].should eq "closed"
end
end

View file

@ -43,6 +43,23 @@ describe Gitlab::API do
end
end
describe "PUT /projects/:id/merge_request/:merge_request_id to close MR" do
it "should return merge_request" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "close"
response.status.should == 200
json_response['state'].should == 'closed'
end
end
describe "PUT /projects/:id/merge_request/:merge_request_id to merge MR" do
it "should return merge_request" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), state_event: "merge"
response.status.should == 200
json_response['state'].should == 'merged'
end
end
describe "PUT /projects/:id/merge_request/:merge_request_id" do
it "should return merge_request" do
put api("/projects/#{project.id}/merge_request/#{merge_request.id}", user), title: "New title"

View file

@ -44,4 +44,14 @@ describe Gitlab::API do
json_response['title'].should == 'updated title'
end
end
describe "PUT /projects/:id/milestones/:milestone_id to close milestone" do
it "should update a project milestone" do
put api("/projects/#{project.id}/milestones/#{milestone.id}", user),
state_event: 'close'
response.status.should == 200
json_response['state'].should == 'closed'
end
end
end

View file

@ -58,8 +58,7 @@ describe "Issues" do
it "should be able to search on different statuses" do
issue = Issue.first # with title 'foobar'
issue.closed = true
issue.save
issue.close
visit project_issues_path(project)
click_link 'Closed'