Commit b5c403b000e8429257a4a3ab150b62683e713e77
1 parent
e14a246f
Exists in
master
and in
29 other branches
ActionItem593: coming back to public view when creating new article
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2352 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
23 additions
and
0 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -84,6 +84,8 @@ class CmsController < MyProfileController | @@ -84,6 +84,8 @@ class CmsController < MyProfileController | ||
84 | @parent_id = parent.id | 84 | @parent_id = parent.id |
85 | end | 85 | end |
86 | 86 | ||
87 | + record_creating_from_public_view | ||
88 | + | ||
87 | @article.profile = profile | 89 | @article.profile = profile |
88 | @article.last_changed_by = user | 90 | @article.last_changed_by = user |
89 | if request.post? | 91 | if request.post? |
@@ -147,5 +149,13 @@ class CmsController < MyProfileController | @@ -147,5 +149,13 @@ class CmsController < MyProfileController | ||
147 | end | 149 | end |
148 | end | 150 | end |
149 | 151 | ||
152 | + def record_creating_from_public_view | ||
153 | + referer = request.referer | ||
154 | + if (referer =~ Regexp.new("^#{url_for(profile.url)}")) | ||
155 | + @back_to = 'public_view' | ||
156 | + @back_url = referer | ||
157 | + end | ||
158 | + end | ||
159 | + | ||
150 | end | 160 | end |
151 | 161 |
test/functional/cms_controller_test.rb
@@ -529,4 +529,17 @@ class CmsControllerTest < Test::Unit::TestCase | @@ -529,4 +529,17 @@ class CmsControllerTest < Test::Unit::TestCase | ||
529 | assert_redirected_to article.url | 529 | assert_redirected_to article.url |
530 | end | 530 | end |
531 | 531 | ||
532 | + should 'record as coming from public view when creating article' do | ||
533 | + @request.expects(:referer).returns('http://colivre.net/testinguser/testingusers-home-page') | ||
534 | + get :new, :profile => 'testinguser', :type => 'TextileArticle' | ||
535 | + assert_tag :tag => 'input', :attributes => { :type => 'hidden', :name => 'back_to', :value => 'public_view' } | ||
536 | + assert_tag :tag => 'a', :descendant => { :content => 'Cancel' }, :attributes => { :href => 'http://colivre.net/testinguser/testingusers-home-page' } | ||
537 | + end | ||
538 | + | ||
539 | + should 'go to public view after creating article coming from there' do | ||
540 | + post :new, :profile => 'testinguser', :type => 'TextileArticle', :back_to => 'public_view', :article => { :name => 'new-article-from-public-view' } | ||
541 | + assert_response :redirect | ||
542 | + assert_redirected_to @profile.articles.find_by_name('new-article-from-public-view').url | ||
543 | + end | ||
544 | + | ||
532 | end | 545 | end |