Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
6e8cb844
Commit
6e8cb844
authored
May 16, 2013
by
AlexDenisov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added few tests on Issues::BulkUpdateContext
parent
d08e1db9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
37 deletions
+70
-37
app/contexts/issues/bulk_update_context.rb
app/contexts/issues/bulk_update_context.rb
+9
-9
spec/contexts/issues/bulk_update_context_spec.rb
spec/contexts/issues/bulk_update_context_spec.rb
+61
-28
No files found.
app/contexts/issues/bulk_update_context.rb
View file @
6e8cb844
...
...
@@ -8,11 +8,14 @@ module Issues
assignee_id
=
update_data
[
:assignee_id
]
status
=
update_data
[
:status
]
unless
status
.
present?
return
{
count:
0
,
success:
false
}
new_state
=
nil
if
status
.
present?
if
status
==
'closed'
new_state
=
:close
else
new_state
=
:reopen
end
end
opts
=
{}
...
...
@@ -22,12 +25,9 @@ module Issues
issues
=
Issue
.
where
(
id:
issues_ids
).
all
issues
=
issues
.
select
{
|
issue
|
can?
(
current_user
,
:modify_issue
,
issue
)
}
new_state
=
:reopen
new_state
=
:close
if
status
==
'closed'
issues
.
each
do
|
issue
|
issue
.
update_attributes
(
opts
)
issue
.
send
new_state
issue
.
send
new_state
if
new_state
end
{
...
...
spec/contexts/issues/bulk_update_context_spec.rb
View file @
6e8cb844
...
...
@@ -2,14 +2,21 @@ require 'spec_helper'
describe
Issues
::
BulkUpdateContext
do
describe
:close_issue
do
let
(
:issue
)
{
create
(
:issue
,
project:
@project
)
}
before
do
@user
=
create
:user
opts
=
{
name:
"GitLab"
}
@project
=
create_project
(
@user
,
opts
)
@project
=
Projects
::
CreateContext
.
new
(
@user
,
opts
).
execute
end
describe
:close_issue
do
before
do
@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
it
"return success"
do
describe
:update_assignee
do
before
do
@new_assignee
=
create
:user
@params
=
{
update:
{
issues_ids:
[
issue
.
id
],
assignee_id:
@new_assignee
.
id
}
}
end
it
{
result
=
Issues
::
BulkUpdateContext
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
result
[
:count
].
should
==
@issues
.
count
result
[
:count
].
should
==
1
@project
.
issues
.
first
.
assignee
.
should
==
@new_assignee
}
end
describe
:update_milestone
do
before
do
@milestone
=
create
:milestone
@params
=
{
update:
{
issues_ids:
[
issue
.
id
],
milestone_id:
@milestone
.
id
}
}
end
def
create_project
(
user
,
opts
)
Projects
::
CreateContext
.
new
(
user
,
opts
).
execute
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment