Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

config to toggle display of phone number field

  • Loading branch information...
commit ee3dd727c87ef5d913ce42f50db45cc4acbcfbac 1 parent ddc48dc
@patrickdavey patrickdavey authored
View
14 app/views/refinery/inquiries/inquiries/new.html.erb
@@ -18,11 +18,15 @@
<%= f.email_field :email, :class => 'text email', :required => 'required',
:placeholder => t('email', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div>
- <div class="field">
- <%= f.label :phone, :class => 'placeholder-fallback' %>
- <%= f.text_field :phone, :class => 'text phone',
- :placeholder => t('phone', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
- </div>
+
+ <% if Refinery::Inquiries.show_phone_number_field %>
+ <div class="field">
+ <%= f.label :phone, :class => 'placeholder-fallback' %>
+ <%= f.text_field :phone, :class => 'text phone',
+ :placeholder => t('phone', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
+ </div>
+ <% end %>
+
<div class='field message_field'>
<%= f.required_label :message, :class => 'placeholder-fallback' %>
<%= f.text_area :message, :rows => 8, :required => 'required',
View
3  lib/generators/refinery/inquiries/templates/config/initializers/refinery/inquiries.rb.erb
@@ -2,6 +2,9 @@ Refinery::Inquiries.configure do |config|
# Configure whether to show privacy link
# config.show_contact_privacy_link = <%= Refinery::Inquiries.show_contact_privacy_link.inspect %>
+ # Configure whether to show phone number field
+ # config.show_phone_number_field = <%= Refinery::Inquiries.show_phone_number_field.inspect %>
+
# Configure whether to show form field placeholders
# config.show_placeholders = <%= Refinery::Inquiries.show_placeholders.inspect %>
end
View
2  lib/refinery/inquiries/configuration.rb
@@ -3,9 +3,11 @@ module Inquiries
include ActiveSupport::Configurable
config_accessor :show_contact_privacy_link
+ config_accessor :show_phone_number_field
config_accessor :show_placeholders
self.show_contact_privacy_link = true
+ self.show_phone_number_field = true
self.show_placeholders = true
end
end
View
28 spec/requests/refinery/inquiries/inquiries_spec.rb
@@ -114,6 +114,34 @@ module Inquiries
end
end
end
+
+ describe "phone number" do
+ context "when show phone numbers setting set to false" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_phone_number_field).and_return(false)
+ end
+
+ it "won't show phone number" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_no_selector("label", :text => 'Phone')
+ page.should have_no_selector("#inquiry_phone")
+ end
+ end
+
+ context "when show phone numbers setting set to true" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_phone_number_field).and_return(true)
+ end
+
+ it "shows the phone number" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_selector("label", :text => 'Phone')
+ page.should have_selector("#inquiry_phone")
+ end
+ end
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.