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
debb65b5
Commit
debb65b5
authored
Aug 29, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update service specs to avoid instance variables
parent
44340fed
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
40 deletions
+40
-40
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+9
-9
spec/services/issues/reopen_service_spec.rb
spec/services/issues/reopen_service_spec.rb
+2
-2
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+29
-29
No files found.
spec/services/issues/close_service_spec.rb
View file @
debb65b5
...
...
@@ -18,12 +18,12 @@ describe Issues::CloseService, services: true do
context
"valid params"
do
before
do
perform_enqueued_jobs
do
@issue
=
described_class
.
new
(
project
,
user
).
execute
(
issue
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
end
it
{
expect
(
@
issue
).
to
be_valid
}
it
{
expect
(
@
issue
).
to
be_closed
}
it
{
expect
(
issue
).
to
be_valid
}
it
{
expect
(
issue
).
to
be_closed
}
it
'sends email to user2 about assign of new issue'
do
email
=
ActionMailer
::
Base
.
deliveries
.
last
...
...
@@ -32,7 +32,7 @@ describe Issues::CloseService, services: true do
end
it
'creates system note about issue reassign'
do
note
=
@
issue
.
notes
.
last
note
=
issue
.
notes
.
last
expect
(
note
.
note
).
to
include
"Status changed to closed"
end
...
...
@@ -44,12 +44,12 @@ describe Issues::CloseService, services: true do
context
'current user is not authorized to close issue'
do
before
do
perform_enqueued_jobs
do
@issue
=
described_class
.
new
(
project
,
guest
).
execute
(
issue
)
described_class
.
new
(
project
,
guest
).
execute
(
issue
)
end
end
it
'does not close the issue'
do
expect
(
@
issue
).
to
be_open
expect
(
issue
).
to
be_open
end
end
...
...
@@ -67,11 +67,11 @@ describe Issues::CloseService, services: true do
context
'external issue tracker'
do
before
do
allow
(
project
).
to
receive
(
:default_issues_tracker?
).
and_return
(
false
)
@issue
=
described_class
.
new
(
project
,
user
).
execute
(
issue
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
it
{
expect
(
@
issue
).
to
be_valid
}
it
{
expect
(
@
issue
).
to
be_opened
}
it
{
expect
(
issue
).
to
be_valid
}
it
{
expect
(
issue
).
to
be_opened
}
it
{
expect
(
todo
.
reload
).
to
be_pending
}
end
end
...
...
spec/services/issues/reopen_service_spec.rb
View file @
debb65b5
...
...
@@ -11,12 +11,12 @@ describe Issues::ReopenService, services: true do
project
.
team
<<
[
guest
,
:guest
]
perform_enqueued_jobs
do
@issue
=
described_class
.
new
(
project
,
guest
).
execute
(
issue
)
described_class
.
new
(
project
,
guest
).
execute
(
issue
)
end
end
it
'does not reopen the issue'
do
expect
(
@
issue
).
to
be_closed
expect
(
issue
).
to
be_closed
end
end
...
...
spec/services/issues/update_service_spec.rb
View file @
debb65b5
...
...
@@ -23,14 +23,13 @@ describe Issues::UpdateService, services: true do
describe
'execute'
do
def
find_note
(
starting_with
)
@
issue
.
notes
.
find
do
|
note
|
issue
.
notes
.
find
do
|
note
|
note
&&
note
.
note
.
start_with?
(
starting_with
)
end
end
def
update_issue
(
opts
)
@issue
=
described_class
.
new
(
project
,
user
,
opts
).
execute
(
issue
)
@issue
.
reload
described_class
.
new
(
project
,
user
,
opts
).
execute
(
issue
)
end
context
"valid params"
do
...
...
@@ -44,18 +43,16 @@ describe Issues::UpdateService, services: true do
}
perform_enqueued_jobs
do
@issue
=
described_class
.
new
(
project
,
user
,
opts
).
execute
(
issue
)
update_issue
(
opts
)
end
@issue
.
reload
end
it
{
expect
(
@
issue
).
to
be_valid
}
it
{
expect
(
@
issue
.
title
).
to
eq
(
'New title'
)
}
it
{
expect
(
@
issue
.
assignee
).
to
eq
(
user2
)
}
it
{
expect
(
@
issue
).
to
be_closed
}
it
{
expect
(
@
issue
.
labels
.
count
).
to
eq
(
1
)
}
it
{
expect
(
@
issue
.
labels
.
first
.
title
).
to
eq
(
label
.
name
)
}
it
{
expect
(
issue
).
to
be_valid
}
it
{
expect
(
issue
.
title
).
to
eq
(
'New title'
)
}
it
{
expect
(
issue
.
assignee
).
to
eq
(
user2
)
}
it
{
expect
(
issue
).
to
be_closed
}
it
{
expect
(
issue
.
labels
.
count
).
to
eq
(
1
)
}
it
{
expect
(
issue
.
labels
.
first
.
title
).
to
eq
(
label
.
name
)
}
it
'sends email to user2 about assign of new issue and email to user3 about issue unassignment'
do
deliveries
=
ActionMailer
::
Base
.
deliveries
...
...
@@ -100,7 +97,7 @@ describe Issues::UpdateService, services: true do
end
it
'creates system note about confidentiality change'
do
update_issue
(
{
confidential:
true
}
)
update_issue
(
confidential:
true
)
note
=
find_note
(
'Made the issue confidential'
)
...
...
@@ -112,7 +109,7 @@ describe Issues::UpdateService, services: true do
expect
(
project
).
not_to
receive
(
:execute_hooks
)
expect
(
project
).
not_to
receive
(
:execute_services
)
update_issue
(
{
confidential:
true
}
)
update_issue
(
confidential:
true
)
end
end
...
...
@@ -121,7 +118,7 @@ describe Issues::UpdateService, services: true do
context
'when the title change'
do
before
do
update_issue
(
{
title:
'New title'
}
)
update_issue
(
title:
'New title'
)
end
it
'marks pending todos as done'
do
...
...
@@ -131,7 +128,7 @@ describe Issues::UpdateService, services: true do
context
'when the description change'
do
before
do
update_issue
(
{
description:
'Also please fix'
}
)
update_issue
(
description:
'Also please fix'
)
end
it
'marks todos as done'
do
...
...
@@ -141,7 +138,7 @@ describe Issues::UpdateService, services: true do
context
'when is reassigned'
do
before
do
update_issue
(
{
assignee:
user2
}
)
update_issue
(
assignee:
user2
)
end
it
'marks previous assignee todos as done'
do
...
...
@@ -165,7 +162,7 @@ describe Issues::UpdateService, services: true do
context
'when the milestone change'
do
before
do
update_issue
(
{
milestone:
create
(
:milestone
)
}
)
update_issue
(
milestone:
create
(
:milestone
)
)
end
it
'marks todos as done'
do
...
...
@@ -175,7 +172,7 @@ describe Issues::UpdateService, services: true do
context
'when the labels change'
do
before
do
update_issue
(
{
label_ids:
[
label
.
id
]
}
)
update_issue
(
label_ids:
[
label
.
id
]
)
end
it
'marks todos as done'
do
...
...
@@ -186,6 +183,7 @@ describe Issues::UpdateService, services: true do
context
'when the issue is relabeled'
do
let!
(
:non_subscriber
)
{
create
(
:user
)
}
let!
(
:subscriber
)
do
create
(
:user
).
tap
do
|
u
|
label
.
toggle_subscription
(
u
)
...
...
@@ -232,12 +230,14 @@ describe Issues::UpdateService, services: true do
end
context
'when issue has tasks'
do
before
{
update_issue
({
description:
"- [ ] Task 1
\n
- [ ] Task 2"
})
}
before
do
update_issue
(
description:
"- [ ] Task 1
\n
- [ ] Task 2"
)
end
it
{
expect
(
@
issue
.
tasks?
).
to
eq
(
true
)
}
it
{
expect
(
issue
.
tasks?
).
to
eq
(
true
)
}
context
'when tasks are marked as completed'
do
before
{
update_issue
(
{
description:
"- [x] Task 1
\n
- [X] Task 2"
}
)
}
before
{
update_issue
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
}
it
'creates system note about task status change'
do
note1
=
find_note
(
'Marked the task **Task 1** as completed'
)
...
...
@@ -250,8 +250,8 @@ describe Issues::UpdateService, services: true do
context
'when tasks are marked as incomplete'
do
before
do
update_issue
(
{
description:
"- [x] Task 1
\n
- [X] Task 2"
}
)
update_issue
(
{
description:
"- [ ] Task 1
\n
- [ ] Task 2"
}
)
update_issue
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
update_issue
(
description:
"- [ ] Task 1
\n
- [ ] Task 2"
)
end
it
'creates system note about task status change'
do
...
...
@@ -265,8 +265,8 @@ describe Issues::UpdateService, services: true do
context
'when tasks position has been modified'
do
before
do
update_issue
(
{
description:
"- [x] Task 1
\n
- [X] Task 2"
}
)
update_issue
(
{
description:
"- [x] Task 1
\n
- [ ] Task 3
\n
- [ ] Task 2"
}
)
update_issue
(
description:
"- [x] Task 1
\n
- [X] Task 2"
)
update_issue
(
description:
"- [x] Task 1
\n
- [ ] Task 3
\n
- [ ] Task 2"
)
end
it
'does not create a system note'
do
...
...
@@ -278,8 +278,8 @@ describe Issues::UpdateService, services: true do
context
'when a Task list with a completed item is totally replaced'
do
before
do
update_issue
(
{
description:
"- [ ] Task 1
\n
- [X] Task 2"
}
)
update_issue
(
{
description:
"- [ ] One
\n
- [ ] Two
\n
- [ ] Three"
}
)
update_issue
(
description:
"- [ ] Task 1
\n
- [X] Task 2"
)
update_issue
(
description:
"- [ ] One
\n
- [ ] Two
\n
- [ ] Three"
)
end
it
'does not create a system note referencing the position the old item'
do
...
...
@@ -290,7 +290,7 @@ describe Issues::UpdateService, services: true do
it
'does not generate a new note at all'
do
expect
do
update_issue
(
{
description:
"- [ ] One
\n
- [ ] Two
\n
- [ ] Three"
}
)
update_issue
(
description:
"- [ ] One
\n
- [ ] Two
\n
- [ ] Three"
)
end
.
not_to
change
{
Note
.
count
}
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