[Git][noosfero/noosfero][master] 2 commits: Define default set of blocks for community angular-theme
Victor Costa
gitlab at mg.gitlab.com
Mon Mar 6 09:52:15 BRT 2017
Victor Costa pushed to branch master at Noosfero / noosfero
Commits:
5854d2e8 by Josafá Souza Jr at 2017-03-06T08:44:31-03:00
Define default set of blocks for community angular-theme
- - - - -
17bb36cc by Victor Costa at 2017-03-06T12:52:07+00:00
Merge branch 'community-default-blocks' into 'master'
Define default set of blocks for community angular-theme
See merge request !1127
- - - - -
2 changed files:
- app/models/community.rb
- test/unit/community_test.rb
Changes:
=====================================
app/models/community.rb
=====================================
--- a/app/models/community.rb
+++ b/app/models/community.rb
@@ -92,4 +92,28 @@ class Community < Organization
%w[join_community leave_scrap]
end
+ def default_set_of_blocks
+ return angular_theme_default_set_of_blocks if Theme.angular_theme?(environment.theme)
+ links = [
+ {:name => _('Community\'s profile'), :address => '/profile/{profile}', :icon => 'ok'},
+ {:name => _('Invite Friends'), :address => '/profile/{profile}/invite/friends', :icon => 'send'},
+ {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'event'},
+ {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'},
+ {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'},
+ ]
+ [
+ [MainBlock.new],
+ [ProfileImageBlock.new(:show_name => true), LinkListBlock.new(:links => links), RecentDocumentsBlock.new]
+ ]
+ end
+
+ def angular_theme_default_set_of_blocks
+ @boxes_limit = 2
+ self.layout_template = 'rightbar'
+ [
+ [MenuBlock.new, MainBlock.new],
+ [CommunitiesBlock.new, TagsBlock.new]
+ ]
+ end
+
end
=====================================
test/unit/community_test.rb
=====================================
--- a/test/unit/community_test.rb
+++ b/test/unit/community_test.rb
@@ -29,9 +29,22 @@ class CommunityTest < ActiveSupport::TestCase
should 'create default set of blocks' do
c = create(Community, :environment => Environment.default, :name => 'my new community')
- refute c.boxes[0].blocks.empty?, 'person must have blocks in area 1'
- refute c.boxes[1].blocks.empty?, 'person must have blocks in area 2'
- refute c.boxes[2].blocks.empty?, 'person must have blocks in area 3'
+ refute c.boxes[0].blocks.empty?, 'community must have blocks in area 1'
+ refute c.boxes[1].blocks.empty?, 'community must have blocks in area 2'
+ assert c.boxes[2].blocks.empty?, 'community must not have blocks in area 3'
+ end
+
+ should 'create a default set of blocks for angular theme' do
+ e = Environment.default
+ e.update_attribute(:theme, 'angular-theme')
+ Theme.expects(:angular_theme?).with('angular-theme').returns(true)
+ c = create(Community, :environment => Environment.default, :name => 'my new community')
+
+ assert_equal 2, c.boxes_limit
+ assert_equal 'rightbar', c.layout_template
+ refute c.boxes[0].blocks.empty?, 'community must have blocks in area 1'
+ refute c.boxes[1].blocks.empty?, 'community must have blocks in area 2'
+ assert c.boxes[2].blocks.empty?, 'community must not have blocks in area 3'
end
should 'create a default set of articles' do
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/f98173f2ea6a6b3e85f6174ee0f68e50336aa874...17bb36cc33df75ec7904be32e7ccb2a4681ed48d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170306/562240a1/attachment-0001.html>
More information about the Noosfero-dev
mailing list