Commit 7d9f8e9e7575fe2f98e77c39215bf1757bcb74a2

Authored by Rodrigo Souto
1 parent c6665719

cms: new content inherits parents visibility

Closes #212
app/controllers/my_profile/cms_controller.rb
... ... @@ -146,6 +146,8 @@ class CmsController < MyProfileController
146 146 parent = check_parent(params[:parent_id])
147 147 if parent
148 148 @article.parent = parent
  149 + @article.published = parent.published
  150 + @article.show_to_followers = parent.show_to_followers
149 151 @parent_id = parent.id
150 152 end
151 153  
... ...
test/functional/cms_controller_test.rb
... ... @@ -62,6 +62,22 @@ class CmsControllerTest < ActionController::TestCase
62 62 assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/cms/new", :method => /post/i }, :descendant => { :tag => "input", :attributes => { :type => 'hidden', :value => 'TextArticle' }}
63 63 end
64 64  
  65 + should 'inherit parents visibility by default' do
  66 + p1 = fast_create(Folder, :published => true, :profile_id => profile.id)
  67 + get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => p1.id
  68 + assert_equal assigns(:article).published, p1.published
  69 +
  70 + p2 = fast_create(Folder, :published => false, :show_to_followers => true, :profile_id => profile.id)
  71 + get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => p2.id
  72 + assert_equal assigns(:article).published, p2.published
  73 + assert_equal assigns(:article).show_to_followers, p2.show_to_followers
  74 +
  75 + p3 = fast_create(Folder, :published => false, :show_to_followers => false, :profile_id => profile.id)
  76 + get :new, :profile => profile.identifier, :type => 'TextArticle', :parent_id => p3.id
  77 + assert_equal assigns(:article).published, p3.published
  78 + assert_equal assigns(:article).show_to_followers, p3.show_to_followers
  79 + end
  80 +
65 81 should 'be able to save a document' do
66 82 assert_difference 'Article.count' do
67 83 post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' }
... ...