Permalink
Browse files

Merge pull request #91 from refinery/issue_65

Add mailer specs.
  • Loading branch information...
ugisozols committed Oct 4, 2012
2 parents 94b4501 + 0c63645 commit 361b3a3c02da666bac661d6312982c250109f06d
View
@@ -9,6 +9,7 @@ gem 'refinerycms-i18n', :git => 'git://github.com/refinery/refinerycms-i18n.git'
group :development, :test do
gem 'refinerycms-testing', :git => 'git://github.com/refinery/refinerycms.git'
gem 'guard-rspec', '~> 0.6.0'
+ gem "capybara-email", "~> 0.1.2"
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
@@ -1 +1 @@
-<%=raw Refinery::Inquiries::Setting.confirmation_message(Globalize.locale).gsub("%name%", @inquiry.name) %>
+<%=raw Refinery::Inquiries::Setting.confirmation_message(Globalize.locale).gsub("%name%", @inquiry.name) -%>
@@ -15,4 +15,4 @@
<%=raw t('.closing_line') %>,
<%=raw Refinery::Core.site_name %>
-<%=raw t('.ps') %>
+<%=raw t('.ps') -%>
@@ -0,0 +1,39 @@
+require "spec_helper"
+require "capybara/email/rspec"
+
+module Refinery
+ module Inquiries
+ describe "mailer" do
+ before do
+ Refinery::Inquiries::Setting.stub(:notification_recipients).and_return("rspec@refinerycms.com")
+
+ clear_emails
+
+ visit refinery.inquiries_new_inquiry_path
+
+ fill_in "Name", :with => "Ugis Ozols"
+ fill_in "Email", :with => "ugis.ozols@refinerycms.com"
+ fill_in "Message", :with => "Hey, I'm testing!"
+ click_button "Send message"
+ end
+
+ it "sends confirmation email" do
+ open_email("ugis.ozols@refinerycms.com")
+
+ current_email.from.should eq(["no-reply@example.com"])
+ current_email.to.should eq(["ugis.ozols@refinerycms.com"])
+ current_email.subject.should eq("Thank you for your inquiry")
+ current_email.body.should eq("Thank you for your inquiry Ugis Ozols,\r\n\r\nThis email is a receipt to confirm we have received your inquiry and we'll be in touch shortly.\r\n\r\nThanks.")
+ end
+
+ it "sends notification email" do
+ open_email("rspec@refinerycms.com")
+
+ current_email.from.should eq(["no-reply@example.com"])
+ current_email.to.should eq(["rspec@refinerycms.com"])
+ current_email.subject.should eq("New inquiry from your website")
+ current_email.body.should eq("Hi there,\r\n\r\nYou just received a new inquiry on your website.\r\n\r\n--- inquiry starts ---\r\n\r\nFrom: Ugis Ozols\r\nEmail: ugis.ozols@refinerycms.com\r\nPhone: \r\nMessage:\r\nHey, I&#x27;m testing!\r\n\r\n--- inquiry ends ---\r\n\r\nKind Regards,\r\nCompany Name\r\n\r\nP.S. All your inquiries are stored in the \"Inquiries\" section of Refinery should you ever want to view it later there.")
+ end
+ end
+ end
+end

0 comments on commit 361b3a3

Please sign in to comment.