I have this test:
 describe 'check_account_status' do
  it 'should send the correct reminder email one week prior to account disablement' do
  # Three weeks since initial email
  reverification = create(:reverification)
  initial_notification = reverification.twitter_reverification_sent_at.to_datetime
  ActionMailer::Base.deliveries.clear
  Timecop.freeze(initial_notification + 21) do
    Reverification.check_account_status
    ActionMailer::Base.deliveries.size.must_equal 1
    ActionMailer::Base.deliveries.first.subject.must_equal I18n.t('.account_mailer.one_week_left.subject')
    reverification.reminder_sent_at.class.must_equal ActiveSupport::TimeWithZone
    reverification.notification_counter.must_equal 1
    must_render_template 'reverification.html.haml'
  end
end
This test produces this error:
check_account_status#test_0001_should send the correct reminder email one week prior to account disablement [/Users/drubio/vms/ohloh-ui/test/models/reverification_test.rb:67]:
Expected: ActiveSupport::TimeWithZone
Actual: NilClass
Here is my code:
class Reverification < ActiveRecord::Base
  belongs_to :account
  FIRST_NOTIFICATION_ERROR = []
  class << self
    def check_account_status
      Reverification.where(twitter_reverified: false).each do |reverification|
        calculate_status(reverification)
        one_week_left(reverification)
      end
    end
    private
    def calculate_status(reverification)
      @right_now = Time.now.utc.to_datetime
      @initial_email_date = reverification.twitter_reverification_sent_at.to_datetime
      @notification_counter = reverification.notification_counter
    end
    def one_week_left(reverification)
    # Check to see if three weeks have passed since the initial email
    # and check to see if its before the one day notification before
    # marking an account as spam.
      if (@right_now.to_i >= (@initial_email_date + 21).to_i) && (@right_now.to_i < (@initial_email_date + 29).to_i)
        begin
          AccountMailer.one_week_left(reverification.account).deliver_now
        rescue
          FIRST_NOTIFICATION_FAILURE << account.id
          return
        end
        update_reverification_fields(reverification)
      end
    end
    def update_reverification_fields(reverification)
      reverification.notification_counter += 1
      reverification.reminder_sent_at = Time.now.utc
      reverification.save!
      reverification.reload
    end
  end
Forgive the indentation, but what seems to be the problem, is that my reverification object doesn't update when it leaves the check_account_status method. I've placed puts statements through out the code and I can see without a doubt that the reverification object is indeed updating. However after it leaves the update_reverification_fields and returns to the test block, the fields are not updated. Why is that? Has anyone encountered this?
 
     
     
    