Commit 4be12fafcad0f0071be9abeaeac490d2d34b499b
Committed by
Joenio Costa
1 parent
db9433b6
Exists in
master
and in
28 other branches
Allowing invalid profiles to set homepage
(ActionItem1530)
Showing
2 changed files
with
20 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -149,7 +149,7 @@ class CmsController < MyProfileController |
149 | 149 | def set_home_page |
150 | 150 | @article = profile.articles.find(params[:id]) |
151 | 151 | profile.home_page = @article |
152 | - profile.save! | |
152 | + profile.save(false) | |
153 | 153 | flash[:notice] = _('"%s" configured as home page.') % @article.name |
154 | 154 | redirect_to :action => 'view', :id => @article.id |
155 | 155 | end | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -121,6 +121,25 @@ class CmsControllerTest < Test::Unit::TestCase |
121 | 121 | assert_equal a, profile.home_page |
122 | 122 | end |
123 | 123 | |
124 | + should 'be able to set home page even when profile description is invalid' do | |
125 | + a = profile.articles.build(:name => 'my new home page') | |
126 | + a.save! | |
127 | + | |
128 | + profile.description = 'a' * 600 | |
129 | + profile.save(false) | |
130 | + | |
131 | + assert !profile.valid? | |
132 | + assert_not_equal a, profile.home_page | |
133 | + | |
134 | + post :set_home_page, :profile => profile.identifier, :id => a.id | |
135 | + | |
136 | + assert_redirected_to :action => 'view', :id => a.id | |
137 | + | |
138 | + profile = Profile.find(@profile.id) | |
139 | + assert_equal a, profile.home_page | |
140 | + end | |
141 | + | |
142 | + | |
124 | 143 | should 'set last_changed_by when creating article' do |
125 | 144 | login_as(profile.identifier) |
126 | 145 | ... | ... |