From 8625b2c8c476eb68e94642e86625ed7fc5fed2c3 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Thu, 23 Jan 2014 16:37:40 +0000 Subject: [PATCH] fix: catalog configuration only for enterprises --- app/views/profile_editor/_organization.rhtml | 7 ++++--- test/functional/profile_editor_controller_test.rb | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/app/views/profile_editor/_organization.rhtml b/app/views/profile_editor/_organization.rhtml index 6c0caa4..b5291af 100644 --- a/app/views/profile_editor/_organization.rhtml +++ b/app/views/profile_editor/_organization.rhtml @@ -66,6 +66,7 @@ <%= render :partial => 'moderation', :locals => { :profile => @profile } %> -

<%=_('Product/Service catalog')%>

- -<%= f.text_field(:products_per_catalog_page, :size=>3) %> +<% if profile.enterprise? && profile.environment.enabled?('products_for_enterprises') %> +

<%=_('Products/Services catalog')%>

+ <%= labelled_form_field(_('Number of products/services displayed per page on catalog'), text_field(:profile_data, :products_per_catalog_page, :size => 3)) %> +<% end %> diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index e32f2dc..da34812 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -988,5 +988,44 @@ class ProfileEditorControllerTest < ActionController::TestCase assert_response :success end + should 'display field to choose number of products if enterprise and enabled on environment' do + enterprise = fast_create(Enterprise) + enterprise.environment.enable('products_for_enterprises') + get :edit, :profile => enterprise.identifier + assert_tag :tag => 'div', :descendant => { :tag => 'h2', :content => 'Products/Services catalog' } + assert_tag :tag => 'div', + :attributes => { :class => 'formfield type-text' }, + :descendant => {:tag => 'input', :attributes => {:id => 'profile_data_products_per_catalog_page'} } + end + + should 'not display field to choose number of products if enterprise but disabled on environment' do + enterprise = fast_create(Enterprise) + enterprise.environment.disable('products_for_enterprises') + get :edit, :profile => enterprise.identifier + assert_no_tag :tag => 'div', :descendant => { :tag => 'h2', :content => 'Products/Services catalog' } + assert_no_tag :tag => 'div', + :attributes => { :class => 'formfield type-text' }, + :descendant => {:tag => 'input', :attributes => {:id => 'profile_data_products_per_catalog_page'} } + end + + should 'not display field to choose number of products if enabled on environment but not enterprise' do + community = fast_create(Community) + community.environment.enable('products_for_enterprises') + get :edit, :profile => community.identifier + assert_no_tag :tag => 'div', :descendant => { :tag => 'h2', :content => 'Products/Services catalog' } + assert_no_tag :tag => 'div', + :attributes => { :class => 'formfield type-text' }, + :descendant => {:tag => 'input', :attributes => {:id => 'profile_data_products_per_catalog_page'} } + end + + should 'not display field to choose number of products if disabled on environment and not enterprise' do + community = fast_create(Community) + community.environment.disable('products_for_enterprises') + get :edit, :profile => community.identifier + assert_no_tag :tag => 'div', :descendant => { :tag => 'h2', :content => 'Products/Services catalog' } + assert_no_tag :tag => 'div', + :attributes => { :class => 'formfield type-text' }, + :descendant => {:tag => 'input', :attributes => {:id => 'profile_data_products_per_catalog_page'} } + end end -- libgit2 0.21.2