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
Léo-Paul Géneau
gitlab-ce
Commits
8cfc6a4d
Commit
8cfc6a4d
authored
May 16, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3956 from AlexDenisov/issues_bulk_update
Issues bulk update
parents
d7c65534
6e8cb844
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
121 additions
and
8 deletions
+121
-8
app/contexts/issues/bulk_update_context.rb
app/contexts/issues/bulk_update_context.rb
+11
-8
spec/contexts/issues/bulk_update_context_spec.rb
spec/contexts/issues/bulk_update_context_spec.rb
+110
-0
No files found.
app/contexts/issues/bulk_update_context.rb
View file @
8cfc6a4d
...
@@ -8,6 +8,16 @@ module Issues
...
@@ -8,6 +8,16 @@ module Issues
assignee_id
=
update_data
[
:assignee_id
]
assignee_id
=
update_data
[
:assignee_id
]
status
=
update_data
[
:status
]
status
=
update_data
[
:status
]
new_state
=
nil
if
status
.
present?
if
status
==
'closed'
new_state
=
:close
else
new_state
=
:reopen
end
end
opts
=
{}
opts
=
{}
opts
[
:milestone_id
]
=
milestone_id
if
milestone_id
.
present?
opts
[
:milestone_id
]
=
milestone_id
if
milestone_id
.
present?
opts
[
:assignee_id
]
=
assignee_id
if
assignee_id
.
present?
opts
[
:assignee_id
]
=
assignee_id
if
assignee_id
.
present?
...
@@ -17,14 +27,7 @@ module Issues
...
@@ -17,14 +27,7 @@ module Issues
issues
.
each
do
|
issue
|
issues
.
each
do
|
issue
|
issue
.
update_attributes
(
opts
)
issue
.
update_attributes
(
opts
)
issue
.
send
new_state
if
new_state
if
status
.
present?
if
status
==
'closed'
issue
.
close
else
issue
.
reopen
end
end
end
end
{
{
...
...
spec/contexts/issues/bulk_update_context_spec.rb
0 → 100644
View file @
8cfc6a4d
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
@issues
=
5
.
times
.
collect
do
create
(
:issue
,
project:
@project
)
end
@params
=
{
update:
{
status:
'closed'
,
issues_ids:
@issues
.
map
(
&
:id
)
}
}
end
it
{
result
=
Issues
::
BulkUpdateContext
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
result
[
:count
].
should
==
@issues
.
count
@project
.
issues
.
opened
.
should
be_empty
@project
.
issues
.
closed
.
should_not
be_empty
}
end
describe
:reopen_issues
do
before
do
@issues
=
5
.
times
.
collect
do
create
(
:closed_issue
,
project:
@project
)
end
@params
=
{
update:
{
status:
'reopen'
,
issues_ids:
@issues
.
map
(
&
:id
)
}
}
end
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
{
result
=
Issues
::
BulkUpdateContext
.
new
(
@project
,
@user
,
@params
).
execute
result
[
:success
].
should
be_true
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
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
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