Commit 09cf54dcfdd1abde73be56b96fb3e1dcf06141e9

Authored by Gabriel Silva
1 parent 1a511c6c
Exists in spb_to_rails4

Fixes software_communities unit and functional tests

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing 20 changed files with 20 additions and 109 deletions   Show diff stats
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
@@ -100,7 +100,7 @@ class SearchController @@ -100,7 +100,7 @@ class SearchController
100 @public_software_selected = false 100 @public_software_selected = false
101 end 101 end
102 102
103 - filtered_software_list.select!{ |software| visible_communities.include?(software.community) } 103 + filtered_software_list = filtered_software_list.select{ |software| visible_communities.include?(software.community) }
104 category_ids = get_filter_category_ids 104 category_ids = get_filter_category_ids
105 105
106 unless category_ids.empty? 106 unless category_ids.empty?
src/noosfero-spb/software_communities/lib/license_helper.rb
1 module LicenseHelper 1 module LicenseHelper
2 def self.find_licenses query 2 def self.find_licenses query
3 licenses = LicenseInfo.where("version ILIKE ?", "%#{query}%").select("id, version") 3 licenses = LicenseInfo.where("version ILIKE ?", "%#{query}%").select("id, version")
4 - licenses.reject!{|license| license.version == "Another"} 4 + licenses = licenses.reject{|license| license.version == "Another"}
5 license_another = LicenseInfo.find_by_version("Another") 5 license_another = LicenseInfo.find_by_version("Another")
6 licenses << license_another if license_another 6 licenses << license_another if license_another
7 licenses 7 licenses
src/noosfero-spb/software_communities/lib/software_info.rb
@@ -21,7 +21,7 @@ class SoftwareInfo &lt; ActiveRecord::Base @@ -21,7 +21,7 @@ class SoftwareInfo &lt; ActiveRecord::Base
21 SoftwareInfo.joins(:community).where("profiles.visible = ? AND environment_id = ? ", true, env.id) 21 SoftwareInfo.joins(:community).where("profiles.visible = ? AND environment_id = ? ", true, env.id)
22 else 22 else
23 searchable_software_objects = SoftwareInfo.transform_list_in_methods_list(SEARCHABLE_SOFTWARE_CLASSES) 23 searchable_software_objects = SoftwareInfo.transform_list_in_methods_list(SEARCHABLE_SOFTWARE_CLASSES)
24 - includes(searchable_software_objects).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')").where("profiles.visible = ? AND environment_id = ?", true, env.id) 24 + includes(searchable_software_objects).joins(:community).where("to_tsvector('simple', #{search_fields}) @@ to_tsquery('#{filtered_query}')").where("profiles.visible = ? AND environment_id = ?", true, env.id)
25 end 25 end
26 } 26 }
27 27
src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb
@@ -35,11 +35,6 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -35,11 +35,6 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
35 @environment.save 35 @environment.save
36 end 36 end
37 37
38 - def teardown  
39 - Community.destroy_all  
40 - SoftwareInfo.destroy_all  
41 - end  
42 -  
43 should "redirect to edit_software_community on edit community of software" do 38 should "redirect to edit_software_community on edit community of software" do
44 software = create_software(software_fields) 39 software = create_software(software_fields)
45 post :edit, :profile => software.community.identifier 40 post :edit, :profile => software.community.identifier
src/noosfero-spb/software_communities/test/functional/search_controller_test.rb
@@ -42,10 +42,6 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -42,10 +42,6 @@ class SearchControllerTest &lt; ActionController::TestCase
42 @softwares[1].save! 42 @softwares[1].save!
43 end 43 end
44 44
45 - def teardown  
46 - SoftwareInfo.destroy_all  
47 - end  
48 -  
49 should "communities searches don't have software" do 45 should "communities searches don't have software" do
50 community = create_community("Community One") 46 community = create_community("Community One")
51 47
src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb
@@ -28,22 +28,14 @@ module PluginTestHelper @@ -28,22 +28,14 @@ module PluginTestHelper
28 name.to_slug, 28 name.to_slug,
29 email, 29 email,
30 password, 30 password,
31 - password_confirmation, 31 + password_confirmation
32 ) 32 )
33 - person = Person::new  
34 33
35 - user.person = person  
36 - person.user = user  
37 -  
38 - person.name = name  
39 - person.identifier = name.to_slug  
40 - person.state = state  
41 - person.city = city 34 + user.person.state = state
  35 + user.person.city = city
42 36
43 user.save 37 user.save
44 - person.save  
45 -  
46 - person 38 + user.person
47 end 39 end
48 40
49 def create_user login, email, password, password_confirmation 41 def create_user login, email, password, password_confirmation
@@ -54,6 +46,7 @@ module PluginTestHelper @@ -54,6 +46,7 @@ module PluginTestHelper
54 user.password = password 46 user.password = password
55 user.password_confirmation = password_confirmation 47 user.password_confirmation = password_confirmation
56 48
  49 + user.save
57 user 50 user
58 end 51 end
59 52
src/noosfero-spb/software_communities/test/unit/communities_block_test.rb
@@ -12,17 +12,10 @@ class CommunitiesBlockTest &lt; ActiveSupport::TestCase @@ -12,17 +12,10 @@ class CommunitiesBlockTest &lt; ActiveSupport::TestCase
12 @community = create_community("Nova Comunidade") 12 @community = create_community("Nova Comunidade")
13 @community.add_member(@person) 13 @community.add_member(@person)
14 14
15 -  
16 @comminities_block = CommunitiesBlock.new 15 @comminities_block = CommunitiesBlock.new
17 @comminities_block.expects(:owner).at_least_once.returns(@person) 16 @comminities_block.expects(:owner).at_least_once.returns(@person)
18 end 17 end
19 18
20 - def teardown  
21 - CommunitiesBlock.destroy_all  
22 - @person = nil  
23 - @community = nil  
24 - @software_info = nil  
25 - end  
26 should "not have community of software or institution in block" do 19 should "not have community of software or institution in block" do
27 assert_includes @comminities_block.profile_list, @community 20 assert_includes @comminities_block.profile_list, @community
28 assert_not_includes @comminities_block.profile_list, @software_info.community 21 assert_not_includes @comminities_block.profile_list, @software_info.community
src/noosfero-spb/software_communities/test/unit/database_helper_test.rb
@@ -12,12 +12,6 @@ class DatabaseHelperTest &lt; ActiveSupport::TestCase @@ -12,12 +12,6 @@ class DatabaseHelperTest &lt; ActiveSupport::TestCase
12 ] 12 ]
13 end 13 end
14 14
15 - def teardown  
16 - @database_objects = nil  
17 - SoftwareDatabase.destroy_all  
18 - DatabaseDescription.destroy_all  
19 - end  
20 -  
21 should "return an empty list" do 15 should "return an empty list" do
22 empty_list = [] 16 empty_list = []
23 assert_equal [], DatabaseHelper.list_database(empty_list) 17 assert_equal [], DatabaseHelper.list_database(empty_list)
src/noosfero-spb/software_communities/test/unit/database_validation_test.rb
@@ -10,12 +10,6 @@ class DatabaseValidationTest &lt; ActiveSupport::TestCase @@ -10,12 +10,6 @@ class DatabaseValidationTest &lt; ActiveSupport::TestCase
10 @database 10 @database
11 end 11 end
12 12
13 - def teardown  
14 - @database = nil  
15 - DatabaseDescription.destroy_all  
16 - SoftwareDatabase.destroy_all  
17 - end  
18 -  
19 should "Save database if all fields are filled" do 13 should "Save database if all fields are filled" do
20 assert_equal true, @database.save 14 assert_equal true, @database.save
21 end 15 end
src/noosfero-spb/software_communities/test/unit/library_helper_test.rb
@@ -9,10 +9,6 @@ class LibraryHelperTest &lt; ActiveSupport::TestCase @@ -9,10 +9,6 @@ class LibraryHelperTest &lt; ActiveSupport::TestCase
9 {"name" => "license3" ,"version" => "2.2", "license" => "debian", "software_id" => "1"}] 9 {"name" => "license3" ,"version" => "2.2", "license" => "debian", "software_id" => "1"}]
10 end 10 end
11 11
12 - def teardown  
13 - @license_objects = nil  
14 - end  
15 -  
16 should "return an empty list" do 12 should "return an empty list" do
17 empty_list = [] 13 empty_list = []
18 assert_equal [],LibraryHelper.list_library(empty_list) 14 assert_equal [],LibraryHelper.list_library(empty_list)
src/noosfero-spb/software_communities/test/unit/library_validation_test.rb
@@ -9,10 +9,6 @@ class LibraryValidationTest &lt; ActiveSupport::TestCase @@ -9,10 +9,6 @@ class LibraryValidationTest &lt; ActiveSupport::TestCase
9 @library.license = "license" 9 @library.license = "license"
10 end 10 end
11 11
12 - def teardown  
13 - @Libray = nil  
14 - end  
15 -  
16 should "Save Libray if all fields are filled" do 12 should "Save Libray if all fields are filled" do
17 assert @library.save 13 assert @library.save
18 end 14 end
src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb
@@ -8,17 +8,13 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase @@ -8,17 +8,13 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase
8 8
9 def setup 9 def setup
10 @operating_system_objects = [ 10 @operating_system_objects = [
11 - {:operating_system_name_id => "1" ,:version => "2.0"},  
12 - {:operating_system_name_id => "2" ,"version" => "2.1"},  
13 - {:operating_system_name_id => "3" ,"version" => "2.2"} 11 + {:operating_system_name_id => OperatingSystemName.find_by_name("Debina").id.to_s, :version => "2.0"},
  12 + {:operating_system_name_id => OperatingSystemName.find_by_name("Fedora").id.to_s, "version" => "2.1"},
  13 + {:operating_system_name_id => OperatingSystemName.find_by_name("CentOS").id.to_s, "version" => "2.2"}
14 ] 14 ]
15 @operating_system_objects 15 @operating_system_objects
16 end 16 end
17 17
18 - def teardown  
19 - @operating_system_objects = nil  
20 - end  
21 -  
22 should "return an empty list" do 18 should "return an empty list" do
23 empty_list = [] 19 empty_list = []
24 assert_equal [],OperatingSystemHelper.list_operating_system(empty_list) 20 assert_equal [],OperatingSystemHelper.list_operating_system(empty_list)
src/noosfero-spb/software_communities/test/unit/operating_system_validation_test.rb
@@ -9,10 +9,6 @@ class OperatingSystemValidationTest &lt; ActiveSupport::TestCase @@ -9,10 +9,6 @@ class OperatingSystemValidationTest &lt; ActiveSupport::TestCase
9 @operating_system 9 @operating_system
10 end 10 end
11 11
12 - def teardown  
13 - @operating_system.destroy  
14 - end  
15 -  
16 should "save OperatingSystem if all fields are filled" do 12 should "save OperatingSystem if all fields are filled" do
17 assert_equal true, @operating_system.save 13 assert_equal true, @operating_system.save
18 end 14 end
src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb
@@ -9,31 +9,24 @@ class GovUserPluginPersonTest &lt; ActiveSupport::TestCase @@ -9,31 +9,24 @@ class GovUserPluginPersonTest &lt; ActiveSupport::TestCase
9 def setup 9 def setup
10 @plugin = SoftwareCommunitiesPlugin.new 10 @plugin = SoftwareCommunitiesPlugin.new
11 11
12 - @user = fast_create(User)  
13 - @person = create_person(  
14 - "My Name",  
15 - "user@email.com",  
16 - "123456",  
17 - "123456",  
18 - "Any State",  
19 - "Some City" 12 + @user = create_user(
  13 + "user",
  14 + "user@email.com",
  15 + "123456",
  16 + "123456"
20 ) 17 )
21 end 18 end
22 19
23 - def teardown  
24 - @plugin = nil  
25 - end  
26 -  
27 should 'get a list of softwares of a person' do 20 should 'get a list of softwares of a person' do
28 software1 = create_software_info "noosfero" 21 software1 = create_software_info "noosfero"
29 software2 = create_software_info "colab" 22 software2 = create_software_info "colab"
30 community = create_community "simple_community" 23 community = create_community "simple_community"
31 24
32 - software1.community.add_member @person 25 + software1.community.add_member @user.person
33 software1.save! 26 software1.save!
34 - community.add_member @person 27 + community.add_member @user.person
35 community.save! 28 community.save!
36 29
37 - assert_equal 1, @person.softwares.count 30 + assert_equal 1, @user.person.softwares.count
38 end 31 end
39 end 32 end
src/noosfero-spb/software_communities/test/unit/software_database_test.rb
@@ -9,11 +9,6 @@ class SoftwareDatabaseTest &lt; ActiveSupport::TestCase @@ -9,11 +9,6 @@ class SoftwareDatabaseTest &lt; ActiveSupport::TestCase
9 @software_database.database_description_id = 1 9 @software_database.database_description_id = 1
10 end 10 end
11 11
12 - def teardown  
13 - DatabaseDescription.destroy_all  
14 - SoftwareDatabase.destroy_all  
15 - end  
16 -  
17 should "save if all informations of @software_database are filled" do 12 should "save if all informations of @software_database are filled" do
18 assert @software_database.save, "Database should have been saved" 13 assert @software_database.save, "Database should have been saved"
19 end 14 end
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
@@ -55,16 +55,6 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase @@ -55,16 +55,6 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
55 @software_info.community = @community 55 @software_info.community = @community
56 end 56 end
57 57
58 - def teardown  
59 - ProgrammingLanguage.destroy_all  
60 - SoftwareLanguage.destroy_all  
61 - DatabaseDescription.destroy_all  
62 - SoftwareDatabase.destroy_all  
63 - OperatingSystem.destroy_all  
64 - OperatingSystemName.destroy_all  
65 - SoftwareInfo.destroy_all  
66 - end  
67 -  
68 should 'Save SoftwareInfo if all fields are filled' do 58 should 'Save SoftwareInfo if all fields are filled' do
69 assert_equal true, @software_info.save 59 assert_equal true, @software_info.save
70 end 60 end
src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb
@@ -13,11 +13,6 @@ class SoftwareLanguageHelperTest &lt; ActiveSupport::TestCase @@ -13,11 +13,6 @@ class SoftwareLanguageHelperTest &lt; ActiveSupport::TestCase
13 @software_language_objects 13 @software_language_objects
14 end 14 end
15 15
16 - def teardown  
17 - @software_language_objects = nil  
18 - ProgrammingLanguage.destroy_all  
19 - end  
20 -  
21 should "return an empty list" do 16 should "return an empty list" do
22 empty_list = [] 17 empty_list = []
23 assert_equal [], SoftwareLanguageHelper.list_language(empty_list) 18 assert_equal [], SoftwareLanguageHelper.list_language(empty_list)
src/noosfero-spb/software_communities/test/unit/software_language_validation.rb
@@ -7,11 +7,6 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase @@ -7,11 +7,6 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase
7 @software_info.save 7 @software_info.save
8 end 8 end
9 9
10 - def teardown  
11 - @software_info = nil  
12 - SoftwareInfo.destroy_all  
13 - end  
14 -  
15 should "Save SoftwareLanguage if version and prog_language are filled" do 10 should "Save SoftwareLanguage if version and prog_language are filled" do
16 @software_language = create_software_language 11 @software_language = create_software_language
17 assert_equal true, @software_language.save 12 assert_equal true, @software_language.save
src/noosfero-spb/software_communities/test/unit/software_registration_test.rb
@@ -9,12 +9,6 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase @@ -9,12 +9,6 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase
9 @license_info = LicenseInfo.create(:version => "New License", :link => "#") 9 @license_info = LicenseInfo.create(:version => "New License", :link => "#")
10 end 10 end
11 11
12 - def teardown  
13 - Community.destroy_all  
14 - SoftwareInfo.destroy_all  
15 - Task.destroy_all  
16 - end  
17 -  
18 should 'include software registration task if is admin' do 12 should 'include software registration task if is admin' do
19 person = create_user('molly').person 13 person = create_user('molly').person
20 @environment.add_admin(person) 14 @environment.add_admin(person)
src/noosfero-spb/software_communities/views/search/_full_community.html.erb
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 23
24 <div class="search-content-description"> 24 <div class="search-content-description">
25 <% body_stripped = strip_tags(software.finality) %> 25 <% body_stripped = strip_tags(software.finality) %>
26 - <%= link_to(excerpt(body_stripped, body_stripped.first(3), 200), community.url) if body_stripped %> 26 + <%= link_to(excerpt(body_stripped, body_stripped.first(3), radius: 200), community.url) if body_stripped %>
27 </div> 27 </div>
28 28
29 <div class="search-software-categories"> 29 <div class="search-software-categories">