diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-16 18:08:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-16 18:08:41 +0300 |
commit | d47f9d2304dbc3a23bba7fe7a5cd07218eeb41cd (patch) | |
tree | 4b4efa1ccd8246fba2dc9f8816d9d2c0268e9818 /spec/lib | |
parent | c158fa8d69c704663d289341a014c44c062cda88 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb | 34 | ||||
-rw-r--r-- | spec/lib/gitlab/file_hook_spec.rb (renamed from spec/lib/gitlab/plugin_spec.rb) | 34 |
2 files changed, 31 insertions, 37 deletions
diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb index b0cec61ce06..6446ab1beb4 100644 --- a/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/delete_service_spec.rb @@ -4,12 +4,8 @@ require 'spec_helper' describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do describe '#execute' do + let!(:application_setting) { create(:application_setting) } let(:result) { subject.execute } - let(:application_setting) { Gitlab::CurrentSettings.current_application_settings } - - before do - allow(ApplicationSetting).to receive(:current_without_cache) { application_setting } - end context 'when project does not exist' do it 'returns error' do @@ -21,24 +17,16 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do end end - context 'with project destroyed but ID still present in application settings' do - before do - application_setting.instance_administration_project_id = 1 - end - - it 'deletes project ID from application settings' do - subject.execute - - expect(application_setting.instance_administration_project_id).to be_nil - end - end - context 'when self monitoring project exists' do let(:group) { create(:group) } let(:project) { create(:project, namespace: group) } - before do - application_setting.instance_administration_project = project + let(:application_setting) do + create( + :application_setting, + instance_administration_project_id: project.id, + instance_administrators_group_id: group.id + ) end it 'destroys project' do @@ -50,7 +38,13 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::DeleteService do it 'deletes project ID from application settings' do subject.execute - expect(application_setting.instance_administration_project_id).to be_nil + expect(application_setting.reload.instance_administration_project_id).to be_nil + end + + it 'does not delete group' do + subject.execute + + expect(application_setting.instance_administrators_group).to eq(group) end end end diff --git a/spec/lib/gitlab/plugin_spec.rb b/spec/lib/gitlab/file_hook_spec.rb index 5d9f6d04caa..d184eb483d4 100644 --- a/spec/lib/gitlab/plugin_spec.rb +++ b/spec/lib/gitlab/file_hook_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' -describe Gitlab::Plugin do - let(:plugin) { Rails.root.join('plugins', 'test.rb') } - let(:tmp_file) { Tempfile.new('plugin-dump') } +describe Gitlab::FileHook do + let(:file_hook) { Rails.root.join('plugins', 'test.rb') } + let(:tmp_file) { Tempfile.new('file_hook-dump') } - let(:plugin_source) do + let(:file_hook_source) do <<~EOS #!/usr/bin/env ruby x = STDIN.read @@ -14,13 +14,13 @@ describe Gitlab::Plugin do EOS end - context 'with plugins present' do + context 'with file_hooks present' do before do - File.write(plugin, plugin_source) + File.write(file_hook, file_hook_source) end after do - FileUtils.rm(plugin) + FileUtils.rm(file_hook) end describe '.any?' do @@ -30,13 +30,13 @@ describe Gitlab::Plugin do end describe '.files?' do - it 'returns a list of plugins' do - expect(described_class.files).to match_array([plugin.to_s]) + it 'returns a list of file_hooks' do + expect(described_class.files).to match_array([file_hook.to_s]) end end end - context 'without any plugins' do + context 'without any file_hooks' do describe '.any?' do it 'returns false' do expect(described_class.any?).to be false @@ -52,21 +52,21 @@ describe Gitlab::Plugin do describe '.execute' do let(:data) { Gitlab::DataBuilder::Push::SAMPLE_DATA } - let(:result) { described_class.execute(plugin.to_s, data) } + let(:result) { described_class.execute(file_hook.to_s, data) } let(:success) { result.first } let(:message) { result.last } before do - File.write(plugin, plugin_source) + File.write(file_hook, file_hook_source) end after do - FileUtils.rm(plugin) + FileUtils.rm(file_hook) end context 'successful execution' do before do - File.chmod(0o777, plugin) + File.chmod(0o777, file_hook) end after do @@ -76,7 +76,7 @@ describe Gitlab::Plugin do it { expect(success).to be true } it { expect(message).to be_empty } - it 'ensures plugin received data via stdin' do + it 'ensures file_hook received data via stdin' do result expect(File.read(tmp_file.path)).to eq(data.to_json) @@ -89,7 +89,7 @@ describe Gitlab::Plugin do end context 'non-zero exit' do - let(:plugin_source) do + let(:file_hook_source) do <<~EOS #!/usr/bin/env ruby exit 1 @@ -97,7 +97,7 @@ describe Gitlab::Plugin do end before do - File.chmod(0o777, plugin) + File.chmod(0o777, file_hook) end it { expect(success).to be false } |