diff options
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/banzai/filter/gollum_tags_filter_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/banzai/filter/wiki_link_filter_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/banzai/pipeline/wiki_pipeline_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb | 50 | ||||
-rw-r--r-- | spec/lib/gitlab/usage_data_spec.rb | 16 |
5 files changed, 36 insertions, 38 deletions
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index 2576dd1bf07..f39b5280490 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -6,8 +6,7 @@ RSpec.describe Banzai::Filter::GollumTagsFilter do include FilterSpecHelper let(:project) { create(:project) } - let(:user) { double } - let(:wiki) { ProjectWiki.new(project, user) } + let(:wiki) { ProjectWiki.new(project, nil) } describe 'validation' do it 'ensure that a :wiki key exists in context' do diff --git a/spec/lib/banzai/filter/wiki_link_filter_spec.rb b/spec/lib/banzai/filter/wiki_link_filter_spec.rb index 7a4464a2604..d1f6ee49260 100644 --- a/spec/lib/banzai/filter/wiki_link_filter_spec.rb +++ b/spec/lib/banzai/filter/wiki_link_filter_spec.rb @@ -7,8 +7,7 @@ RSpec.describe Banzai::Filter::WikiLinkFilter do let(:namespace) { build_stubbed(:namespace, name: "wiki_link_ns") } let(:project) { build_stubbed(:project, :public, name: "wiki_link_project", namespace: namespace) } - let(:user) { double } - let(:wiki) { ProjectWiki.new(project, user) } + let(:wiki) { ProjectWiki.new(project, nil) } let(:repository_upload_folder) { Wikis::CreateAttachmentService::ATTACHMENT_PATH } it "doesn't rewrite absolute links" do diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb index 4af782c7d73..b102de24041 100644 --- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Banzai::Pipeline::WikiPipeline do let_it_be(:namespace) { create(:namespace, name: "wiki_link_ns") } let_it_be(:project) { create(:project, :public, name: "wiki_link_project", namespace: namespace) } - let_it_be(:wiki) { ProjectWiki.new(project, double(:user)) } + let_it_be(:wiki) { ProjectWiki.new(project, nil) } let_it_be(:page) { build(:wiki_page, wiki: wiki, title: 'nested/twice/start-page') } describe 'TableOfContents' do diff --git a/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb b/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb index 584d8407e79..6db77f19877 100644 --- a/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/track_unique_actions_spec.rb @@ -7,12 +7,12 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi let(:time) { Time.zone.now } - def track_action(params) - track_unique_events.track_action(params) + def track_event(params) + track_unique_events.track_event(params) end - def count_unique_events(params) - track_unique_events.count_unique_events(params) + def count_unique(params) + track_unique_events.count_unique(params) end context 'tracking an event' do @@ -29,28 +29,28 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi design = Event::TARGET_TYPES[:design] wiki = Event::TARGET_TYPES[:wiki] - expect(track_action(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy - expect(track_action(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy - expect(track_action(event_action: :pushed, event_target: project, author_id: 2)).to be_truthy - expect(track_action(event_action: :pushed, event_target: project, author_id: 3)).to be_truthy - expect(track_action(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)).to be_truthy - expect(track_action(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)).to be_truthy + expect(track_event(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy + expect(track_event(event_action: :pushed, event_target: project, author_id: 1)).to be_truthy + expect(track_event(event_action: :pushed, event_target: project, author_id: 2)).to be_truthy + expect(track_event(event_action: :pushed, event_target: project, author_id: 3)).to be_truthy + expect(track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days)).to be_truthy + expect(track_event(event_action: :created, event_target: project, author_id: 5, time: time - 3.days)).to be_truthy - expect(track_action(event_action: :destroyed, event_target: design, author_id: 3)).to be_truthy - expect(track_action(event_action: :created, event_target: design, author_id: 4)).to be_truthy - expect(track_action(event_action: :updated, event_target: design, author_id: 5)).to be_truthy - expect(track_action(event_action: :pushed, event_target: design, author_id: 6)).to be_truthy + expect(track_event(event_action: :destroyed, event_target: design, author_id: 3)).to be_truthy + expect(track_event(event_action: :created, event_target: design, author_id: 4)).to be_truthy + expect(track_event(event_action: :updated, event_target: design, author_id: 5)).to be_truthy + expect(track_event(event_action: :pushed, event_target: design, author_id: 6)).to be_truthy - expect(track_action(event_action: :destroyed, event_target: wiki, author_id: 5)).to be_truthy - expect(track_action(event_action: :created, event_target: wiki, author_id: 3)).to be_truthy - expect(track_action(event_action: :updated, event_target: wiki, author_id: 4)).to be_truthy - expect(track_action(event_action: :pushed, event_target: wiki, author_id: 6)).to be_truthy + expect(track_event(event_action: :destroyed, event_target: wiki, author_id: 5)).to be_truthy + expect(track_event(event_action: :created, event_target: wiki, author_id: 3)).to be_truthy + expect(track_event(event_action: :updated, event_target: wiki, author_id: 4)).to be_truthy + expect(track_event(event_action: :pushed, event_target: wiki, author_id: 6)).to be_truthy - expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(3) - expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: Date.tomorrow)).to eq(4) - expect(count_unique_events(event_action: described_class::DESIGN_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3) - expect(count_unique_events(event_action: described_class::WIKI_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3) - expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: time - 2.days)).to eq(1) + expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(3) + expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: Date.tomorrow)).to eq(4) + expect(count_unique(event_action: described_class::DESIGN_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3) + expect(count_unique(event_action: described_class::WIKI_ACTION, date_from: time - 5.days, date_to: Date.today)).to eq(3) + expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time - 5.days, date_to: time - 2.days)).to eq(1) end end end @@ -73,8 +73,8 @@ RSpec.describe Gitlab::UsageDataCounters::TrackUniqueActions, :clean_gitlab_redi end it 'returns the expected values' do - expect(track_action(event_action: action, event_target: target, author_id: 2)).to be_nil - expect(count_unique_events(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(0) + expect(track_event(event_action: action, event_target: target, author_id: 2)).to be_nil + expect(count_unique(event_action: described_class::PUSH_ACTION, date_from: time, date_to: Date.today)).to eq(0) end end end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 681784369e0..2fb30b3228a 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -924,14 +924,14 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do wiki = Event::TARGET_TYPES[:wiki] design = Event::TARGET_TYPES[:design] - counter.track_action(event_action: :pushed, event_target: project, author_id: 1) - counter.track_action(event_action: :pushed, event_target: project, author_id: 1) - counter.track_action(event_action: :pushed, event_target: project, author_id: 2) - counter.track_action(event_action: :pushed, event_target: project, author_id: 3) - counter.track_action(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days) - counter.track_action(event_action: :created, event_target: project, author_id: 5, time: time - 3.days) - counter.track_action(event_action: :created, event_target: wiki, author_id: 3) - counter.track_action(event_action: :created, event_target: design, author_id: 3) + counter.track_event(event_action: :pushed, event_target: project, author_id: 1) + counter.track_event(event_action: :pushed, event_target: project, author_id: 1) + counter.track_event(event_action: :pushed, event_target: project, author_id: 2) + counter.track_event(event_action: :pushed, event_target: project, author_id: 3) + counter.track_event(event_action: :pushed, event_target: project, author_id: 4, time: time - 3.days) + counter.track_event(event_action: :created, event_target: project, author_id: 5, time: time - 3.days) + counter.track_event(event_action: :created, event_target: wiki, author_id: 3) + counter.track_event(event_action: :created, event_target: design, author_id: 3) end it 'returns the distinct count of user actions within the specified time period' do |