diff --git a/plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb b/plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb index e51eb74..4a043e2 100644 --- a/plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb +++ b/plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb @@ -8,7 +8,7 @@ class BscPluginMyprofileController < MyProfileController end def search_enterprise - render :text => environment.enterprises.find(:all, :conditions => ["type <> 'BscPlugin::Bsc' AND (LOWER(name) LIKE ? OR LOWER(identifier) LIKE ?)", "%#{params[:q]}%", "%#{params[:q]}%"]). + render :text => environment.enterprises.find(:all, :conditions => ["type <> 'BscPlugin::Bsc' AND (LOWER(name) LIKE ? OR LOWER(identifier) LIKE ?) AND (identifier NOT LIKE ?)", "%#{params[:q]}%", "%#{params[:q]}%", "%_template"]). select { |enterprise| enterprise.bsc.nil? && !profile.already_requested?(enterprise)}. map {|enterprise| {:id => enterprise.id, :name => enterprise.name} }. to_json diff --git a/plugins/bsc/lib/bsc_plugin/bsc_helper.rb b/plugins/bsc/lib/bsc_plugin/bsc_helper.rb index 08286c5..adee568 100644 --- a/plugins/bsc/lib/bsc_plugin/bsc_helper.rb +++ b/plugins/bsc/lib/bsc_plugin/bsc_helper.rb @@ -1,5 +1,6 @@ module BscPlugin::BscHelper include ActionView::Helpers::FormTagHelper + include ActionView::Helpers::TextHelper def token_input_field_tag(name, element_id, search_action, options = {}, text_field_options = {}, html_options = {}) options[:min_chars] ||= 3 diff --git a/plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb b/plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb index aa7440f..8090903 100644 --- a/plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb +++ b/plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb @@ -50,6 +50,18 @@ class BscPluginMyprofileControllerTest < Test::Unit::TestCase assert_match /#{e6.name}/, @response.body end + should 'do not list profiles template on search' do + e1 = Enterprise.create!(:name => 'Sample Enterprise 1', :identifier => 'sample-enterprise-1') + e2 = Enterprise.create!(:name => 'Sample Enterprise 2', :identifier => 'sample-enterprise-2') + t1 = Enterprise.create!(:name => 'Enterprise template', :identifier => 'enterprise_template') + t2 = Enterprise.create!(:name => 'Inactive enterprise template', :identifier => 'inactive_enterprise_template') + + get :search_enterprise, :profile => bsc.identifier, :q => 'ent' + + assert_no_match /#{t1.name}/, @response.body + assert_no_match /#{t2.name}/, @response.body + end + should 'save associations' do e1 = fast_create(Enterprise, :enabled => false) e2 = fast_create(Enterprise, :enabled => false) -- libgit2 0.21.2