Commit 29cf7928ac34425d1bd15702f6e16b44ec3c71f6
Committed by
Luciano Prestes
1 parent
f45efad9
Exists in
refactor_software_communities_rails4
Refactor community to software
Signed-off-by: Artur Bersan de Faria <arturbersan@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing
17 changed files
with
94 additions
and
128 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/ext/communities_block.rb
1 | require_dependency 'communities_block' | 1 | require_dependency 'communities_block' |
2 | 2 | ||
3 | class CommunitiesBlock | 3 | class CommunitiesBlock |
4 | - | ||
5 | def profile_list | 4 | def profile_list |
6 | result = get_visible_profiles | 5 | result = get_visible_profiles |
6 | + puts "*"*80 | ||
7 | + puts result.count | ||
8 | + result = result.select { |community| !community.is_a? SoftwareCommunitiesPlugin::Software } | ||
9 | + puts "*"*80 | ||
10 | + puts result.count | ||
7 | result.slice(0..get_limit-1) | 11 | result.slice(0..get_limit-1) |
8 | end | 12 | end |
9 | 13 | ||
10 | def profile_count | 14 | def profile_count |
11 | profile_list.count | 15 | profile_list.count |
12 | end | 16 | end |
13 | - | ||
14 | - private | ||
15 | - | ||
16 | - def get_visible_profiles | ||
17 | - visible_profiles = profiles.visible.includes( | ||
18 | - [:image,:domains,:preferred_domain,:environment] | ||
19 | - ) | ||
20 | - | ||
21 | - delete_communities = [] | ||
22 | - valid_communities_string = Community.get_valid_communities_string | ||
23 | - Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} | ||
24 | - | ||
25 | - visible_profiles = visible_profiles.where(["profiles.id NOT IN (?)", delete_communities]) unless delete_communities.empty? | ||
26 | - | ||
27 | - if !prioritize_profiles_with_image | ||
28 | - return visible_profiles.all( | ||
29 | - :limit => get_limit, | ||
30 | - :order => 'profiles.updated_at DESC' | ||
31 | - ).sort_by {rand} | ||
32 | - elsif profiles.visible.with_image.count >= get_limit | ||
33 | - return visible_profiles.with_image.all( | ||
34 | - :limit => get_limit * 5, | ||
35 | - :order => 'profiles.updated_at DESC' | ||
36 | - ).sort_by {rand} | ||
37 | - else | ||
38 | - visible_profiles = visible_profiles.with_image.sort_by {rand} + | ||
39 | - visible_profiles.without_image.all( | ||
40 | - :limit => get_limit * 5, :order => 'profiles.updated_at DESC' | ||
41 | - ).sort_by {rand} | ||
42 | - return visible_profiles | ||
43 | - end | ||
44 | - end | ||
45 | end | 17 | end |
src/noosfero-spb/software_communities/lib/ext/person.rb
@@ -6,19 +6,17 @@ class Person | @@ -6,19 +6,17 @@ class Person | ||
6 | 6 | ||
7 | delegate :login, :to => :user, :prefix => true | 7 | delegate :login, :to => :user, :prefix => true |
8 | 8 | ||
9 | - def software? | ||
10 | - false | ||
11 | - end | ||
12 | - | 9 | + alias :old_communities :communities |
13 | def softwares | 10 | def softwares |
14 | - softwares = [] | ||
15 | - self.communities.each do |community| | ||
16 | - if community.software? | ||
17 | - softwares << community | ||
18 | - end | 11 | + self.old_communities.select do |community| |
12 | + community.is_a?(SoftwareCommunitiesPlugin::Software) | ||
19 | end | 13 | end |
14 | + end | ||
20 | 15 | ||
21 | - softwares | 16 | + def communities |
17 | + self.old_communities.select do |community| | ||
18 | + !community.is_a?(SoftwareCommunitiesPlugin::Software) | ||
19 | + end | ||
22 | end | 20 | end |
23 | 21 | ||
24 | end | 22 | end |
src/noosfero-spb/software_communities/lib/software_communities_plugin/api.rb
@@ -8,7 +8,7 @@ class SoftwareCommunitiesPlugin::API < Grape::API | @@ -8,7 +8,7 @@ class SoftwareCommunitiesPlugin::API < Grape::API | ||
8 | resource :software_communities do | 8 | resource :software_communities do |
9 | get do | 9 | get do |
10 | authenticate! | 10 | authenticate! |
11 | - softwares = select_filtered_collection_of(environment,'communities',params).joins(:software_info) | 11 | + softwares = select_filtered_collection_of(environment,'softwares',params).joins(:software_info) |
12 | softwares = softwares.visible_for_person(current_person) | 12 | softwares = softwares.visible_for_person(current_person) |
13 | present softwares.map{|o|o.software_info}, :with => Entities::SoftwareInfo | 13 | present softwares.map{|o|o.software_info}, :with => Entities::SoftwareInfo |
14 | end | 14 | end |
src/noosfero-spb/software_communities/lib/software_communities_plugin/api_entities.rb
@@ -20,8 +20,8 @@ module Entities | @@ -20,8 +20,8 @@ module Entities | ||
20 | expose :operating_system_names | 20 | expose :operating_system_names |
21 | expose :created_at, :format_with => :timestamp | 21 | expose :created_at, :format_with => :timestamp |
22 | expose :updated_at, :format_with => :timestamp | 22 | expose :updated_at, :format_with => :timestamp |
23 | - expose :community_id do |software_info,options| | ||
24 | - software_info.community.id | 23 | + expose :software_id do |software_info,options| |
24 | + software_info.software.id | ||
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 |
src/noosfero-spb/software_communities/lib/software_communities_plugin/create_software.rb
@@ -24,17 +24,19 @@ class SoftwareCommunitiesPlugin::CreateSoftware < Task | @@ -24,17 +24,19 @@ class SoftwareCommunitiesPlugin::CreateSoftware < Task | ||
24 | identifier = self.identifier | 24 | identifier = self.identifier |
25 | identifier ||= self.name.to_slug | 25 | identifier ||= self.name.to_slug |
26 | 26 | ||
27 | - community = Community.create!(:name => self.name, | 27 | + software = SoftwareCommunitiesPlugin::Software.new(:name => self.name, |
28 | :identifier => identifier, | 28 | :identifier => identifier, |
29 | :template_id => template_id) | 29 | :template_id => template_id) |
30 | 30 | ||
31 | - community.environment = self.environment | ||
32 | - community.add_admin(self.requestor) | 31 | + software.environment = self.environment |
32 | + software.add_admin(self.requestor) | ||
33 | 33 | ||
34 | - software = SoftwareCommunitiesPlugin::SoftwareInfo.create!(:finality => self.finality, | ||
35 | - :repository_link => self.repository_link, :community_id => community.id, | ||
36 | - :license_info => self.license_info) | ||
37 | - software.verify_license_info(self.another_license_version, self.another_license_link) | 34 | + software_info = SoftwareCommunitiesPlugin::SoftwareInfo.new(:finality => self.finality, |
35 | + :repository_link => self.repository_link, :license_info => self.license_info) | ||
36 | + | ||
37 | + software.software_info = software_info | ||
38 | + | ||
39 | + software_info.verify_license_info(self.another_license_version, self.another_license_link) | ||
38 | software.save! | 40 | software.save! |
39 | end | 41 | end |
40 | 42 | ||
@@ -110,7 +112,7 @@ class SoftwareCommunitiesPlugin::CreateSoftware < Task | @@ -110,7 +112,7 @@ class SoftwareCommunitiesPlugin::CreateSoftware < Task | ||
110 | private | 112 | private |
111 | 113 | ||
112 | def mount_url | 114 | def mount_url |
113 | - identifier = Community.where(:name => self.name).first.identifier | 115 | + identifier = SoftwareCommunitiesPlugin::Software.where(:name => self.name).first.identifier |
114 | # The use of url_for doesn't allow the /social within the Public Software | 116 | # The use of url_for doesn't allow the /social within the Public Software |
115 | # portal. That's why the url is mounted so 'hard coded' | 117 | # portal. That's why the url is mounted so 'hard coded' |
116 | url = "#{environment.top_url}/myprofile/#{identifier}/profile_editor/edit_software_community" | 118 | url = "#{environment.top_url}/myprofile/#{identifier}/profile_editor/edit_software_community" |
src/noosfero-spb/software_communities/lib/software_communities_plugin/software.rb
1 | -class SoftwareCommunitiesPlugin::Software < Organization | ||
2 | - | 1 | +class SoftwareCommunitiesPlugin::Software < Community |
3 | SEARCHABLE_SOFTWARE_FIELDS = { | 2 | SEARCHABLE_SOFTWARE_FIELDS = { |
4 | :name => 1, | 3 | :name => 1, |
5 | :identifier => 2, | 4 | :identifier => 2, |
6 | :nickname => 3 | 5 | :nickname => 3 |
7 | } | 6 | } |
8 | 7 | ||
9 | - attr_accessible :visible | ||
10 | - | ||
11 | has_one :software_info, :dependent=>:destroy, :class_name => "SoftwareCommunitiesPlugin::SoftwareInfo" | 8 | has_one :software_info, :dependent=>:destroy, :class_name => "SoftwareCommunitiesPlugin::SoftwareInfo" |
12 | 9 | ||
10 | + delegate :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, | ||
11 | + :operating_platform, :demonstration_url, :acronym, | ||
12 | + :objectives, :features, :license_info, | ||
13 | + :finality, :repository_link, :public_software, :first_edit, | ||
14 | + :to => :software_info | ||
15 | + | ||
16 | + | ||
13 | settings_items :hits, :type => :integer, :default => 0 | 17 | settings_items :hits, :type => :integer, :default => 0 |
14 | 18 | ||
15 | def self.create_after_moderation(requestor, attributes = {}) | 19 | def self.create_after_moderation(requestor, attributes = {}) |
src/noosfero-spb/software_communities/test/helpers/plugin_test_helper.rb
1 | module PluginTestHelper | 1 | module PluginTestHelper |
2 | 2 | ||
3 | def create_software name | 3 | def create_software name |
4 | - software = fast_create(SoftwareCommunitiesPlugin::Software) | 4 | + software = SoftwareCommunitiesPlugin::Software.new |
5 | software.name = name | 5 | software.name = name |
6 | software.identifier = name.to_slug | 6 | software.identifier = name.to_slug |
7 | - software.save | 7 | + |
8 | software | 8 | software |
9 | end | 9 | end |
10 | 10 |
src/noosfero-spb/software_communities/test/unit/api_test.rb
@@ -29,12 +29,12 @@ class SoftwareCommunitiesApiTest < ActiveSupport::TestCase | @@ -29,12 +29,12 @@ class SoftwareCommunitiesApiTest < ActiveSupport::TestCase | ||
29 | assert_equal @software_info.id, json["software_info"]["id"] | 29 | assert_equal @software_info.id, json["software_info"]["id"] |
30 | end | 30 | end |
31 | 31 | ||
32 | - should 'list only softwares with visible community' do | 32 | + should 'list only softwares with visible software' do |
33 | @software_info = create_software_info("software_test") | 33 | @software_info = create_software_info("software_test") |
34 | @software_info2 = create_software_info("software_test2") | 34 | @software_info2 = create_software_info("software_test2") |
35 | 35 | ||
36 | - @software_info2.community.visible = false | ||
37 | - @software_info2.community.save! | 36 | + @software_info2.software.visible = false |
37 | + @software_info2.software.save! | ||
38 | 38 | ||
39 | get "/api/v1/software_communities?#{params.to_query}" | 39 | get "/api/v1/software_communities?#{params.to_query}" |
40 | json = JSON.parse(last_response.body) | 40 | json = JSON.parse(last_response.body) |
src/noosfero-spb/software_communities/test/unit/communities_block_test.rb
@@ -6,27 +6,26 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | @@ -6,27 +6,26 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | ||
6 | def setup | 6 | def setup |
7 | @person = create_person("My Name", "user@email.com", "123456", "123456", "Any State", "Some City") | 7 | @person = create_person("My Name", "user@email.com", "123456", "123456", "Any State", "Some City") |
8 | 8 | ||
9 | - @software_info = create_software_info("Novo Software") | ||
10 | - @software_info.community.add_member(@person) | 9 | + @software = create_software_info("New Software").software |
10 | + @software.add_member(@person) | ||
11 | 11 | ||
12 | - @community = create_community("Nova Comunidade") | 12 | + @community = create_community("New Community") |
13 | @community.add_member(@person) | 13 | @community.add_member(@person) |
14 | 14 | ||
15 | - | ||
16 | - @comminities_block = CommunitiesBlock.new | ||
17 | - @comminities_block.expects(:owner).at_least_once.returns(@person) | ||
18 | - end | ||
19 | - | ||
20 | - def teardown | ||
21 | - CommunitiesBlock.destroy_all | ||
22 | - @person = nil | ||
23 | - @community = nil | ||
24 | - @software_info = nil | 15 | + @communities_block = CommunitiesBlock.new |
16 | + @communities_block.expects(:owner).at_least_once.returns(@person) | ||
25 | end | 17 | end |
26 | 18 | ||
27 | - should "not have community of software or institution in block" do | ||
28 | - assert_includes @comminities_block.profile_list, @community | ||
29 | - assert_not_includes @comminities_block.profile_list, @software_info.community | 19 | + should "not have software community in block" do |
20 | + puts "="*80 | ||
21 | + puts "Softwares" | ||
22 | + puts @person.softwares | ||
23 | + puts "="*80 | ||
24 | + puts "Communities" | ||
25 | + puts @person.communities | ||
26 | + puts "*"*80 | ||
27 | + assert_includes @communities_block.profile_list, @community | ||
28 | + assert_not_includes @communities_block.profile_list, @software | ||
30 | end | 29 | end |
31 | 30 | ||
32 | end | 31 | end |
src/noosfero-spb/software_communities/test/unit/create_software_test.rb
@@ -28,23 +28,23 @@ class CreateSoftwareTest < ActiveSupport::TestCase | @@ -28,23 +28,23 @@ class CreateSoftwareTest < ActiveSupport::TestCase | ||
28 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :license_info => @license_info) | 28 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :license_info => @license_info) |
29 | 29 | ||
30 | assert_difference 'SoftwareCommunitiesPlugin::SoftwareInfo.count' do | 30 | assert_difference 'SoftwareCommunitiesPlugin::SoftwareInfo.count' do |
31 | - assert_difference 'Community.count' do | 31 | + assert_difference 'SoftwareCommunitiesPlugin::Software.count' do |
32 | task.finish | 32 | task.finish |
33 | end | 33 | end |
34 | end | 34 | end |
35 | 35 | ||
36 | - assert_equal @requestor, Community['software-test'].admins.first | 36 | + assert_equal @requestor, SoftwareCommunitiesPlugin::Software['software-test'].admins.first |
37 | end | 37 | end |
38 | 38 | ||
39 | should 'create new software community with all informed data when confirmed' do | 39 | should 'create new software community with all informed data when confirmed' do |
40 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :repository_link => "#", :license_info => @license_info) | 40 | task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :repository_link => "#", :license_info => @license_info) |
41 | 41 | ||
42 | task.finish | 42 | task.finish |
43 | - software = Community["software-test"].software_info | 43 | + software = SoftwareCommunitiesPlugin::Software["software-test"] |
44 | 44 | ||
45 | assert_equal "Any", software.finality | 45 | assert_equal "Any", software.finality |
46 | assert_equal "#", software.repository_link | 46 | assert_equal "#", software.repository_link |
47 | - assert_equal "Software Test", software.community.name | 47 | + assert_equal "Software Test", software.name |
48 | end | 48 | end |
49 | 49 | ||
50 | should 'override message methods from Task' do | 50 | should 'override message methods from Task' do |
src/noosfero-spb/software_communities/test/unit/software_communities_person_test.rb
@@ -20,12 +20,12 @@ class GovUserPluginPersonTest < ActiveSupport::TestCase | @@ -20,12 +20,12 @@ class GovUserPluginPersonTest < ActiveSupport::TestCase | ||
20 | should 'get a list of softwares of a person' do | 20 | should 'get a list of softwares of a person' do |
21 | software1 = create_software_info "noosfero" | 21 | software1 = create_software_info "noosfero" |
22 | software2 = create_software_info "colab" | 22 | software2 = create_software_info "colab" |
23 | - software = create_software "simple_community" | 23 | + community = fast_create Community |
24 | 24 | ||
25 | software1.software.add_member @user.person | 25 | software1.software.add_member @user.person |
26 | software1.save! | 26 | software1.save! |
27 | - software.add_member @user.person | ||
28 | - software.save! | 27 | + community.add_member @user.person |
28 | + community.save! | ||
29 | 29 | ||
30 | assert_equal 1, @user.person.softwares.count | 30 | assert_equal 1, @user.person.softwares.count |
31 | end | 31 | end |
src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb
@@ -5,12 +5,12 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | @@ -5,12 +5,12 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | ||
5 | include PluginTestHelper | 5 | include PluginTestHelper |
6 | 6 | ||
7 | def setup | 7 | def setup |
8 | - @community = create_community("A new community") | 8 | + @software = create_software_info("A new software").software |
9 | @software_events_block = SoftwareCommunitiesPlugin::SoftwareEventsBlock.new | 9 | @software_events_block = SoftwareCommunitiesPlugin::SoftwareEventsBlock.new |
10 | 10 | ||
11 | box = Box.new | 11 | box = Box.new |
12 | box.position = 1 | 12 | box.position = 1 |
13 | - box.owner = @community | 13 | + box.owner = @software |
14 | box.blocks << @software_events_block | 14 | box.blocks << @software_events_block |
15 | box.save! | 15 | box.save! |
16 | 16 | ||
@@ -32,13 +32,13 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | @@ -32,13 +32,13 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | ||
32 | @e6 = Event.new :name=>"Event 6", :body=>"Event 5 body", | 32 | @e6 = Event.new :name=>"Event 6", :body=>"Event 5 body", |
33 | :start_date=>(DateTime.now) | 33 | :start_date=>(DateTime.now) |
34 | 34 | ||
35 | - @community.events << @e1 | ||
36 | - @community.events << @e2 | ||
37 | - @community.events << @e3 | ||
38 | - @community.events << @e4 | ||
39 | - @community.events << @e5 | ||
40 | - @community.events << @e6 | ||
41 | - @community.save! | 35 | + @software.events << @e1 |
36 | + @software.events << @e2 | ||
37 | + @software.events << @e3 | ||
38 | + @software.events << @e4 | ||
39 | + @software.events << @e5 | ||
40 | + @software.events << @e6 | ||
41 | + @software.save! | ||
42 | end | 42 | end |
43 | 43 | ||
44 | should "get events with start date equals or bigger than current day ordered by start date" do | 44 | should "get events with start date equals or bigger than current day ordered by start date" do |
@@ -56,14 +56,14 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | @@ -56,14 +56,14 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | ||
56 | assert_equal @e5, events.last | 56 | assert_equal @e5, events.last |
57 | end | 57 | end |
58 | 58 | ||
59 | - should "include community events that have no end date" do | 59 | + should "include software events that have no end date" do |
60 | events = @software_events_block.get_events | 60 | events = @software_events_block.get_events |
61 | 61 | ||
62 | assert_equal true, events.include?(@e5) | 62 | assert_equal true, events.include?(@e5) |
63 | assert_equal true, events.include?(@e6) | 63 | assert_equal true, events.include?(@e6) |
64 | end | 64 | end |
65 | 65 | ||
66 | - should "give community events except by a event with a given slug" do | 66 | + should "give software events except by a event with a given slug" do |
67 | events = @software_events_block.get_events_except(@e1.slug) | 67 | events = @software_events_block.get_events_except(@e1.slug) |
68 | 68 | ||
69 | assert_equal false, events.include?(@e1) | 69 | assert_equal false, events.include?(@e1) |
@@ -82,7 +82,7 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | @@ -82,7 +82,7 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | ||
82 | 82 | ||
83 | assert_equal false, @software_events_block.has_events_to_display? | 83 | assert_equal false, @software_events_block.has_events_to_display? |
84 | 84 | ||
85 | - last_event = @community.events.last | 85 | + last_event = @software.events.last |
86 | last_event.start_date = DateTime.now | 86 | last_event.start_date = DateTime.now |
87 | last_event.end_date = DateTime.now + 1.day | 87 | last_event.end_date = DateTime.now + 1.day |
88 | last_event.save! | 88 | last_event.save! |
@@ -103,6 +103,6 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | @@ -103,6 +103,6 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase | ||
103 | private | 103 | private |
104 | 104 | ||
105 | def update_all_events start_date, end_date | 105 | def update_all_events start_date, end_date |
106 | - @community.events.update_all :start_date => start_date, :end_date => end_date | 106 | + @software.events.update_all :start_date => start_date, :end_date => end_date |
107 | end | 107 | end |
108 | end | 108 | end |
src/noosfero-spb/software_communities/test/unit/software_info_test.rb
@@ -33,7 +33,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | @@ -33,7 +33,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
33 | software_info = create_software_info("soft1") | 33 | software_info = create_software_info("soft1") |
34 | another_software_info = create_software_info("soft2") | 34 | another_software_info = create_software_info("soft2") |
35 | other_env = Environment.create!(name: "sisp") | 35 | other_env = Environment.create!(name: "sisp") |
36 | - another_soft_profile = another_software_info.community | 36 | + another_soft_profile = another_software_info.software |
37 | another_soft_profile.environment_id = other_env.id | 37 | another_soft_profile.environment_id = other_env.id |
38 | another_soft_profile.save | 38 | another_soft_profile.save |
39 | 39 |
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
@@ -3,8 +3,8 @@ require 'test_helper' | @@ -3,8 +3,8 @@ require 'test_helper' | ||
3 | class SoftwareInfoValidationTest < ActiveSupport::TestCase | 3 | class SoftwareInfoValidationTest < ActiveSupport::TestCase |
4 | 4 | ||
5 | def setup | 5 | def setup |
6 | - @community = fast_create( | ||
7 | - Community, | 6 | + @software = fast_create( |
7 | + SoftwareCommunitiesPlugin::Software, | ||
8 | :identifier => 'new-software', | 8 | :identifier => 'new-software', |
9 | :name => 'New Software' | 9 | :name => 'New Software' |
10 | ) | 10 | ) |
@@ -52,7 +52,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | @@ -52,7 +52,7 @@ class SoftwareInfoValidationTest < ActiveSupport::TestCase | ||
52 | 52 | ||
53 | @software_info.features = "Do a lot of things" | 53 | @software_info.features = "Do a lot of things" |
54 | @software_info.objectives = "All tests should pass !" | 54 | @software_info.objectives = "All tests should pass !" |
55 | - @software_info.community = @community | 55 | + @software_info.software = @software |
56 | end | 56 | end |
57 | 57 | ||
58 | should 'Save SoftwareInfo if all fields are filled' do | 58 | should 'Save SoftwareInfo if all fields are filled' do |
src/noosfero-spb/software_communities/test/unit/software_language_validation.rb
1 | require 'test_helper' | 1 | require 'test_helper' |
2 | +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' | ||
2 | 3 | ||
3 | class SoftwareLanguageValidationTest < ActiveSupport::TestCase | 4 | class SoftwareLanguageValidationTest < ActiveSupport::TestCase |
5 | + include PluginTestHelper | ||
6 | + | ||
4 | def setup | 7 | def setup |
5 | create_programming_language | 8 | create_programming_language |
6 | - @software_info = create_software_info | 9 | + @software_info = create_software_info('Noosfero') |
10 | + @software_info.e_mag = true | ||
11 | + @software_info.icp_brasil = true | ||
12 | + @software_info.intern = true | ||
13 | + @software_info.e_ping = true | ||
14 | + @software_info.e_arq = true | ||
15 | + @software_info.operating_platform = 'GNU/Linux' | ||
16 | + @software_info.features = "Do a lot of things" | ||
17 | + @software_info.objectives = "All tests should pass !" | ||
7 | @software_info.save | 18 | @software_info.save |
8 | end | 19 | end |
9 | 20 | ||
10 | - def teardown | ||
11 | - @software_info = nil | ||
12 | - SoftwareCommunitiesPlugin::SoftwareInfo.destroy_all | ||
13 | - end | ||
14 | - | ||
15 | should "Save SoftwareLanguage if version and prog_language are filled" do | 21 | should "Save SoftwareLanguage if version and prog_language are filled" do |
16 | @software_language = create_software_language | 22 | @software_language = create_software_language |
17 | assert_equal true, @software_language.save | 23 | assert_equal true, @software_language.save |
@@ -45,21 +51,6 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase | @@ -45,21 +51,6 @@ class SoftwareLanguageValidationTest < ActiveSupport::TestCase | ||
45 | software_language | 51 | software_language |
46 | end | 52 | end |
47 | 53 | ||
48 | - def create_software_info | ||
49 | - software_info = SoftwareCommunitiesPlugin::SoftwareInfo.new | ||
50 | - software_info.community_id = fast_create(Community).id | ||
51 | - software_info.community.name = 'Noosfero' | ||
52 | - software_info.e_mag = true | ||
53 | - software_info.icp_brasil = true | ||
54 | - software_info.intern = true | ||
55 | - software_info.e_ping = true | ||
56 | - software_info.e_arq = true | ||
57 | - software_info.operating_platform = 'GNU/Linux' | ||
58 | - software_info.features = "Do a lot of things" | ||
59 | - software_info.objectives = "All tests should pass !" | ||
60 | - software_info | ||
61 | - end | ||
62 | - | ||
63 | def create_programming_language | 54 | def create_programming_language |
64 | SoftwareCommunitiesPlugin::ProgrammingLanguage.create(:name=>"C") | 55 | SoftwareCommunitiesPlugin::ProgrammingLanguage.create(:name=>"C") |
65 | SoftwareCommunitiesPlugin::ProgrammingLanguage.create(:name=>"C++") | 56 | SoftwareCommunitiesPlugin::ProgrammingLanguage.create(:name=>"C++") |
src/noosfero-spb/software_communities/test/unit/software_tab_data_block_test.rb
@@ -8,7 +8,7 @@ class SoftwareTabDataBlockTest < ActiveSupport::TestCase | @@ -8,7 +8,7 @@ class SoftwareTabDataBlockTest < ActiveSupport::TestCase | ||
8 | @software_info = create_software_info("A new Software") | 8 | @software_info = create_software_info("A new Software") |
9 | @software_info.save! | 9 | @software_info.save! |
10 | 10 | ||
11 | - @soft_community = @software_info.community | 11 | + @soft_community = @software_info.software |
12 | 12 | ||
13 | @soft_community.blogs << Blog.new(:name=>"First blog") | 13 | @soft_community.blogs << Blog.new(:name=>"First blog") |
14 | @soft_community.blogs << Blog.new(:name=>"Second blog") | 14 | @soft_community.blogs << Blog.new(:name=>"Second blog") |
@@ -25,7 +25,7 @@ class SoftwareTabDataBlockTest < ActiveSupport::TestCase | @@ -25,7 +25,7 @@ class SoftwareTabDataBlockTest < ActiveSupport::TestCase | ||
25 | assert_equal @soft_community.blogs.first, SoftwareCommunitiesPlugin::SoftwareTabDataBlock.new.actual_blog | 25 | assert_equal @soft_community.blogs.first, SoftwareCommunitiesPlugin::SoftwareTabDataBlock.new.actual_blog |
26 | end | 26 | end |
27 | 27 | ||
28 | - should "actual_blog get the defined community blog" do | 28 | + should "actual_blog get the defined software blog" do |
29 | last_blog = @soft_community.blogs.last | 29 | last_blog = @soft_community.blogs.last |
30 | soft_tab_data = create_software_tab_data_block(last_blog) | 30 | soft_tab_data = create_software_tab_data_block(last_blog) |
31 | 31 |
src/noosfero-spb/software_communities/test/unit/softwares_block_test.rb
@@ -32,12 +32,12 @@ class SoftwaresBlockTest < ActiveSupport::TestCase | @@ -32,12 +32,12 @@ class SoftwaresBlockTest < ActiveSupport::TestCase | ||
32 | ) | 32 | ) |
33 | 33 | ||
34 | software_info = create_software_info("new software") | 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 | block = SoftwareCommunitiesPlugin::SoftwaresBlock.new | 37 | block = SoftwareCommunitiesPlugin::SoftwaresBlock.new |
38 | block.expects(:owner).at_least_once.returns(user) | 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 | end | 41 | end |
42 | 42 | ||
43 | end | 43 | end |