Commit 86be5aff939c3c96e1636bab025cf987bf38e375
1 parent
b6e3b059
Exists in
refactor_software_communities
software-communities: refactoring namespaces
- Fix unit tests Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Showing
15 changed files
with
39 additions
and
37 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/ext/community.rb
@@ -10,7 +10,7 @@ class Community | @@ -10,7 +10,7 @@ class Community | ||
10 | 10 | ||
11 | attr_accessible :visible | 11 | attr_accessible :visible |
12 | 12 | ||
13 | - has_one :software_info, :dependent=>:destroy | 13 | + has_one :software_info, :dependent=>:destroy, :class_name => "SoftwareCommunitiesPlugin::SoftwareInfo" |
14 | 14 | ||
15 | settings_items :hits, :type => :integer, :default => 0 | 15 | settings_items :hits, :type => :integer, :default => 0 |
16 | 16 | ||
@@ -57,7 +57,7 @@ class Community | @@ -57,7 +57,7 @@ class Community | ||
57 | def remove_of_community_search_software? | 57 | def remove_of_community_search_software? |
58 | return software? | 58 | return software? |
59 | end | 59 | end |
60 | - | 60 | + |
61 | def hit | 61 | def hit |
62 | self.hits += 1 | 62 | self.hits += 1 |
63 | self.save! | 63 | self.save! |
src/noosfero-spb/software_communities/lib/ext/search_controller.rb
@@ -63,11 +63,11 @@ class SearchController | @@ -63,11 +63,11 @@ class SearchController | ||
63 | params[:query] ||= "" | 63 | params[:query] ||= "" |
64 | visible_communities = visible_profiles(Community) | 64 | visible_communities = visible_profiles(Community) |
65 | 65 | ||
66 | - filtered_software_list = SoftwareInfo.search_by_query(params[:query]) | 66 | + filtered_software_list = SoftwareCommunitiesPlugin::SoftwareInfo.search_by_query(params[:query]) |
67 | 67 | ||
68 | if params[:only_softwares] | 68 | if params[:only_softwares] |
69 | params[:only_softwares].collect!{ |software_name| software_name.to_slug } | 69 | params[:only_softwares].collect!{ |software_name| software_name.to_slug } |
70 | - filtered_software_list = SoftwareInfo.all.select{ |s| params[:only_softwares].include?(s.identifier) } | 70 | + filtered_software_list = SoftwareCommunitiesPlugin::SoftwareInfo.all.select{ |s| params[:only_softwares].include?(s.identifier) } |
71 | @public_software_selected = false | 71 | @public_software_selected = false |
72 | end | 72 | end |
73 | 73 | ||
@@ -130,7 +130,7 @@ class SearchController | @@ -130,7 +130,7 @@ class SearchController | ||
130 | return 15 if params[:software_display].nil? | 130 | return 15 if params[:software_display].nil? |
131 | 131 | ||
132 | if params[:software_display] == "all" | 132 | if params[:software_display] == "all" |
133 | - SoftwareInfo.count | 133 | + SoftwareCommunitiesPlugin::SoftwareInfo.count |
134 | else | 134 | else |
135 | params[:software_display].to_i | 135 | params[:software_display].to_i |
136 | end | 136 | end |
src/noosfero-spb/software_communities/lib/software_communities_plugin/software_info.rb
@@ -7,8 +7,8 @@ class SoftwareCommunitiesPlugin::SoftwareInfo < ActiveRecord::Base | @@ -7,8 +7,8 @@ class SoftwareCommunitiesPlugin::SoftwareInfo < ActiveRecord::Base | ||
7 | } | 7 | } |
8 | 8 | ||
9 | SEARCHABLE_SOFTWARE_CLASSES = [ | 9 | SEARCHABLE_SOFTWARE_CLASSES = [ |
10 | + Community, | ||
10 | SoftwareCommunitiesPlugin::SoftwareInfo, | 11 | SoftwareCommunitiesPlugin::SoftwareInfo, |
11 | - SoftwareCommunitiesPlugin::Community, | ||
12 | SoftwareCommunitiesPlugin::ProgrammingLanguage, | 12 | SoftwareCommunitiesPlugin::ProgrammingLanguage, |
13 | SoftwareCommunitiesPlugin::DatabaseDescription | 13 | SoftwareCommunitiesPlugin::DatabaseDescription |
14 | ] | 14 | ] |
@@ -122,7 +122,7 @@ class SoftwareCommunitiesPlugin::SoftwareInfo < ActiveRecord::Base | @@ -122,7 +122,7 @@ class SoftwareCommunitiesPlugin::SoftwareInfo < ActiveRecord::Base | ||
122 | license_another = SoftwareCommunitiesPlugin::LicenseInfo.find_by_version("Another") | 122 | license_another = SoftwareCommunitiesPlugin::LicenseInfo.find_by_version("Another") |
123 | 123 | ||
124 | if license_another && license.id == license_another.id | 124 | if license_another && license.id == license_another.id |
125 | - LicenseInfo.new( | 125 | + SoftwareCommunitiesPlugin::LicenseInfo.new( |
126 | :version => self.another_license_version, | 126 | :version => self.another_license_version, |
127 | :link => self.another_license_link | 127 | :link => self.another_license_link |
128 | ) | 128 | ) |
src/noosfero-spb/software_communities/lib/software_communities_plugin/software_language.rb
1 | class SoftwareCommunitiesPlugin::SoftwareLanguage < ActiveRecord::Base | 1 | class SoftwareCommunitiesPlugin::SoftwareLanguage < ActiveRecord::Base |
2 | - attr_accessible :version | ||
3 | 2 | ||
4 | - belongs_to :software_info, :class => "SoftwareCommunitiesPlugin::SoftwareInfo" | ||
5 | - belongs_to :programming_language, :class => "SoftwareCommunitiesPlugin::ProgrammingLanguage" | 3 | + belongs_to :software_info, :class_name => "SoftwareCommunitiesPlugin::SoftwareInfo" |
4 | + belongs_to :programming_language, :class_name => "SoftwareCommunitiesPlugin::ProgrammingLanguage" | ||
5 | + | ||
6 | + attr_accessible :version | ||
6 | 7 | ||
7 | validates_length_of( | 8 | validates_length_of( |
8 | :version, | 9 | :version, |
src/noosfero-spb/software_communities/lib/software_communities_plugin/software_language_helper.rb
1 | -class SoftwareCommunitiesPlugin::SoftwareLanguageHelper < DynamicTableHelper | 1 | +class SoftwareCommunitiesPlugin::SoftwareLanguageHelper < SoftwareCommunitiesPlugin::DynamicTableHelper |
2 | #FIX verify MODEL_NAME | 2 | #FIX verify MODEL_NAME |
3 | MODEL_NAME = "language" | 3 | MODEL_NAME = "language" |
4 | FIELD_NAME = "programming_language_id" | 4 | FIELD_NAME = "programming_language_id" |
src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb
@@ -10,7 +10,7 @@ module PluginTestHelper | @@ -10,7 +10,7 @@ module PluginTestHelper | ||
10 | 10 | ||
11 | def create_software_info name, finality = "something", acronym = "" | 11 | def create_software_info name, finality = "something", acronym = "" |
12 | community = create_community(name) | 12 | community = create_community(name) |
13 | - software_info = SoftwareInfo.new | 13 | + software_info = SoftwareCommunitiesPlugin::SoftwareInfo.new |
14 | software_info.community = community | 14 | software_info.community = community |
15 | software_info.finality = finality | 15 | software_info.finality = finality |
16 | software_info.acronym = acronym | 16 | software_info.acronym = acronym |
@@ -55,7 +55,7 @@ module PluginTestHelper | @@ -55,7 +55,7 @@ module PluginTestHelper | ||
55 | end | 55 | end |
56 | 56 | ||
57 | def create_license_info version, link = "" | 57 | def create_license_info version, link = "" |
58 | - license = LicenseInfo.create(:version => version) | 58 | + license = SoftwareCommunitiesPlugin::LicenseInfo.create(:version => version) |
59 | license.link = link | 59 | license.link = link |
60 | license.save | 60 | license.save |
61 | 61 |
src/noosfero-spb/software_communities/test/helpers/software_test_helper.rb
1 | module SoftwareTestHelper | 1 | module SoftwareTestHelper |
2 | 2 | ||
3 | def create_language language_fields | 3 | def create_language language_fields |
4 | - language = SoftwareLanguage.new | 4 | + language = SoftwareCommunitiesPlugin::SoftwareLanguage.new |
5 | 5 | ||
6 | language_fields[0].each do |k,v| | 6 | language_fields[0].each do |k,v| |
7 | language[k] = v | 7 | language[k] = v |
@@ -12,7 +12,7 @@ module SoftwareTestHelper | @@ -12,7 +12,7 @@ module SoftwareTestHelper | ||
12 | 12 | ||
13 | def create_database database_fields | 13 | def create_database database_fields |
14 | 14 | ||
15 | - database = SoftwareDatabase.new | 15 | + database = SoftwareCommunitiesPlugin::SoftwareDatabase.new |
16 | 16 | ||
17 | database_fields[0].each do |k,v| | 17 | database_fields[0].each do |k,v| |
18 | database[k] = v | 18 | database[k] = v |
@@ -23,7 +23,7 @@ module SoftwareTestHelper | @@ -23,7 +23,7 @@ module SoftwareTestHelper | ||
23 | end | 23 | end |
24 | 24 | ||
25 | def create_library library_fields | 25 | def create_library library_fields |
26 | - library = Library.new | 26 | + library = SoftwareCommunitiesPlugin::Library.new |
27 | 27 | ||
28 | library_fields[0].each do |k,v| | 28 | library_fields[0].each do |k,v| |
29 | library[k] = v | 29 | library[k] = v |
@@ -33,7 +33,7 @@ module SoftwareTestHelper | @@ -33,7 +33,7 @@ module SoftwareTestHelper | ||
33 | end | 33 | end |
34 | 34 | ||
35 | def create_operating_system operating_system_hash | 35 | def create_operating_system operating_system_hash |
36 | - operating_system = OperatingSystem.new | 36 | + operating_system = SoftwareCommunitiesPlugin::OperatingSystem.new |
37 | 37 | ||
38 | operating_system_hash[0].each do |k,v| | 38 | operating_system_hash[0].each do |k,v| |
39 | operating_system[k] = v | 39 | operating_system[k] = v |
@@ -43,7 +43,7 @@ module SoftwareTestHelper | @@ -43,7 +43,7 @@ module SoftwareTestHelper | ||
43 | end | 43 | end |
44 | 44 | ||
45 | def create_license license_hash | 45 | def create_license license_hash |
46 | - license_info = LicenseInfo.new | 46 | + license_info = SoftwareCommunitiesPlugin::LicenseInfo.new |
47 | 47 | ||
48 | license_hash.each do |k,v| | 48 | license_hash.each do |k,v| |
49 | license_info[k] = v | 49 | license_info[k] = v |
@@ -53,7 +53,7 @@ module SoftwareTestHelper | @@ -53,7 +53,7 @@ module SoftwareTestHelper | ||
53 | end | 53 | end |
54 | 54 | ||
55 | def create_categories categories_hash | 55 | def create_categories categories_hash |
56 | - software_categories = SoftwareCategories.new | 56 | + software_categories = SoftwareCommunitiesPlugin::SoftwareCategories.new |
57 | 57 | ||
58 | categories_hash.each do |k,v| | 58 | categories_hash.each do |k,v| |
59 | software_categories[k] = v | 59 | software_categories[k] = v |
@@ -64,7 +64,7 @@ module SoftwareTestHelper | @@ -64,7 +64,7 @@ module SoftwareTestHelper | ||
64 | 64 | ||
65 | def create_software fields | 65 | def create_software fields |
66 | 66 | ||
67 | - software = SoftwareInfo.new | 67 | + software = SoftwareCommunitiesPlugin::SoftwareInfo.new |
68 | community = Community.new | 68 | community = Community.new |
69 | software_hash = fields[2] | 69 | software_hash = fields[2] |
70 | license_system_hash = fields[0] | 70 | license_system_hash = fields[0] |
@@ -128,7 +128,7 @@ module SoftwareTestHelper | @@ -128,7 +128,7 @@ module SoftwareTestHelper | ||
128 | 128 | ||
129 | #Fields for software language | 129 | #Fields for software language |
130 | fields_language['version'] = 'test' | 130 | fields_language['version'] = 'test' |
131 | - fields_language['programming_language_id'] = ProgrammingLanguage.last.id | 131 | + fields_language['programming_language_id'] = SoftwareCommunitiesPlugin::ProgrammingLanguage.last.id |
132 | fields_language['operating_system'] = 'test' | 132 | fields_language['operating_system'] = 'test' |
133 | list_language << fields_language | 133 | list_language << fields_language |
134 | list_language << {} | 134 | list_language << {} |
@@ -136,7 +136,7 @@ module SoftwareTestHelper | @@ -136,7 +136,7 @@ module SoftwareTestHelper | ||
136 | 136 | ||
137 | #Fields for database | 137 | #Fields for database |
138 | fields_database['version'] = 'test' | 138 | fields_database['version'] = 'test' |
139 | - fields_database['database_description_id'] = DatabaseDescription.last.id | 139 | + fields_database['database_description_id'] = SoftwareCommunitiesPlugin::DatabaseDescription.last.id |
140 | fields_database['operating_system'] = 'test' | 140 | fields_database['operating_system'] = 'test' |
141 | list_database << fields_database | 141 | list_database << fields_database |
142 | list_database << {} | 142 | list_database << {} |
@@ -144,7 +144,7 @@ module SoftwareTestHelper | @@ -144,7 +144,7 @@ module SoftwareTestHelper | ||
144 | 144 | ||
145 | #Fields for operating system | 145 | #Fields for operating system |
146 | fields_operating_system['version'] = 'version' | 146 | fields_operating_system['version'] = 'version' |
147 | - fields_operating_system['operating_system_name_id'] = OperatingSystemName.last.id | 147 | + fields_operating_system['operating_system_name_id'] = SoftwareCommunitiesPlugin::OperatingSystemName.last.id |
148 | list_operating_system << fields_operating_system | 148 | list_operating_system << fields_operating_system |
149 | list_operating_system << {} | 149 | list_operating_system << {} |
150 | hash_list << list_operating_system | 150 | hash_list << list_operating_system |
@@ -158,7 +158,7 @@ module SoftwareTestHelper | @@ -158,7 +158,7 @@ module SoftwareTestHelper | ||
158 | hash_list << fields_software | 158 | hash_list << fields_software |
159 | 159 | ||
160 | #Fields for license | 160 | #Fields for license |
161 | - fields_license['license_infos_id'] = LicenseInfo.last.id | 161 | + fields_license['license_infos_id'] = SoftwareCommunitiesPlugin::LicenseInfo.last.id |
162 | hash_list << fields_license | 162 | hash_list << fields_license |
163 | 163 | ||
164 | hash_list | 164 | hash_list |
@@ -169,7 +169,7 @@ module SoftwareTestHelper | @@ -169,7 +169,7 @@ module SoftwareTestHelper | ||
169 | 169 | ||
170 | #Fields for license info | 170 | #Fields for license info |
171 | fields_license = { | 171 | fields_license = { |
172 | - license_infos_id: LicenseInfo.last.id | 172 | + license_infos_id: SoftwareCommunitiesPlugin::LicenseInfo.last.id |
173 | } | 173 | } |
174 | hash_list << fields_license | 174 | hash_list << fields_license |
175 | 175 | ||
@@ -190,4 +190,4 @@ module SoftwareTestHelper | @@ -190,4 +190,4 @@ module SoftwareTestHelper | ||
190 | end | 190 | end |
191 | end | 191 | end |
192 | #version: LicenseInfo.last.version, | 192 | #version: LicenseInfo.last.version, |
193 | -#id: LicenseInfo.last.id | ||
194 | \ No newline at end of file | 193 | \ No newline at end of file |
194 | +#id: LicenseInfo.last.id |
src/noosfero-spb/software_communities/test/unit/categories_and_tags_block_test.rb
1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' | 1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' |
2 | require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | 2 | require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' |
3 | 3 | ||
4 | -class SoftwareCommunitiesPlugin::CategoriesAndTagsBlockTest < ActiveSupport::TestCase | 4 | +class CategoriesAndTagsBlockTest < ActiveSupport::TestCase |
5 | include PluginTestHelper | 5 | include PluginTestHelper |
6 | should 'inherit from Block' do | 6 | should 'inherit from Block' do |
7 | assert_kind_of Block, SoftwareCommunitiesPlugin::CategoriesAndTagsBlock.new | 7 | assert_kind_of Block, SoftwareCommunitiesPlugin::CategoriesAndTagsBlock.new |
src/noosfero-spb/software_communities/test/unit/communities_block_test.rb
@@ -13,12 +13,12 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | @@ -13,12 +13,12 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | ||
13 | @community.add_member(@person) | 13 | @community.add_member(@person) |
14 | 14 | ||
15 | 15 | ||
16 | - @comminities_block = SoftwareCommunitiesPlugin::CommunitiesBlock.new | 16 | + @comminities_block = CommunitiesBlock.new |
17 | @comminities_block.expects(:owner).at_least_once.returns(@person) | 17 | @comminities_block.expects(:owner).at_least_once.returns(@person) |
18 | end | 18 | end |
19 | 19 | ||
20 | def teardown | 20 | def teardown |
21 | - SoftwareCommunitiesPlugin::CommunitiesBlock.destroy_all | 21 | + CommunitiesBlock.destroy_all |
22 | @person = nil | 22 | @person = nil |
23 | @community = nil | 23 | @community = nil |
24 | @software_info = nil | 24 | @software_info = nil |
src/noosfero-spb/software_communities/test/unit/create_software_test.rb
@@ -26,7 +26,7 @@ class CreateSoftwareTest < ActiveSupport::TestCase | @@ -26,7 +26,7 @@ class CreateSoftwareTest < ActiveSupport::TestCase | ||
26 | should 'actually create new software community when confirmed' do | 26 | should 'actually create new software community when confirmed' do |
27 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any") | 27 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any") |
28 | 28 | ||
29 | - assert_difference 'SoftwareInfo.count' do | 29 | + assert_difference 'SoftwareCommunitiesPlugin::SoftwareInfo.count' do |
30 | assert_difference 'Community.count' do | 30 | assert_difference 'Community.count' do |
31 | task.finish | 31 | task.finish |
32 | end | 32 | end |
src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb
1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' | 1 | require File.dirname(__FILE__) + '/../../../../test/test_helper' |
2 | 2 | ||
3 | -OperatingSystemName.create(:name=>"Debina") | ||
4 | -OperatingSystemName.create(:name=>"Fedora") | ||
5 | -OperatingSystemName.create(:name=>"CentOS") | 3 | +SoftwareCommunitiesPlugin::OperatingSystemName.create(:name=>"Debina") |
4 | +SoftwareCommunitiesPlugin::OperatingSystemName.create(:name=>"Fedora") | ||
5 | +SoftwareCommunitiesPlugin::OperatingSystemName.create(:name=>"CentOS") | ||
6 | 6 | ||
7 | class OperatingSystemHelperTest < ActiveSupport::TestCase | 7 | class OperatingSystemHelperTest < ActiveSupport::TestCase |
8 | 8 |
src/noosfero-spb/software_communities/test/unit/software_info_test.rb
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | @@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
3 | 3 | ||
4 | class SoftwareInfoValidationTest < ActiveSupport::TestCase | 4 | class SoftwareInfoValidationTest < ActiveSupport::TestCase |
5 | 5 | ||
6 | - include SoftwareCommunitiesPlugin::PluginTestHelper | 6 | + include PluginTestHelper |
7 | 7 | ||
8 | should "Return original license_info when license is not 'Another'" do | 8 | should "Return original license_info when license is not 'Another'" do |
9 | @software_info = create_software_info("software_test") | 9 | @software_info = create_software_info("software_test") |
src/noosfero-spb/software_communities/test/unit/software_registration_test.rb
@@ -19,7 +19,8 @@ class SoftwareRegistrationTest < ActiveSupport::TestCase | @@ -19,7 +19,8 @@ class SoftwareRegistrationTest < ActiveSupport::TestCase | ||
19 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!( | 19 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!( |
20 | :name => "Teste One", | 20 | :name => "Teste One", |
21 | :requestor => person, | 21 | :requestor => person, |
22 | - :environment => @environment | 22 | + :environment => @environment, |
23 | + :finality => "Something" | ||
23 | ) | 24 | ) |
24 | assert_equal [task], Task.to(person).pending | 25 | assert_equal [task], Task.to(person).pending |
25 | end | 26 | end |
src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' | @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | 2 | require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' |
3 | 3 | ||
4 | class SoftwareTabDataBlockTest < ActiveSupport::TestCase | 4 | class SoftwareTabDataBlockTest < ActiveSupport::TestCase |
5 | - include SoftwareCommunitiesPlugin::PluginTestHelper | 5 | + include PluginTestHelper |
6 | 6 | ||
7 | def setup | 7 | def setup |
8 | @software_info = create_software_info("A new Software") | 8 | @software_info = create_software_info("A new Software") |
src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' | @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../../../../test/test_helper' | ||
2 | require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | 2 | require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' |
3 | 3 | ||
4 | class SoftwaresBlockTest < ActiveSupport::TestCase | 4 | class SoftwaresBlockTest < ActiveSupport::TestCase |
5 | - include SoftwareCommunitiesPlugin::PluginTestHelper | 5 | + include PluginTestHelper |
6 | should 'inherit from ProfileListBlock' do | 6 | should 'inherit from ProfileListBlock' do |
7 | assert_kind_of ProfileListBlock, SoftwareCommunitiesPlugin::SoftwaresBlock.new | 7 | assert_kind_of ProfileListBlock, SoftwareCommunitiesPlugin::SoftwaresBlock.new |
8 | end | 8 | end |