2013-02-05 14:16:51 -05:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe UserNotifications do
|
2013-02-25 11:42:20 -05:00
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
|
|
|
|
describe ".signup" do
|
|
|
|
subject { UserNotifications.signup(user) }
|
|
|
|
|
|
|
|
its(:to) { should == [user.email] }
|
|
|
|
its(:subject) { should be_present }
|
|
|
|
its(:from) { should == [SiteSetting.notification_email] }
|
|
|
|
its(:body) { should be_present }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe ".forgot_password" do
|
|
|
|
subject { UserNotifications.forgot_password(user) }
|
|
|
|
|
|
|
|
its(:to) { should == [user.email] }
|
|
|
|
its(:subject) { should be_present }
|
|
|
|
its(:from) { should == [SiteSetting.notification_email] }
|
2013-02-25 11:42:20 -05:00
|
|
|
its(:body) { should be_present }
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '.daily_digest' do
|
|
|
|
subject { UserNotifications.digest(user) }
|
|
|
|
|
|
|
|
context "without new topics" do
|
|
|
|
its(:to) { should be_blank }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with new topics" do
|
|
|
|
before do
|
2013-06-03 16:12:24 -04:00
|
|
|
Topic.expects(:for_digest).returns([Fabricate(:topic, user: Fabricate(:coding_horror))])
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
its(:to) { should == [user.email] }
|
|
|
|
its(:subject) { should be_present }
|
|
|
|
its(:from) { should == [SiteSetting.notification_email] }
|
2013-02-25 11:42:20 -05:00
|
|
|
its(:body) { should be_present }
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.user_mentioned' do
|
|
|
|
|
|
|
|
let(:post) { Fabricate(:post, user: user) }
|
2013-02-27 18:30:14 -05:00
|
|
|
let(:username) { "walterwhite"}
|
|
|
|
|
2013-02-05 14:16:51 -05:00
|
|
|
let(:notification) do
|
2013-02-27 18:30:14 -05:00
|
|
|
Fabricate(:notification, user: user, topic: post.topic, post_number: post.post_number, data: {display_username: username}.to_json )
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { UserNotifications.user_mentioned(user, notification: notification, post: notification.post) }
|
|
|
|
|
|
|
|
its(:to) { should == [user.email] }
|
|
|
|
its(:subject) { should be_present }
|
|
|
|
its(:from) { should == [SiteSetting.notification_email] }
|
2013-02-27 18:30:14 -05:00
|
|
|
|
|
|
|
it "should have the correct from address" do
|
2013-02-27 19:01:45 -05:00
|
|
|
subject.header['from'].to_s.should == "#{username} via #{SiteSetting.title} <#{SiteSetting.notification_email}>"
|
2013-02-27 18:30:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2013-02-25 11:42:20 -05:00
|
|
|
its(:body) { should be_present }
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|