summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/discussions_controller_spec.rb
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2018-04-05 11:23:57 -0300
committerOswaldo Ferreira <oswaldo@gitlab.com>2018-04-05 12:13:42 -0300
commit07f516d167b935acce6289a656872bad9a88b0ac (patch)
treea7efacbe1337f02eb2532ea1e1c968f5ef1f642e /spec/controllers/projects/discussions_controller_spec.rb
parent166b4575a6353668c894fea0ba234d0b371dee03 (diff)
downloadgitlab-ce-07f516d167b935acce6289a656872bad9a88b0ac.tar.gz
Adjust 404's for LegacyDiffNote discussion rendering
Diffstat (limited to 'spec/controllers/projects/discussions_controller_spec.rb')
-rw-r--r--spec/controllers/projects/discussions_controller_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/controllers/projects/discussions_controller_spec.rb b/spec/controllers/projects/discussions_controller_spec.rb
index fcb0c2f28c8..53647749a60 100644
--- a/spec/controllers/projects/discussions_controller_spec.rb
+++ b/spec/controllers/projects/discussions_controller_spec.rb
@@ -16,6 +16,53 @@ describe Projects::DiscussionsController do
}
end
+ describe 'GET show' do
+ before do
+ sign_in user
+ end
+
+ context 'when user is not authorized to read the MR' do
+ it 'returns 404' do
+ get :show, request_params, format: :json
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+
+ context 'when user is authorized to read the MR' do
+ before do
+ project.add_reporter(user)
+ end
+
+ it 'returns status 200' do
+ get :show, request_params, format: :json
+
+ expect(response).to have_gitlab_http_status(200)
+ end
+
+ it 'returns status 404 if MR does not exists' do
+ merge_request.destroy!
+
+ get :show, request_params, format: :json
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+ end
+
+ context 'when user is authorized but note is LegacyDiffNote' do
+ before do
+ project.add_developer(user)
+ note.update!(type: 'LegacyDiffNote')
+ end
+
+ it 'returns status 200' do
+ get :show, request_params, format: :json
+
+ expect(response).to have_gitlab_http_status(200)
+ end
+ end
+ end
+
describe 'POST resolve' do
before do
sign_in user