Commit 982fcc8548a764d812ce19aceebd0aed0e64efc2
1 parent
ee50ba4e
Exists in
master
and in
5 other branches
Add tests for software communities plugin controller
Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
1 changed file
with
96 additions
and
27 deletions
Show diff stats
test/functional/software_communities_plugin_controller_test.rb
... | ... | @@ -4,7 +4,6 @@ require File.dirname(__FILE__) + '/../../controllers/software_communities_plugin |
4 | 4 | class SoftwareCommunitiesPluginController; def rescue_action(e) raise e end; end |
5 | 5 | |
6 | 6 | class SoftwareCommunitiesPluginControllerTest < ActionController::TestCase |
7 | - | |
8 | 7 | def setup |
9 | 8 | @admin = create_user("adminuser").person |
10 | 9 | @admin.stubs(:has_permission?).returns("true") |
... | ... | @@ -15,33 +14,103 @@ class SoftwareCommunitiesPluginControllerTest < ActionController::TestCase |
15 | 14 | @environment.add_admin(@admin) |
16 | 15 | @environment.save |
17 | 16 | |
18 | - @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") | |
19 | - @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | |
20 | - @juridical_nature = JuridicalNature.create(:name => "Autarquia") | |
17 | + LicenseInfo.create(:version=>"CC-GPL-V2", :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt") | |
18 | + LicenseInfo.create(:version=>"Academic Free License 3.0 (AFL-3.0)", :link=>"http://www.openfoundry.org/en/licenses/753-academic-free-license-version-30-afl") | |
19 | + LicenseInfo.create(:version=>"Apache License 2.0 (Apache-2.0)", :link=>"http://www.apache.org/licenses/LICENSE-2.0") | |
20 | + LicenseInfo.create(:version=>'BSD 2-Clause "Simplified" or "FreeBSD" License (BSD-2-Clause)', :link=>"http://opensource.org/licenses/BSD-2-Clause") | |
21 | + | |
22 | + ProgrammingLanguage.create(:name =>"Java") | |
23 | + ProgrammingLanguage.create(:name =>"Ruby") | |
24 | + ProgrammingLanguage.create(:name =>"C") | |
25 | + ProgrammingLanguage.create(:name =>"C++") | |
26 | + DatabaseDescription.create(:name => "PostgreSQL") | |
27 | + DatabaseDescription.create(:name => "MySQL") | |
28 | + DatabaseDescription.create(:name => "MongoDB") | |
29 | + DatabaseDescription.create(:name => "Oracle") | |
30 | + OperatingSystemName.create(:name=>"Debian") | |
31 | + | |
21 | 32 | @response = ActionController::TestResponse.new |
33 | + end | |
34 | + | |
35 | + should 'return the licenses datas' do | |
36 | + xhr :get, :get_license_data, :query => "" | |
37 | + | |
38 | + licenses = JSON.parse(@response.body) | |
39 | + | |
40 | + assert_equal 4, licenses.count | |
41 | + end | |
42 | + | |
43 | + should 'return licenses that has Free on their version name' do | |
44 | + xhr :get, :get_license_data, :query => "Free" | |
45 | + | |
46 | + licenses = JSON.parse(@response.body) | |
47 | + | |
48 | + assert_equal 2, licenses.count | |
49 | + end | |
50 | + | |
51 | + should 'return no licenses that has Common on their version name' do | |
52 | + xhr :get, :get_license_data, :query => "Common" | |
53 | + | |
54 | + licenses = JSON.parse(@response.body) | |
55 | + | |
56 | + assert_equal 0, licenses.count | |
57 | + end | |
58 | + | |
59 | + should 'render block template' do | |
60 | + xhr :get, :get_block_template | |
61 | + | |
62 | + assert_tag :tag => 'input', :attributes => { :class => "block_download_name" } | |
63 | + assert_tag :tag => 'input', :attributes => { :class => "block_download_link" } | |
64 | + assert_tag :tag => 'input', :attributes => { :class => "block_download_software_description" } | |
65 | + assert_tag :tag => 'input', :attributes => { :class => "block_download_minimum_requirements" } | |
66 | + assert_tag :tag => 'input', :attributes => { :class => "block_download_size" } | |
67 | + end | |
68 | + | |
69 | + should 'return the programming languages' do | |
70 | + xhr :get, :get_field_data, :query => "", :field => "software_language" | |
71 | + | |
72 | + languages = JSON.parse(@response.body) | |
73 | + | |
74 | + assert_equal 4, languages.count | |
75 | + end | |
76 | + | |
77 | + should 'return the programming languages that has C on their name' do | |
78 | + xhr :get, :get_field_data, :query => "C", :field => "software_language" | |
79 | + | |
80 | + languages = JSON.parse(@response.body) | |
81 | + | |
82 | + assert_equal 2, languages.count | |
83 | + end | |
84 | + | |
85 | + should 'dont return the programming languages that has HTML on their name' do | |
86 | + xhr :get, :get_field_data, :query => "HTML", :field => "software_language" | |
87 | + | |
88 | + languages = JSON.parse(@response.body) | |
89 | + | |
90 | + assert_equal 1, languages.count | |
91 | + end | |
92 | + | |
93 | + should 'return the databases' do | |
94 | + xhr :get, :get_field_data, :query => "", :field => "software_database" | |
95 | + | |
96 | + databases = JSON.parse(@response.body) | |
97 | + | |
98 | + assert_equal 4, databases.count | |
99 | + end | |
100 | + | |
101 | + should 'return the databases that has SQL on their name' do | |
102 | + xhr :get, :get_field_data, :query => "SQL", :field => "software_database" | |
103 | + | |
104 | + databases = JSON.parse(@response.body) | |
105 | + | |
106 | + assert_equal 3, databases.count | |
107 | + end | |
108 | + | |
109 | + should 'dont return the database that has on their name' do | |
110 | + xhr :get, :get_field_data, :query => "Cache", :field => "software_database" | |
111 | + | |
112 | + databases = JSON.parse(@response.body) | |
22 | 113 | |
23 | - @institution_list = [] | |
24 | - @institution_list << InstitutionTestHelper.create_public_institution( | |
25 | - "Ministerio Publico da Uniao", | |
26 | - "MPU", | |
27 | - "BR", | |
28 | - "DF", | |
29 | - "Gama", | |
30 | - @juridical_nature, | |
31 | - @gov_power, | |
32 | - @gov_sphere, | |
33 | - "12.345.678/9012-45" | |
34 | - ) | |
35 | - @institution_list << InstitutionTestHelper.create_public_institution( | |
36 | - "Tribunal Regional da Uniao", | |
37 | - "TRU", | |
38 | - "BR", | |
39 | - "DF", | |
40 | - "Brasilia", | |
41 | - @juridical_nature, | |
42 | - @gov_power, | |
43 | - @gov_sphere, | |
44 | - "12.345.678/9012-90" | |
45 | - ) | |
114 | + assert_equal 1, databases.count | |
46 | 115 | end |
47 | 116 | end | ... | ... |