[Git][noosfero/noosfero][master] 2 commits: Fixes bug on forum topic creation
Rodrigo Souto
gitlab at mg.gitlab.com
Tue Feb 23 16:07:38 BRT 2016
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
d85c8a1f by Tallys Martins at 2016-02-23T15:53:12-03:00
Fixes bug on forum topic creation
Closes #167
- When a topic is created in a forum, the parent_id was not being set.
Signed-off-by: Tallys Martins <tallysmartins at yahoo.com.br>
- - - - -
2a045324 by Tallys Martins at 2016-02-23T15:53:12-03:00
Adds tests to forum topic creation
Signed-off-by: Alexandre Barbosa <alexandreab at live.com>
Signed-off-by: Tallys Martins <tallysmartins at yahoo.com.br>
- - - - -
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
@@ -32,7 +32,8 @@ class CmsController < MyProfileController
end
protect_if :only => [:new, :upload_files] do |c, user, profile|
- parent = profile.articles.find_by_id(c.params[:parent_id])
+ parent_id = c.params[:article].present? ? c.params[:article][:parent_id] : c.params[:parent_id]
+ parent = profile.articles.find_by_id(parent_id)
user && user.can_post_content?(profile, parent)
end
=====================================
test/functional/cms_controller_test.rb
=====================================
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -1619,6 +1619,50 @@ class CmsControllerTest < ActionController::TestCase
assert_tag :tag => 'input', :attributes => {:name => 'article[accept_comments]', :value => 1, :type => 'checkbox'}
end
+ should 'logged in user NOT be able to create topic on forum when topic creation is set to Me' do
+ u = create_user('linux')
+ login_as :linux
+ profile.articles << f = Forum.new(:name => 'Forum for test',
+ :topic_creation => 'self',
+ :body => 'Forum Body')
+
+ post :new, :profile => profile.identifier, :type => 'TinyMceArticle',
+ :article => {:name => 'New Topic by linux', :body => 'Article Body',
+ :parent_id => f.id}
+
+ assert_template :access_denied
+ assert_not_equal 'New Topic by linux', Article.last.name
+ end
+
+ should 'logged in user NOT be able to create topic on forum when topic creation is set to Friends/Members' do
+ u = create_user('linux')
+ login_as :linux
+ profile.articles << f = Forum.new(:name => 'Forum for test',
+ :topic_creation => 'related',
+ :body => 'Forum Body')
+
+ post :new, :profile => profile.identifier, :type => 'TinyMceArticle',
+ :article => {:name => 'New Topic by linux', :body => 'Article Body',
+ :parent_id => f.id}
+
+ assert_template :access_denied
+ assert_not_equal 'New Topic by linux', Article.last.name
+ end
+
+ should 'logged in user be able to create topic on forum when topic creation is set to Logged in users' do
+ u = create_user('linux')
+ login_as :linux
+ profile.articles << f = Forum.new(:name => 'Forum for test',
+ :topic_creation => 'users',
+ :body => 'Forum Body')
+
+ post :new, :profile => profile.identifier, :type => 'TinyMceArticle',
+ :article => {:name => 'New Topic by linux', :body => 'Article Body',
+ :parent_id => f.id}
+
+ assert_equal 'New Topic by linux', Article.last.name
+ end
+
should 'display accept comments option when editing forum post with a different label' do
profile.articles << f = Forum.new(:name => 'Forum for test')
profile.articles << a = TinyMceArticle.new(:name => 'Forum post for test', :parent => f)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/8e65e1f31f15693684801946d9530b528b684c4d...2a0453241dc9bd4de32b9595d8020cc206063ffa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160223/f13c30de/attachment.html>
More information about the Noosfero-dev
mailing list