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
86ef67ee
Commit
86ef67ee
authored
Mar 20, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Present ajax call errors when failing to update an Issue
parent
4ea85da9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+8
-1
app/models/concerns/spammable.rb
app/models/concerns/spammable.rb
+1
-1
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+20
-3
No files found.
app/controllers/projects/issues_controller.rb
View file @
86ef67ee
...
...
@@ -148,7 +148,14 @@ class Projects::IssuesController < Projects::ApplicationController
end
format
.
json
do
render
json:
@issue
.
to_json
(
include:
{
milestone:
{},
assignee:
{
only:
[
:name
,
:username
],
methods:
[
:avatar_url
]
},
labels:
{
methods: :text_color
}
},
methods:
[
:task_status
,
:task_status_short
])
if
@issue
.
valid?
render
json:
@issue
.
to_json
(
methods:
[
:task_status
,
:task_status_short
],
include:
{
milestone:
{},
assignee:
{
only:
[
:name
,
:username
],
methods:
[
:avatar_url
]
},
labels:
{
methods: :text_color
}
})
else
render
json:
{
errors:
@issue
.
errors
.
full_messages
},
status: :unprocessable_entity
end
end
end
...
...
app/models/concerns/spammable.rb
View file @
86ef67ee
...
...
@@ -41,7 +41,7 @@ module Spammable
def
check_for_spam
error_msg
=
if
Gitlab
::
Recaptcha
.
enabled?
"Your
#{
spammable_entity_type
}
has been recognized as spam. "
\
"
You can still submit it by solving Captcha
."
"
Please, change the content or solve the reCAPTCHA to proceed
."
else
"Your
#{
spammable_entity_type
}
has been recognized as spam and has been discarded."
end
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
86ef67ee
...
...
@@ -241,6 +241,7 @@ describe Projects::IssuesController do
expect
(
spam_logs
.
first
.
recaptcha_verified
).
to
be_falsey
end
context
'as HTML'
do
it
'renders verify template'
do
update_spam_issue
...
...
@@ -248,6 +249,22 @@ describe Projects::IssuesController do
end
end
context
'as JSON'
do
before
do
update_issue
({
title:
'Spam Title'
,
description:
'Spam lives here'
},
format: :json
)
end
it
'renders json errors'
do
expect
(
json_response
)
.
to
eql
(
"errors"
=>
[
"Your issue has been recognized as spam. Please, change the content or solve the reCAPTCHA to proceed."
])
end
it
'returns 422 status'
do
expect
(
response
).
to
have_http_status
(
422
)
end
end
end
context
'when captcha is verified'
do
let
(
:spammy_title
)
{
'Whatever'
}
let!
(
:spam_logs
)
{
create_list
(
:spam_log
,
2
,
user:
user
,
title:
spammy_title
)
}
...
...
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