summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb
diff options
context:
space:
mode:
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.rb37
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