diff options
author | AlexDenisov <1101.debian@gmail.com> | 2013-05-16 14:32:16 +0400 |
---|---|---|
committer | AlexDenisov <1101.debian@gmail.com> | 2013-05-16 14:32:27 +0400 |
commit | 6e8cb844499dfcc77bd92f3daf0f7890400ec072 (patch) | |
tree | 5fb1909e5da126030d23c0f0c37482aa657027c3 /spec | |
parent | d08e1db93091418694130870406995f21502d478 (diff) |
Added few tests on Issues::BulkUpdateContext
Diffstat (limited to 'spec')
-rw-r--r-- | spec/contexts/issues/bulk_update_context_spec.rb | 89 |
1 files changed, 61 insertions, 28 deletions
diff --git a/spec/contexts/issues/bulk_update_context_spec.rb b/spec/contexts/issues/bulk_update_context_spec.rb index 0ea1799f5c9..0966ee35745 100644 --- a/spec/contexts/issues/bulk_update_context_spec.rb +++ b/spec/contexts/issues/bulk_update_context_spec.rb @@ -2,14 +2,21 @@ require 'spec_helper' describe Issues::BulkUpdateContext do + let(:issue) { + create(:issue, project: @project) + } + + before do + @user = create :user + opts = { + name: "GitLab" + } + @project = Projects::CreateContext.new(@user, opts).execute + end + describe :close_issue do before do - @user = create :user - opts = { - name: "GitLab" - } - @project = create_project(@user, opts) @issues = 5.times.collect do create(:issue, project: @project) end @@ -19,31 +26,22 @@ describe Issues::BulkUpdateContext do issues_ids: @issues.map(&:id) } } - end - it "close issues" do - Issues::BulkUpdateContext.new(@project, @user, @params).execute - @project.issues.opened.should be_empty - @project.issues.closed.should_not be_empty - end - - it "return success" do + it { result = Issues::BulkUpdateContext.new(@project, @user, @params).execute result[:success].should be_true result[:count].should == @issues.count - end + + @project.issues.opened.should be_empty + @project.issues.closed.should_not be_empty + } end describe :reopen_issues do before do - @user = create :user - opts = { - name: "GitLab" - } - @project = create_project(@user, opts) @issues = 5.times.collect do create(:closed_issue, project: @project) end @@ -53,25 +51,60 @@ describe Issues::BulkUpdateContext do issues_ids: @issues.map(&:id) } } - end - it "reopen issues" do - Issues::BulkUpdateContext.new(@project, @user, @params).execute + it { + result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result[:success].should be_true + result[:count].should == @issues.count + @project.issues.closed.should be_empty @project.issues.opened.should_not be_empty + } + + end + + describe :update_assignee do + + before do + @new_assignee = create :user + @params = { + update: { + issues_ids: [issue.id], + assignee_id: @new_assignee.id + } + } end - it "return success" do + it { result = Issues::BulkUpdateContext.new(@project, @user, @params).execute result[:success].should be_true - result[:count].should == @issues.count - end + result[:count].should == 1 + + @project.issues.first.assignee.should == @new_assignee + } end - def create_project(user, opts) - Projects::CreateContext.new(user, opts).execute + describe :update_milestone do + + before do + @milestone = create :milestone + @params = { + update: { + issues_ids: [issue.id], + milestone_id: @milestone.id + } + } + end + + it { + result = Issues::BulkUpdateContext.new(@project, @user, @params).execute + result[:success].should be_true + result[:count].should == 1 + + @project.issues.first.milestone.should == @milestone + } end -end +end |