Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 21:09:16 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 21:09:16 +0300
commit80e9fdc9682cfbcfb9202a2733605a6a6bd23f05 (patch)
tree168375ea13d1a1f01d4cbcf6f0513fc9883e9477 /spec
parent5372e109c0660e4670aa987568a51082beca1b3c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/groups/settings/integrations_controller_spec.rb45
-rw-r--r--spec/lib/gitlab/sidekiq_cluster/cli_spec.rb4
-rw-r--r--spec/lib/gitlab/sidekiq_cluster_spec.rb2
-rw-r--r--spec/models/project_import_state_spec.rb16
-rw-r--r--spec/serializers/diffs_entity_spec.rb16
-rw-r--r--spec/support/shared_contexts/navbar_structure_context.rb1
6 files changed, 63 insertions, 21 deletions
diff --git a/spec/controllers/groups/settings/integrations_controller_spec.rb b/spec/controllers/groups/settings/integrations_controller_spec.rb
index eee65476dab..6df1ad8a383 100644
--- a/spec/controllers/groups/settings/integrations_controller_spec.rb
+++ b/spec/controllers/groups/settings/integrations_controller_spec.rb
@@ -11,17 +11,40 @@ describe Groups::Settings::IntegrationsController do
sign_in(user)
end
- describe '#edit' do
- context 'when group_level_integrations not enabled' do
- it 'returns not_found' do
- stub_feature_flags(group_level_integrations: { enabled: false, thing: group })
-
- get :edit, params: { group_id: group, id: Service.available_services_names.sample }
+ describe '#index' do
+ context 'when user is not owner' do
+ it 'renders not_found' do
+ get :index, params: { group_id: group }
expect(response).to have_gitlab_http_status(:not_found)
end
end
+ context 'when user is owner' do
+ before do
+ group.add_owner(user)
+ end
+
+ context 'when group_level_integrations not enabled' do
+ it 'returns not_found' do
+ stub_feature_flags(group_level_integrations: { enabled: false, thing: group })
+
+ get :index, params: { group_id: group }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
+ it 'successfully displays the template' do
+ get :index, params: { group_id: group }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response).to render_template(:index)
+ end
+ end
+ end
+
+ describe '#edit' do
context 'when user is not owner' do
it 'renders not_found' do
get :edit, params: { group_id: group, id: Service.available_services_names.sample }
@@ -35,6 +58,16 @@ describe Groups::Settings::IntegrationsController do
group.add_owner(user)
end
+ context 'when group_level_integrations not enabled' do
+ it 'returns not_found' do
+ stub_feature_flags(group_level_integrations: { enabled: false, thing: group })
+
+ get :edit, params: { group_id: group, id: Service.available_services_names.sample }
+
+ expect(response).to have_gitlab_http_status(:not_found)
+ end
+ end
+
Service.available_services_names.each do |integration_name|
context "#{integration_name}" do
it 'successfully displays the template' do
diff --git a/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb b/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb
index 72727aab601..fa23bf8958c 100644
--- a/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb
+++ b/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb
@@ -236,7 +236,7 @@ describe Gitlab::SidekiqCluster::CLI do
.with([]).and_return([])
expect(Gitlab::SidekiqCluster).to receive(:signal_processes)
- .with([], :KILL)
+ .with([], "-KILL")
stub_const("Gitlab::SidekiqCluster::CLI::CHECK_TERMINATE_INTERVAL_SECONDS", 0.1)
allow(cli).to receive(:terminate_timeout_seconds) { 1 }
@@ -264,7 +264,7 @@ describe Gitlab::SidekiqCluster::CLI do
.with(worker_pids).and_return([102])
expect(Gitlab::SidekiqCluster).to receive(:signal_processes)
- .with([102], :KILL)
+ .with([102], "-KILL")
cli.run(%w(foo))
diff --git a/spec/lib/gitlab/sidekiq_cluster_spec.rb b/spec/lib/gitlab/sidekiq_cluster_spec.rb
index 9316ac29dd6..3f466e9f2a3 100644
--- a/spec/lib/gitlab/sidekiq_cluster_spec.rb
+++ b/spec/lib/gitlab/sidekiq_cluster_spec.rb
@@ -44,7 +44,7 @@ describe Gitlab::SidekiqCluster do
end
describe '.signal_processes' do
- it 'sends a signal to every thread' do
+ it 'sends a signal to every given process' do
expect(described_class).to receive(:signal).with(1, :INT)
described_class.signal_processes([1], :INT)
diff --git a/spec/models/project_import_state_spec.rb b/spec/models/project_import_state_spec.rb
index 157477767af..720dc4f435f 100644
--- a/spec/models/project_import_state_spec.rb
+++ b/spec/models/project_import_state_spec.rb
@@ -14,8 +14,8 @@ describe ProjectImportState, type: :model do
end
describe 'Project import job' do
- let(:import_state) { create(:import_state, import_url: generate(:url)) }
- let(:project) { import_state.project }
+ let_it_be(:import_state) { create(:import_state, import_url: generate(:url)) }
+ let_it_be(:project) { import_state.project }
before do
allow_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository)
@@ -29,8 +29,16 @@ describe ProjectImportState, type: :model do
it 'imports a project', :sidekiq_might_not_need_inline do
expect(RepositoryImportWorker).to receive(:perform_async).and_call_original
- expect { import_state.schedule }.to change { import_state.jid }
- expect(import_state.status).to eq('finished')
+ expect { import_state.schedule }.to change { import_state.status }.from('none').to('finished')
+ end
+
+ it 'records job and correlation IDs', :sidekiq_might_not_need_inline do
+ allow(Labkit::Correlation::CorrelationId).to receive(:current_or_new_id).and_return('abc')
+
+ import_state.schedule
+
+ expect(import_state.jid).to be_an_instance_of(String)
+ expect(import_state.correlation_id).to eq('abc')
end
end
diff --git a/spec/serializers/diffs_entity_spec.rb b/spec/serializers/diffs_entity_spec.rb
index b42240037df..482f9e76c62 100644
--- a/spec/serializers/diffs_entity_spec.rb
+++ b/spec/serializers/diffs_entity_spec.rb
@@ -45,26 +45,26 @@ describe DiffsEntity do
let(:commit) { commits.third }
it 'includes commit references for previous and next' do
- expect(subject[:commit][:prev_commit_id]).to eq(commits.second.id)
- expect(subject[:commit][:next_commit_id]).to eq(commits.fourth.id)
+ expect(subject[:commit][:next_commit_id]).to eq(commits.second.id)
+ expect(subject[:commit][:prev_commit_id]).to eq(commits.fourth.id)
end
end
context "when the passed commit is the first in the group" do
let(:commit) { commits.first }
- it 'includes commit references for nil and next' do
- expect(subject[:commit][:prev_commit_id]).to be_nil
- expect(subject[:commit][:next_commit_id]).to eq(commits.second.id)
+ it 'includes commit references for nil and previous commit' do
+ expect(subject[:commit][:next_commit_id]).to be_nil
+ expect(subject[:commit][:prev_commit_id]).to eq(commits.second.id)
end
end
context "when the passed commit is the last in the group" do
let(:commit) { commits.last }
- it 'includes commit references for previous and nil' do
- expect(subject[:commit][:prev_commit_id]).to eq(commits[-2].id)
- expect(subject[:commit][:next_commit_id]).to be_nil
+ it 'includes commit references for the next and nil' do
+ expect(subject[:commit][:next_commit_id]).to eq(commits[-2].id)
+ expect(subject[:commit][:prev_commit_id]).to be_nil
end
end
end
diff --git a/spec/support/shared_contexts/navbar_structure_context.rb b/spec/support/shared_contexts/navbar_structure_context.rb
index 2a98855a83f..9ffe13545f7 100644
--- a/spec/support/shared_contexts/navbar_structure_context.rb
+++ b/spec/support/shared_contexts/navbar_structure_context.rb
@@ -120,6 +120,7 @@ RSpec.shared_context 'group navbar structure' do
_('General'),
_('Projects'),
_('CI / CD'),
+ _('Integrations'),
_('Webhooks'),
_('Audit Events')
]