Commit ad2b99ba3ddeea33b345fafc4e9a87418b39dfe7

Authored by Marcos Pereira
1 parent 79f2972a

fix unit tests

Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
src/noosfero-spb/software_communities/lib/ext/person.rb
... ... @@ -18,7 +18,7 @@ class Person
18 18 # end
19 19  
20 20 def softwares
21   - memberships.softwares
  21 + Software.memberships_of(self)
22 22 end
23 23  
24 24 end
... ...
src/noosfero-spb/software_communities/lib/software_communities_plugin/api_entities.rb
... ... @@ -3,8 +3,8 @@ module Entities
3 3 root 'software_infos', 'software_info'
4 4 expose :id, :finality, :repository_link, :public_software, :acronym, :objectives,
5 5 :features,:license_info, :software_languages, :software_databases, :operating_system_names
6   - expose :community_id do |software_info,options|
7   - software_info.community.id
  6 + expose :software_id do |software_info,options|
  7 + software_info.software.id
8 8 end
9 9 end
10 10 end
... ...
src/noosfero-spb/software_communities/test/unit/communities_block_test.rb
... ... @@ -7,7 +7,7 @@ class CommunitiesBlockTest &lt; ActiveSupport::TestCase
7 7 @person = create_person("My Name", "user@email.com", "123456", "123456", "Any State", "Some City")
8 8  
9 9 @software_info = create_software_info("Novo Software")
10   - @software_info.community.add_member(@person)
  10 + @software_info.software.add_member(@person)
11 11  
12 12 @community = fast_create(Community)
13 13 @community.add_member(@person)
... ... @@ -23,9 +23,10 @@ class CommunitiesBlockTest &lt; ActiveSupport::TestCase
23 23 @community = nil
24 24 @software_info = nil
25 25 end
  26 +
26 27 should "not have community of software or institution in block" do
27 28 assert_includes @comminities_block.profile_list, @community
28   - assert_not_includes @comminities_block.profile_list, @software_info.community
  29 + assert_not_includes @comminities_block.profile_list, @software_info.software
29 30 end
30 31  
31 32 end
... ...
src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb
... ... @@ -26,10 +26,9 @@ class GovUserPluginPersonTest &lt; ActiveSupport::TestCase
26 26  
27 27 should 'get a list of softwares of a person' do
28 28 software1 = create_software_info "noosfero"
29   - software2 = create_software_info "colab"
30 29 community = fast_create(Community)
31 30  
32   - software1.community.add_member @person
  31 + software1.software.add_member @person
33 32 software1.save!
34 33 community.add_member @person
35 34 community.save!
... ...
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
... ... @@ -9,6 +9,11 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
9 9 :name => 'New Software'
10 10 )
11 11  
  12 + @software = fast_create(Software,
  13 + :identifier => 'new-software',
  14 + :name => 'New Software'
  15 + )
  16 +
12 17 @language = ProgrammingLanguage.new(:name => 'C++')
13 18 @language.save
14 19 @software_language = SoftwareLanguage.new(
... ... @@ -49,7 +54,7 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
49 54  
50 55 @software_info.features = "Do a lot of things"
51 56 @software_info.objectives = "All tests should pass !"
52   - @software_info.community = @community
  57 + @software_info.software=@software
53 58 end
54 59  
55 60 def teardown
... ...
src/noosfero-spb/software_communities/test/unit/software_language_validation.rb
... ... @@ -51,6 +51,7 @@ class SoftwareLanguageValidationTest &lt; ActiveSupport::TestCase
51 51 software_info = SoftwareInfo.new
52 52 software_info.software = software
53 53 software_info.software.name = 'Noosfero'
  54 + software_info.software.identifier = 'Noosfero'.to_slug
54 55 software_info.e_mag = true
55 56 software_info.icp_brasil = true
56 57 software_info.intern = true
... ...
src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb
... ... @@ -8,32 +8,32 @@ class SoftwareTabDataBlockTest &lt; ActiveSupport::TestCase
8 8 @software_info = create_software_info("A new Software")
9 9 @software_info.save!
10 10  
11   - @soft_community = @software_info.community
  11 + @software = @software_info.software
12 12  
13   - @soft_community.blogs << Blog.new(:name=>"First blog")
14   - @soft_community.blogs << Blog.new(:name=>"Second blog")
15   - @soft_community.save!
  13 + @software.blogs << Blog.new(:name=>"First blog")
  14 + @software.blogs << Blog.new(:name=>"Second blog")
  15 + @software.save!
16 16  
17   - SoftwareTabDataBlock.any_instance.stubs(:owner).returns(@soft_community)
  17 + SoftwareTabDataBlock.any_instance.stubs(:owner).returns(@software)
18 18 end
19 19  
20 20 should "get its owner blogs" do
21   - assert_equal @soft_community.blogs, SoftwareTabDataBlock.new.blogs
  21 + assert_equal @software.blogs, SoftwareTabDataBlock.new.blogs
22 22 end
23 23  
24 24 should "actual_blog get the first blog if it is not defined" do
25   - assert_equal @soft_community.blogs.first, SoftwareTabDataBlock.new.actual_blog
  25 + assert_equal @software.blogs.first, SoftwareTabDataBlock.new.actual_blog
26 26 end
27 27  
28   - should "actual_blog get the defined community blog" do
29   - last_blog = @soft_community.blogs.last
  28 + should "actual_blog get the defined software blog" do
  29 + last_blog = @software.blogs.last
30 30 soft_tab_data = create_software_tab_data_block(last_blog)
31 31  
32 32 assert_equal last_blog, soft_tab_data.actual_blog
33 33 end
34 34  
35 35 should "get the actual_blog posts" do
36   - last_blog = @soft_community.blogs.last
  36 + last_blog = @software.blogs.last
37 37 soft_tab_data = create_software_tab_data_block(last_blog)
38 38 craete_sample_posts(last_blog, 2)
39 39  
... ... @@ -42,7 +42,7 @@ class SoftwareTabDataBlockTest &lt; ActiveSupport::TestCase
42 42 end
43 43  
44 44 should "limit the number of posts" do
45   - last_blog = @soft_community.blogs.last
  45 + last_blog = @software.blogs.last
46 46 soft_tab_data = create_software_tab_data_block(last_blog)
47 47 craete_sample_posts(last_blog, 6)
48 48  
... ... @@ -60,7 +60,7 @@ class SoftwareTabDataBlockTest &lt; ActiveSupport::TestCase
60 60 def craete_sample_posts blog, quantity=1
61 61 quantity.times do |number|
62 62 TinyMceArticle.create! :name=>"Simple post #{number}", :body=>"Simple post #{number}",
63   - :parent=> blog, :profile=>@soft_community
  63 + :parent=> blog, :profile=>@software
64 64 end
65 65 end
66 66 end
... ...
src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb
... ... @@ -32,12 +32,12 @@ class SoftwaresBlockTest &lt; ActiveSupport::TestCase
32 32 )
33 33  
34 34 software_info = create_software_info("new software")
35   - software_info.community.add_member(user)
  35 + software_info.software.add_member(user)
36 36  
37 37 block = SoftwaresBlock.new
38 38 block.expects(:owner).at_least_once.returns(user)
39 39  
40   - assert_equivalent [software_info.community], block.profiles
  40 + assert_equivalent [software_info.software], block.profiles
41 41 end
42 42  
43 43 end
... ...