Commit 453004fab2b6b717a5ddb0541028319d907b4020

Authored by Antonio Terceiro
1 parent ee15e749

Better defaults

(ActionItem1680)
app/models/enterprise.rb
... ... @@ -122,17 +122,28 @@ class Enterprise < Organization
122 122 end
123 123  
124 124 def default_set_of_blocks
  125 + links = [
  126 + {:name => _("Enterprises's profile"), :address => '/profile/{profile}', :icon => 'ok'},
  127 + {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'},
  128 + {:name => _('Products'), :address => '/catalog/{profile}', :icon => 'new'},
  129 + ]
125 130 blocks = [
126   - [MainBlock],
127   - [ProfileInfoBlock, MembersBlock],
128   - [RecentDocumentsBlock]
  131 + [MainBlock.new],
  132 + [ProfileImageBlock.new, LinkListBlock.new(:links => links)],
  133 + []
129 134 ]
130 135 if !environment.enabled?('disable_products_for_enterprises')
131   - blocks[2].unshift ProductsBlock
  136 + blocks[2].unshift ProductsBlock.new
132 137 end
133 138 blocks
134 139 end
135 140  
  141 + def default_set_of_articles
  142 + [
  143 + Blog.new(:name => _('Blog')),
  144 + ]
  145 + end
  146 +
136 147 before_create do |enterprise|
137 148 if enterprise.environment.enabled?('enterprises_are_disabled_when_created')
138 149 enterprise.enabled = false
... ... @@ -154,10 +165,4 @@ class Enterprise < Organization
154 165 enable_contact_us
155 166 end
156 167  
157   - protected
158   -
159   - def default_homepage(attrs)
160   - EnterpriseHomepage.new(attrs)
161   - end
162   -
163 168 end
... ...
app/models/environment.rb
... ... @@ -45,9 +45,7 @@ class Environment < ActiveRecord::Base
45 45 :name => N_('Member'),
46 46 :environment => self,
47 47 :permissions => [
48   - 'edit_profile',
49   - 'post_content',
50   - 'manage_products'
  48 + 'invite_members',
51 49 ]
52 50 )
53 51 # moderators for enterprises, communities etc
... ... @@ -209,7 +207,7 @@ class Environment < ActiveRecord::Base
209 207 settings_items :location, :type => String
210 208 settings_items :layout_template, :type => String, :default => 'default'
211 209 settings_items :homepage, :type => String
212   - settings_items :description, :type => String
  210 + settings_items :description, :type => String, :default => '<div style="text-align: center"><a href="http://noosfero.org/"><img src="/images/noosfero-network.png" alt="Noosfero"/></a></div>'
213 211 settings_items :category_types, :type => Array, :default => ['Category']
214 212 settings_items :enable_ssl
215 213 settings_items :local_docs, :type => Array, :default => []
... ... @@ -261,6 +259,24 @@ class Environment &lt; ActiveRecord::Base
261 259 features.delete_if{ |k, v| !self.enabled?(k) }
262 260 end
263 261  
  262 + before_create :enable_default_features
  263 + def enable_default_features
  264 + %w(
  265 + disable_asset_products
  266 + disable_gender_icon
  267 + disable_products_for_enterprises
  268 + disable_select_city_for_contact
  269 + enterprise_registration
  270 + media_panel
  271 + organizations_are_moderated_by_default
  272 + show_balloon_with_profile_links_when_clicked
  273 + use_portal_community
  274 + wysiwyg_editor_for_environment_home
  275 + ).each do |feature|
  276 + enable(feature)
  277 + end
  278 + end
  279 +
264 280 # returns <tt>true</tt> if this Environment has terms of use to be
265 281 # accepted by users before registration.
266 282 def has_terms_of_use?
... ...
app/models/link_list_block.rb
... ... @@ -52,7 +52,7 @@ class LinkListBlock &lt; Block
52 52 def link_html(link)
53 53 klass = 'icon-' + link[:icon] if link[:icon]
54 54 sanitize_link(
55   - link_to(link[:name], expand_address(link[:address]), :class => klass)
  55 + link_to(_(link[:name]), expand_address(link[:address]), :class => klass)
56 56 )
57 57 end
58 58  
... ...
app/models/organization.rb
... ... @@ -99,10 +99,24 @@ class Organization &lt; Profile
99 99 end
100 100  
101 101 def default_set_of_blocks
  102 + links = [
  103 + {:name => _("Community's profile"), :address => '/profile/{profile}', :icon => 'ok'},
  104 + {:name => _('Invite Friends'), :address => '/profile/{profile}/invite/friends', :icon => 'send'},
  105 + {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'menu-events'},
  106 + {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'},
  107 + {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'},
  108 + ]
  109 + [
  110 + [MainBlock.new],
  111 + [ProfileImageBlock.new, LinkListBlock.new(:links => links)],
  112 + [MembersBlock.new, RecentDocumentsBlock.new]
  113 + ]
  114 + end
  115 +
  116 + def default_set_of_articles
102 117 [
103   - [MainBlock],
104   - [ProfileInfoBlock, RecentDocumentsBlock],
105   - [MembersBlock, TagsBlock]
  118 + Blog.new(:name => _('Blog')),
  119 + Folder.new(:name => _('Gallery'), :view_as => 'image_gallery'),
106 120 ]
107 121 end
108 122  
... ...
app/models/person.rb
... ... @@ -203,10 +203,23 @@ class Person &lt; Profile
203 203 end
204 204  
205 205 def default_set_of_blocks
  206 + links = [
  207 + {:name => _('Profile'), :address => '/profile/{profile}', :icon => 'menu-people'},
  208 + {:name => _('Image gallery'), :address => '/{profile}/gallery', :icon => 'photos'},
  209 + {:name => _('Agenda'), :address => '/profile/{profile}/events', :icon => 'menu-events'},
  210 + {:name => _('Blog'), :address => '/{profile}/blog', :icon => 'edit'},
  211 + ]
  212 + [
  213 + [MainBlock.new],
  214 + [ProfileImageBlock.new, LinkListBlock.new(:links => links), RecentDocumentsBlock.new],
  215 + [FriendsBlock.new, CommunitiesBlock.new]
  216 + ]
  217 + end
  218 +
  219 + def default_set_of_articles
206 220 [
207   - [MainBlock],
208   - [ProfileInfoBlock, RecentDocumentsBlock, TagsBlock],
209   - [FriendsBlock, EnterprisesBlock, CommunitiesBlock]
  221 + Blog.new(:name => _('Blog')),
  222 + Folder.new(:name => _('Gallery'), :view_as => 'image_gallery'),
210 223 ]
211 224 end
212 225  
... ...
app/models/profile.rb
... ... @@ -293,7 +293,7 @@ class Profile &lt; ActiveRecord::Base
293 293 if self.respond_to?(:default_set_of_blocks)
294 294 default_set_of_blocks.each_with_index do |blocks,i|
295 295 blocks.each do |block|
296   - self.boxes[i].blocks << block.new
  296 + self.boxes[i].blocks << block
297 297 end
298 298 end
299 299 end
... ... @@ -507,25 +507,32 @@ private :generate_url, :url_options
507 507 if template
508 508 copy_articles_from template
509 509 else
510   - # a default homepage
511   - hp = default_homepage(:name => _("My home page"), :body => _("<p>This is a default homepage created for me. It can be changed though the control panel.</p>"), :advertise => false)
512   - hp.profile = self
513   - hp.save!
514   - self.home_page = hp
515   -
516   - # a default rss feed
517   - feed = RssFeed.new(:name => 'feed')
518   - self.articles << feed
519   -
520   - # a default private folder if public
521   - if self.public?
522   - folder = Folder.new(:name => _("Intranet"), :published => false)
523   - self.articles << folder
  510 + default_set_of_articles.each do |article|
  511 + article.profile = self
  512 + article.advertise = false
  513 + article.save!
524 514 end
525 515 end
526 516 self.save!
527 517 end
528 518  
  519 + # Override this method in subclasses of Profile to create a default article
  520 + # set upon creation. Note that this method will be called *only* if there is
  521 + # no template for the type of profile (i.e. if the template was removed or in
  522 + # the creation of the template itself).
  523 + #
  524 + # This method must return an array of pre-populated articles, which will be
  525 + # associated to the profile before being saved. Example:
  526 + #
  527 + # def default_set_of_articles
  528 + # [Blog.new(:name => 'Blog'), Folder.new(:name => 'Gallery', :view_as => 'image_gallery')]
  529 + # end
  530 + #
  531 + # By default, this method returns an empty array.
  532 + def default_set_of_articles
  533 + []
  534 + end
  535 +
529 536 def copy_articles_from other
530 537 other.top_level_articles.each do |a|
531 538 copy_article_tree a
... ... @@ -610,10 +617,6 @@ private :generate_url, :url_options
610 617 !forbidden.include?(cat.class)
611 618 end
612 619  
613   - def default_homepage(attrs)
614   - TinyMceArticle.new(attrs)
615   - end
616   -
617 620 include ActionView::Helpers::TextHelper
618 621 def short_name(chars = 15)
619 622 if self[:nickname].blank?
... ...
features/blog.feature
... ... @@ -7,6 +7,7 @@ Feature: blog
7 7 And the following users
8 8 | login | name |
9 9 | joaosilva | Joao Silva |
  10 + And "joaosilva" has no articles
10 11 And I am logged in as "joaosilva"
11 12  
12 13 Scenario: create a blog
... ...
features/delete_profile.feature
... ... @@ -34,7 +34,7 @@ Feature: delete profile
34 34 And I follow "Delete profile"
35 35 Then I should see "Are you sure you want to delete this profile?"
36 36 When I follow "No, I gave up"
37   - Then I should be on Joao Silva's homepage
  37 + Then I should be on Joao Silva's profile
38 38  
39 39 Scenario: community admin can see link to delete profile
40 40 Given the following community
... ...
features/edit_article.feature
... ... @@ -123,8 +123,9 @@ Feature: edit article
123 123 And I should be on "Save the whales" edit page
124 124  
125 125 Scenario: save and continue when creating a new article
126   - Given I am on /joaosilva
127   - When I follow "New article"
  126 + Given I am on Joao Silva's control panel
  127 + When I follow "Manage Content"
  128 + And I follow "New article"
128 129 And I follow "Text article with visual editor"
129 130 And I fill in "Title" with "My new article"
130 131 And I fill in "Text" with "text for the new article"
... ...
features/edit_blog_archives_block.feature
... ... @@ -7,6 +7,7 @@ Feature: edit_blog_archives_block
7 7 And the following users
8 8 | login | name |
9 9 | joaosilva | Joao Silva |
  10 + And "joaosilva" has no articles
10 11 And the following blogs
11 12 | owner | name |
12 13 | joaosilva | Blog One |
... ...
features/events.feature
... ... @@ -143,6 +143,9 @@ Feature: events
143 143 Then I should see "YAPC::Brasil 2010"
144 144  
145 145 Scenario: provide button to go back to profile homepage
  146 + Given the following articles
  147 + | owner | name | homepage |
  148 + | josesilva | my homepage | true |
146 149 Given I am on /profile/josesilva/events
147 150 When I follow "Back to josesilva"
148 151 Then I should be on josesilva's homepage
... ...
features/login.feature
... ... @@ -22,6 +22,9 @@ Feature: login
22 22 And the following users
23 23 | login | name |
24 24 | mariasilva | Maria Silva |
  25 + And the following articles
  26 + | owner | name | homepage |
  27 + | mariasilva | my home page | true |
25 28 And I go to Maria Silva's homepage
26 29 And I follow "Login"
27 30 And I fill in the following:
... ...
features/publish_article.feature
... ... @@ -25,8 +25,6 @@ Feature: publish article
25 25 And I follow "Spread"
26 26 And I check "Sample Community"
27 27 And I press "Spread this"
28   - And I am on Sample Community's homepage
29   - And I follow "View profile"
30 28 And I go to Sample Community's sitemap
31 29 When I follow "Sample Article"
32 30 Then I should see "This is the first published article"
... ... @@ -40,8 +38,6 @@ Feature: publish article
40 38 And I check "Sample Community"
41 39 And I fill in "Title" with "Another name"
42 40 And I press "Spread this"
43   - And I am on Sample Community's homepage
44   - And I follow "View profile"
45 41 When I go to Sample Community's sitemap
46 42 Then I should see "Another name"
47 43 And I should not see "Sample Article"
... ... @@ -94,12 +90,8 @@ Feature: publish article
94 90 And I check "Another Community2"
95 91 When I press "Spread this"
96 92 Then I should see "The title (article name) is already being used by another article, please use another title."
97   - And I am on Another Community1's homepage
98   - And I follow "View profile"
99 93 When I go to Another Community1's sitemap
100 94 Then I should see "Sample Article"
101   - And I am on Another Community2's homepage
102   - And I follow "View profile"
103 95 When I go to Another Community2's sitemap
104 96 Then I should see "Sample Article"
105 97  
... ...
features/search.feature
... ... @@ -28,13 +28,13 @@ Feature: search
28 28 Scenario: simple search for enterprise
29 29 Given the following enterprises
30 30 | identifier | name |
31   - | products-factory | Products factory |
32   - | services-provider | Services Provider |
  31 + | shop1 | Shoes shop |
  32 + | shop2 | Fruits shop |
33 33 And I go to the search page
34   - And I fill in "query" with "services"
  34 + And I fill in "query" with "shoes"
35 35 And I press "Search"
36   - Then I should see "Services Provider"
37   - And I should not see "Products factory"
  36 + Then I should see "Shoes shop"
  37 + And I should not see "Fruits shop"
38 38  
39 39 Scenario: simple search for content
40 40 Given the following users
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -51,7 +51,12 @@ Given /^the following (articles|events|blogs|folders)$/ do |content, table|
51 51 table.hashes.map{|item| item.dup}.each do |item|
52 52 owner_identifier = item.delete("owner")
53 53 owner = Profile[owner_identifier]
54   - klass.create!(item.merge(:profile => owner))
  54 + home = item.delete("homepage")
  55 + result = klass.create!(item.merge(:profile => owner))
  56 + if home
  57 + owner.home_page = result
  58 + owner.save!
  59 + end
55 60 end
56 61 end
57 62  
... ...
public/designs/themes/base/footer.rhtml
... ... @@ -2,10 +2,6 @@
2 2 <a id="link-to-doc" class='icon-help'><%= link_to _('Manual'), '/doc' %></a>
3 3 </div><!-- end id="footer-links" -->
4 4 <div id="copyright">
5   - <p id='noosfero-license'>
6   - Powered by <a
7   - href="http://www.noosfero.org/" id='link-noosfero'>Noosfero</a>, licensed under
8   - <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero General Public
9   - License</a>, version 3 or above. </p>
  5 + <p><%= _('This social network uses Noosfero, developed by %s and licensed under the <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero General Public License</a> version 3 or any later version.') % link_to('Colivre', 'http://colivre.coop.br/') %></p>
10 6 </div><!-- end id="copyright" -->
11 7 <%= language_chooser %>
... ...
public/designs/themes/base/style.css
... ... @@ -363,6 +363,7 @@ body, th, td, input {
363 363 padding: 0px;
364 364 font-size: 11px;
365 365 color: #555;
  366 + margin-bottom: 20px;
366 367 }
367 368  
368 369 #theme-footer a {
... ...
public/images/noosfero-network.png 0 → 100644

96.8 KB

script/sample-data
... ... @@ -9,19 +9,7 @@ environment = nil
9 9 if environment_id
10 10 environment = Environment.find(environment_id)
11 11 else
12   - DEFAULT_ENVIRONMENT_TEXT = <<EOF
13   - <h1>Environment homepage</h1>
14   - <p>
15   - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis diam enim, et ultricies lacus. Pellentesque sit amet velit non ante bibendum consectetur. Etiam at aliquet mauris. Pellentesque volutpat pellentesque dolor, at cursus lacus suscipit varius. Nunc at lectus tortor, eu dapibus urna. Ut at odio sem, sed laoreet augue. Nunc vestibulum, lectus id tempor vulputate, turpis nisl placerat justo, non placerat est lectus a risus. Nullam elementum convallis lectus, eget volutpat sapien malesuada quis. Fusce aliquet elementum placerat. Donec dolor mauris, accumsan eu gravida sed, mollis a metus. Quisque dictum felis vel diam ornare dapibus. Cras vel est velit. Fusce in tincidunt urna. Proin tincidunt pellentesque turpis, nec blandit nulla volutpat at. Suspendisse potenti.
16   - </p>
17   - <p>
18   - Nunc pellentesque sem in ante lacinia egestas nec et dolor. Fusce enim leo, condimentum nec iaculis in, convallis eget diam. Integer ultricies massa eu augue tristique eu semper lorem aliquam. Praesent nibh lorem, eleifend nec laoreet ac, tempus et augue. Phasellus pulvinar nibh eget magna pellentesque ultricies. Donec varius, sapien in fermentum pellentesque, odio risus viverra lectus, sed tincidunt arcu elit id ipsum. Nunc aliquet lobortis sem, vitae dapibus velit bibendum id. Vivamus nec augue arcu, sed adipiscing quam. Maecenas at porta odio. Ut felis arcu, commodo in vestibulum a, convallis et justo. Nulla feugiat odio in dui mollis a pretium orci porta. Morbi at nisl sem, non tempus dui.
19   - </p>
20   - <p>
21   - Maecenas neque ante, bibendum sed mollis ac, aliquet eu dolor. Fusce quis enim mi, vestibulum laoreet purus. Curabitur vel odio non mi tempus commodo. Duis suscipit justo sit amet felis volutpat scelerisque. Integer in mi vulputate lacus porttitor posuere id sed sapien. Nam aliquam molestie est a eleifend. Integer at velit nec felis sodales ornare. Etiam magna elit, facilisis at consectetur nec, commodo sit amet sapien. Maecenas fermentum leo vitae turpis viverra auctor. Phasellus facilisis ipsum quis felis semper et condimentum augue porttitor. Morbi vitae mauris risus. Nunc lobortis quam eu tellus tempus ut tristique odio luctus. Fusce justo purus, tincidunt eu tristique et, pharetra non tortor. Cras malesuada accumsan venenatis. Donec ornare iaculis porttitor. Praesent vestibulum metus fermentum risus interdum gravida. Vivamus placerat commodo nunc vitae aliquet. Fusce sit amet libero facilisis ante dictum hendrerit ac sed massa.
22   - </p>
23   -EOF
24   - environment = Environment.create!(:name => 'Noosfero', :is_default => true, :description => DEFAULT_ENVIRONMENT_TEXT) unless (Environment.default)
  12 + environment = Environment.default || Environment.create!(:name => 'Noosfero', :is_default => true)
25 13 end
26 14  
27 15 system('./script/sample-profiles')
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -344,30 +344,6 @@ class ContentViewerControllerTest &lt; Test::Unit::TestCase
344 344 assert_response :success
345 345 end
346 346  
347   - should 'show message for disabled enterprises' do
348   - login_as(@profile.identifier)
349   - ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
350   - get :view_page, :profile => ent.identifier, :page => []
351   - assert_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise
352   - end
353   -
354   - should 'not show message for disabled enterprise to non-enterprises' do
355   - login_as(@profile.identifier)
356   - @profile.enabled = false; @profile.save!
357   - get :view_page, :profile => @profile.identifier, :page => []
358   - assert_no_tag :tag => 'div', :attributes => { :id => 'profile-disabled' }, :content => Environment.default.message_for_disabled_enterprise
359   - end
360   -
361   - should 'not show message for disabled enterprise if there is a block for it' do
362   - login_as(@profile.identifier)
363   - ent = fast_create(Enterprise, :name => 'my test enterprise', :identifier => 'my-test-enterprise', :enabled => false)
364   - ent.boxes << Box.new
365   - ent.boxes[0].blocks << DisabledEnterpriseMessageBlock.new
366   - ent.save
367   - get :view_page, :profile => ent.identifier, :page => []
368   - assert_no_tag :tag => 'div', :attributes => {:id => 'article'}, :descendant => { :tag => 'div', :attributes => { :id => 'profile-disabled' }}
369   - end
370   -
371 347 should 'load the correct profile when using hosted domain' do
372 348 profile = create_user('mytestuser').person
373 349 profile.domains << Domain.create!(:name => 'micojones.net')
... ...
test/functional/tasks_controller_test.rb
... ... @@ -155,7 +155,8 @@ class TasksControllerTest &lt; Test::Unit::TestCase
155 155  
156 156 should 'create published article after finish approve article task' do
157 157 PublishedArticle.destroy_all
158   - c = Community.create!(:name => 'test comm', :moderated_articles => false)
  158 + c = fast_create(Community)
  159 + c.update_attributes(:moderated_articles => false)
159 160 @controller.stubs(:profile).returns(c)
160 161 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
161 162 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
... ... @@ -167,7 +168,8 @@ class TasksControllerTest &lt; Test::Unit::TestCase
167 168  
168 169 should 'create published article in folder after finish approve article task' do
169 170 PublishedArticle.destroy_all
170   - c = Community.create!(:name => 'test comm', :moderated_articles => false)
  171 + c = fast_create(Community)
  172 + c.update_attributes(:moderated_articles => false)
171 173 @controller.stubs(:profile).returns(c)
172 174 folder = c.articles.create!(:name => 'test folder', :type => 'Folder')
173 175 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
... ... @@ -180,7 +182,8 @@ class TasksControllerTest &lt; Test::Unit::TestCase
180 182  
181 183 should 'be highlighted if asked when approving a published article' do
182 184 PublishedArticle.destroy_all
183   - c = Community.create!(:name => 'test comm', :moderated_articles => false)
  185 + c = fast_create(Community)
  186 + c.update_attributes(:moderated_articles => false)
184 187 @controller.stubs(:profile).returns(c)
185 188 folder = c.articles.create!(:name => 'test folder', :type => 'Folder')
186 189 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
... ... @@ -193,7 +196,8 @@ class TasksControllerTest &lt; Test::Unit::TestCase
193 196  
194 197 should 'create published article after choosing root folder on approve article task' do
195 198 PublishedArticle.destroy_all
196   - c = Community.create!(:name => 'test comm', :moderated_articles => false)
  199 + c = fast_create(Community)
  200 + c.update_attributes(:moderated_articles => false)
197 201 @controller.stubs(:profile).returns(c)
198 202 c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id))
199 203 article = profile.articles.create!(:name => 'something interesting', :body => 'ruby on rails')
... ... @@ -204,7 +208,7 @@ class TasksControllerTest &lt; Test::Unit::TestCase
204 208 end
205 209  
206 210 should 'handle blank names for published articles' do
207   - c = Community.create!(:name => 'test comm')
  211 + c = fast_create(Community)
208 212 @controller.stubs(:profile).returns(c)
209 213 c.affiliate(profile, Profile::Roles.all_roles(c.environment))
210 214 person = create_user('test_user').person
... ...
test/unit/community_test.rb
... ... @@ -27,22 +27,17 @@ class CommunityTest &lt; Test::Unit::TestCase
27 27 should 'create default set of blocks' do
28 28 c = Community.create!(:environment => Environment.default, :name => 'my new community')
29 29  
30   - assert c.boxes[0].blocks.map(&:class).include?(MainBlock)
31   -
32   - assert c.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock)
33   - assert c.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock)
34   -
35   - assert c.boxes[2].blocks.map(&:class).include?(MembersBlock)
36   - assert c.boxes[2].blocks.map(&:class).include?(TagsBlock)
37   -
38   - assert_equal 5, c.blocks.size
  30 + assert !c.boxes[0].blocks.empty?, 'person must have blocks in area 1'
  31 + assert !c.boxes[1].blocks.empty?, 'person must have blocks in area 2'
  32 + assert !c.boxes[2].blocks.empty?, 'person must have blocks in area 3'
39 33 end
40 34  
41   - should 'get a default home page and RSS feed' do
  35 + should 'create a default set of articles' do
  36 + Community.any_instance.stubs(:default_set_of_articles).returns([Blog.new(:name => 'blog')])
42 37 community = Community.create!(:environment => Environment.default, :name => 'my new community')
43 38  
44   - assert_kind_of Article, community.home_page
45   - assert_kind_of RssFeed, community.articles.find_by_path('feed')
  39 + assert_kind_of Blog, community.articles.find_by_path('blog')
  40 + assert_kind_of RssFeed, community.articles.find_by_path('blog/feed')
46 41 end
47 42  
48 43 should 'have contact_person' do
... ...
test/unit/enterprise_test.rb
... ... @@ -59,25 +59,20 @@ class EnterpriseTest &lt; Test::Unit::TestCase
59 59 end
60 60 end
61 61  
62   - should 'get a default homepage and RSS feed' do
  62 + should 'create a default set of articles' do
  63 + Enterprise.any_instance.expects(:default_set_of_articles).returns([Blog.new(:name => 'Blog')])
63 64 enterprise = Enterprise.create!(:name => 'my test enterprise', :identifier => 'myenterprise')
64 65  
65   - assert_kind_of Article, enterprise.home_page
66   - assert_kind_of RssFeed, enterprise.articles.find_by_path('feed')
  66 + assert_kind_of Blog, enterprise.articles.find_by_path('blog')
  67 + assert_kind_of RssFeed, enterprise.articles.find_by_path('blog/feed')
67 68 end
68 69  
69 70 should 'create default set of blocks' do
70 71 e = Enterprise.create(:name => 'my new community', :identifier => 'mynewcommunity')
71 72  
72   - assert e.boxes[0].blocks.map(&:class).include?(MainBlock), 'enterprise must have a MainBlock upon creation'
73   -
74   - assert e.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'enterprise must have a ProfileInfoBlock upon creation'
75   - assert e.boxes[1].blocks.map(&:class).include?(MembersBlock), 'enterprise must have a MembersBlock upon creation'
76   -
77   - assert e.boxes[2].blocks.map(&:class).include?(RecentDocumentsBlock), 'enterprise must have a RecentDocumentsBlock upon creation'
78   - assert e.boxes[2].blocks.map(&:class).include?(ProductsBlock), 'enterprise must have a ProductsBlock upon creation'
79   -
80   - assert_equal 5, e.blocks.size
  73 + assert !e.boxes[0].blocks.empty?, 'person must have blocks in area 1'
  74 + assert !e.boxes[1].blocks.empty?, 'person must have blocks in area 2'
  75 + assert !e.boxes[2].blocks.empty?, 'person must have blocks in area 3'
81 76 end
82 77  
83 78 should 'be found in search for its product categories' do
... ... @@ -252,11 +247,6 @@ class EnterpriseTest &lt; Test::Unit::TestCase
252 247 assert_equal [p.category_full_name], ent.product_categories
253 248 end
254 249  
255   - should 'default home page is a EnterpriseHomepage' do
256   - enterprise = Enterprise.create!(:name => 'my test enterprise', :identifier => 'myenterprise')
257   - assert_kind_of EnterpriseHomepage, enterprise.home_page
258   - end
259   -
260 250 should 'not create a products block for enterprise if environment do not let' do
261 251 env = Environment.default
262 252 env.enable('disable_products_for_enterprises')
... ...
test/unit/person_test.rb
... ... @@ -173,27 +173,29 @@ class PersonTest &lt; Test::Unit::TestCase
173 173 assert !person.is_admin?(env2)
174 174 end
175 175  
176   - should 'get a default home page and a RSS feed' do
  176 + should 'create a default set of articles' do
  177 + Person.any_instance.stubs(:default_set_of_articles).returns([Blog.new(:name => 'blog')])
177 178 person = create_user_full('mytestuser').person
178 179  
179   - assert_kind_of Article, person.home_page
180   - assert_kind_of RssFeed, person.articles.find_by_path('feed')
  180 + assert_kind_of Blog, person.articles.find_by_path('blog')
  181 + assert_kind_of RssFeed, person.articles.find_by_path('blog/feed')
181 182 end
182 183  
183   - should 'create default set of blocks' do
  184 + should 'create a default set of blocks' do
184 185 p = create_user_full('testingblocks').person
185 186  
186   - assert p.boxes[0].blocks.map(&:class).include?(MainBlock), 'person must have a MainBlock upon creation'
187   -
188   - assert p.boxes[1].blocks.map(&:class).include?(ProfileInfoBlock), 'person must have a ProfileInfoBlock upon creation'
189   - assert p.boxes[1].blocks.map(&:class).include?(RecentDocumentsBlock), 'person must have a RecentDocumentsBlock upon creation'
190   - assert p.boxes[1].blocks.map(&:class).include?(TagsBlock), 'person must have a Tags Block upon creation'
191   -
192   - assert p.boxes[2].blocks.map(&:class).include?(CommunitiesBlock), 'person must have a CommunitiesBlock upon creation'
193   - assert p.boxes[2].blocks.map(&:class).include?(EnterprisesBlock), 'person must have a EnterprisesBlock upon creation'
194   - assert p.boxes[2].blocks.map(&:class).include?(FriendsBlock), 'person must have a FriendsBlock upon creation'
  187 + assert !p.boxes[0].blocks.empty?, 'person must have blocks in area 1'
  188 + assert !p.boxes[1].blocks.empty?, 'person must have blocks in area 2'
  189 + assert !p.boxes[2].blocks.empty?, 'person must have blocks in area 3'
  190 + end
195 191  
196   - assert_equal 7, p.blocks.size
  192 + should 'link to all articles created by default' do
  193 + p = create_user_full('testingblocks').person
  194 + blocks = p.blocks.select { |b| b.is_a?(LinkListBlock) }
  195 + p.articles.reject { |a| a.is_a?(RssFeed) }.each do |article|
  196 + path = '/' + p.identifier + '/' + article.path
  197 + assert blocks.any? { |b| b.links.any? { |link| b.expand_address(link[:address]) == path }}, "#{path.inspect} must be linked by at least one of the blocks: #{blocks.inspect}"
  198 + end
197 199 end
198 200  
199 201 should 'have friends' do
... ...
test/unit/profile_test.rb
... ... @@ -73,8 +73,8 @@ class ProfileTest &lt; Test::Unit::TestCase
73 73 end
74 74  
75 75 should 'provide access to home page' do
76   - profile = create(Profile)
77   - assert_kind_of Article, profile.home_page
  76 + profile = Profile.new
  77 + assert_nil profile.home_page
78 78 end
79 79  
80 80 def test_name_should_be_mandatory
... ... @@ -335,13 +335,6 @@ class ProfileTest &lt; Test::Unit::TestCase
335 335 assert_equal false, Profile.new.has_members?
336 336 end
337 337  
338   - should 'create a homepage and a feed on creation' do
339   - profile = create(Profile)
340   -
341   - assert_kind_of Article, profile.home_page
342   - assert_kind_of RssFeed, profile.articles.find_by_path('feed')
343   - end
344   -
345 338 should 'not allow to add members' do
346 339 c = fast_create(Profile)
347 340 p = create_user('mytestuser').person
... ... @@ -429,26 +422,21 @@ class ProfileTest &lt; Test::Unit::TestCase
429 422 assert_equal [p3,p2], Profile.recent(2)
430 423 end
431 424  
432   - should 'advertise false to homepage and feed on creation' do
  425 + should 'not advertise articles created together with the profile' do
  426 + Profile.any_instance.stubs(:default_set_of_articles).returns([Article.new(:name => 'home'), RssFeed.new(:name => 'feed')])
433 427 profile = create(Profile)
434   - assert !profile.home_page.advertise?
  428 + assert !profile.articles.find_by_path('home').advertise?
435 429 assert !profile.articles.find_by_path('feed').advertise?
436 430 end
437 431  
438   - should 'advertise true to homepage after update' do
  432 + should 'advertise article after update' do
  433 + Profile.any_instance.stubs(:default_set_of_articles).returns([Article.new(:name => 'home')])
439 434 profile = create(Profile)
440   - assert !profile.home_page.advertise?
441   - profile.home_page.name = 'Changed name'
442   - assert profile.home_page.save!
443   - assert profile.home_page.advertise?
444   - end
445   -
446   - should 'advertise true to feed after update' do
447   - profile = create(Profile)
448   - assert !profile.articles.find_by_path('feed').advertise?
449   - profile.articles.find_by_path('feed').name = 'Changed name'
450   - assert profile.articles.find_by_path('feed').save!
451   - assert profile.articles.find_by_path('feed').advertise?
  435 + article = profile.articles.find_by_path('home')
  436 + assert !article.advertise?
  437 + article.name = 'Changed name'
  438 + article.save!
  439 + assert article.advertise?
452 440 end
453 441  
454 442 should 'have latitude and longitude' do
... ... @@ -774,11 +762,6 @@ class ProfileTest &lt; Test::Unit::TestCase
774 762 end
775 763 end
776 764  
777   - should 'default home page is a TinyMceArticle' do
778   - profile = create(Profile)
779   - assert_kind_of TinyMceArticle, profile.home_page
780   - end
781   -
782 765 should 'not add a category twice to profile' do
783 766 c1 = fast_create(Category)
784 767 c2 = fast_create(Category, :parent_id => c1.id)
... ... @@ -923,14 +906,6 @@ class ProfileTest &lt; Test::Unit::TestCase
923 906 assert !p2.public?
924 907 end
925 908  
926   - should 'create a initial private folder when a public profile is created' do
927   - p1 = create(Profile)
928   - p2 = create(Profile, :public_profile => false)
929   -
930   - assert p1.articles.find(:first, :conditions => {:published => false})
931   - assert !p2.articles.find(:first, :conditions => {:published => false})
932   - end
933   -
934 909 should 'remove member with many roles' do
935 910 person = create_user('test_user').person
936 911 community = fast_create(Community)
... ...