Skip to content

Commit

Permalink
change it so that the rake task only passes the number of days not th…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
peggles2 authored Feb 19, 2020
1 parent 2a6d00e commit 4d6fc0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/tasks/user.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions spec/lib/tasks/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4d6fc0e

Please sign in to comment.