diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index 4e60496..d636aef 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -60,6 +60,10 @@ module FormsHelper state_id = 'state-' + FormsHelper.next_id_number city_id = 'city-' + FormsHelper.next_id_number + + if states.length < 1 + return + end if simple states = [State.new(:name => _('Select the State'))] + states diff --git a/app/views/contact/new.rhtml b/app/views/contact/new.rhtml index a9c69c4..ec8aa26 100644 --- a/app/views/contact/new.rhtml +++ b/app/views/contact/new.rhtml @@ -9,8 +9,10 @@ <%= required_fields_message %> - <% unless environment.enabled?('disable_select_city_for_contact') %> - <%= labelled_form_field _('City and state'), select_city(true) %> + <% location_fields = select_city(true) %> + + <% unless environment.enabled?('disable_select_city_for_contact') || location_fields.blank? %> + <%= labelled_form_field _('City and state'), location_fields %> <% end %> <%= required f.text_field(:subject) %> <%= required f.text_area(:message, :rows => 10, :cols => 60) %> diff --git a/features/contact.feature b/features/contact.feature new file mode 100644 index 0000000..0f3809a --- /dev/null +++ b/features/contact.feature @@ -0,0 +1,24 @@ +Feature: contact organization +As a user +I want to contact an organization +In order to ask questions and solve problems + + Background: + Given the following users + | login | name | + | joaosilva | Joao Silva | + And the following communities + | identifier | name | + | sample-community | Sample Community | + And I am logged in as "joaosilva" + + Scenario: contact us show state field only if there is any state + Given I am on Sample Community's homepage + When I follow "Contact us" + Then I should not see "City and state" + Given the following states + | name | + | Bahia | + When I follow "Contact us" + Then I should see "City and state" + diff --git a/test/functional/contact_controller_test.rb b/test/functional/contact_controller_test.rb index 0fa3f2b..fd935e2 100644 --- a/test/functional/contact_controller_test.rb +++ b/test/functional/contact_controller_test.rb @@ -64,6 +64,7 @@ class ContactControllerTest < Test::Unit::TestCase end should 'not display select/city select when disable it in environment' do + state = State.create!(:name => "Bahia", :environment => Environment.default) get :new, :profile => profile.identifier assert_tag :tag => 'select', :attributes => {:name => 'state'} env = Environment.default diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 7c67db9..85fc2af 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -365,6 +365,7 @@ class SearchControllerTest < Test::Unit::TestCase end should 'display option to search within a given point and distance' do + state = State.create!(:name => "Bahia", :environment => Environment.default) get :popup assert_tag :tag => 'select', :attributes => {:name => 'radius'} -- libgit2 0.21.2