diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
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 | 37 |
1 files changed, 36 insertions, 1 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 46fc2cbdc9b..2ea98002de1 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 @@ -184,6 +184,41 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET status' do expect(json_response.dig("provider_repos").count).to eq(1) end end + + context 'when namespace_id query param is provided' do + let_it_be(:current_user) { create(:user) } + + let(:namespace) { create(:namespace) } + + before do + allow(controller).to receive(:current_user).and_return(current_user) + end + + context 'when user is allowed to create projects in this namespace' do + before do + allow(current_user).to receive(:can?).and_return(true) + end + + it 'provides namespace to the template' do + get :status, params: { namespace_id: namespace.id }, format: :html + + expect(response).to have_gitlab_http_status :ok + expect(assigns(:namespace)).to eq(namespace) + end + end + + context 'when user is not allowed to create projects in this namespace' do + before do + allow(current_user).to receive(:can?).and_return(false) + end + + it 'renders 404' do + get :status, params: { namespace_id: namespace.id }, format: :html + + expect(response).to have_gitlab_http_status :not_found + end + end + end end end @@ -515,7 +550,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET realtime_changes' do get :realtime_changes - expect(json_response).to eq([{ "id" => project.id, "import_status" => project.import_status }]) + expect(json_response).to match([a_hash_including({ "id" => project.id, "import_status" => project.import_status })]) expect(Integer(response.headers['Poll-Interval'])).to be > -1 end end |