Commit a52480d8ab0fa89f4680db5f13ae149c94e641f7

Authored by Rodrigo Souto
1 parent 92c207ee

[macro-support-review] Adding index on article name

db/schema.rb
... ... @@ -131,6 +131,7 @@ ActiveRecord::Schema.define(:version => 20130606110602) do
131 131 t.integer "license_id"
132 132 end
133 133  
  134 + add_index "articles", ["name"], :name => "index_articles_on_name"
134 135 add_index "articles", ["parent_id"], :name => "index_articles_on_parent_id"
135 136 add_index "articles", ["profile_id"], :name => "index_articles_on_profile_id"
136 137 add_index "articles", ["slug"], :name => "index_articles_on_slug"
... ...
lib/noosfero/plugin.rb
... ... @@ -377,7 +377,7 @@ class Noosfero::Plugin
377 377 def profile_info_extra_contents
378 378 nil
379 379 end
380   -
  380 +
381 381 # -> Removes the invite friend button from the friends controller
382 382 # returns = boolean
383 383 def remove_invite_friends_button
... ... @@ -439,7 +439,7 @@ class Noosfero::Plugin
439 439 def login_extra_contents
440 440 nil
441 441 end
442   -
  442 +
443 443 # -> Adds adicional content to comment form
444 444 # returns = lambda block that creates html code
445 445 def comment_form_extra_contents(args)
... ...
plugins/comment_group/controllers/profile/comment_group_plugin_profile_controller.rb
... ... @@ -4,7 +4,7 @@ class CommentGroupPluginProfileController < ProfileController
4 4 def view_comments
5 5 article_id = params[:article_id]
6 6 group_id = params[:group_id]
7   -
  7 +
8 8 article = profile.articles.find(article_id)
9 9 comments = article.group_comments.without_spam.in_group(group_id)
10 10 render :update do |page|
... ...
plugins/comment_group/controllers/public/comment_group_plugin_public_controller.rb
... ... @@ -2,7 +2,7 @@ class CommentGroupPluginPublicController < PublicController
2 2 append_view_path File.join(File.dirname(__FILE__) + '/../views')
3 3  
4 4 def comment_group
5   - render :json => { :group_id => Comment.find(params[:id]).group_id }
  5 + render :json => { :group_id => Comment.find(params[:id]).group_id }
6 6 end
7 7  
8 8 end
... ...
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
... ... @@ -2,13 +2,13 @@ require_dependency 'article'
2 2  
3 3 class Article
4 4  
5   - #FIXME make this test
  5 + #FIXME make this test
6 6 has_many :group_comments, :class_name => 'Comment', :foreign_key => 'source_id', :dependent => :destroy, :order => 'created_at asc', :conditions => [ 'group_id IS NOT NULL']
7 7  
8   - #FIXME make this test
  8 + #FIXME make this test
9 9 validate :not_empty_group_comments_removed
10 10  
11   - #FIXME make this test
  11 + #FIXME make this test
12 12 def not_empty_group_comments_removed
13 13 if body
14 14 groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq
... ...
plugins/comment_group/public/comment_group.js
... ... @@ -16,7 +16,7 @@ function makeCommentable() {
16 16 //text = start.parent().children();
17 17 text = jQuery('#article_body_ifr').contents().find('*');
18 18 selection = text.slice(text.index(start), text.index(end)+1);
19   -
  19 +
20 20 hasTag = false;
21 21 selection.each(function(key, value) {
22 22 commentTag = jQuery(value).closest('.article_comments');
... ...
plugins/comment_group/public/comment_group_macro.js
... ... @@ -4,7 +4,7 @@ jQuery(document).ready(function($) {
4 4 if(anchor.length==0) return;
5 5  
6 6 var val = anchor.split('-'); //anchor format = #comment-\d+
7   - if(val.length!=2 || val[0]!='#comment') return;
  7 + if(val.length!=2 || val[0]!='#comment') return;
8 8 if($('div[data-macro=comment_group_plugin/allow_comment]').length==0) return; //comment_group_plugin/allow_comment div must exists
9 9 var comment_id = val[1];
10 10 if(!/^\d+$/.test(comment_id)) return; //test for integer
... ... @@ -18,12 +18,12 @@ jQuery(document).ready(function($) {
18 18 $.scrollTo(button);
19 19 }
20 20 });
21   -});
  21 +});
22 22  
23 23 function toggleGroup(group) {
24 24 var div = jQuery('div.comments_list_toggle_group_'+group);
25 25 var visible = div.is(':visible');
26   - if(!visible)
  26 + if(!visible)
27 27 jQuery('div.comment-group-loading-'+group).addClass('comment-button-loading');
28 28  
29 29 div.toggle('fast');
... ...
plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb
... ... @@ -25,7 +25,7 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase
25 25 assert_match /comments_list_group_0/, @response.body
26 26 assert_match /\"comment-count-0\", \"1\"/, @response.body
27 27 end
28   -
  28 +
29 29 should 'do not show global comments' do
30 30 comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'global comment', :body => 'global', :group_id => nil)
31 31 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
34 34 assert_match /comments_list_group_0/, @response.body
35 35 assert_match /\"comment-count-0\", \"1\"/, @response.body
36 36 end
37   -
  37 +
38 38 end
... ...
plugins/comment_group/test/functional/comment_group_plugin_public_controller_test.rb
... ... @@ -20,14 +20,14 @@ class CommentGroupPluginPublicControllerTest < ActionController::TestCase
20 20  
21 21 should 'be able to return group_id for a comment' do
22 22 comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0)
23   - xhr :get, :comment_group, :id => comment.id
  23 + xhr :get, :comment_group, :id => comment.id
24 24 assert_match /\{\"group_id\":0\}/, @response.body
25 25 end
26   -
  26 +
27 27 should 'return group_id=null for a global comment' do
28 28 comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala' )
29   - xhr :get, :comment_group, :id => comment.id
  29 + xhr :get, :comment_group, :id => comment.id
30 30 assert_match /\{\"group_id\":null\}/, @response.body
31 31 end
32   -
  32 +
33 33 end
... ...
plugins/comment_group/test/unit/comment_group_plugin_test.rb
... ... @@ -7,7 +7,7 @@ class CommentGroupPluginTest < ActiveSupport::TestCase
7 7 def setup
8 8 @environment = Environment.default
9 9 end
10   -
  10 +
11 11 attr_reader :environment
12 12  
13 13 should 'load_comments returns all the comments wihout group of an article passed as parameter' do
... ... @@ -20,7 +20,7 @@ class CommentGroupPluginTest < ActiveSupport::TestCase
20 20 assert_equal [], [c2, c3] - plugin.load_comments(article)
21 21 assert_equal [], plugin.load_comments(article) - [c2, c3]
22 22 end
23   -
  23 +
24 24 should 'load_comments not returns spam comments' do
25 25 article = fast_create(Article)
26 26 c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
... ... @@ -31,7 +31,7 @@ class CommentGroupPluginTest < ActiveSupport::TestCase
31 31 assert_equal [], [c2] - plugin.load_comments(article)
32 32 assert_equal [], plugin.load_comments(article) - [c2]
33 33 end
34   -
  34 +
35 35 should 'load_comments returns only root comments of article' do
36 36 article = fast_create(Article)
37 37 c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
... ... @@ -42,5 +42,5 @@ class CommentGroupPluginTest < ActiveSupport::TestCase
42 42 assert_equal [], [c2] - plugin.load_comments(article)
43 43 assert_equal [], plugin.load_comments(article) - [c2]
44 44 end
45   -
  45 +
46 46 end
... ...
test/unit/application_helper_test.rb
... ... @@ -694,7 +694,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase
694 694 <div data-macro='unexistent' class='failed-macro unexistent'>Unsupported macro unexistent!</div>
695 695 ").search('div')
696 696  
697   - # comparing div attributes between parsed and expected html
  697 + # comparing div attributes between parsed and expected html
698 698 parsed_divs.each_with_index do |div, i|
699 699 assert_equal expected_divs[i].attributes.to_hash, div.attributes.to_hash
700 700 assert_equal expected_divs[i].inner_text, div.inner_text
... ...
test/unit/comment_test.rb
... ... @@ -711,7 +711,7 @@ class CommentTest &lt; ActiveSupport::TestCase
711 711 c2 = create_comment
712 712 comments.push(c2)
713 713 create_comment(:reply_of_id => c2.id)
714   -
  714 +
715 715 assert_equal 6, Comment.count_thread(comments)
716 716 end
717 717  
... ...
test/unit/macros_helper_test.rb
... ... @@ -104,7 +104,7 @@ class MacrosHelperTest &lt; ActiveSupport::TestCase
104 104  
105 105 assert_equal "<script src=\"#{Plugin1.public_path('macro.js')}\" type=\"text/javascript\"></script>", include_macro_js_files
106 106 end
107   -
  107 +
108 108 should 'get macro css files' do
109 109 class Plugin1::Macro < Noosfero::Plugin::Macro
110 110 def self.configuration
... ... @@ -118,7 +118,7 @@ class MacrosHelperTest &lt; ActiveSupport::TestCase
118 118  
119 119 assert_equal Plugin1.public_path('macro.css'), macro_css_files
120 120 end
121   -
  121 +
122 122 should 'get macro specific generator' do
123 123 class Plugin1::Macro < Noosfero::Plugin::Macro
124 124 def self.configuration
... ...