<commit_before>#   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<commit_msg>update maintenance mailer spec for new mail text<commit_after>#   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("for #{AppConfig.settings.maintenance.remove_old_users.after_days} 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("sign in to your account before #{@removal_timestamp.utc}")
    end
  end
end
{'fraction_non_alphanumeric': 0.09968944099378882, 'fraction_numerical': 0.008695652173913044, 'mean_word_length': 3.743740795287187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6518255', 'n_tokens_mistral': 984, 'n_tokens_neox': 949, 'n_words': 240}