diff options
Diffstat (limited to 'spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb b/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb index 2fcc88ef36a..5a4322f73b6 100644 --- a/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb +++ b/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb @@ -145,6 +145,8 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do group.add_owner(user) client = stub_client(repos: repos, orgs: [org], org_repos: [org_repo]) allow(client).to receive(:each_page).and_return([OpenStruct.new(objects: repos)].to_enum) + # GitHub controller has filtering done using GitHub Search API + stub_feature_flags(remove_legacy_github_client: false) end it 'filters list of repositories by name' do @@ -157,6 +159,16 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do expect(json_response.dig("namespaces", 0, "id")).to eq(group.id) end + it 'filters the list, ignoring the case of the name' do + get :status, params: { filter: 'EMACS' }, format: :json + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response.dig("imported_projects").count).to eq(0) + expect(json_response.dig("provider_repos").count).to eq(1) + expect(json_response.dig("provider_repos", 0, "id")).to eq(repo_2.id) + expect(json_response.dig("namespaces", 0, "id")).to eq(group.id) + end + context 'when user input contains html' do let(:expected_filter) { 'test' } let(:filter) { "<html>#{expected_filter}</html>" } @@ -167,6 +179,23 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do expect(assigns(:filter)).to eq(expected_filter) end end + + context 'when the client returns a non-string name' do + before do + repos = [build(:project, name: 2, path: 'test')] + + client = stub_client(repos: repos) + allow(client).to receive(:each_page).and_return([OpenStruct.new(objects: repos)].to_enum) + end + + it 'does not raise an error' do + get :status, params: { filter: '2' }, format: :json + + expect(response).to have_gitlab_http_status :ok + + expect(json_response.dig("provider_repos").count).to eq(1) + end + end end end |