From cdbcb5d853cedf9c47c3fe9c2ffd897c17b41113 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 31 Jul 2020 15:41:26 +0200 Subject: [PATCH] Fixed test: Ensure action is performed by current Ticket Owner to mark it as seen. --- spec/jobs/ticket_online_notification_seen_job_spec.rb | 2 +- spec/support/user_info.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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|