diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-02-16 11:40:06 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-02-16 11:40:06 +0000 |
commit | 8db62f25480562e8497c3fb6d9f4611fc5902d94 (patch) | |
tree | e02c69ae311f6fd734b55dec865c54727da13132 /spec | |
parent | 1563caf4375bcb63f1a4ac3fa4897263c3c3f98c (diff) | |
parent | f5ab126fd0e607811638ca36b6752d5c74535adf (diff) | |
download | gitlab-ce-8db62f25480562e8497c3fb6d9f4611fc5902d94.tar.gz |
Merge branch 'rs-issue-13467' into 'master'
Ensure Commit#show responds 404 instead of 500 when given an invalid ID
Closes #13467
See merge request !2823
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/commit_controller_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb new file mode 100644 index 00000000000..438e776ec4b --- /dev/null +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -0,0 +1,37 @@ +require 'rails_helper' + +describe Projects::CommitController do + describe 'GET show' do + let(:project) { create(:project) } + + before do + user = create(:user) + project.team << [user, :master] + + sign_in(user) + end + + context 'with valid id' do + it 'responds with 200' do + go id: project.commit.id + + expect(response).to be_ok + end + end + + context 'with invalid id' do + it 'responds with 404' do + go id: project.commit.id.reverse + + expect(response).to be_not_found + end + end + + def go(id:) + get :show, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + id: id + end + end +end |