diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/support/shared_examples/lib | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/support/shared_examples/lib')
6 files changed, 29 insertions, 110 deletions
diff --git a/spec/support/shared_examples/lib/banzai/filters/sanitization_filter_shared_examples.rb b/spec/support/shared_examples/lib/banzai/filters/sanitization_filter_shared_examples.rb index 134e38833cf..b5c07f45d59 100644 --- a/spec/support/shared_examples/lib/banzai/filters/sanitization_filter_shared_examples.rb +++ b/spec/support/shared_examples/lib/banzai/filters/sanitization_filter_shared_examples.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.shared_examples 'default whitelist' do - it 'sanitizes tags that are not whitelisted' do +RSpec.shared_examples 'default allowlist' do + it 'sanitizes tags that are not allowed' do act = %q{<textarea>no inputs</textarea> and <blink>no blinks</blink>} exp = 'no inputs and no blinks' expect(filter(act).to_html).to eq exp diff --git a/spec/support/shared_examples/lib/gitlab/cycle_analytics/base_stage_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/cycle_analytics/base_stage_shared_examples.rb deleted file mode 100644 index d76089d56dd..00000000000 --- a/spec/support/shared_examples/lib/gitlab/cycle_analytics/base_stage_shared_examples.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -ISSUES_MEDIAN = 30.minutes.to_i - -RSpec.shared_examples 'base stage' do - let(:stage) { described_class.new(options: { project: double }) } - - before do - allow(stage).to receive(:project_median).and_return(1.12) - allow_next_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher) do |instance| - allow(instance).to receive(:event_result).and_return({}) - end - end - - it 'has the median data value' do - expect(stage.as_json[:value]).not_to be_nil - end - - it 'has the median data stage' do - expect(stage.as_json[:title]).not_to be_nil - end - - it 'has the median data description' do - expect(stage.as_json[:description]).not_to be_nil - end - - it 'has the title' do - expect(stage.title).to eq(stage_name.to_s.capitalize) - end - - it 'has the events' do - expect(stage.events).not_to be_nil - end -end - -RSpec.shared_examples 'calculate #median with date range' do - context 'when valid date range is given' do - before do - stage_options[:from] = 5.days.ago - stage_options[:to] = 5.days.from_now - end - - it { expect(stage.project_median).to eq(ISSUES_MEDIAN) } - end - - context 'when records are out of the date range' do - before do - stage_options[:from] = 2.years.ago - stage_options[:to] = 1.year.ago - end - - it { expect(stage.project_median).to eq(nil) } - end -end - -RSpec.shared_examples 'Gitlab::Analytics::CycleAnalytics::DataCollector backend examples' do - let(:stage_params) { Gitlab::Analytics::CycleAnalytics::DefaultStages.send("params_for_#{stage_name}_stage").merge(project: project) } - let(:stage) { Analytics::CycleAnalytics::ProjectStage.new(stage_params) } - let(:data_collector) { Gitlab::Analytics::CycleAnalytics::DataCollector.new(stage: stage, params: { from: stage_options[:from], current_user: project.creator }) } - let(:attribute_to_verify) { :title } - - context 'provides the same results as the old implementation' do - it 'for the median' do - expect(data_collector.median.seconds).to be_within(0.5).of(ISSUES_MEDIAN) - end - - it 'for the list of event records' do - records = data_collector.records_fetcher.serialized_records - expect(records.map { |event| event[attribute_to_verify] }).to eq(expected_ordered_attribute_values) - end - end -end diff --git a/spec/support/shared_examples/lib/gitlab/cycle_analytics/default_query_config_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/cycle_analytics/default_query_config_shared_examples.rb deleted file mode 100644 index 4f648b27ea2..00000000000 --- a/spec/support/shared_examples/lib/gitlab/cycle_analytics/default_query_config_shared_examples.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.shared_examples 'default query config' do - let(:project) { create(:project) } - let(:event) { described_class.new(stage: stage_name, options: { from: 1.day.ago, project: project }) } - - it 'has the stage attribute' do - expect(event.stage).not_to be_nil - end - - it 'has the projection attributes' do - expect(event.projections).not_to be_nil - end -end diff --git a/spec/support/shared_examples/lib/gitlab/middleware/multipart_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/middleware/multipart_shared_examples.rb index 6327367fcc2..40deaa27955 100644 --- a/spec/support/shared_examples/lib/gitlab/middleware/multipart_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/middleware/multipart_shared_examples.rb @@ -5,7 +5,7 @@ RSpec.shared_examples 'handling all upload parameters conditions' do include_context 'with one temporary file for multipart' let(:rewritten_fields) { rewritten_fields_hash('file' => uploaded_filepath) } - let(:params) { upload_parameters_for(filepath: uploaded_filepath, key: 'file', filename: filename, remote_id: remote_id) } + let(:params) { upload_parameters_for(filepath: uploaded_filepath, key: 'file', mode: mode, filename: filename, remote_id: remote_id) } it 'builds an UploadedFile' do expect_uploaded_files(filepath: uploaded_filepath, original_filename: filename, remote_id: remote_id, size: uploaded_file.size, params_path: %w(file)) @@ -19,8 +19,8 @@ RSpec.shared_examples 'handling all upload parameters conditions' do let(:rewritten_fields) { rewritten_fields_hash('file1' => uploaded_filepath, 'file2' => uploaded_filepath2) } let(:params) do - upload_parameters_for(filepath: uploaded_filepath, key: 'file1', filename: filename, remote_id: remote_id).merge( - upload_parameters_for(filepath: uploaded_filepath2, key: 'file2', filename: filename2, remote_id: remote_id2) + upload_parameters_for(filepath: uploaded_filepath, key: 'file1', mode: mode, filename: filename, remote_id: remote_id).merge( + upload_parameters_for(filepath: uploaded_filepath2, key: 'file2', mode: mode, filename: filename2, remote_id: remote_id2) ) end @@ -38,7 +38,7 @@ RSpec.shared_examples 'handling all upload parameters conditions' do include_context 'with one temporary file for multipart' let(:rewritten_fields) { rewritten_fields_hash('user[avatar]' => uploaded_filepath) } - let(:params) { { 'user' => { 'avatar' => upload_parameters_for(filepath: uploaded_filepath, filename: filename, remote_id: remote_id) } } } + let(:params) { { 'user' => { 'avatar' => upload_parameters_for(filepath: uploaded_filepath, mode: mode, filename: filename, remote_id: remote_id) } } } it 'builds an UploadedFile' do expect_uploaded_files(filepath: uploaded_filepath, original_filename: filename, remote_id: remote_id, size: uploaded_file.size, params_path: %w(user avatar)) @@ -54,8 +54,8 @@ RSpec.shared_examples 'handling all upload parameters conditions' do let(:params) do { 'user' => { - 'avatar' => upload_parameters_for(filepath: uploaded_filepath, filename: filename, remote_id: remote_id), - 'screenshot' => upload_parameters_for(filepath: uploaded_filepath2, filename: filename2, remote_id: remote_id2) + 'avatar' => upload_parameters_for(filepath: uploaded_filepath, mode: mode, filename: filename, remote_id: remote_id), + 'screenshot' => upload_parameters_for(filepath: uploaded_filepath2, mode: mode, filename: filename2, remote_id: remote_id2) } } end @@ -74,7 +74,7 @@ RSpec.shared_examples 'handling all upload parameters conditions' do include_context 'with one temporary file for multipart' let(:rewritten_fields) { rewritten_fields_hash('user[avatar][bananas]' => uploaded_filepath) } - let(:params) { { 'user' => { 'avatar' => { 'bananas' => upload_parameters_for(filepath: uploaded_filepath, filename: filename, remote_id: remote_id) } } } } + let(:params) { { 'user' => { 'avatar' => { 'bananas' => upload_parameters_for(filepath: uploaded_filepath, mode: mode, filename: filename, remote_id: remote_id) } } } } it 'builds an UploadedFile' do expect_uploaded_files(filepath: uploaded_file, original_filename: filename, remote_id: remote_id, size: uploaded_file.size, params_path: %w(user avatar bananas)) @@ -91,10 +91,10 @@ RSpec.shared_examples 'handling all upload parameters conditions' do { 'user' => { 'avatar' => { - 'bananas' => upload_parameters_for(filepath: uploaded_filepath, filename: filename, remote_id: remote_id) + 'bananas' => upload_parameters_for(filepath: uploaded_filepath, mode: mode, filename: filename, remote_id: remote_id) }, 'friend' => { - 'ananas' => upload_parameters_for(filepath: uploaded_filepath2, filename: filename2, remote_id: remote_id2) + 'ananas' => upload_parameters_for(filepath: uploaded_filepath2, mode: mode, filename: filename2, remote_id: remote_id2) } } } @@ -122,11 +122,11 @@ RSpec.shared_examples 'handling all upload parameters conditions' do end let(:params) do - upload_parameters_for(filepath: uploaded_filepath, filename: filename, key: 'file', remote_id: remote_id).merge( + upload_parameters_for(filepath: uploaded_filepath, filename: filename, key: 'file', mode: mode, remote_id: remote_id).merge( 'user' => { - 'avatar' => upload_parameters_for(filepath: uploaded_filepath2, filename: filename2, remote_id: remote_id2), + 'avatar' => upload_parameters_for(filepath: uploaded_filepath2, mode: mode, filename: filename2, remote_id: remote_id2), 'friend' => { - 'avatar' => upload_parameters_for(filepath: uploaded_filepath3, filename: filename3, remote_id: remote_id3) + 'avatar' => upload_parameters_for(filepath: uploaded_filepath3, mode: mode, filename: filename3, remote_id: remote_id3) } } ) diff --git a/spec/support/shared_examples/lib/gitlab/project_search_results_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/project_search_results_shared_examples.rb index 94ef41ce5a5..f83fecee4ea 100644 --- a/spec/support/shared_examples/lib/gitlab/project_search_results_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/project_search_results_shared_examples.rb @@ -54,7 +54,7 @@ RSpec.shared_examples 'access restricted confidential issues' do end end - context 'when the user is a developper' do + context 'when the user is a developer' do let(:user) do create(:user) { |user| project.add_developer(user) } end @@ -70,10 +70,19 @@ RSpec.shared_examples 'access restricted confidential issues' do context 'when the user is admin', :request_store do let(:user) { create(:user, admin: true) } - it 'lists all project issues' do - expect(objects).to contain_exactly(issue, - security_issue_1, - security_issue_2) + context 'when admin mode is enabled', :enable_admin_mode do + it 'lists all project issues' do + expect(objects).to contain_exactly(issue, + security_issue_1, + security_issue_2) + end + end + + context 'when admin mode is disabled' do + it 'does not list project confidential issues' do + expect(objects).to contain_exactly(issue) + expect(results.limited_issues_count).to eq 1 + end end end end diff --git a/spec/support/shared_examples/lib/gitlab/usage_data_counters/incident_management_activity_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/usage_data_counters/incident_management_activity_shared_examples.rb index 788c35dd5bf..88bc8e8d0c1 100644 --- a/spec/support/shared_examples/lib/gitlab/usage_data_counters/incident_management_activity_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/usage_data_counters/incident_management_activity_shared_examples.rb @@ -13,7 +13,7 @@ RSpec.shared_examples 'an incident management tracked event' do |event| expect(Gitlab::UsageDataCounters::HLLRedisCounter) .to receive(:track_event) - .with(current_user.id, event.to_s) + .with(event.to_s, values: current_user.id) .and_call_original expect { subject } |