Skip to content

Commit

Permalink
SRCH-1304 - warn only approved users (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
peggles2 committed Mar 2, 2020
1 parent 4d6fc0e commit e14c1c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tasks/user.rake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace :usasearch do
desc 'Warns not active users account will be deactivated'
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.
UserApproval.warn_set_to_not_approved(User.approved.
not_active_since(date.to_date), date.to_date)
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ not_active_76_days:
email: not_active_for_76_days@fixtures.org
current_login_at: <%= 76.days.ago.to_s(:db) %>

not_active_unapproved_76_days:
<<: *DEFAULTS
email: not_active_unapproved_for_76_days@fixtures.org
current_login_at: <%= 76.days.ago.to_s(:db) %>
approval_status: not_approved

never_active_76_days:
<<: *DEFAULTS
email: never_active_for_76_days@fixtures.org
Expand Down
9 changes: 8 additions & 1 deletion spec/lib/tasks/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
end

describe 'usasearch:user:warn_set_to_not_approved' do
let(:users) { User.not_active_since(76.days.ago.to_date) }
let(:users) { User.approved.not_active_since(76.days.ago.to_date) }
let(:not_approved_users) { User.not_approved.not_active_since(76.days.ago.to_date)}
let(:task_name) { "usasearch:user:warn_set_to_not_approved" }

before do
Expand All @@ -107,6 +108,12 @@
@rake[task_name].invoke(76)
end

it 'will not call warn_set_to_not_approved on not approved users' do
expect(UserApproval).not_to receive(:warn_set_to_not_approved).
with(not_approved_users, 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)
Expand Down

0 comments on commit e14c1c7

Please sign in to comment.