Commit 7d9f8e9e7575fe2f98e77c39215bf1757bcb74a2
1 parent
c6665719
Exists in
staging
and in
3 other branches
cms: new content inherits parents visibility
Closes #212
Showing
2 changed files
with
18 additions
and
0 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -146,6 +146,8 @@ class CmsController < MyProfileController | @@ -146,6 +146,8 @@ class CmsController < MyProfileController | ||
146 | parent = check_parent(params[:parent_id]) | 146 | parent = check_parent(params[:parent_id]) |
147 | if parent | 147 | if parent |
148 | @article.parent = parent | 148 | @article.parent = parent |
149 | + @article.published = parent.published | ||
150 | + @article.show_to_followers = parent.show_to_followers | ||
149 | @parent_id = parent.id | 151 | @parent_id = parent.id |
150 | end | 152 | end |
151 | 153 |
test/functional/cms_controller_test.rb
@@ -62,6 +62,22 @@ class CmsControllerTest < ActionController::TestCase | @@ -62,6 +62,22 @@ class CmsControllerTest < ActionController::TestCase | ||
62 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/cms/new", :method => /post/i }, :descendant => { :tag => "input", :attributes => { :type => 'hidden', :value => 'TextArticle' }} | 62 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/#{profile.identifier}/cms/new", :method => /post/i }, :descendant => { :tag => "input", :attributes => { :type => 'hidden', :value => 'TextArticle' }} |
63 | end | 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 | should 'be able to save a document' do | 81 | should 'be able to save a document' do |
66 | assert_difference 'Article.count' do | 82 | assert_difference 'Article.count' do |
67 | post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' } | 83 | post :new, :type => 'TextArticle', :profile => profile.identifier, :article => { :name => 'a test article', :body => 'the text of the article ...' } |