summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
commit983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch)
treeb153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/controllers
parenta2bddee2cdb38673df0e004d5b32d9f77797de64 (diff)
downloadgitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/admin/integrations_controller_spec.rb9
-rw-r--r--spec/controllers/admin/runners_controller_spec.rb24
-rw-r--r--spec/controllers/admin/users_controller_spec.rb11
-rw-r--r--spec/controllers/groups/settings/integrations_controller_spec.rb7
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb39
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb4
-rw-r--r--spec/controllers/repositories/git_http_controller_spec.rb38
7 files changed, 119 insertions, 13 deletions
diff --git a/spec/controllers/admin/integrations_controller_spec.rb b/spec/controllers/admin/integrations_controller_spec.rb
index 8e48ecddd0f..817223bd91a 100644
--- a/spec/controllers/admin/integrations_controller_spec.rb
+++ b/spec/controllers/admin/integrations_controller_spec.rb
@@ -49,11 +49,12 @@ describe Admin::IntegrationsController do
end
context 'invalid params' do
- let(:url) { 'https://jira.localhost' }
+ let(:url) { 'invalid' }
- it 'updates the integration' do
- expect(response).to have_gitlab_http_status(:found)
- expect(integration.reload.url).to eq(url)
+ it 'does not update the integration' do
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to render_template(:edit)
+ expect(integration.reload.url).not_to eq(url)
end
end
end
diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb
index 7582006df36..803fcf90135 100644
--- a/spec/controllers/admin/runners_controller_spec.rb
+++ b/spec/controllers/admin/runners_controller_spec.rb
@@ -72,6 +72,30 @@ describe Admin::RunnersController do
expect(response).to have_gitlab_http_status(:ok)
end
+
+ describe 'Cost factors values' do
+ context 'when it is Gitlab.com' do
+ before do
+ expect(Gitlab).to receive(:com?).at_least(:once) { true }
+ end
+
+ it 'renders cost factors fields' do
+ get :show, params: { id: runner.id }
+
+ expect(response.body).to match /Private projects Minutes cost factor/
+ expect(response.body).to match /Public projects Minutes cost factor/
+ end
+ end
+
+ context 'when it is not Gitlab.com' do
+ it 'does not show cost factor fields' do
+ get :show, params: { id: runner.id }
+
+ expect(response.body).not_to match /Private projects Minutes cost factor/
+ expect(response.body).not_to match /Public projects Minutes cost factor/
+ end
+ end
+ end
end
describe '#update' do
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index a4ce510b413..387fc0407b6 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -340,6 +340,17 @@ describe Admin::UsersController do
end
end
+ describe "DELETE #remove_email" do
+ it 'deletes the email' do
+ email = create(:email, user: user)
+
+ delete :remove_email, params: { id: user.username, email_id: email.id }
+
+ expect(user.reload.emails).not_to include(email)
+ expect(flash[:notice]).to eq('Successfully removed email.')
+ end
+ end
+
describe "POST impersonate" do
context "when the user is blocked" do
before do
diff --git a/spec/controllers/groups/settings/integrations_controller_spec.rb b/spec/controllers/groups/settings/integrations_controller_spec.rb
index 6df1ad8a383..76cd74de183 100644
--- a/spec/controllers/groups/settings/integrations_controller_spec.rb
+++ b/spec/controllers/groups/settings/integrations_controller_spec.rb
@@ -100,11 +100,12 @@ describe Groups::Settings::IntegrationsController do
end
context 'invalid params' do
- let(:url) { 'https://jira.localhost' }
+ let(:url) { 'invalid' }
it 'does not update the integration' do
- expect(response).to have_gitlab_http_status(:found)
- expect(integration.reload.url).to eq(url)
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to render_template(:edit)
+ expect(integration.reload.url).not_to eq(url)
end
end
end
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index 9526e14a748..862a4bd3559 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -1427,6 +1427,45 @@ describe Projects::IssuesController do
end
end
+ describe 'POST export_csv' do
+ let(:viewer) { user }
+ let(:issue) { create(:issue, project: project) }
+
+ before do
+ project.add_developer(user)
+ end
+
+ def request_csv
+ post :export_csv, params: { namespace_id: project.namespace.to_param, project_id: project.to_param }
+ end
+
+ context 'when logged in' do
+ before do
+ sign_in(viewer)
+ end
+
+ it 'allows CSV export' do
+ expect(ExportCsvWorker).to receive(:perform_async).with(viewer.id, project.id, anything)
+
+ request_csv
+
+ expect(response).to redirect_to(project_issues_path(project))
+ expect(response.flash[:notice]).to match(/\AYour CSV export has started/i)
+ end
+ end
+
+ context 'when not logged in' do
+ let(:project) { create(:project_empty_repo, :public) }
+
+ it 'redirects to the sign in page' do
+ request_csv
+
+ expect(ExportCsvWorker).not_to receive(:perform_async)
+ expect(response).to redirect_to(new_user_session_path)
+ end
+ end
+ end
+
describe 'GET #discussions' do
let!(:discussion) { create(:discussion_note_on_issue, noteable: issue, project: issue.project) }
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 5104c83283d..aaeaf53d100 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -1245,7 +1245,7 @@ describe Projects::MergeRequestsController do
end
it 'renders MergeRequest as JSON' do
- expect(json_response.keys).to include('id', 'iid')
+ expect(json_response.keys).to include('id', 'iid', 'title', 'has_ci', 'merge_status', 'can_be_merged', 'current_user')
end
end
@@ -1279,7 +1279,7 @@ describe Projects::MergeRequestsController do
it 'renders MergeRequest as JSON' do
subject
- expect(json_response.keys).to include('id', 'iid')
+ expect(json_response.keys).to include('id', 'iid', 'title', 'has_ci', 'merge_status', 'can_be_merged', 'current_user')
end
end
diff --git a/spec/controllers/repositories/git_http_controller_spec.rb b/spec/controllers/repositories/git_http_controller_spec.rb
index e565c757f95..59455d90c25 100644
--- a/spec/controllers/repositories/git_http_controller_spec.rb
+++ b/spec/controllers/repositories/git_http_controller_spec.rb
@@ -95,7 +95,7 @@ describe Repositories::GitHttpController do
allow(controller).to receive(:access_check).and_return(nil)
end
- after do
+ def send_request
post :git_upload_pack, params: params
end
@@ -106,16 +106,46 @@ describe Repositories::GitHttpController do
it 'does not update project statistics' do
expect(ProjectDailyStatisticsWorker).not_to receive(:perform_async)
+
+ send_request
end
end
if expected
- it 'updates project statistics' do
- expect(ProjectDailyStatisticsWorker).to receive(:perform_async)
+ context 'when project_statistics_sync feature flag is disabled' do
+ before do
+ stub_feature_flags(project_statistics_sync: false)
+ end
+
+ it 'updates project statistics async' do
+ expect(ProjectDailyStatisticsWorker).to receive(:perform_async)
+
+ send_request
+ end
+ end
+
+ it 'updates project statistics sync' do
+ expect { send_request }.to change {
+ Projects::DailyStatisticsFinder.new(project).total_fetch_count
+ }.from(0).to(1)
end
else
+ context 'when project_statistics_sync feature flag is disabled' do
+ before do
+ stub_feature_flags(project_statistics_sync: false)
+ end
+
+ it 'does not update project statistics' do
+ expect(ProjectDailyStatisticsWorker).not_to receive(:perform_async)
+
+ send_request
+ end
+ end
+
it 'does not update project statistics' do
- expect(ProjectDailyStatisticsWorker).not_to receive(:perform_async)
+ expect { send_request }.not_to change {
+ Projects::DailyStatisticsFinder.new(project).total_fetch_count
+ }.from(0)
end
end
end