2013-02-05 13:16:51 -06:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe EmailLog do
|
2013-02-25 10:42:20 -06:00
|
|
|
|
2013-02-05 13:16:51 -06:00
|
|
|
it { should belong_to :user }
|
|
|
|
it { should validate_presence_of :to_address }
|
|
|
|
it { should validate_presence_of :email_type }
|
|
|
|
|
2013-06-10 15:46:08 -05:00
|
|
|
context 'after_create' do
|
2013-02-05 13:16:51 -06:00
|
|
|
|
2013-06-10 15:46:08 -05:00
|
|
|
context 'with user' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
it 'updates the last_emailed_at value for the user' do
|
|
|
|
lambda {
|
|
|
|
user.email_logs.create(email_type: 'blah', to_address: user.email)
|
|
|
|
user.reload
|
|
|
|
}.should change(user, :last_emailed_at)
|
|
|
|
end
|
2013-02-05 13:16:51 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|