Commit 65f22b96cf6ddeee465033b491a76c40f711fc54
1 parent
d74fdaec
Exists in
master
and in
28 other branches
Do not list templates when assigning enterprises to bsc
- also, fix missing Helper for plugin (ActionItem2102)
Showing
3 changed files
with
14 additions
and
1 deletions
Show diff stats
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
plugins/bsc/test/functional/bsc_plugin_myprofile_controller_test.rb
... | ... | @@ -50,6 +50,18 @@ class BscPluginMyprofileControllerTest < 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) | ... | ... |