diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-12 12:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-12 12:10:03 +0300 |
commit | 7717a594e88951ba2b92358aa9a10a0030799678 (patch) | |
tree | 6206e93f20ee0ab44cbf31ae6dcb9d918d77fefe /spec/lib | |
parent | a20bd972bcc5e653641e6291a80957ce85958988 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/api/entities/projects/topic_spec.rb | 19 | ||||
-rw-r--r-- | spec/lib/gitlab/security/scan_configuration_spec.rb | 64 | ||||
-rw-r--r-- | spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb | 2 |
3 files changed, 85 insertions, 0 deletions
diff --git a/spec/lib/api/entities/projects/topic_spec.rb b/spec/lib/api/entities/projects/topic_spec.rb new file mode 100644 index 00000000000..cdf142dbb7d --- /dev/null +++ b/spec/lib/api/entities/projects/topic_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe API::Entities::Projects::Topic do + let(:topic) { create(:topic) } + + subject { described_class.new(topic).as_json } + + it 'exposes correct attributes' do + expect(subject).to include( + :id, + :name, + :description, + :total_projects_count, + :avatar_url + ) + end +end diff --git a/spec/lib/gitlab/security/scan_configuration_spec.rb b/spec/lib/gitlab/security/scan_configuration_spec.rb new file mode 100644 index 00000000000..9b62c13f3bb --- /dev/null +++ b/spec/lib/gitlab/security/scan_configuration_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe ::Gitlab::Security::ScanConfiguration do + let_it_be(:project) { create(:project, :repository) } + + let(:scan) { described_class.new(project: project, type: type, configured: configured) } + + describe '#available?' do + subject { scan.available? } + + let(:configured) { true } + + context 'with a core scanner' do + let(:type) { :sast } + + it { is_expected.to be_truthy } + end + + context 'with custom scanner' do + let(:type) { :my_scanner } + + it { is_expected.to be_falsey } + end + end + + describe '#configured?' do + subject { scan.configured? } + + let(:type) { :sast } + let(:configured) { false } + + it { is_expected.to be_falsey } + end + + describe '#configuration_path' do + subject { scan.configuration_path } + + let(:configured) { true } + + context 'with a non configurable scaner' do + let(:type) { :secret_detection } + + it { is_expected.to be_nil } + end + + context 'with licensed scanner for FOSS environment' do + let(:type) { :dast } + + before do + stub_env('FOSS_ONLY', '1') + end + + it { is_expected.to be_nil } + end + + context 'with custom scanner' do + let(:type) { :my_scanner } + + it { is_expected.to be_nil } + end + end +end diff --git a/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb index c879fdea3ad..b6fb3fecf20 100644 --- a/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::SidekiqLogging::JSONFormatter do 'class' => 'PostReceive', 'bar' => 'test', 'created_at' => timestamp, + 'scheduled_at' => timestamp, 'enqueued_at' => timestamp, 'started_at' => timestamp, 'retried_at' => timestamp, @@ -31,6 +32,7 @@ RSpec.describe Gitlab::SidekiqLogging::JSONFormatter do 'severity' => 'INFO', 'time' => timestamp_iso8601, 'created_at' => timestamp_iso8601, + 'scheduled_at' => timestamp_iso8601, 'enqueued_at' => timestamp_iso8601, 'started_at' => timestamp_iso8601, 'retried_at' => timestamp_iso8601, |