diff --git a/db/schema.rb b/db/schema.rb index 61f9d3e..8d39bb1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -131,6 +131,7 @@ ActiveRecord::Schema.define(:version => 20130606110602) do t.integer "license_id" end + add_index "articles", ["name"], :name => "index_articles_on_name" add_index "articles", ["parent_id"], :name => "index_articles_on_parent_id" add_index "articles", ["profile_id"], :name => "index_articles_on_profile_id" add_index "articles", ["slug"], :name => "index_articles_on_slug" diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index fcb4a4d..6fb1ef5 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -377,7 +377,7 @@ class Noosfero::Plugin def profile_info_extra_contents nil end - + # -> Removes the invite friend button from the friends controller # returns = boolean def remove_invite_friends_button @@ -439,7 +439,7 @@ class Noosfero::Plugin def login_extra_contents nil end - + # -> Adds adicional content to comment form # returns = lambda block that creates html code def comment_form_extra_contents(args) diff --git a/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb b/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb index 0bcb1f8..8c31a25 100644 --- a/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb +++ b/plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb @@ -4,7 +4,7 @@ class CommentGroupPluginProfileController < ProfileController def view_comments article_id = params[:article_id] group_id = params[:group_id] - + article = profile.articles.find(article_id) comments = article.group_comments.without_spam.in_group(group_id) render :update do |page| diff --git a/plugins/comment_group/controllers/public/comment_group_plugin_public_controller.rb b/plugins/comment_group/controllers/public/comment_group_plugin_public_controller.rb index 61d9a86..2063f20 100644 --- a/plugins/comment_group/controllers/public/comment_group_plugin_public_controller.rb +++ b/plugins/comment_group/controllers/public/comment_group_plugin_public_controller.rb @@ -2,7 +2,7 @@ class CommentGroupPluginPublicController < PublicController append_view_path File.join(File.dirname(__FILE__) + '/../views') def comment_group - render :json => { :group_id => Comment.find(params[:id]).group_id } + render :json => { :group_id => Comment.find(params[:id]).group_id } end end diff --git a/plugins/comment_group/lib/comment_group_plugin/ext/article.rb b/plugins/comment_group/lib/comment_group_plugin/ext/article.rb index db1e2c7..fb7e156 100644 --- a/plugins/comment_group/lib/comment_group_plugin/ext/article.rb +++ b/plugins/comment_group/lib/comment_group_plugin/ext/article.rb @@ -2,13 +2,13 @@ require_dependency 'article' class Article - #FIXME make this test + #FIXME make this test has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL'] - #FIXME make this test + #FIXME make this test validate :not_empty_group_comments_removed - #FIXME make this test + #FIXME make this test def not_empty_group_comments_removed if body groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq diff --git a/plugins/comment_group/public/comment_group.js b/plugins/comment_group/public/comment_group.js index 7309295..2f65f78 100644 --- a/plugins/comment_group/public/comment_group.js +++ b/plugins/comment_group/public/comment_group.js @@ -16,7 +16,7 @@ function makeCommentable() { //text = start.parent().children(); text = jQuery('#article_body_ifr').contents().find('*'); selection = text.slice(text.index(start), text.index(end)+1); - + hasTag = false; selection.each(function(key, value) { commentTag = jQuery(value).closest('.article_comments'); diff --git a/plugins/comment_group/public/comment_group_macro.js b/plugins/comment_group/public/comment_group_macro.js index 8aa7944..de2c3c4 100644 --- a/plugins/comment_group/public/comment_group_macro.js +++ b/plugins/comment_group/public/comment_group_macro.js @@ -4,7 +4,7 @@ jQuery(document).ready(function($) { if(anchor.length==0) return; var val = anchor.split('-'); //anchor format = #comment-\d+ - if(val.length!=2 || val[0]!='#comment') return; + if(val.length!=2 || val[0]!='#comment') return; if($('div[data-macro=comment_group_plugin/allow_comment]').length==0) return; //comment_group_plugin/allow_comment div must exists var comment_id = val[1]; if(!/^\d+$/.test(comment_id)) return; //test for integer @@ -18,12 +18,12 @@ jQuery(document).ready(function($) { $.scrollTo(button); } }); -}); +}); function toggleGroup(group) { var div = jQuery('div.comments_list_toggle_group_'+group); var visible = div.is(':visible'); - if(!visible) + if(!visible) jQuery('div.comment-group-loading-'+group).addClass('comment-button-loading'); div.toggle('fast'); diff --git a/plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb b/plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb index eeae722..69d31ab 100644 --- a/plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb +++ b/plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb @@ -25,7 +25,7 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase assert_match /comments_list_group_0/, @response.body assert_match /\"comment-count-0\", \"1\"/, @response.body end - + should 'do not show global comments' do comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'global comment', :body => 'global', :group_id => nil) comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0) @@ -34,5 +34,5 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase assert_match /comments_list_group_0/, @response.body assert_match /\"comment-count-0\", \"1\"/, @response.body end - + end diff --git a/plugins/comment_group/test/functional/comment_group_plugin_public_controller_test.rb b/plugins/comment_group/test/functional/comment_group_plugin_public_controller_test.rb index 3cb011c..fe330f3 100644 --- a/plugins/comment_group/test/functional/comment_group_plugin_public_controller_test.rb +++ b/plugins/comment_group/test/functional/comment_group_plugin_public_controller_test.rb @@ -20,14 +20,14 @@ class CommentGroupPluginPublicControllerTest < ActionController::TestCase should 'be able to return group_id for a comment' do comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0) - xhr :get, :comment_group, :id => comment.id + xhr :get, :comment_group, :id => comment.id assert_match /\{\"group_id\":0\}/, @response.body end - + should 'return group_id=null for a global comment' do comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala' ) - xhr :get, :comment_group, :id => comment.id + xhr :get, :comment_group, :id => comment.id assert_match /\{\"group_id\":null\}/, @response.body end - + end diff --git a/plugins/comment_group/test/unit/comment_group_plugin_test.rb b/plugins/comment_group/test/unit/comment_group_plugin_test.rb index a8279b1..bc5c991 100644 --- a/plugins/comment_group/test/unit/comment_group_plugin_test.rb +++ b/plugins/comment_group/test/unit/comment_group_plugin_test.rb @@ -7,7 +7,7 @@ class CommentGroupPluginTest < ActiveSupport::TestCase def setup @environment = Environment.default end - + attr_reader :environment should 'load_comments returns all the comments wihout group of an article passed as parameter' do @@ -20,7 +20,7 @@ class CommentGroupPluginTest < ActiveSupport::TestCase assert_equal [], [c2, c3] - plugin.load_comments(article) assert_equal [], plugin.load_comments(article) - [c2, c3] end - + should 'load_comments not returns spam comments' do article = fast_create(Article) c1 = fast_create(Comment, :source_id => article.id, :group_id => 1) @@ -31,7 +31,7 @@ class CommentGroupPluginTest < ActiveSupport::TestCase assert_equal [], [c2] - plugin.load_comments(article) assert_equal [], plugin.load_comments(article) - [c2] end - + should 'load_comments returns only root comments of article' do article = fast_create(Article) c1 = fast_create(Comment, :source_id => article.id, :group_id => 1) @@ -42,5 +42,5 @@ class CommentGroupPluginTest < ActiveSupport::TestCase assert_equal [], [c2] - plugin.load_comments(article) assert_equal [], plugin.load_comments(article) - [c2] end - + end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 4cc0fdd..8f7e621 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -694,7 +694,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase