Commit d79592a7f613f47e2dce67184ca3e2106658e2e5
1 parent
31f007f7
Exists in
master
and in
4 other branches
Added spec on bulk issues update
Showing
1 changed file
with
77 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,77 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe Issues::BulkUpdateContext do | |
4 | + | |
5 | + describe :close_issue do | |
6 | + | |
7 | + before do | |
8 | + @user = create :user | |
9 | + opts = { | |
10 | + name: "GitLab" | |
11 | + } | |
12 | + @project = create_project(@user, opts) | |
13 | + @issues = 5.times.collect do | |
14 | + create(:issue, project: @project) | |
15 | + end | |
16 | + @params = { | |
17 | + update: { | |
18 | + status: 'closed', | |
19 | + issues_ids: @issues.map(&:id) | |
20 | + } | |
21 | + } | |
22 | + | |
23 | + end | |
24 | + | |
25 | + it "close issues" do | |
26 | + Issues::BulkUpdateContext.new(@project, @user, @params).execute | |
27 | + @project.issues.opened.should be_empty | |
28 | + @project.issues.closed.should_not be_empty | |
29 | + end | |
30 | + | |
31 | + it "return success" do | |
32 | + result = Issues::BulkUpdateContext.new(@project, @user, @params).execute | |
33 | + result[:success].should be_true | |
34 | + result[:count].should == @issues.count | |
35 | + end | |
36 | + | |
37 | + end | |
38 | + | |
39 | + describe :reopen_issues do | |
40 | + | |
41 | + before do | |
42 | + @user = create :user | |
43 | + opts = { | |
44 | + name: "GitLab" | |
45 | + } | |
46 | + @project = create_project(@user, opts) | |
47 | + @issues = 5.times.collect do | |
48 | + create(:closed_issue, project: @project) | |
49 | + end | |
50 | + @params = { | |
51 | + update: { | |
52 | + status: 'reopen', | |
53 | + issues_ids: @issues.map(&:id) | |
54 | + } | |
55 | + } | |
56 | + | |
57 | + end | |
58 | + | |
59 | + it "reopen issues" do | |
60 | + Issues::BulkUpdateContext.new(@project, @user, @params).execute | |
61 | + @project.issues.closed.should be_empty | |
62 | + @project.issues.opened.should_not be_empty | |
63 | + end | |
64 | + | |
65 | + it "return success" do | |
66 | + result = Issues::BulkUpdateContext.new(@project, @user, @params).execute | |
67 | + result[:success].should be_true | |
68 | + result[:count].should == @issues.count | |
69 | + end | |
70 | + | |
71 | + end | |
72 | + | |
73 | + def create_project(user, opts) | |
74 | + Projects::CreateContext.new(user, opts).execute | |
75 | + end | |
76 | +end | |
77 | + | ... | ... |