From 206492735f7dcaed88fde1bb1b2a30947a0ff68a Mon Sep 17 00:00:00 2001 From: JoenioCosta Date: Thu, 10 Jul 2008 20:48:20 +0000 Subject: [PATCH] ActionItem501: redefining default blocks of enterprise and person --- app/models/enterprise.rb | 4 ++-- app/models/person.rb | 4 ++-- app/models/profile.rb | 2 +- script/anhetegua | 11 ----------- test/functional/content_viewer_controller_test.rb | 5 +++-- test/unit/enterprise_test.rb | 9 ++++----- test/unit/person_test.rb | 2 +- 7 files changed, 13 insertions(+), 24 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index a4b943d..1e71b7d 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -61,8 +61,8 @@ class Enterprise < Organization def default_set_of_blocks [ [MainBlock], - [ProfileInfoBlock, ProductsBlock, RecentDocumentsBlock], - [MembersBlock, TagsBlock] + [ProfileInfoBlock, MembersBlock], + [ProductsBlock, RecentDocumentsBlock] ] end diff --git a/app/models/person.rb b/app/models/person.rb index 81c772d..69f3c40 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -73,8 +73,8 @@ class Person < Profile def default_set_of_blocks [ [MainBlock], - [ProfileInfoBlock, RecentDocumentsBlock], - [TagsBlock, FriendsBlock, CommunitiesBlock, EnterprisesBlock] + [ProfileInfoBlock, RecentDocumentsBlock, TagsBlock], + [FriendsBlock, EnterprisesBlock, CommunitiesBlock] ] end diff --git a/app/models/profile.rb b/app/models/profile.rb index 59cdcf5..a5ce5fb 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -171,7 +171,7 @@ class Profile < ActiveRecord::Base # registar callback for creating boxes after the object is created. after_create :create_default_set_of_boxes - + # creates the initial set of boxes when the profile is created. Can be # overriden for each subclass to create a custom set of boxes for its # instances. diff --git a/script/anhetegua b/script/anhetegua index b6bd1ff..8da2367 100755 --- a/script/anhetegua +++ b/script/anhetegua @@ -201,17 +201,6 @@ colivre.products.build(:name => 'capacitação em software livre', :product_cate colivre.products.build(:name => 'arte digital', :product_category => arte_digital).save! colivre.products.build(:name => 'instalação e manutenção de servidores', :product_category => admin_de_sistemas).save! -colivre_hp = TinyMceArticle.new(:name => 'Colivre - Cooperativa de Tecnologias Livres', :body => '

A Colivre, Cooperativa de Tecnologias Livres, é uma organização baiana que presta serviços de instalação de redes, segurança, capacitação, migração e desenvolvimento de novas soluções, trabalhando exclusivamente com Tecnologias Livres. Para tanto, contamos com uma equipe formada por desenvolvedores/as de software, webdesigners e gestoras/es com vasta experiência na área.

', :tag_list => 'software livre, colivre, cooperativa' ) -colivre_hp.profile = colivre -colivre_hp.save! -colivre.home_page = colivre_hp -colivre.save! - -empa_hp = TinyMceArticle.new(:name => 'Empreendimento A - um empreendimento genérico', :body => '

Esse é um empreendimento cadastrado como exemplo no sitema

', :tag_list => 'cooperativa, teste') -empa_hp.profile = empa -empa.home_page = empa_hp -empa.save! - # creating sample communities comm1 = Community.create!(:name => 'Outra Economia é Possível') comm1.affiliate(ze, owner_role) diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 0ce8a5c..a8d12b9 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -129,7 +129,8 @@ class ContentViewerControllerTest < Test::Unit::TestCase end - should "not be able to remove other people's comments" do + should "not be able to remove other people's comments if not moderator or admin" do + create_user('normaluser') profile = create_user('testuser').person article = profile.articles.build(:name => 'test') article.save! @@ -138,7 +139,7 @@ class ContentViewerControllerTest < Test::Unit::TestCase comment = article.comments.build(:author => commenter, :title => 'a comment', :body => 'lalala') comment.save! - login_as 'ze' # ze cannot remove other people's comments + login_as 'normaluser' # normaluser cannot remove other people's comments assert_no_difference Comment, :count do post :view_page, :profile => profile.identifier, :page => [ 'test' ], :remove_comment => comment.id assert_response :redirect diff --git a/test/unit/enterprise_test.rb b/test/unit/enterprise_test.rb index 02904b9..aca0e5d 100644 --- a/test/unit/enterprise_test.rb +++ b/test/unit/enterprise_test.rb @@ -68,13 +68,12 @@ class EnterpriseTest < Test::Unit::TestCase assert e.boxes[0].blocks.map(&:class).include?(MainBlock), 'enterprise must have a MainBlock upon creation' assert e.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'enterprise must have a ProfileInfoBlock upon creation' - assert e.boxes[1].blocks.map(&:class).include?(ProductsBlock), 'enterprise must have a ProductsBlock upon creation' - assert e.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'enterprise must have a RecentDocumentsBlock upon creation' + assert e.boxes[1].blocks.map(&:class).include?(MembersBlock), 'enterprise must have a MembersBlock upon creation' - assert e.boxes[2].blocks.map(&:class).include?(MembersBlock), 'enterprise must have a MembersBlock upon creation' - assert e.boxes[2].blocks.map(&:class).include?(TagsBlock), 'enterprise must have a TagsBlock upon creation' + assert e.boxes[2].blocks.map(&:class).include?(RecentDocumentsBlock), 'enterprise must have a RecentDocumentsBlock upon creation' + assert e.boxes[2].blocks.map(&:class).include?(ProductsBlock), 'enterprise must have a ProductsBlock upon creation' - assert_equal 6, e.blocks.size + assert_equal 5, e.blocks.size end should 'be found in search for its product categories' do diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb index 280572a..712d736 100644 --- a/test/unit/person_test.rb +++ b/test/unit/person_test.rb @@ -138,8 +138,8 @@ class PersonTest < Test::Unit::TestCase assert p.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'person must have a ProfileInfoBlock upon creation' assert p.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'person must have a RecentDocumentsBlock upon creation' + assert p.boxes[1].blocks.map(&:class).include?(TagsBlock), 'person must have a Tags Block upon creation' - assert p.boxes[2].blocks.map(&:class).include?(TagsBlock), 'person must have a Tags Block upon creation' assert p.boxes[2].blocks.map(&:class).include?(CommunitiesBlock), 'person must have a CommunitiesBlock upon creation' assert p.boxes[2].blocks.map(&:class).include?(EnterprisesBlock), 'person must have a EnterprisesBlock upon creation' assert p.boxes[2].blocks.map(&:class).include?(FriendsBlock), 'person must have a FriendsBlock upon creation' -- libgit2 0.21.2