Skip to content
Browse files

Merge pull request #104 from patrickdavey/adding_config

Adding config options for placeholders and phone number field.
  • Loading branch information...
2 parents d59ef56 + ee3dd72 commit 2df37cd157d42aa7994df8d5f21599497786e8fc @parndt parndt committed
View
22 app/views/refinery/inquiries/inquiries/new.html.erb
@@ -10,19 +10,27 @@
} %>
<div class="field">
<%= f.required_label :name, :class => 'placeholder-fallback' %>
- <%= f.text_field :name, :class => 'text', :required => 'required', :placeholder => t('name', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
+ <%= f.text_field :name, :class => 'text', :required => 'required',
+ :placeholder => t('name', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div>
<div class="field">
<%= f.required_label :email, :class => 'placeholder-fallback' %>
- <%= f.email_field :email, :class => 'text email', :required => 'required', :placeholder => t('email', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
- </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') %>
+ <%= f.email_field :email, :class => 'text email', :required => 'required',
+ :placeholder => t('email', :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', :placeholder => t('message', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') %>
+ <%= f.text_area :message, :rows => 8, :required => 'required',
+ :placeholder => t('message', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div>
<div class="actions">
<%= f.submit t('.send') %>
View
6 lib/generators/refinery/inquiries/templates/config/initializers/refinery/inquiries.rb.erb
@@ -1,4 +1,10 @@
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
4 lib/refinery/inquiries/configuration.rb
@@ -3,7 +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
56 spec/requests/refinery/inquiries/inquiries_spec.rb
@@ -64,7 +64,7 @@ module Inquiries
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)
+ Refinery::Inquiries.config.stub(:show_contact_privacy_link).and_return(false)
end
it "won't show link" do
@@ -88,6 +88,60 @@ module Inquiries
end
end
end
+
+ describe "palceholders" do
+ context "when show placeholders setting set to false" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_placeholders).and_return(false)
+ end
+
+ it "won't show placeholders" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_no_selector("input[placeholder]")
+ end
+ end
+
+ context "when show placeholders setting set to true" do
+ before(:each) do
+ Refinery::Inquiries.config.stub(:show_placeholders).and_return(true)
+ end
+
+ it "shows the placeholders" do
+ visit refinery.inquiries_new_inquiry_path
+
+ page.should have_selector("input[placeholder]")
+ 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

0 comments on commit 2df37cd

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