debian-mirror-gitlab/spec/support/shared_examples/controllers/trackable_shared_examples.rb

40 lines
883 B
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2020-03-13 15:44:24 +05:30
RSpec.shared_examples 'a Trackable Controller' do
2021-01-29 00:20:46 +05:30
describe '#track_event', :snowplow do
2019-12-21 20:55:43 +05:30
before do
sign_in user
end
context 'with no params' do
controller(described_class) do
def index
track_event
head :ok
end
end
2021-01-29 00:20:46 +05:30
it 'tracks the action name', :snowplow do
2019-12-21 20:55:43 +05:30
get :index
2021-01-29 00:20:46 +05:30
expect_snowplow_event(category: 'AnonymousController', action: 'index')
2019-12-21 20:55:43 +05:30
end
end
context 'with params' do
controller(described_class) do
def index
track_event('some_event', category: 'SomeCategory', label: 'errorlabel')
head :ok
end
end
it 'tracks with the specified param' do
get :index
2021-01-29 00:20:46 +05:30
expect_snowplow_event(category: 'SomeCategory', action: 'some_event', label: 'errorlabel')
2019-12-21 20:55:43 +05:30
end
end
end
end