Commit e2b6e67b authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '338584-test-case-404' into 'master'

Test case return 404 instead of 500 error

See merge request gitlab-org/gitlab!68548
parents 4e0c677d cfc199ab
......@@ -26,7 +26,7 @@ class Projects::Quality::TestCasesController < Projects::ApplicationController
.execute
.iid_in(params[:id])
.without_order
.first
.take! # rubocop: disable CodeReuse/ActiveRecord
serializer = IssueSerializer.new(current_user: current_user, project: project)
......
......@@ -108,6 +108,16 @@ RSpec.describe Projects::Quality::TestCasesController do
expect(assigns(:test_case)).to eq(test_case)
expect(assigns(:issuable_sidebar)).to be_present
end
context 'when test case is not found' do
let(:test_case) { non_existing_record_id }
it 'returns 404' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
end
......
......@@ -179,4 +179,18 @@ RSpec.describe 'Test Cases', :js do
end
end
end
describe 'for a nonexistent test case' do
let(:test_case) { non_existing_record_id }
it 'renders 404 page' do
requests = inspect_requests do
visit project_quality_test_case_path(project, test_case)
wait_for_all_requests
end
expect(requests.first.status_code).to eq(404)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment