From d19bd8e06abac33fcd533a4e72286f5481af1baa Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Fri, 26 Jul 2024 12:44:56 +0200 Subject: [PATCH] clean up --- app/helpers/person_helper.rb | 4 ++-- spec/domain/ptime/client_spec.rb | 4 ++-- spec/rails_helper.rb | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/helpers/person_helper.rb b/app/helpers/person_helper.rb index ac25c245b..3c6dde47b 100644 --- a/app/helpers/person_helper.rb +++ b/app/helpers/person_helper.rb @@ -95,11 +95,11 @@ def fetch_ptime_or_skills_data def build_dropdown_data(ptime_employees) ptime_employees.map do |ptime_employee| ptime_employee_name = append_ptime_employee_name(ptime_employee) - person_id = Person.find_by(ptime_employee_id: ptime_employee[:id]) + skills_person = Person.find_by(ptime_employee_id: ptime_employee[:id]) ptime_employee_id = ptime_employee[:id] already_exists = ptime_employee_id.in?(Person.pluck(:ptime_employee_id)) path = new_person_path(ptime_employee_id: ptime_employee_id) - path = person_path(person_id) if already_exists + path = person_path(skills_person) if already_exists [ptime_employee_name, path] end diff --git a/spec/domain/ptime/client_spec.rb b/spec/domain/ptime/client_spec.rb index 2ac931ff7..166499d4f 100644 --- a/spec/domain/ptime/client_spec.rb +++ b/spec/domain/ptime/client_spec.rb @@ -7,13 +7,13 @@ end it 'should not raise PTimeClientError if LAST_PTIME_ERROR is less than 5 minutes ago' do - ENV['LAST_PTIME_ERROR'] = 6.minutes.ago.to_s + stub_env_var("LAST_PTIME_ERROR", 6.minutes.ago.to_s) fetched_employees = Ptime::Client.new.request(:get, "employees", { per_page: 1000 }) expect(fetched_employees).to eq(ptime_employees_data) end it 'should raise PTimeClientError if LAST_PTIME_ERROR is less than 5 minutes ago' do - ENV['LAST_PTIME_ERROR'] = 4.minutes.ago.to_s + stub_env_var("LAST_PTIME_ERROR", 4.minutes.ago.to_s) expect { Ptime::Client.new.request(:get, "employees", { per_page: 1000 }) }.to raise_error(CustomExceptions::PTimeClientError) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 196810e2f..d57d07b37 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -66,7 +66,8 @@ stub_env_variables_and_request end - config.before { allow($stdout).to receive(:puts) } + show_logs = ENV.fetch('SHOW_LOGS', false) + config.before { allow($stdout).to receive(:puts) } unless show_logs # Controller helper config.include(JsonMacros, type: :controller)