diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2019-03-09 15:22:58 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-03-09 15:22:58 +0300 |
commit | de784ac10516ec1e1c93d164f3d99b2ff09e5889 (patch) | |
tree | fd3e0a4d845545f2ffa72e82294394a2139a4e50 /spec/controllers/autocomplete_controller_spec.rb | |
parent | 6908c5f70eb4d5d7e8ef28b43d73d71da9b2a0c3 (diff) |
Filter merge requests by target branch
Diffstat (limited to 'spec/controllers/autocomplete_controller_spec.rb')
-rw-r--r-- | spec/controllers/autocomplete_controller_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb index 4458a7223bf..d8b75c5151e 100644 --- a/spec/controllers/autocomplete_controller_spec.rb +++ b/spec/controllers/autocomplete_controller_spec.rb @@ -371,5 +371,36 @@ describe AutocompleteController do expect(json_response[3]).to match('name' => 'thumbsdown') end end + + context 'Get merge_request_target_branches' do + let(:user2) { create(:user) } + let!(:merge_request1) { create(:merge_request, source_project: project, target_branch: 'feature') } + + context 'unauthorized user' do + it 'returns empty json' do + get :merge_request_target_branches + + expect(json_response).to be_empty + end + end + + context 'sign in as user without any accesible merge requests' do + it 'returns empty json' do + sign_in(user2) + get :merge_request_target_branches + + expect(json_response).to be_empty + end + end + + context 'sign in as user with a accesible merge request' do + it 'returns json' do + sign_in(user) + get :merge_request_target_branches + + expect(json_response).to contain_exactly({ 'title' => 'feature' }) + end + end + end end end |