summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock4
-rw-r--r--spec/mailers/notify_spec.rb82
-rw-r--r--spec/spec_helper.rb1
4 files changed, 88 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index 1cb5520ad3b..af5b0241397 100644
--- a/Gemfile
+++ b/Gemfile
@@ -66,4 +66,5 @@ group :test do
gem "turn", :require => false
gem "simplecov", :require => false
gem "shoulda", "3.0.1"
+ gem 'email_spec'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 182cf669197..6a18f7d17d6 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -114,6 +114,9 @@ GEM
warden (~> 1.1)
diff-lcs (1.1.3)
drapper (0.8.4)
+ email_spec (1.2.1)
+ mail (~> 2.2)
+ rspec (~> 2.0)
erubis (2.7.0)
escape_utils (0.2.4)
eventmachine (0.12.10)
@@ -330,6 +333,7 @@ DEPENDENCIES
database_cleaner
devise (~> 1.5)
drapper
+ email_spec
faker
foreman
git
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
new file mode 100644
index 00000000000..97ac15dc4bc
--- /dev/null
+++ b/spec/mailers/notify_spec.rb
@@ -0,0 +1,82 @@
+require 'spec_helper'
+
+describe Notify do
+ include EmailSpec::Helpers
+ include EmailSpec::Matchers
+
+ before :all do
+ default_url_options[:host] = 'example.com'
+ end
+
+ let(:example_email) { 'user@example.com' }
+
+ describe 'new user email' do
+ let(:example_password) { 'thisismypassword' }
+ let(:example_site_url) { root_url }
+ let(:new_user) { Factory.new(:user, :email => example_email, :password => example_password) }
+
+ subject { Notify.new_user_email(new_user, new_user.password) }
+
+ it 'is sent to the new user' do
+ should deliver_to new_user.email
+ end
+
+ it 'has the correct subject' do
+ should have_subject /Account was created for you/
+ end
+
+ it 'contains the new user\'s login name' do
+ should have_body_text /#{new_user.email}/
+ end
+
+ it 'contains the new user\'s password' do
+ should have_body_text /#{new_user.password}/
+ end
+
+ it 'includes a link to the site' do
+ should have_body_text /#{example_site_url}/
+ end
+ end
+
+ describe 'new issue email' do
+ let(:project) { Factory.create(:project) }
+ let(:assignee) { Factory.create(:user, :email => example_email) }
+ let(:issue) { Factory.create(:issue, :assignee => assignee, :project => project ) }
+
+ subject { Notify.new_issue_email(issue) }
+
+ it 'is sent to the assignee' do
+ should deliver_to assignee.email
+ end
+
+ it 'has the correct subject' do
+ should have_subject /New Issue was created/
+ end
+
+ it 'contains a link to the new issue' do
+ should have_body_text /#{project_issue_url project, issue}/
+ end
+ end
+
+ describe 'note wall email' do
+ let(:project) { Factory.create(:project) }
+ let(:recipient) { Factory.create(:user, :email => example_email) }
+ let(:author) { Factory.create(:user) }
+ let(:note) { Factory.create(:note, :project => project, :author => author) }
+ let(:note_url) { wall_project_url(project, :anchor => "note_#{note.id}") }
+
+ subject { Notify.note_wall_email(recipient, note) }
+
+ it 'is sent to the given recipient' do
+ should deliver_to recipient.email
+ end
+
+ it 'has the correct subject' do
+ should have_subject /#{project.name}/
+ end
+
+ it 'contains a link to the wall note' do
+ should have_body_text /#{note_url}/
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index f24496ec92c..18b7854d102 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -11,6 +11,7 @@ require 'capybara/dsl'
require 'webmock/rspec'
require 'factories'
require 'monkeypatch'
+require 'email_spec'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.