Skip to content
Browse files

Add mailer specs.

  • Loading branch information...
1 parent 8ac0dab commit 9524cd25f4b7b2d023c6f050b96e64d0cfc3fb77 @ugisozols ugisozols committed
View
1 Gemfile
@@ -9,6 +9,7 @@ gem 'refinerycms-i18n', :git => 'git://github.com/parndt/refinerycms-i18n.git'
group :development, :test do
gem 'refinerycms-testing', :git => 'git://github.com/resolve/refinerycms.git'
gem 'guard-rspec', '~> 0.6.0'
+ gem "capybara-email", "~> 0.1.2"
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
View
2 app/views/refinery/inquiries/inquiry_mailer/confirmation.text.erb
@@ -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) -%>
View
2 app/views/refinery/inquiries/inquiry_mailer/notification.text.erb
@@ -15,4 +15,4 @@
<%=raw t('.closing_line') %>,
<%=raw Refinery::Core.site_name %>
-<%=raw t('.ps') %>
+<%=raw t('.ps') -%>
View
38 spec/requests/refinery/inquiries/mailer_spec.rb
@@ -0,0 +1,38 @@
+require "spec_helper"
+require "capybara/email/rspec"
+
+module Refinery
+ module Inquiries
+ describe "mailer" do
+ before do
+ 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
+ to = Refinery::Inquiries::Setting.notification_recipients
+ open_email(to)
+
+ current_email.from.should eq(["no-reply@example.com"])
+ current_email.to.should eq([to])
+ 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'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 9524cd2

Please sign in to comment.
Something went wrong with that request. Please try again.