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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
3568c68e
Commit
3568c68e
authored
Apr 03, 2019
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract EE specific files/lines for Discussion spec/services
Part of moving GitLab into single codebase
parent
39d4ee8c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
134 deletions
+137
-134
ee/spec/services/system_note_service_spec.rb
ee/spec/services/system_note_service_spec.rb
+134
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+3
-133
No files found.
ee/spec/services/system_note_service_spec.rb
View file @
3568c68e
# frozen_string_literal: true
require
'spec_helper'
require
'spec_helper'
describe
SystemNoteService
do
describe
SystemNoteService
do
...
@@ -6,7 +8,7 @@ describe SystemNoteService do
...
@@ -6,7 +8,7 @@ describe SystemNoteService do
include
RepoHelpers
include
RepoHelpers
set
(
:group
)
{
create
(
:group
)
}
set
(
:group
)
{
create
(
:group
)
}
l
et
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
s
et
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
set
(
:author
)
{
create
(
:user
)
}
set
(
:author
)
{
create
(
:user
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
noteable
}
let
(
:issue
)
{
noteable
}
...
@@ -36,6 +38,68 @@ describe SystemNoteService do
...
@@ -36,6 +38,68 @@ describe SystemNoteService do
it_behaves_like
'a system note'
it_behaves_like
'a system note'
end
end
describe
'.relate_issue'
do
let
(
:noteable_ref
)
{
create
(
:issue
)
}
subject
{
described_class
.
relate_issue
(
noteable
,
noteable_ref
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'relate'
}
end
context
'when issue marks another as related'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"marked this issue as related to
#{
noteable_ref
.
to_reference
(
project
)
}
"
end
end
end
describe
'.unrelate_issue'
do
let
(
:noteable_ref
)
{
create
(
:issue
)
}
subject
{
described_class
.
unrelate_issue
(
noteable
,
noteable_ref
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'unrelate'
}
end
context
'when issue relation is removed'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"removed the relation with
#{
noteable_ref
.
to_reference
(
project
)
}
"
end
end
end
describe
'.approve_mr'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
{
described_class
.
approve_mr
(
noteable
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'approved'
}
end
context
'when merge request approved'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"approved this merge request"
end
end
end
describe
'.unapprove_mr'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
{
described_class
.
unapprove_mr
(
noteable
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'unapproved'
}
end
context
'when merge request approved'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"unapproved this merge request"
end
end
end
describe
'.change_weight_note'
do
describe
'.change_weight_note'
do
context
'when weight changed'
do
context
'when weight changed'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
,
title:
'Lorem ipsum'
,
weight:
4
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
,
title:
'Lorem ipsum'
,
weight:
4
)
}
...
@@ -124,4 +188,73 @@ describe SystemNoteService do
...
@@ -124,4 +188,73 @@ describe SystemNoteService do
end
end
end
end
end
end
describe
'.epic_issue'
do
let
(
:noteable
)
{
epic
}
let
(
:project
)
{
nil
}
context
'issue added to an epic'
do
subject
{
described_class
.
epic_issue
(
epic
,
issue
,
author
,
:added
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'epic_issue_added'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"added issue
#{
issue
.
to_reference
(
epic
.
group
)
}
"
)
end
end
context
'issue removed from an epic'
do
subject
{
described_class
.
epic_issue
(
epic
,
issue
,
author
,
:removed
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'epic_issue_removed'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"removed issue
#{
issue
.
to_reference
(
epic
.
group
)
}
"
)
end
end
context
'invalid type'
do
it
'raises an error'
do
expect
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:invalid
)
}
.
not_to
change
{
Note
.
count
}
end
end
end
describe
'.issue_on_epic'
do
context
'issue added to an epic'
do
subject
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:added
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'issue_added_to_epic'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"added to epic
#{
epic
.
to_reference
(
issue
.
project
)
}
"
)
end
end
context
'issue removed from an epic'
do
subject
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:removed
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'issue_removed_from_epic'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"removed from epic
#{
epic
.
to_reference
(
issue
.
project
)
}
"
)
end
end
context
'invalid type'
do
it
'does not create a new note'
do
expect
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:invalid
)
}
.
not_to
change
{
Note
.
count
}
end
end
end
end
end
spec/services/system_note_service_spec.rb
View file @
3568c68e
# frozen_string_literal: true
require
'spec_helper'
require
'spec_helper'
describe
SystemNoteService
do
describe
SystemNoteService
do
...
@@ -7,11 +9,10 @@ describe SystemNoteService do
...
@@ -7,11 +9,10 @@ describe SystemNoteService do
include
AssetsHelpers
include
AssetsHelpers
set
(
:group
)
{
create
(
:group
)
}
set
(
:group
)
{
create
(
:group
)
}
l
et
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
s
et
(
:project
)
{
create
(
:project
,
:repository
,
group:
group
)
}
set
(
:author
)
{
create
(
:user
)
}
set
(
:author
)
{
create
(
:user
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
let
(
:issue
)
{
noteable
}
let
(
:issue
)
{
noteable
}
let
(
:epic
)
{
create
(
:epic
)
}
shared_examples_for
'a system note'
do
shared_examples_for
'a system note'
do
let
(
:expected_noteable
)
{
noteable
}
let
(
:expected_noteable
)
{
noteable
}
...
@@ -898,68 +899,6 @@ describe SystemNoteService do
...
@@ -898,68 +899,6 @@ describe SystemNoteService do
end
end
end
end
describe
'.relate_issue'
do
let
(
:noteable_ref
)
{
create
(
:issue
)
}
subject
{
described_class
.
relate_issue
(
noteable
,
noteable_ref
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'relate'
}
end
context
'when issue marks another as related'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"marked this issue as related to
#{
noteable_ref
.
to_reference
(
project
)
}
"
end
end
end
describe
'.unrelate_issue'
do
let
(
:noteable_ref
)
{
create
(
:issue
)
}
subject
{
described_class
.
unrelate_issue
(
noteable
,
noteable_ref
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'unrelate'
}
end
context
'when issue relation is removed'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"removed the relation with
#{
noteable_ref
.
to_reference
(
project
)
}
"
end
end
end
describe
'.approve_mr'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
{
described_class
.
approve_mr
(
noteable
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'approved'
}
end
context
'when merge request approved'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"approved this merge request"
end
end
end
describe
'.unapprove_mr'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
subject
{
described_class
.
unapprove_mr
(
noteable
,
author
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'unapproved'
}
end
context
'when merge request approved'
do
it
'sets the note text'
do
expect
(
subject
.
note
).
to
eq
"unapproved this merge request"
end
end
end
describe
'.change_time_estimate'
do
describe
'.change_time_estimate'
do
subject
{
described_class
.
change_time_estimate
(
noteable
,
project
,
author
)
}
subject
{
described_class
.
change_time_estimate
(
noteable
,
project
,
author
)
}
...
@@ -1271,73 +1210,4 @@ describe SystemNoteService do
...
@@ -1271,73 +1210,4 @@ describe SystemNoteService do
end
end
end
end
end
end
describe
'.epic_issue'
do
let
(
:noteable
)
{
epic
}
let
(
:project
)
{
nil
}
context
'issue added to an epic'
do
subject
{
described_class
.
epic_issue
(
epic
,
issue
,
author
,
:added
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'epic_issue_added'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"added issue
#{
issue
.
to_reference
(
epic
.
group
)
}
"
)
end
end
context
'issue removed from an epic'
do
subject
{
described_class
.
epic_issue
(
epic
,
issue
,
author
,
:removed
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'epic_issue_removed'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"removed issue
#{
issue
.
to_reference
(
epic
.
group
)
}
"
)
end
end
context
'invalid type'
do
it
'raises an error'
do
expect
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:invalid
)
}
.
not_to
change
{
Note
.
count
}
end
end
end
describe
'.issue_on_epic'
do
context
'issue added to an epic'
do
subject
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:added
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'issue_added_to_epic'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"added to epic
#{
epic
.
to_reference
(
issue
.
project
)
}
"
)
end
end
context
'issue removed from an epic'
do
subject
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:removed
)
}
it_behaves_like
'a system note'
do
let
(
:action
)
{
'issue_removed_from_epic'
}
end
it
'creates the note text correctly'
do
expect
(
subject
.
note
).
to
eq
(
"removed from epic
#{
epic
.
to_reference
(
issue
.
project
)
}
"
)
end
end
context
'invalid type'
do
it
'does not create a new note'
do
expect
{
described_class
.
issue_on_epic
(
issue
,
epic
,
author
,
:invalid
)
}
.
not_to
change
{
Note
.
count
}
end
end
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