Commit bac0d14232e05128b93f46264f00cd2e059b0110

Authored by Luciano Prestes
1 parent 480435c7

Update namespaces

src/noosfero-spb/software_communities/db/migrate/20160104170028_changing_software_statistics_from_block_to_software_info.rb
1 1 class ChangingSoftwareStatisticsFromBlockToSoftwareInfo < ActiveRecord::Migration
2 2 def up
3   - select_all("SELECT * FROM software_infos").each do |software|
  3 + select_all("SELECT * FROM software_communities_plugin_software_infos").each do |software|
4 4 benefited_people = 0
5 5 saved_resources = 0
6 6  
... ...
src/noosfero-spb/software_communities/db/migrate/20160107131641_change_software_info_structure.rb
1 1 class ChangeSoftwareInfoStructure < ActiveRecord::Migration
2 2 def up
3   - change_table :software_infos do |t|
  3 + change_table :software_communities_plugin_software_infos do |t|
4 4 t.text :sisp_url
5 5 t.text :agency_identification
6 6 t.text :software_requirements
... ... @@ -20,26 +20,26 @@ class ChangeSoftwareInfoStructure &lt; ActiveRecord::Migration
20 20 t.integer :sisp_id
21 21 end
22 22  
23   - change_column :software_infos, :finality, :text
  23 + change_column :software_communities_plugin_software_infos, :finality, :text
24 24 end
25 25  
26 26 def down
27   - remove_column :software_infos, :agency_identification
28   - remove_column :software_infos, :software_requirements
29   - remove_column :software_infos, :hardware_requirements
30   - remove_column :software_infos, :documentation
31   - remove_column :software_infos, :system_applications
32   - remove_column :software_infos, :active_versions
33   - remove_column :software_infos, :estimated_cost
34   - remove_column :software_infos, :responsible
35   - remove_column :software_infos, :responsible_for_acquirement
36   - remove_column :software_infos, :system_info
37   - remove_column :software_infos, :development_info
38   - remove_column :software_infos, :maintenance
39   - remove_column :software_infos, :standards_adherence
40   - remove_column :software_infos, :platform
41   - remove_column :software_infos, :sisp_type
42   - remove_column :software_infos, :sisp_id
43   - remove_column :software_infos, :sisp_url
  27 + remove_column :software_communities_plugin_software_infos, :agency_identification
  28 + remove_column :software_communities_plugin_software_infos, :software_requirements
  29 + remove_column :software_communities_plugin_software_infos, :hardware_requirements
  30 + remove_column :software_communities_plugin_software_infos, :documentation
  31 + remove_column :software_communities_plugin_software_infos, :system_applications
  32 + remove_column :software_communities_plugin_software_infos, :active_versions
  33 + remove_column :software_communities_plugin_software_infos, :estimated_cost
  34 + remove_column :software_communities_plugin_software_infos, :responsible
  35 + remove_column :software_communities_plugin_software_infos, :responsible_for_acquirement
  36 + remove_column :software_communities_plugin_software_infos, :system_info
  37 + remove_column :software_communities_plugin_software_infos, :development_info
  38 + remove_column :software_communities_plugin_software_infos, :maintenance
  39 + remove_column :software_communities_plugin_software_infos, :standards_adherence
  40 + remove_column :software_communities_plugin_software_infos, :platform
  41 + remove_column :software_communities_plugin_software_infos, :sisp_type
  42 + remove_column :software_communities_plugin_software_infos, :sisp_id
  43 + remove_column :software_communities_plugin_software_infos, :sisp_url
44 44 end
45 45 end
... ...
src/noosfero-spb/software_communities/db/migrate/20160112191716_add_license_to_softwares_with_none.rb
1 1 class AddLicenseToSoftwaresWithNone < ActiveRecord::Migration
2 2 def up
3   - execute("UPDATE software_infos SET license_info_id=(SELECT id FROM license_infos WHERE version='Another') WHERE license_info_id IS NULL;")
  3 + execute("UPDATE software_communities_plugin_software_infos SET license_info_id=(SELECT id FROM software_communities_plugin_license_infos WHERE version='Another') WHERE license_info_id IS NULL;")
4 4 end
5 5  
6 6 def down
... ...
src/noosfero-spb/software_communities/db/migrate/20160114190943_add_timestamps_to_software_info.rb
1 1 class AddTimestampsToSoftwareInfo < ActiveRecord::Migration
2 2 def up
3   - change_table :software_infos do |t|
  3 + change_table :software_communities_plugin_software_infos do |t|
4 4 t.datetime :created_at, :null => false, :default => Time.zone.now
5 5 t.datetime :updated_at, :null => false, :default => Time.zone.now
6 6 end
7 7 end
8 8  
9 9 def down
10   - remove_column :software_infos, :created_at
11   - remove_column :software_infos, :updated_at
  10 + remove_column :software_communities_plugin_software_infos, :created_at
  11 + remove_column :software_communities_plugin_software_infos, :updated_at
12 12 end
13 13 end
... ...
src/noosfero-spb/software_communities/lib/sisp_tab_data_block.rb
... ... @@ -1,23 +0,0 @@
1   -class SispTabDataBlock < SoftwareTabDataBlock
2   - def self.description
3   - _('Sisp Tab Data')
4   - end
5   -
6   - def help
7   - _('This block is used to display SISP Data')
8   - end
9   -
10   - def content(args={})
11   - block = self
12   -
13   - lambda do |object|
14   - render(
15   - :file => 'blocks/sisp_tab_data',
16   - :locals => {
17   - :block => block
18   - }
19   - )
20   - end
21   - end
22   -
23   -end
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
... ... @@ -63,10 +63,10 @@ class SoftwareCommunitiesPlugin &lt; Noosfero::Plugin
63 63 SoftwareCommunitiesPlugin::SearchCatalogBlock => { :type => [Environment] },
64 64 SoftwareCommunitiesPlugin::SoftwareHighlightsBlock => { :type => [Environment] },
65 65 SoftwareCommunitiesPlugin::SoftwareTabDataBlock => {:type => [Community], :position => 1},
66   - SispTabDataBlock => {:type => [Community], :position => 1},
  66 + SoftwareCommunitiesPlugin::SispTabDataBlock => {:type => [Community], :position => 1},
67 67 SoftwareCommunitiesPlugin::WikiBlock => {:type => [Community]},
68   - SoftwareCommunitiesPlugin::StatisticBlock => { :type => [Community] }
69   - SoftwareEventsBlock => { :type => [Community] }
  68 + SoftwareCommunitiesPlugin::StatisticBlock => { :type => [Community] },
  69 + SoftwareCommunitiesPlugin::SoftwareEventsBlock => { :type => [Community] }
70 70 }
71 71 end
72 72  
... ...
src/noosfero-spb/software_communities/lib/software_communities_plugin/sisp_tab_data_block.rb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +class SoftwareCommunitiesPlugin::SispTabDataBlock < SoftwareCommunitiesPlugin::SoftwareTabDataBlock
  2 + def self.description
  3 + _('Sisp Tab Data')
  4 + end
  5 +
  6 + def help
  7 + _('This block is used to display SISP Data')
  8 + end
  9 +
  10 + def content(args={})
  11 + block = self
  12 +
  13 + lambda do |object|
  14 + render(
  15 + :file => 'blocks/sisp_tab_data',
  16 + :locals => {
  17 + :block => block
  18 + }
  19 + )
  20 + end
  21 + end
  22 +
  23 +end
... ...
src/noosfero-spb/software_communities/lib/software_communities_plugin/software_events_block.rb 0 → 100644
... ... @@ -0,0 +1,56 @@
  1 +class SoftwareCommunitiesPlugin::SoftwareEventsBlock < Block
  2 +
  3 + settings_items :amount_of_events, :type => :integer, :default => 3
  4 + attr_accessible :amount_of_events
  5 +
  6 + validates :amount_of_events,
  7 + :presence => true, :numericality => {
  8 + greater_than_or_equal_to: 1
  9 + }
  10 +
  11 + def self.description
  12 + _('Software community events')
  13 + end
  14 +
  15 + def help
  16 + _('This block displays the software community events in a list.')
  17 + end
  18 +
  19 + def default_title
  20 + _('Other events')
  21 + end
  22 +
  23 + def content(args={})
  24 + block = self
  25 +
  26 + lambda do |object|
  27 + render(
  28 + :file => 'blocks/software_events',
  29 + :locals => { :block => block }
  30 + )
  31 + end
  32 + end
  33 +
  34 + def cacheable?
  35 + false
  36 + end
  37 +
  38 + def get_events
  39 + yesterday = DateTime.yesterday.end_of_day
  40 + self.owner.events.where("start_date > ?", yesterday).order(:start_date, :id).limit(self.amount_of_events)
  41 + end
  42 +
  43 + def get_events_except event_slug=""
  44 + event_slug = "" if event_slug.nil?
  45 +
  46 + get_events.where("slug NOT IN (?)", event_slug)
  47 + end
  48 +
  49 + def has_events_to_display? current_event_slug=""
  50 + not get_events_except(current_event_slug).empty?
  51 + end
  52 +
  53 + def should_display_title?
  54 + self.box.position != 1
  55 + end
  56 +end
... ...
src/noosfero-spb/software_communities/lib/software_events_block.rb
... ... @@ -1,56 +0,0 @@
1   -class SoftwareEventsBlock < Block
2   -
3   - settings_items :amount_of_events, :type => :integer, :default => 3
4   - attr_accessible :amount_of_events
5   -
6   - validates :amount_of_events,
7   - :presence => true, :numericality => {
8   - greater_than_or_equal_to: 1
9   - }
10   -
11   - def self.description
12   - _('Software community events')
13   - end
14   -
15   - def help
16   - _('This block displays the software community events in a list.')
17   - end
18   -
19   - def default_title
20   - _('Other events')
21   - end
22   -
23   - def content(args={})
24   - block = self
25   -
26   - lambda do |object|
27   - render(
28   - :file => 'blocks/software_events',
29   - :locals => { :block => block }
30   - )
31   - end
32   - end
33   -
34   - def cacheable?
35   - false
36   - end
37   -
38   - def get_events
39   - yesterday = DateTime.yesterday.end_of_day
40   - self.owner.events.where("start_date > ?", yesterday).order(:start_date, :id).limit(self.amount_of_events)
41   - end
42   -
43   - def get_events_except event_slug=""
44   - event_slug = "" if event_slug.nil?
45   -
46   - get_events.where("slug NOT IN (?)", event_slug)
47   - end
48   -
49   - def has_events_to_display? current_event_slug=""
50   - not get_events_except(current_event_slug).empty?
51   - end
52   -
53   - def should_display_title?
54   - self.box.position != 1
55   - end
56   -end
src/noosfero-spb/software_communities/lib/tasks/create_sample_softwares.rake
... ... @@ -9,12 +9,12 @@ end
9 9  
10 10 def create_software_info(name, acronym = "", finality = "default")
11 11 community = create_community(name)
12   - software_info = SoftwareInfo.new
  12 + software_info = SoftwareCommunitiesPlugin::SoftwareInfo.new
13 13 software_info.community = community
14 14 software_info.public_software = true
15 15 software_info.acronym = acronym
16 16 software_info.finality = finality
17   - software_info.license_info = LicenseInfo.first
  17 + software_info.license_info = SoftwareCommunitiesPlugin::LicenseInfo.first
18 18  
19 19 if software_info.community.valid? && software_info.valid?
20 20 print "."
... ... @@ -25,6 +25,7 @@ def create_software_info(name, acronym = &quot;&quot;, finality = &quot;default&quot;)
25 25 nil
26 26 end
27 27 end
  28 +
28 29 namespace :software do
29 30 desc "Create sample softwares"
30 31 task :create_sample_softwares => :environment do
... ...
src/noosfero-spb/software_communities/test/unit/create_software_test.rb
... ... @@ -4,6 +4,7 @@ class CreateSoftwareTest &lt; ActiveSupport::TestCase
4 4  
5 5 def setup
6 6 @requestor = create_user('testuser').person
  7 + @license_info = SoftwareCommunitiesPlugin::LicenseInfo.create(:version => 'New License', :link => '#')
7 8 end
8 9  
9 10 should 'be a task' do
... ... @@ -11,7 +12,7 @@ class CreateSoftwareTest &lt; ActiveSupport::TestCase
11 12 end
12 13  
13 14 should 'require a requestor' do
14   - task = SoftwareCommunitiesPlugin::CreateSoftware.new(:name => 'Software Test', :target => Environment.default)
  15 + task = SoftwareCommunitiesPlugin::CreateSoftware.new(:name => 'Software Test', :target => Environment.default, :license_info => @license_info)
15 16 task.valid?
16 17  
17 18 assert task.errors[:requestor_id.to_s].present?
... ... @@ -24,7 +25,7 @@ class CreateSoftwareTest &lt; ActiveSupport::TestCase
24 25 end
25 26  
26 27 should 'actually create new software community when confirmed' do
27   - task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any")
  28 + task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :license_info => @license_info)
28 29  
29 30 assert_difference 'SoftwareCommunitiesPlugin::SoftwareInfo.count' do
30 31 assert_difference 'Community.count' do
... ... @@ -36,7 +37,7 @@ class CreateSoftwareTest &lt; ActiveSupport::TestCase
36 37 end
37 38  
38 39 should 'create new software community with all informed data when confirmed' do
39   - task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :repository_link => "#", )
  40 + task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :repository_link => "#", :license_info => @license_info)
40 41  
41 42 task.finish
42 43 software = Community["software-test"].software_info
... ... @@ -47,7 +48,7 @@ class CreateSoftwareTest &lt; ActiveSupport::TestCase
47 48 end
48 49  
49 50 should 'override message methods from Task' do
50   - task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any")
  51 + task = SoftwareCommunitiesPlugin::CreateSoftware.create!(:name => 'Software Test', :target => Environment.default, :requestor => @requestor, :finality => "Any", :license_info => @license_info)
51 52  
52 53 task.finish
53 54  
... ...
src/noosfero-spb/software_communities/test/unit/operating_system_helper_test.rb
... ... @@ -8,9 +8,9 @@ class OperatingSystemHelperTest &lt; ActiveSupport::TestCase
8 8  
9 9 def setup
10 10 @operating_system_objects = [
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"}
  11 + {:operating_system_name_id => SoftwareCommunitiesPlugin::OperatingSystemName.find_by_name("Debina").id.to_s, :version => "2.0"},
  12 + {:operating_system_name_id => SoftwareCommunitiesPlugin::OperatingSystemName.find_by_name("Fedora").id.to_s, "version" => "2.1"},
  13 + {:operating_system_name_id => SoftwareCommunitiesPlugin::OperatingSystemName.find_by_name("CentOS").id.to_s, "version" => "2.2"}
14 14 ]
15 15 @operating_system_objects
16 16 end
... ...
src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb
... ... @@ -6,7 +6,7 @@ class SoftwareEventsBlockTest &lt; ActiveSupport::TestCase
6 6  
7 7 def setup
8 8 @community = create_community("A new community")
9   - @software_events_block = SoftwareEventsBlock.new
  9 + @software_events_block = SoftwareCommunitiesPlugin::SoftwareEventsBlock.new
10 10  
11 11 box = Box.new
12 12 box.position = 1
... ...
src/noosfero-spb/software_communities/test/unit/software_info_validation_test.rb
... ... @@ -31,7 +31,7 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
31 31 @operating_system.operating_system_name = @operating_system_name
32 32 @operating_system.save
33 33  
34   - @license_info = LicenseInfo.create(:version => 'New License', :link => '#')
  34 + @license_info = SoftwareCommunitiesPlugin::LicenseInfo.create(:version => 'New License', :link => '#')
35 35  
36 36 @software_info = SoftwareCommunitiesPlugin::SoftwareInfo.new(
37 37 :acronym => "SFTW",
... ... @@ -55,16 +55,6 @@ class SoftwareInfoValidationTest &lt; ActiveSupport::TestCase
55 55 @software_info.community = @community
56 56 end
57 57  
58   - def teardown
59   - SoftwareCommunitiesPlugin::ProgrammingLanguage.destroy_all
60   - SoftwareCommunitiesPlugin::SoftwareLanguage.destroy_all
61   - SoftwareCommunitiesPlugin::DatabaseDescription.destroy_all
62   - SoftwareCommunitiesPlugin::SoftwareDatabase.destroy_all
63   - SoftwareCommunitiesPlugin::OperatingSystem.destroy_all
64   - SoftwareCommunitiesPlugin::OperatingSystemName.destroy_all
65   - SoftwareCommunitiesPlugin::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_registration_test.rb
... ... @@ -6,7 +6,8 @@ class SoftwareRegistrationTest &lt; ActiveSupport::TestCase
6 6 @environment = Environment.default
7 7 @environment.enable_plugin(SoftwareCommunitiesPlugin)
8 8  
9   - @license_info = LicenseInfo.create(:version => "New License", :link => "#")
  9 + @license_info = SoftwareCommunitiesPlugin::LicenseInfo.create(:version => "New License", :link => "#")
  10 + end
10 11  
11 12 def teardown
12 13 Community.destroy_all
... ...