Commit c400ca46674ac04fea24c6b924a543319effd8d3
1 parent
87ba3ac3
Exists in
master
and in
28 other branches
ActionItem545: set EnterpriseHomepage as default homepage of enterprises
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2187 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
23 additions
and
2 deletions
Show diff stats
app/models/enterprise.rb
app/models/profile.rb
@@ -316,7 +316,7 @@ class Profile < ActiveRecord::Base | @@ -316,7 +316,7 @@ class Profile < ActiveRecord::Base | ||
316 | 316 | ||
317 | after_create :insert_default_homepage_and_feed | 317 | after_create :insert_default_homepage_and_feed |
318 | def insert_default_homepage_and_feed | 318 | def insert_default_homepage_and_feed |
319 | - hp = TinyMceArticle.new(:name => _("%s's home page") % self.name, :body => _("<p>This is a default homepage created for %s. It can be changed though the control panel.</p>") % self.name, :advertise => false) | 319 | + hp = default_homepage(:name => _("%s's home page") % self.name, :body => _("<p>This is a default homepage created for %s. It can be changed though the control panel.</p>") % self.name, :advertise => false) |
320 | hp.profile = self | 320 | hp.profile = self |
321 | hp.save! | 321 | hp.save! |
322 | self.home_page = hp | 322 | self.home_page = hp |
@@ -390,4 +390,8 @@ class Profile < ActiveRecord::Base | @@ -390,4 +390,8 @@ class Profile < ActiveRecord::Base | ||
390 | !forbidden.include?(cat.class) | 390 | !forbidden.include?(cat.class) |
391 | end | 391 | end |
392 | 392 | ||
393 | + def default_homepage(attrs) | ||
394 | + TinyMceArticle.new(attrs) | ||
395 | + end | ||
396 | + | ||
393 | end | 397 | end |
test/functional/environment_design_controller_test.rb
@@ -29,7 +29,7 @@ class EnvironmentDesignControllerTest < Test::Unit::TestCase | @@ -29,7 +29,7 @@ class EnvironmentDesignControllerTest < Test::Unit::TestCase | ||
29 | 29 | ||
30 | should 'be able to edit LinkListBlock' do | 30 | should 'be able to edit LinkListBlock' do |
31 | login_as(create_admin_user(Environment.default)) | 31 | login_as(create_admin_user(Environment.default)) |
32 | - l = LinkListBlock.create!() | 32 | + l = LinkListBlock.create!(:links => [{:name => 'link 1', :address => '/address_1'}]) |
33 | Environment.default.boxes.create! | 33 | Environment.default.boxes.create! |
34 | Environment.default.boxes.first.blocks << l | 34 | Environment.default.boxes.first.blocks << l |
35 | get :edit, :id => l.id | 35 | get :edit, :id => l.id |
test/unit/enterprise_test.rb
@@ -192,4 +192,10 @@ class EnterpriseTest < Test::Unit::TestCase | @@ -192,4 +192,10 @@ class EnterpriseTest < Test::Unit::TestCase | ||
192 | 192 | ||
193 | assert_equal [full_name], ent.product_categories | 193 | assert_equal [full_name], ent.product_categories |
194 | end | 194 | end |
195 | + | ||
196 | + should 'default home page is a EnterpriseHomepage' do | ||
197 | + enterprise = Enterprise.create!(:name => 'my test enterprise', :identifier => 'myenterprise') | ||
198 | + assert_kind_of EnterpriseHomepage, enterprise.home_page | ||
199 | + end | ||
200 | + | ||
195 | end | 201 | end |
test/unit/profile_test.rb
@@ -659,6 +659,11 @@ class ProfileTest < Test::Unit::TestCase | @@ -659,6 +659,11 @@ class ProfileTest < Test::Unit::TestCase | ||
659 | assert_equal '', p.location | 659 | assert_equal '', p.location |
660 | end | 660 | end |
661 | 661 | ||
662 | + should 'default home page is a TinyMceArticle' do | ||
663 | + profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile') | ||
664 | + assert_kind_of TinyMceArticle, profile.home_page | ||
665 | + end | ||
666 | + | ||
662 | private | 667 | private |
663 | 668 | ||
664 | def assert_invalid_identifier(id) | 669 | def assert_invalid_identifier(id) |