Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

94 lines (72 sloc) 3.135 kB
require "spec_helper"
module Refinery
module Inquiries
describe "inquiries" do
before(:each) do
Factory(:refinery_user)
# load in seeds we use in migration
Refinery::Inquiries::Engine.load_seed
end
context "when valid data" do
it "is successful" do
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"
page.current_path.should == refinery.thank_you_inquiries_inquiries_path
page.should have_content("Thank You")
within "#body_content" do
page.should have_content("We've received your inquiry and will get back to you with a response shortly.")
page.should have_content("Return to the home page")
page.should have_selector("a[href='/']")
end
Refinery::Inquiries::Inquiry.count.should == 1
end
end
context "when invalid data" do
let(:name_error_message) { "Name can't be blank" }
let(:email_error_message) { "Email is invalid" }
let(:message_error_message) { "Message can't be blank" }
it "is not successful" do
visit refinery.inquiries_new_inquiry_path
click_button "Send message"
page.current_path.should == refinery.inquiries_new_inquiry_path
page.should have_content("There were problems with the following fields")
page.should have_content(name_error_message)
page.should have_content(email_error_message)
page.should have_content(message_error_message)
page.should have_no_content("Phone can't be blank")
Refinery::Inquiries::Inquiry.count.should == 0
end
it "displays the error messages in the same order as the fields" do
visit refinery.inquiries_new_inquiry_path
click_button "Send message"
page.body.should match /#{name_error_message}.+#{email_error_message}.+#{message_error_message}/m
end
end
describe "privacy" do
context "when show contact privacy link setting set to false" do
before(:each) do
Refinery::Inquiries.stub(:show_contact_privacy_link).and_return(false)
end
it "won't show link" do
visit refinery.inquiries_new_inquiry_path
page.should have_no_content("We value your privacy")
page.should have_no_selector("a[href='/pages/privacy-policy']")
end
end
context "when show contact privacy link setting set to true" do
before(:each) do
Refinery::Inquiries.config.stub(:show_contact_privacy_link).and_return(true)
end
it "shows the link" do
visit refinery.inquiries_new_inquiry_path
page.should have_content("We value your privacy")
page.should have_selector("a[href='/pages/privacy-policy']")
end
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.