Skip to content

Commit

Permalink
config to toggle display of phone number field
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdavey committed Mar 8, 2013
1 parent ddc48dc commit ee3dd72
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/views/refinery/inquiries/inquiries/new.html.erb
Expand Up @@ -18,11 +18,15 @@
<%= f.email_field :email, :class => 'text email', :required => 'required', <%= f.email_field :email, :class => 'text email', :required => 'required',
:placeholder => t('email', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %> :placeholder => t('email', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %>
</div> </div>
<div class="field">
<%= f.label :phone, :class => 'placeholder-fallback' %> <% if Refinery::Inquiries.show_phone_number_field %>
<%= f.text_field :phone, :class => 'text phone', <div class="field">
:placeholder => t('phone', :scope => 'activerecord.attributes.refinery/inquiries/inquiry') if Refinery::Inquiries.show_placeholders %> <%= f.label :phone, :class => 'placeholder-fallback' %>
</div> <%= 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'> <div class='field message_field'>
<%= f.required_label :message, :class => 'placeholder-fallback' %> <%= f.required_label :message, :class => 'placeholder-fallback' %>
<%= f.text_area :message, :rows => 8, :required => 'required', <%= f.text_area :message, :rows => 8, :required => 'required',
Expand Down
Expand Up @@ -2,6 +2,9 @@ Refinery::Inquiries.configure do |config|
# Configure whether to show privacy link # Configure whether to show privacy link
# config.show_contact_privacy_link = <%= Refinery::Inquiries.show_contact_privacy_link.inspect %> # 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 # Configure whether to show form field placeholders
# config.show_placeholders = <%= Refinery::Inquiries.show_placeholders.inspect %> # config.show_placeholders = <%= Refinery::Inquiries.show_placeholders.inspect %>
end end
2 changes: 2 additions & 0 deletions lib/refinery/inquiries/configuration.rb
Expand Up @@ -3,9 +3,11 @@ module Inquiries
include ActiveSupport::Configurable include ActiveSupport::Configurable


config_accessor :show_contact_privacy_link config_accessor :show_contact_privacy_link
config_accessor :show_phone_number_field
config_accessor :show_placeholders config_accessor :show_placeholders


self.show_contact_privacy_link = true self.show_contact_privacy_link = true
self.show_phone_number_field = true
self.show_placeholders = true self.show_placeholders = true
end end
end end
28 changes: 28 additions & 0 deletions spec/requests/refinery/inquiries/inquiries_spec.rb
Expand Up @@ -114,6 +114,34 @@ module Inquiries
end end
end 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 end
end end

0 comments on commit ee3dd72

Please sign in to comment.