diff options
Diffstat (limited to 'spec/lib')
5 files changed, 191 insertions, 28 deletions
diff --git a/spec/lib/gitlab/import_export/group/tree_restorer_spec.rb b/spec/lib/gitlab/import_export/group/tree_restorer_spec.rb index 2794acb8980..d2153221e8f 100644 --- a/spec/lib/gitlab/import_export/group/tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/group/tree_restorer_spec.rb @@ -21,6 +21,7 @@ RSpec.describe Gitlab::ImportExport::Group::TreeRestorer do group_tree_restorer = described_class.new(user: user, shared: @shared, group: @group) expect(group_tree_restorer.restore).to be_truthy + expect(group_tree_restorer.groups_mapping).not_to be_empty end end diff --git a/spec/lib/gitlab/import_export/repo_saver_spec.rb b/spec/lib/gitlab/import_export/repo_saver_spec.rb index 3887ee7294e..52001e778d6 100644 --- a/spec/lib/gitlab/import_export/repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/repo_saver_spec.rb @@ -25,6 +25,14 @@ RSpec.describe Gitlab::ImportExport::RepoSaver do expect(bundler.save).to be true end + it 'creates the directory for the repository' do + allow(bundler).to receive(:bundle_full_path).and_return('/foo/bar/file.tar.gz') + + expect(FileUtils).to receive(:mkdir_p).with('/foo/bar', anything) + + bundler.save # rubocop:disable Rails/SaveBang + end + context 'when the repo is empty' do let!(:project) { create(:project) } diff --git a/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb index b8eddc0ca7f..59c601f54de 100644 --- a/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb @@ -39,7 +39,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s 'snippets', 'code_review', 'terraform', - 'ci_templates' + 'ci_templates', + 'quickactions' ) end end diff --git a/spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb new file mode 100644 index 00000000000..d4c423f57fe --- /dev/null +++ b/spec/lib/gitlab/usage_data_counters/quick_action_activity_unique_counter_spec.rb @@ -0,0 +1,163 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::UsageDataCounters::QuickActionActivityUniqueCounter, :clean_gitlab_redis_shared_state do + let(:user) { build(:user, id: 1) } + let(:note) { build(:note, author: user) } + let(:args) { nil } + + shared_examples_for 'a tracked quick action unique event' do + specify do + expect { 3.times { subject } } + .to change { + Gitlab::UsageDataCounters::HLLRedisCounter.unique_events( + event_names: action, + start_date: 2.weeks.ago, + end_date: 2.weeks.from_now + ) + } + .by(1) + end + end + + subject { described_class.track_unique_action(quickaction_name, args: args, user: user) } + + describe '.track_unique_action' do + let(:quickaction_name) { 'approve' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_approve' } + end + end + + context 'tracking assigns' do + let(:quickaction_name) { 'assign' } + + context 'single assignee' do + let(:args) { '@one' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_assign_single' } + end + end + + context 'multiple assignees' do + let(:args) { '@one @two' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_assign_multiple' } + end + end + + context 'assigning "me"' do + let(:args) { 'me' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_assign_self' } + end + end + + context 'assigning a reviewer' do + let(:quickaction_name) { 'assign_reviewer' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_assign_reviewer' } + end + end + + context 'assigning a reviewer with request review alias' do + let(:quickaction_name) { 'request_review' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_assign_reviewer' } + end + end + end + + context 'tracking copy_metadata' do + let(:quickaction_name) { 'copy_metadata' } + + context 'for issues' do + let(:args) { '#123' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_copy_metadata_issue' } + end + end + + context 'for merge requests' do + let(:args) { '!123' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_copy_metadata_merge_request' } + end + end + end + + context 'tracking spend' do + let(:quickaction_name) { 'spend' } + + context 'adding time' do + let(:args) { '1d' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_spend_add' } + end + end + + context 'removing time' do + let(:args) { '-1d' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_spend_subtract' } + end + end + end + + context 'tracking unassign' do + let(:quickaction_name) { 'unassign' } + + context 'unassigning everyone' do + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_unassign_all' } + end + end + + context 'unassigning specific users' do + let(:args) { '@hello' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_unassign_specific' } + end + end + end + + context 'tracking unlabel' do + context 'called as unlabel' do + let(:quickaction_name) { 'unlabel' } + + context 'removing all labels' do + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_unlabel_all' } + end + end + + context 'removing specific labels' do + let(:args) { '~wow' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_unlabel_specific' } + end + end + end + + context 'called as remove_label' do + let(:quickaction_name) { 'remove_label' } + + it_behaves_like 'a tracked quick action unique event' do + let(:action) { 'i_quickactions_unlabel_all' } + end + end + end +end diff --git a/spec/lib/gitlab/utils/markdown_spec.rb b/spec/lib/gitlab/utils/markdown_spec.rb index 23cd770d168..acc5bd47c8c 100644 --- a/spec/lib/gitlab/utils/markdown_spec.rb +++ b/spec/lib/gitlab/utils/markdown_spec.rb @@ -53,33 +53,23 @@ RSpec.describe Gitlab::Utils::Markdown do end context 'when string has a product suffix' do - let(:string) { 'My Header (ULTIMATE)' } - - it 'ignores a product suffix' do - is_expected.to eq 'my-header' - end - - context 'with self modifier' do - let(:string) { 'My Header (PREMIUM SELF)' } - - it 'ignores a product suffix' do - is_expected.to eq 'my-header' - end - end - - context 'with "*" around a product suffix' do - let(:string) { 'My Header **(PREMIUM)**' } - - it 'ignores a product suffix' do - is_expected.to eq 'my-header' - end - end - - context 'with "*" around a product suffix and sass modifier' do - let(:string) { 'My Header **(PREMIUM SASS)**' } - - it 'ignores a product suffix' do - is_expected.to eq 'my-header' + %w[CORE STARTER PREMIUM ULTIMATE FREE BRONZE SILVER GOLD].each do |tier| + ['', ' ONLY', ' SELF', ' SASS'].each do |modifier| + context "#{tier}#{modifier}" do + let(:string) { "My Header (#{tier}#{modifier})" } + + it 'ignores a product suffix' do + is_expected.to eq 'my-header' + end + + context 'with "*" around a product suffix' do + let(:string) { "My Header **(#{tier}#{modifier})**" } + + it 'ignores a product suffix' do + is_expected.to eq 'my-header' + end + end + end end end end |