Commit e8aff3e44f799c242603da0f138aeb2278ecb65d
1 parent
f9c4fdea
Exists in
staging
and in
42 other branches
ActionItem21: removing articles
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1009 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -59,6 +59,13 @@ class CmsController < MyProfileController |
59 | 59 | redirect_to :action => 'view', :id => @article.id |
60 | 60 | end |
61 | 61 | |
62 | + post_only :destroy | |
63 | + def destroy | |
64 | + @article = profile.articles.find(params[:id]) | |
65 | + @article.destroy | |
66 | + redirect_to :action => (@article.parent ? 'view' : 'index'), :id => @article.parent | |
67 | + end | |
68 | + | |
62 | 69 | protected |
63 | 70 | |
64 | 71 | class << self | ... | ... |
test/functional/cms_controller_test.rb
... | ... | @@ -136,4 +136,14 @@ class CmsControllerTest < Test::Unit::TestCase |
136 | 136 | assert_equal 'application_xnoosferosomething', obj.mime_type_to_action_name('application/x-noosfero-something') |
137 | 137 | end |
138 | 138 | |
139 | + should 'be able to remove article' do | |
140 | + a = profile.articles.build(:name => 'my-article') | |
141 | + a.save! | |
142 | + | |
143 | + assert_difference Article, :count, -1 do | |
144 | + post :destroy, :profile => profile.identifier, :id => a.id | |
145 | + assert_redirected_to :action => 'index' | |
146 | + end | |
147 | + end | |
148 | + | |
139 | 149 | end | ... | ... |