[Git][noosfero/noosfero][master] 2 commits: cms: new content inherits parents visibility

Rodrigo Souto gitlab at mg.gitlab.com
Tue Aug 23 13:33:53 BRT 2016


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
7d9f8e9e by Rodrigo Souto at 2016-08-16T18:33:46-03:00
cms: new content inherits parents visibility

Closes #212

- - - - -
368d30de by Rodrigo Souto at 2016-08-23T16:33:44+00:00
Merge branch 'default-visibility' into 'master'

cms: new content inherits parents visibility

Closes #212

See merge request !1007
- - - - -


2 changed files:

- app/controllers/my_profile/cms_controller.rb
- test/functional/cms_controller_test.rb


Changes:

=====================================
app/controllers/my_profile/cms_controller.rb
=====================================
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -146,6 +146,8 @@ class CmsController < MyProfileController
     parent = check_parent(params[:parent_id])
     if parent
       @article.parent = parent
+      @article.published = parent.published
+      @article.show_to_followers = parent.show_to_followers
       @parent_id = parent.id
     end
 


=====================================
test/functional/cms_controller_test.rb
=====================================
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -62,6 +62,22 @@ class CmsControllerTest < ActionController::TestCase
     assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/cms/new", :method => /post/i }, :descendant => { :tag => "input", :attributes => { :type => 'hidden', :value => 'TextArticle' }}
   end
 
+  should 'inherit parents visibility by default' do
+    p1 = fast_create(Folder, :published => true, :profile_id => profile.id)
+    get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => p1.id
+    assert_equal assigns(:article).published, p1.published
+
+    p2 = fast_create(Folder, :published => false, :show_to_followers => true, :profile_id => profile.id)
+    get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => p2.id
+    assert_equal assigns(:article).published, p2.published
+    assert_equal assigns(:article).show_to_followers, p2.show_to_followers
+
+    p3 = fast_create(Folder, :published => false, :show_to_followers => false, :profile_id => profile.id)
+    get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => p3.id
+    assert_equal assigns(:article).published, p3.published
+    assert_equal assigns(:article).show_to_followers, p3.show_to_followers
+  end
+
   should 'be able to save a document' do
     assert_difference 'Article.count' do
       post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' }



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/98bbf65c8d8eb20fcd7e5638e492c2952a56c1ec...368d30debe9ca69384debdcad4366362cd4b746a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160823/ff55f375/attachment-0001.html>


More information about the Noosfero-dev mailing list