diaspora/spec/mailers/maintenance_spec.rb
Jason Robinson 69c3566958 Maintenance feature to remove old users
Add Sidetiq webview to the Sidekiq monitoring panel

Add rake task maintenance:queue_users_for_removal
This basically just triggers an immediate run of the normal maintenance remove old users functionality that is normally (if enabled) scheduled to run once a day via sidetiq

Add extra safety when checking for user removal due to inactivity.
Now also user.last_seen will also be checked to make sure a user will not be removed in the event that the Devise rememember me login functionality has stopped the users remove_after timestamp from being removed.

Add initializer for maintenance job.
Add warning about mail being disabled if remove_old_users maintenance is enabled.
2014-10-16 22:53:08 +03:00

41 lines
1.5 KiB
Ruby

# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe Maintenance, :type => :mailer do
describe 'create warning' do
before do
@removal_timestamp = Time.now + 3.days
@user = FactoryGirl.create(:user_with_aspect, :username => "local", :remove_after => @removal_timestamp)
end
it "#should deliver successfully" do
expect {
Maintenance.account_removal_warning(@user).deliver
}.to_not raise_error
end
it "#should be added to the delivery queue" do
expect {
Maintenance.account_removal_warning(@user).deliver
}.to change(ActionMailer::Base.deliveries, :size).by(1)
end
it "#should include correct recipient" do
Maintenance.account_removal_warning(@user).deliver
expect(ActionMailer::Base.deliveries.last.to[0]).to include(@user.email)
end
it "#should include after inactivity days from settings" do
Maintenance.account_removal_warning(@user).deliver
expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("more than "+AppConfig.settings.maintenance.remove_old_users.after_days.to_s+" days")
end
it "#should include timestamp for account removal" do
Maintenance.account_removal_warning(@user).deliver
expect(ActionMailer::Base.deliveries.last.body.parts[0].body.raw_source).to include("logging into the account before "+@removal_timestamp.utc.to_s)
end
end
end