[Git][noosfero/noosfero][master] 2 commits: Available blocks including plugin blocks
Leandro Nunes
gitlab at mg.gitlab.com
Fri May 5 12:06:31 BRT 2017
Leandro Nunes pushed to branch master at Noosfero / noosfero
Commits:
d269babd by Evandro Jr at 2017-05-05T15:06:18+00:00
Available blocks including plugin blocks
- - - - -
8ed8d821 by Leandro Nunes at 2017-05-05T15:06:19+00:00
Merge branch 'available-blocks-including-plugin-blocks' into 'master'
Available blocks including plugin blocks
Closes noosfero-themes/angular-theme#357
See merge request !1193
- - - - -
6 changed files:
- app/controllers/admin/environment_design_controller.rb
- app/controllers/my_profile/profile_design_controller.rb
- app/models/environment.rb
- app/models/profile.rb
- test/unit/environment_test.rb
- test/unit/profile_test.rb
Changes:
=====================================
app/controllers/admin/environment_design_controller.rb
=====================================
--- a/app/controllers/admin/environment_design_controller.rb
+++ b/app/controllers/admin/environment_design_controller.rb
@@ -3,7 +3,7 @@ class EnvironmentDesignController < BoxOrganizerController
protect 'edit_environment_design', :environment
def available_blocks
- boxes_holder.available_blocks(user) + plugins.dispatch(:extra_blocks, :type => Environment)
+ boxes_holder.available_blocks(user)
end
end
=====================================
app/controllers/my_profile/profile_design_controller.rb
=====================================
--- a/app/controllers/my_profile/profile_design_controller.rb
+++ b/app/controllers/my_profile/profile_design_controller.rb
@@ -24,7 +24,7 @@ class ProfileDesignController < BoxOrganizerController
end
def available_blocks
- profile.available_blocks(user) + plugins.dispatch(:extra_blocks, type: boxes_holder.class)
+ profile.available_blocks(user)
end
def update_categories
=====================================
app/models/environment.rb
=====================================
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -1067,9 +1067,10 @@ class Environment < ApplicationRecord
end
def available_blocks(person)
- [ ArticleBlock, LoginBlock, RecentDocumentsBlock, EnterprisesBlock,
+ core_blocks = [ ArticleBlock, LoginBlock, RecentDocumentsBlock, EnterprisesBlock,
CommunitiesBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock,
HighlightsBlock, CategoriesBlock, RawHTMLBlock, TagsCloudBlock ]
+ core_blocks + plugins.dispatch(:extra_blocks, type: self.class)
end
include Noosfero::Plugin::HotSpot
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -1247,6 +1247,6 @@ private :generate_url, :url_options
blocks << BlogArchivesBlock if self.has_blog?
# block exclusive for environment admin
blocks << RawHTMLBlock if person.present? && person.is_admin?(self.environment)
- blocks
+ blocks + plugins.dispatch(:extra_blocks, type: self.class)
end
end
=====================================
test/unit/environment_test.rb
=====================================
--- a/test/unit/environment_test.rb
+++ b/test/unit/environment_test.rb
@@ -1798,4 +1798,26 @@ class EnvironmentTest < ActiveSupport::TestCase
assert_includes environment.reserved_identifiers, 'identifier1'
assert_includes environment.reserved_identifiers, 'identifier2'
end
+
+ should 'list available core\'s blocks' do
+ environment = Environment.default
+ person = create_user('mytestuser').person
+ assert_includes environment.available_blocks(person), ArticleBlock
+ end
+
+ should 'list available blocks' do
+ environment = Environment.default
+ person = create_user('mytestuser').person
+ class CustomBlock1 < Block; end;
+ class TestBlockPlugin < Noosfero::Plugin
+ def self.extra_blocks
+ {
+ CustomBlock1 => {:type => Environment},
+ }
+ end
+ end
+ Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestBlockPlugin.new])
+ assert_includes environment.available_blocks(person), CustomBlock1
+ end
+
end
=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -2375,12 +2375,27 @@ class ProfileTest < ActiveSupport::TestCase
assert_equal 'some description', c.custom_field_value(:description)
end
- should 'list available blocks' do
+ should 'list available core\'s block' do
profile = Profile.new
person = create_user('mytestuser').person
assert_includes profile.available_blocks(person), ArticleBlock
end
+ should 'list available blocks' do
+ class CustomBlock1 < Block; end;
+ person = create_user('mytestuser').person
+ class TestBlockPlugin < Noosfero::Plugin
+ def self.extra_blocks
+ {
+ CustomBlock1 => {:type => Person},
+ }
+ end
+ end
+ Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestBlockPlugin.new])
+ assert_includes person.available_blocks(person), CustomBlock1
+ end
+
+
should 'list BlogArchivesBlock as available block when profile has a blog' do
profile = Profile.new
profile.expects(:has_blog?).returns(true)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/9072a73e82b62ed8a3c4cbcaecf62630b3c1b1fa...8ed8d821c43c5c6349e764d52e77ee55dca92d2b
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/9072a73e82b62ed8a3c4cbcaecf62630b3c1b1fa...8ed8d821c43c5c6349e764d52e77ee55dca92d2b
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170505/7f9e5948/attachment-0001.html>
More information about the Noosfero-dev
mailing list