diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-03-20 23:36:53 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-03-21 14:20:15 -0300 |
commit | 86ef67eee559c536e159673b26fb524c92d2eb82 (patch) | |
tree | 6ecc2205a9a817293b08bd172bf5b1f21219f198 /spec/controllers | |
parent | 4ea85da9fb99bc4d875cc3dc644476f34f0b8bc3 (diff) | |
download | gitlab-ce-86ef67eee559c536e159673b26fb524c92d2eb82.tar.gz |
Present ajax call errors when failing to update an Issue
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/issues_controller_spec.rb | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 57a921e3676..c467ab9fb8a 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -241,10 +241,27 @@ describe Projects::IssuesController do expect(spam_logs.first.recaptcha_verified).to be_falsey end - it 'renders verify template' do - update_spam_issue + context 'as HTML' do + it 'renders verify template' do + update_spam_issue + + expect(response).to render_template(:verify) + 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 - expect(response).to render_template(:verify) + it 'returns 422 status' do + expect(response).to have_http_status(422) + end end end |