diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2019-08-12 12:58:05 +0000 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2019-08-12 12:58:05 +0000 |
commit | d2ecbd747b148d965a7f7ab4f438ad02ca21faf9 (patch) | |
tree | c50c706adde38e29b7b9cd4b0da2abe56f1de739 /spec | |
parent | 832824f46eced9c5e781bd41082a4743600fb050 (diff) | |
parent | 485b8b86edaeed1ba3a8bf55df23ca6cbc1f015b (diff) | |
download | gitlab-ce-d2ecbd747b148d965a7f7ab4f438ad02ca21faf9.tar.gz |
Merge branch 'georgekoltsov/51260-add-filtering-to-bitbucket-server-import' into 'master'
Add BitBucketServerImport project filtering
See merge request gitlab-org/gitlab-ce!31420
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/import/bitbucket_server_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/bitbucket_server/client_spec.rb | 11 |
2 files changed, 24 insertions, 1 deletions
diff --git a/spec/controllers/import/bitbucket_server_controller_spec.rb b/spec/controllers/import/bitbucket_server_controller_spec.rb index b89d7317b9c..e1aeab46fca 100644 --- a/spec/controllers/import/bitbucket_server_controller_spec.rb +++ b/spec/controllers/import/bitbucket_server_controller_spec.rb @@ -134,6 +134,8 @@ describe Import::BitbucketServerController do describe 'GET status' do render_views + let(:repos) { instance_double(BitbucketServer::Collection) } + before do allow(controller).to receive(:bitbucket_client).and_return(client) @@ -145,7 +147,6 @@ describe Import::BitbucketServerController do it 'assigns repository categories' do created_project = create(:project, :import_finished, import_type: 'bitbucket_server', creator_id: user.id, import_source: @created_repo.browse_url) - repos = instance_double(BitbucketServer::Collection) expect(repos).to receive(:partition).and_return([[@repo, @created_repo], [@invalid_repo]]) expect(repos).to receive(:current_page).and_return(1) @@ -159,6 +160,17 @@ describe Import::BitbucketServerController do expect(assigns(:repos)).to eq([@repo]) expect(assigns(:incompatible_repos)).to eq([@invalid_repo]) end + + context 'when filtering' do + let(:filter) { 'test' } + + it 'passes filter param to bitbucket client' do + expect(repos).to receive(:partition).and_return([[@repo, @created_repo], [@invalid_repo]]) + expect(client).to receive(:repos).with(filter: filter, limit: 25, page_offset: 0).and_return(repos) + + get :status, params: { filter: filter }, as: :json + end + end end describe 'GET jobs' do diff --git a/spec/lib/bitbucket_server/client_spec.rb b/spec/lib/bitbucket_server/client_spec.rb index 988710b7c4d..aa0217856ee 100644 --- a/spec/lib/bitbucket_server/client_spec.rb +++ b/spec/lib/bitbucket_server/client_spec.rb @@ -58,6 +58,17 @@ describe BitbucketServer::Client do subject.repos(page_offset: 10, limit: 25) end + + context 'when filter param is passed' do + let(:filter) { 'test' } + let(:expected_path) { "#{path}?name=#{filter}" } + + it 'requests a collection with filter applied' do + expect(BitbucketServer::Paginator).to receive(:new).with(anything, expected_path, :repo, page_offset: 0, limit: nil) + + subject.repos(filter: filter) + end + end end describe '#create_branch' do |