From 4d6fc0eca8c9215fd247e93230f435b0f092720e Mon Sep 17 00:00:00 2001 From: peggles2 Date: Wed, 19 Feb 2020 10:59:53 -0500 Subject: [PATCH] change it so that the rake task only passes the number of days not the date (#537) * change it so that the rake task only passes the number of days not the date * ensure number of days is an integer --- lib/tasks/user.rake | 5 +++-- spec/lib/tasks/user_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/tasks/user.rake b/lib/tasks/user.rake index d3976ca2d9..35385eb97e 100644 --- a/lib/tasks/user.rake +++ b/lib/tasks/user.rake @@ -20,9 +20,10 @@ namespace :usasearch do end desc 'Warns not active users account will be deactivated' - task :warn_set_to_not_approved, [:date] => [:environment] do |_t, args| + task :warn_set_to_not_approved, [:number_of_days] => [:environment] do |_t, args| + date = args.number_of_days.to_i.days.ago UserApproval.warn_set_to_not_approved(User. - not_active_since(args.date.to_date), args.date.to_date) + not_active_since(date.to_date), date.to_date) end end end diff --git a/spec/lib/tasks/user_spec.rb b/spec/lib/tasks/user_spec.rb index fde9c8c1c7..d7a958e6e5 100644 --- a/spec/lib/tasks/user_spec.rb +++ b/spec/lib/tasks/user_spec.rb @@ -104,13 +104,13 @@ it 'calls warn_set_to_not_approved' do expect(UserApproval).to receive(:warn_set_to_not_approved). with(users, 76.days.ago.to_date) - @rake[task_name].invoke(76.days.ago.to_date) + @rake[task_name].invoke(76) end it 'will not call warn_set_to_not_approved prematurely' do expect(UserApproval).not_to receive(:warn_set_to_not_approved). with(users, 75.days.ago.to_date) - @rake[task_name].invoke(76.days.ago.to_date) + @rake[task_name].invoke(76) end end end