diff options
author | bunufi <dainius.stn@gmail.com> | 2018-03-05 12:57:47 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-03-05 12:57:47 +0000 |
commit | 47d4890d3ad8a1c2ecb2b9c497d537c044c76e25 (patch) | |
tree | df257cd59e7af3df53d219b6e8e4e704f5e46f1d /spec | |
parent | bd57be280d6dede47844a23a487a24bbbc49201c (diff) | |
download | gitlab-ce-47d4890d3ad8a1c2ecb2b9c497d537c044c76e25.tar.gz |
Update API: add search param to branches
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/branches_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index e433597f58b..64f51d9843d 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -39,6 +39,27 @@ describe API::Branches do end end + context 'when search parameter is passed' do + context 'and branch exists' do + it 'returns correct branches' do + get api(route, user), per_page: 100, search: branch_name + + searched_branch_names = json_response.map { |branch| branch['name'] } + project_branch_names = project.repository.branch_names.grep(/#{branch_name}/) + + expect(searched_branch_names).to match_array(project_branch_names) + end + end + + context 'and branch does not exist' do + it 'returns an empty array' do + get api(route, user), per_page: 100, search: 'no_such_branch_name_entropy_of_jabadabadu' + + expect(json_response).to eq [] + end + end + end + context 'when unauthenticated', 'and project is public' do before do project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC) |