diff --git a/spec/jobs/ticket_online_notification_seen_job_spec.rb b/spec/jobs/ticket_online_notification_seen_job_spec.rb index e6e1124be..a7904d539 100644 --- a/spec/jobs/ticket_online_notification_seen_job_spec.rb +++ b/spec/jobs/ticket_online_notification_seen_job_spec.rb @@ -12,7 +12,7 @@ RSpec.describe TicketOnlineNotificationSeenJob, type: :job do expect(online_notification.reload.seen).to be false end - it 'checks if online notification has been seen' do + it 'checks if online notification has been seen', current_user_id: -> { user.id } do ticket.state_id = Ticket::State.lookup(name: 'closed').id ticket.save! diff --git a/spec/support/user_info.rb b/spec/support/user_info.rb index 7246bf9c4..f8df4af51 100644 --- a/spec/support/user_info.rb +++ b/spec/support/user_info.rb @@ -7,10 +7,12 @@ # DB ForeignKey violation errors. # If a `:current_user_id` metadata argument is set the initial value for # UserInfo.current_user_id will be set to the arguments given value +# if it's a Proc it will get evaluated RSpec.configure do |config| config.before(:each) do |example| - UserInfo.current_user_id = example.metadata[:current_user_id] + current_user_id = example.metadata[:current_user_id] + UserInfo.current_user_id = current_user_id.is_a?(Proc) ? instance_exec(¤t_user_id) : current_user_id end config.after(:each) do |_example|