Skip to content

Commit

Permalink
Reordered error messages to match order of fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwagener authored and parndt committed Jul 18, 2012
1 parent 204df01 commit a6f1e7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/refinery/inquiries/inquiry.rb
Expand Up @@ -9,8 +9,8 @@ class Inquiry < Refinery::Core::BaseModel
:extra_spam_words => %w()

validates :name, :presence => true
validates :message, :presence => true
validates :email, :format=> { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
validates :message, :presence => true

acts_as_indexed :fields => [:name, :email, :message, :phone]

Expand Down
18 changes: 15 additions & 3 deletions spec/requests/refinery/inquiries/inquiries_spec.rb
Expand Up @@ -33,20 +33,32 @@ module Inquiries
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 can't be blank")
page.should have_content("Email is invalid")
page.should have_content("Message can't be blank")
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
Expand Down

0 comments on commit a6f1e7d

Please sign in to comment.