Commit 09cf54dcfdd1abde73be56b96fb3e1dcf06141e9
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 | 100 | @public_software_selected = false |
| 101 | 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 | 104 | category_ids = get_filter_category_ids |
| 105 | 105 | |
| 106 | 106 | unless category_ids.empty? | ... | ... |
src/noosfero-spb/software_communities/lib/license_helper.rb
| 1 | 1 | module LicenseHelper |
| 2 | 2 | def self.find_licenses query |
| 3 | 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 | 5 | license_another = LicenseInfo.find_by_version("Another") |
| 6 | 6 | licenses << license_another if license_another |
| 7 | 7 | licenses | ... | ... |
src/noosfero-spb/software_communities/lib/software_info.rb
| ... | ... | @@ -21,7 +21,7 @@ class SoftwareInfo < ActiveRecord::Base |
| 21 | 21 | SoftwareInfo.joins(:community).where("profiles.visible = ? AND environment_id = ? ", true, env.id) |
| 22 | 22 | else |
| 23 | 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 | 25 | end |
| 26 | 26 | } |
| 27 | 27 | ... | ... |
src/noosfero-spb/software_communities/test/functional/profile_editor_controller_test.rb
| ... | ... | @@ -35,11 +35,6 @@ class ProfileEditorControllerTest < ActionController::TestCase |
| 35 | 35 | @environment.save |
| 36 | 36 | end |
| 37 | 37 | |
| 38 | - def teardown | |
| 39 | - Community.destroy_all | |
| 40 | - SoftwareInfo.destroy_all | |
| 41 | - end | |
| 42 | - | |
| 43 | 38 | should "redirect to edit_software_community on edit community of software" do |
| 44 | 39 | software = create_software(software_fields) |
| 45 | 40 | post :edit, :profile => software.community.identifier | ... | ... |
src/noosfero-spb/software_communities/test/functional/search_controller_test.rb
| ... | ... | @@ -42,10 +42,6 @@ class SearchControllerTest < ActionController::TestCase |
| 42 | 42 | @softwares[1].save! |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | - def teardown | |
| 46 | - SoftwareInfo.destroy_all | |
| 47 | - end | |
| 48 | - | |
| 49 | 45 | should "communities searches don't have software" do |
| 50 | 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 | 28 | name.to_slug, |
| 29 | 29 | email, |
| 30 | 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 | 37 | user.save |
| 44 | - person.save | |
| 45 | - | |
| 46 | - person | |
| 38 | + user.person | |
| 47 | 39 | end |
| 48 | 40 | |
| 49 | 41 | def create_user login, email, password, password_confirmation |
| ... | ... | @@ -54,6 +46,7 @@ module PluginTestHelper |
| 54 | 46 | user.password = password |
| 55 | 47 | user.password_confirmation = password_confirmation |
| 56 | 48 | |
| 49 | + user.save | |
| 57 | 50 | user |
| 58 | 51 | end |
| 59 | 52 | ... | ... |
src/noosfero-spb/software_communities/test/unit/communities_block_test.rb
| ... | ... | @@ -12,17 +12,10 @@ class CommunitiesBlockTest < ActiveSupport::TestCase |
| 12 | 12 | @community = create_community("Nova Comunidade") |
| 13 | 13 | @community.add_member(@person) |
| 14 | 14 | |
| 15 | - | |
| 16 | 15 | @comminities_block = CommunitiesBlock.new |
| 17 | 16 | @comminities_block.expects(:owner).at_least_once.returns(@person) |
| 18 | 17 | end |
| 19 | 18 | |
| 20 | - def teardown | |
| 21 | - CommunitiesBlock.destroy_all | |
| 22 | - @person = nil | |
| 23 | - @community = nil | |
| 24 | - @software_info = nil | |
| 25 | - end | |
| 26 | 19 | should "not have community of software or institution in block" do |
| 27 | 20 | assert_includes @comminities_block.profile_list, @community |
| 28 | 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 < ActiveSupport::TestCase |
| 12 | 12 | ] |
| 13 | 13 | end |
| 14 | 14 | |
| 15 | - def teardown | |
| 16 | - @database_objects = nil | |
| 17 | - SoftwareDatabase.destroy_all | |
| 18 | - DatabaseDescription.destroy_all | |
| 19 | - end | |
| 20 | - | |
| 21 | 15 | should "return an empty list" do |
| 22 | 16 | empty_list = [] |
| 23 | 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 < ActiveSupport::TestCase |
| 10 | 10 | @database |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | - def teardown | |
| 14 | - @database = nil | |
| 15 | - DatabaseDescription.destroy_all | |
| 16 | - SoftwareDatabase.destroy_all | |
| 17 | - end | |
| 18 | - | |
| 19 | 13 | should "Save database if all fields are filled" do |
| 20 | 14 | assert_equal true, @database.save |
| 21 | 15 | end | ... | ... |
src/noosfero-spb/software_communities/test/unit/library_helper_test.rb
| ... | ... | @@ -9,10 +9,6 @@ class LibraryHelperTest < ActiveSupport::TestCase |
| 9 | 9 | {"name" => "license3" ,"version" => "2.2", "license" => "debian", "software_id" => "1"}] |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | - def teardown | |
| 13 | - @license_objects = nil | |
| 14 | - end | |
| 15 | - | |
| 16 | 12 | should "return an empty list" do |
| 17 | 13 | empty_list = [] |
| 18 | 14 | assert_equal [],LibraryHelper.list_library(empty_list) | ... | ... |
src/noosfero-spb/software_communities/test/unit/library_validation_test.rb
src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb
| ... | ... | @@ -8,17 +8,13 @@ class OperatingSystemHelperTest < ActiveSupport::TestCase |
| 8 | 8 | |
| 9 | 9 | def setup |
| 10 | 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 | 15 | @operating_system_objects |
| 16 | 16 | end |
| 17 | 17 | |
| 18 | - def teardown | |
| 19 | - @operating_system_objects = nil | |
| 20 | - end | |
| 21 | - | |
| 22 | 18 | should "return an empty list" do |
| 23 | 19 | empty_list = [] |
| 24 | 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 < ActiveSupport::TestCase |
| 9 | 9 | @operating_system |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | - def teardown | |
| 13 | - @operating_system.destroy | |
| 14 | - end | |
| 15 | - | |
| 16 | 12 | should "save OperatingSystem if all fields are filled" do |
| 17 | 13 | assert_equal true, @operating_system.save |
| 18 | 14 | end | ... | ... |
src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb
| ... | ... | @@ -9,31 +9,24 @@ class GovUserPluginPersonTest < ActiveSupport::TestCase |
| 9 | 9 | def setup |
| 10 | 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 | 18 | end |
| 22 | 19 | |
| 23 | - def teardown | |
| 24 | - @plugin = nil | |
| 25 | - end | |
| 26 | - | |
| 27 | 20 | should 'get a list of softwares of a person' do |
| 28 | 21 | software1 = create_software_info "noosfero" |
| 29 | 22 | software2 = create_software_info "colab" |
| 30 | 23 | community = create_community "simple_community" |
| 31 | 24 | |
| 32 | - software1.community.add_member @person | |
| 25 | + software1.community.add_member @user.person | |
| 33 | 26 | software1.save! |
| 34 | - community.add_member @person | |
| 27 | + community.add_member @user.person | |
| 35 | 28 | community.save! |
| 36 | 29 | |
| 37 | - assert_equal 1, @person.softwares.count | |
| 30 | + assert_equal 1, @user.person.softwares.count | |
| 38 | 31 | end |
| 39 | 32 | end | ... | ... |
src/noosfero-spb/software_communities/test/unit/software_database_test.rb
| ... | ... | @@ -9,11 +9,6 @@ class SoftwareDatabaseTest < ActiveSupport::TestCase |
| 9 | 9 | @software_database.database_description_id = 1 |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | - def teardown | |
| 13 | - DatabaseDescription.destroy_all | |
| 14 | - SoftwareDatabase.destroy_all | |
| 15 | - end | |
| 16 | - | |
| 17 | 12 | should "save if all informations of @software_database are filled" do |
| 18 | 13 | assert @software_database.save, "Database should have been saved" |
| 19 | 14 | end | ... | ... |
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
| ... | ... | @@ -55,16 +55,6 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase |
| 55 | 55 | @software_info.community = @community |
| 56 | 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 | 58 | should 'Save SoftwareInfo if all fields are filled' do |
| 69 | 59 | assert_equal true, @software_info.save |
| 70 | 60 | end | ... | ... |
src/noosfero-spb/software_communities/test/unit/software_language_helper_test.rb
| ... | ... | @@ -13,11 +13,6 @@ class SoftwareLanguageHelperTest < ActiveSupport::TestCase |
| 13 | 13 | @software_language_objects |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | - def teardown | |
| 17 | - @software_language_objects = nil | |
| 18 | - ProgrammingLanguage.destroy_all | |
| 19 | - end | |
| 20 | - | |
| 21 | 16 | should "return an empty list" do |
| 22 | 17 | empty_list = [] |
| 23 | 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 < ActiveSupport::TestCase |
| 7 | 7 | @software_info.save |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | - def teardown | |
| 11 | - @software_info = nil | |
| 12 | - SoftwareInfo.destroy_all | |
| 13 | - end | |
| 14 | - | |
| 15 | 10 | should "Save SoftwareLanguage if version and prog_language are filled" do |
| 16 | 11 | @software_language = create_software_language |
| 17 | 12 | assert_equal true, @software_language.save | ... | ... |
src/noosfero-spb/software_communities/test/unit/software_registration_test.rb
| ... | ... | @@ -9,12 +9,6 @@ class SoftwareRegistrationTest < ActiveSupport::TestCase |
| 9 | 9 | @license_info = LicenseInfo.create(:version => "New License", :link => "#") |
| 10 | 10 | end |
| 11 | 11 | |
| 12 | - def teardown | |
| 13 | - Community.destroy_all | |
| 14 | - SoftwareInfo.destroy_all | |
| 15 | - Task.destroy_all | |
| 16 | - end | |
| 17 | - | |
| 18 | 12 | should 'include software registration task if is admin' do |
| 19 | 13 | person = create_user('molly').person |
| 20 | 14 | @environment.add_admin(person) | ... | ... |
src/noosfero-spb/software_communities/views/search/_full_community.html.erb
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | |
| 24 | 24 | <div class="search-content-description"> |
| 25 | 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 | 27 | </div> |
| 28 | 28 | |
| 29 | 29 | <div class="search-software-categories"> | ... | ... |