diff options
Diffstat (limited to 'spec/lib/gitlab')
4 files changed, 55 insertions, 34 deletions
diff --git a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb index ee2173a9c8d..1a7d837af73 100644 --- a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb @@ -4,17 +4,6 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do include_context :email_shared_context - it_behaves_like :reply_processing_shared_examples - - before do - stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo") - stub_config_setting(host: 'localhost') - end - - let(:email_raw) { email_fixture('emails/valid_new_issue.eml') } - let(:namespace) { create(:namespace, path: 'gitlabhq') } - - let!(:project) { create(:project, :public, namespace: namespace, path: 'gitlabhq') } let!(:user) do create( :user, @@ -23,6 +12,17 @@ RSpec.describe Gitlab::Email::Handler::CreateIssueHandler do ) end + let!(:project) { create(:project, :public, namespace: namespace, path: 'gitlabhq') } + let(:namespace) { create(:namespace, path: 'gitlabhq') } + let(:email_raw) { email_fixture('emails/valid_new_issue.eml') } + + it_behaves_like :reply_processing_shared_examples + + before do + stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo") + stub_config_setting(host: 'localhost') + end + context "when email key" do let(:mail) { Mail::Message.new(email_raw) } diff --git a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb index 75d5fc040cb..37ee4591db0 100644 --- a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb @@ -4,6 +4,18 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Handler::CreateMergeRequestHandler do include_context :email_shared_context + let!(:user) do + create( + :user, + email: 'jake@adventuretime.ooo', + incoming_email_token: 'auth_token' + ) + end + + let!(:project) { create(:project, :public, :repository, namespace: namespace, path: 'gitlabhq') } + let(:namespace) { create(:namespace, path: 'gitlabhq') } + let(:email_raw) { email_fixture('emails/valid_new_merge_request.eml') } + it_behaves_like :reply_processing_shared_examples before do @@ -15,18 +27,6 @@ RSpec.describe Gitlab::Email::Handler::CreateMergeRequestHandler do TestEnv.clean_test_path end - let(:email_raw) { email_fixture('emails/valid_new_merge_request.eml') } - let(:namespace) { create(:namespace, path: 'gitlabhq') } - - let!(:project) { create(:project, :public, :repository, namespace: namespace, path: 'gitlabhq') } - let!(:user) do - create( - :user, - email: 'jake@adventuretime.ooo', - incoming_email_token: 'auth_token' - ) - end - context "when email key" do let(:mail) { Mail::Message.new(email_raw) } diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb index e5598bbd10f..07b8070be30 100644 --- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb @@ -4,6 +4,16 @@ require 'spec_helper' RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do include_context :email_shared_context + let!(:sent_notification) do + SentNotification.record_note(note, user.id, mail_key) + end + + let(:noteable) { note.noteable } + let(:note) { create(:diff_note_on_merge_request, project: project) } + let(:user) { create(:user) } + let(:project) { create(:project, :public, :repository) } + let(:email_raw) { fixture_file('emails/valid_reply.eml') } + it_behaves_like :reply_processing_shared_examples before do @@ -11,16 +21,6 @@ RSpec.describe Gitlab::Email::Handler::CreateNoteHandler do stub_config_setting(host: 'localhost') end - let(:email_raw) { fixture_file('emails/valid_reply.eml') } - let(:project) { create(:project, :public, :repository) } - let(:user) { create(:user) } - let(:note) { create(:diff_note_on_merge_request, project: project) } - let(:noteable) { note.noteable } - - let!(:sent_notification) do - SentNotification.record_note(note, user.id, mail_key) - end - context "when the recipient address doesn't include a mail key" do let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") } diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index c80e15055c6..a119c85401d 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -999,6 +999,9 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do describe '#action_monthly_active_users', :clean_gitlab_redis_shared_state do let(:time_period) { { created_at: 2.days.ago..time } } let(:time) { Time.zone.now } + let(:user1) { build(:user, id: 1) } + let(:user2) { build(:user, id: 2) } + let(:user3) { build(:user, id: 3) } before do counter = Gitlab::UsageDataCounters::TrackUniqueEvents @@ -1014,6 +1017,20 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do 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) + + counter = Gitlab::UsageDataCounters::EditorUniqueCounter + + counter.track_web_ide_edit_action(author: user1) + counter.track_web_ide_edit_action(author: user1) + counter.track_sfe_edit_action(author: user1) + counter.track_snippet_editor_edit_action(author: user1) + counter.track_snippet_editor_edit_action(author: user1, time: time - 3.days) + + counter.track_web_ide_edit_action(author: user2) + counter.track_sfe_edit_action(author: user2) + + counter.track_web_ide_edit_action(author: user3, time: time - 3.days) + counter.track_snippet_editor_edit_action(author: user3) end it 'returns the distinct count of user actions within the specified time period' do @@ -1021,7 +1038,11 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do { action_monthly_active_users_design_management: 1, action_monthly_active_users_project_repo: 3, - action_monthly_active_users_wiki_repo: 1 + action_monthly_active_users_wiki_repo: 1, + action_monthly_active_users_web_ide_edit: 2, + action_monthly_active_users_sfe_edit: 2, + action_monthly_active_users_snippet_editor_edit: 2, + action_monthly_active_users_ide_edit: 3 } ) end |