search_controller_test.rb
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require File.dirname(__FILE__) + '/../../../../test/test_helper'
require File.dirname(__FILE__) + '/../../../../app/controllers/public/search_controller'
require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
class SearchController; def rescue_action(e) raise e end; end
class SearchControllerTest < ActionController::TestCase
include PluginTestHelper
def setup
@environment = Environment.default
@environment.enabled_plugins = ['MpogSoftwarePlugin']
@environment.save
@controller = SearchController.new
@request = ActionController::TestRequest.new
@request.stubs(:ssl?).returns(:false)
@response = ActionController::TestResponse.new
@category_software = Category.create!(:name => _("Software"), :environment => @environment)
end
should "communities searches don't have software or institution" do
community = create_community("New Community")
software = create_software_info("New Software")
institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")
get :communities, :query => "New"
assert_includes assigns(:searches)[:communities][:results], community
assert_not_includes assigns(:searches)[:communities][:results], software
assert_not_includes assigns(:searches)[:communities][:results], institution
end
should "software_infos search don't have community or institution" do
community = create_community("New Community")
software = create_software_info("New Software")
institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")
get :software_infos, :query => "New"
assert_includes assigns(:searches)[:software_infos][:results], software.community
assert_not_includes assigns(:searches)[:software_infos][:results], community
assert_not_includes assigns(:searches)[:software_infos][:results], institution.community
end
should "software_infos search by category" do
software_with_category = create_software_info("New Software With Category")
software_without_category = create_software_info("New Software Without Category")
category = Category.create!(:name => "Health", :environment => @environment, :parent => @category_software)
software_with_category.community.categories << category
software_with_category.save!
get :software_infos, :query => "New", :filter => category.id
assert_includes assigns(:searches)[:software_infos][:results], software_with_category.community
assert_not_includes assigns(:searches)[:software_infos][:results], software_without_category.community
end
should "institutions_search don't have community or software" do
community = create_community("New Community")
software = create_software_info("New Software")
institution = create_private_institution("New Private Institution", "NPI" , "Brazil", "DF", "Gama", "66.544.314/0001-63")
get :institutions, :query => "New"
assert_includes assigns(:searches)[:institutions][:results], institution.community
assert_not_includes assigns(:searches)[:institutions][:results], community
assert_not_includes assigns(:searches)[:institutions][:results], software.community
end
end