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
3fdccc12
Commit
3fdccc12
authored
Apr 27, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust Issue references pluralization on success message
parent
a2f93a75
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
6 deletions
+45
-6
app/services/related_issues/create_service.rb
app/services/related_issues/create_service.rb
+7
-1
spec/services/related_issues/create_service_spec.rb
spec/services/related_issues/create_service_spec.rb
+38
-5
No files found.
app/services/related_issues/create_service.rb
View file @
3fdccc12
...
...
@@ -15,7 +15,7 @@ module RelatedIssues
return
error
(
exception
.
message
,
401
)
end
success
(
message:
"
#{
issues_sentence
(
referenced_issues
)
}
were successfully related"
)
success
_message
end
private
...
...
@@ -50,6 +50,12 @@ module RelatedIssues
end
end
def
success_message
verb
=
referenced_issues
.
size
>
1
?
'were'
:
'was'
success
(
message:
"
#{
issues_sentence
(
referenced_issues
)
}
#{
verb
}
successfully related"
)
end
def
issues_sentence
(
issues
)
issues
.
map
{
|
issue
|
issue
.
to_reference
(
@issue
.
project
)
}.
sort
.
to_sentence
end
...
...
spec/services/related_issues/create_service_spec.rb
View file @
3fdccc12
...
...
@@ -16,7 +16,7 @@ describe RelatedIssues::CreateService, service: true do
subject
{
described_class
.
new
(
issue
,
user
,
params
).
execute
}
context
'when
i
ssue not found'
do
context
'when
I
ssue not found'
do
let
(
:params
)
do
{
issue_references:
[
'#999'
]
}
end
...
...
@@ -46,7 +46,7 @@ describe RelatedIssues::CreateService, service: true do
end
end
context
'when a
ll Issue references are valid
'
do
context
'when a
ny Issue to relate
'
do
let
(
:issue_a
)
{
create
:issue
,
project:
project
}
let
(
:another_project
)
{
create
:empty_project
,
namespace:
project
.
namespace
}
let
(
:another_project_issue
)
{
create
:issue
,
project:
another_project
}
...
...
@@ -69,9 +69,9 @@ describe RelatedIssues::CreateService, service: true do
expect
(
RelatedIssue
.
last
).
to
have_attributes
(
issue:
issue
,
related_issue:
another_project_issue
)
end
it
'returns success message with Issue references
'
do
is_expected
.
to
eq
(
message:
"
#{
issue_a_ref
}
and
#{
another_project_issue_ref
}
were successfully related"
,
status: :success
)
end
it
'returns success message with Issue reference
'
do
is_expected
.
to
eq
(
message:
"
#{
issue_a_ref
}
and
#{
another_project_issue_ref
}
were successfully related"
,
status: :success
)
end
it
'creates notes'
do
# First two-way relation notes
...
...
@@ -90,6 +90,39 @@ describe RelatedIssues::CreateService, service: true do
end
end
context
'success message'
do
let
(
:issue_a
)
{
create
:issue
,
project:
project
}
let
(
:another_project
)
{
create
:empty_project
,
namespace:
project
.
namespace
}
let
(
:another_project_issue
)
{
create
:issue
,
project:
another_project
}
let
(
:issue_a_ref
)
{
issue_a
.
to_reference
}
let
(
:another_project_issue_ref
)
{
another_project_issue
.
to_reference
(
project
)
}
before
do
another_project
.
team
<<
[
user
,
:developer
]
end
context
'multiple Issues relation'
do
let
(
:params
)
do
{
issue_references:
[
issue_a_ref
,
another_project_issue_ref
]
}
end
it
'returns success message with Issue reference'
do
is_expected
.
to
eq
(
message:
"
#{
issue_a_ref
}
and
#{
another_project_issue_ref
}
were successfully related"
,
status: :success
)
end
end
context
'single Issue relation'
do
let
(
:params
)
do
{
issue_references:
[
issue_a_ref
]
}
end
it
'returns success message with Issue reference'
do
is_expected
.
to
eq
(
message:
"
#{
issue_a_ref
}
was successfully related"
,
status: :success
)
end
end
end
context
'when relation already exists'
do
let
(
:issue_a
)
{
create
:issue
,
project:
project
}
let
(
:issue_b
)
{
create
:issue
,
project:
project
}
...
...
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