Commit 65f22b96cf6ddeee465033b491a76c40f711fc54

Authored by Joenio Costa
1 parent d74fdaec

Do not list templates when assigning enterprises to bsc

- also, fix missing Helper for plugin

(ActionItem2102)
plugins/bsc/controllers/bsc_plugin_myprofile_controller.rb
... ... @@ -8,7 +8,7 @@ class BscPluginMyprofileController < MyProfileController
8 8 end
9 9  
10 10 def search_enterprise
11   - render :text => environment.enterprises.find(:all, :conditions => ["type <> 'BscPlugin::Bsc' AND (LOWER(name) LIKE ? OR LOWER(identifier) LIKE ?)", "%#{params[:q]}%", "%#{params[:q]}%"]).
  11 + 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"]).
12 12 select { |enterprise| enterprise.bsc.nil? && !profile.already_requested?(enterprise)}.
13 13 map {|enterprise| {:id => enterprise.id, :name => enterprise.name} }.
14 14 to_json
... ...
plugins/bsc/lib/bsc_plugin/bsc_helper.rb
1 1 module BscPlugin::BscHelper
2 2 include ActionView::Helpers::FormTagHelper
  3 + include ActionView::Helpers::TextHelper
3 4  
4 5 def token_input_field_tag(name, element_id, search_action, options = {}, text_field_options = {}, html_options = {})
5 6 options[:min_chars] ||= 3
... ...
plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb
... ... @@ -50,6 +50,18 @@ class BscPluginMyprofileControllerTest &lt; Test::Unit::TestCase
50 50 assert_match /#{e6.name}/, @response.body
51 51 end
52 52  
  53 + should 'do not list profiles template on search' do
  54 + e1 = Enterprise.create!(:name => 'Sample Enterprise 1', :identifier => 'sample-enterprise-1')
  55 + e2 = Enterprise.create!(:name => 'Sample Enterprise 2', :identifier => 'sample-enterprise-2')
  56 + t1 = Enterprise.create!(:name => 'Enterprise template', :identifier => 'enterprise_template')
  57 + t2 = Enterprise.create!(:name => 'Inactive enterprise template', :identifier => 'inactive_enterprise_template')
  58 +
  59 + get :search_enterprise, :profile => bsc.identifier, :q => 'ent'
  60 +
  61 + assert_no_match /#{t1.name}/, @response.body
  62 + assert_no_match /#{t2.name}/, @response.body
  63 + end
  64 +
53 65 should 'save associations' do
54 66 e1 = fast_create(Enterprise, :enabled => false)
55 67 e2 = fast_create(Enterprise, :enabled => false)
... ...