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

@ -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