diff options
Diffstat (limited to 'spec/models/concerns/database_event_tracking_spec.rb')
-rw-r--r-- | spec/models/concerns/database_event_tracking_spec.rb | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/spec/models/concerns/database_event_tracking_spec.rb b/spec/models/concerns/database_event_tracking_spec.rb index 976462b4174..502cecaaf76 100644 --- a/spec/models/concerns/database_event_tracking_spec.rb +++ b/spec/models/concerns/database_event_tracking_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' RSpec.describe DatabaseEventTracking, :snowplow do + before do + allow(Gitlab::Tracking).to receive(:database_event).and_call_original + end + let(:test_class) do Class.new(ActiveRecord::Base) do include DatabaseEventTracking @@ -17,7 +21,7 @@ RSpec.describe DatabaseEventTracking, :snowplow do context 'if event emmiter failed' do before do - allow(Gitlab::Tracking).to receive(:event).and_raise(StandardError) # rubocop:disable RSpec/ExpectGitlabTracking + allow(Gitlab::Tracking).to receive(:database_event).and_raise(StandardError) # rubocop:disable RSpec/ExpectGitlabTracking end it 'tracks the exception' do @@ -35,7 +39,7 @@ RSpec.describe DatabaseEventTracking, :snowplow do it 'does not track the event' do create_test_class_record - expect_no_snowplow_event + expect_no_snowplow_event(tracking_method: :database_event) end end @@ -46,24 +50,48 @@ RSpec.describe DatabaseEventTracking, :snowplow do it 'when created' do create_test_class_record - expect_snowplow_event(category: category, action: "#{event}_create", label: 'application_setting_terms', - property: 'create', namespace: nil, "id" => 1) + expect_snowplow_event( + tracking_method: :database_event, + category: category, + action: "#{event}_create", + label: 'application_setting_terms', + property: 'create', + namespace: nil, + project: nil, + "id" => 1 + ) end it 'when updated' do create_test_class_record test_class.first.update!(id: 3) - expect_snowplow_event(category: category, action: "#{event}_update", label: 'application_setting_terms', - property: 'update', namespace: nil, "id" => 3) + expect_snowplow_event( + tracking_method: :database_event, + category: category, + action: "#{event}_update", + label: 'application_setting_terms', + property: 'update', + namespace: nil, + project: nil, + "id" => 3 + ) end it 'when destroyed' do create_test_class_record test_class.first.destroy! - expect_snowplow_event(category: category, action: "#{event}_destroy", label: 'application_setting_terms', - property: 'destroy', namespace: nil, "id" => 1) + expect_snowplow_event( + tracking_method: :database_event, + category: category, + action: "#{event}_destroy", + label: 'application_setting_terms', + property: 'destroy', + namespace: nil, + project: nil, + "id" => 1 + ) end end end |