Commit 4251dcbc2ae5c540b6719fa64dac98909a18c1cd

Authored by Rodrigo Souto
2 parents 17071057 f8ed5a33

Merge branch 'stable'

Conflicts:
	app/views/cms/view.rhtml
	test/functional/profile_controller_test.rb
Showing 127 changed files with 562 additions and 495 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 127 files displayed.

@@ -44,6 +44,7 @@ Antonio Terceiro <terceiro@colivre.coop.br> @@ -44,6 +44,7 @@ Antonio Terceiro <terceiro@colivre.coop.br>
44 Aurelio A. Heckert <aurelio@colivre.coop.br> 44 Aurelio A. Heckert <aurelio@colivre.coop.br>
45 Braulio Bhavamitra <brauliobo@gmail.com> 45 Braulio Bhavamitra <brauliobo@gmail.com>
46 Bráulio Bhavamitra <brauliobo@gmail.com> 46 Bráulio Bhavamitra <brauliobo@gmail.com>
  47 +Braulio Bhavamitra <braulio@eita.org.br>
47 Caio <caio.csalgado@gmail.com> 48 Caio <caio.csalgado@gmail.com>
48 Caio + Diego + Pedro + João <caio.csalgado@gmail.com> 49 Caio + Diego + Pedro + João <caio.csalgado@gmail.com>
49 Caio Formiga <caio.formiga@gmail.com> 50 Caio Formiga <caio.formiga@gmail.com>
@@ -147,6 +148,7 @@ João M. M. Silva + Rafael Manzo &lt;jaodsilv@linux.ime.usp.br&gt; @@ -147,6 +148,7 @@ João M. M. Silva + Rafael Manzo &lt;jaodsilv@linux.ime.usp.br&gt;
147 João M. M. Silva + Renan Teruo <jaodsilv@linux.ime.usp.br> 148 João M. M. Silva + Renan Teruo <jaodsilv@linux.ime.usp.br>
148 Joenio Costa <joenio@colivre.coop.br> 149 Joenio Costa <joenio@colivre.coop.br>
149 Josef Spillner <josef.spillner@tu-dresden.de> 150 Josef Spillner <josef.spillner@tu-dresden.de>
  151 +Junior Silva <juniorsilva7@juniorsilva-Aspire-5750Z.(none)>
150 Keilla Menezes <keilla@colivre.coop.br> 152 Keilla Menezes <keilla@colivre.coop.br>
151 Larissa Reis <larissa@colivre.coop.br> 153 Larissa Reis <larissa@colivre.coop.br>
152 Larissa Reis <reiss.larissa@gmail.com> 154 Larissa Reis <reiss.larissa@gmail.com>
app/helpers/boxes_helper.rb
@@ -99,9 +99,9 @@ module BoxesHelper @@ -99,9 +99,9 @@ module BoxesHelper
99 unless block.visible? 99 unless block.visible?
100 options[:title] = _("This block is invisible. Your visitors will not see it.") 100 options[:title] = _("This block is invisible. Your visitors will not see it.")
101 end 101 end
102 - if @controller.send(:content_editor?)  
103 - result = filter_html(result, block)  
104 - end 102 +
  103 + result = filter_html(result, block)
  104 +
105 box_decorator.block_target(block.box, block) + 105 box_decorator.block_target(block.box, block) +
106 content_tag('div', 106 content_tag('div',
107 content_tag('div', 107 content_tag('div',
app/helpers/cms_helper.rb
@@ -28,7 +28,7 @@ module CmsHelper @@ -28,7 +28,7 @@ module CmsHelper
28 end 28 end
29 29
30 def link_to_article(article) 30 def link_to_article(article)
31 - article_name = short_filename(article.title, 30) 31 + article_name = article.title
32 if article.folder? 32 if article.folder?
33 link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article) 33 link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article)
34 else 34 else
app/models/action_tracker_notification.rb
@@ -3,7 +3,7 @@ class ActionTrackerNotification &lt; ActiveRecord::Base @@ -3,7 +3,7 @@ class ActionTrackerNotification &lt; ActiveRecord::Base
3 belongs_to :profile 3 belongs_to :profile
4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id' 4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id'
5 5
6 - has_many :comments, :through => :action_tracker, :class_name => 'Comment', :foreign_key => 'source_id' 6 + delegate :comments, :to => :action_tracker, :allow_nil => true
7 7
8 validates_presence_of :profile_id, :action_tracker_id 8 validates_presence_of :profile_id, :action_tracker_id
9 validates_uniqueness_of :action_tracker_id, :scope => :profile_id 9 validates_uniqueness_of :action_tracker_id, :scope => :profile_id
app/models/article.rb
@@ -57,7 +57,7 @@ class Article &lt; ActiveRecord::Base @@ -57,7 +57,7 @@ class Article &lt; ActiveRecord::Base
57 has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ] 57 has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ]
58 has_many :categories, :through => :article_categorizations 58 has_many :categories, :through => :article_categorizations
59 59
60 - has_many :article_categorizations_including_virtual, :class_name => 'ArticleCategorization', :dependent => :destroy 60 + has_many :article_categorizations_including_virtual, :class_name => 'ArticleCategorization'
61 has_many :categories_including_virtual, :through => :article_categorizations_including_virtual, :source => :category 61 has_many :categories_including_virtual, :through => :article_categorizations_including_virtual, :source => :category
62 62
63 acts_as_having_settings :field => :setting 63 acts_as_having_settings :field => :setting
app/models/category.rb
@@ -22,23 +22,15 @@ class Category &lt; ActiveRecord::Base @@ -22,23 +22,15 @@ class Category &lt; ActiveRecord::Base
22 22
23 named_scope :on_level, lambda { |parent| {:conditions => {:parent_id => parent}} } 23 named_scope :on_level, lambda { |parent| {:conditions => {:parent_id => parent}} }
24 24
25 - named_scope :sub_categories, lambda { |category|  
26 - {:conditions => ['categories.path LIKE ? AND categories.id != ?', "%#{category.slug}%", category.id]}  
27 - }  
28 -  
29 - named_scope :sub_tree, lambda { |category|  
30 - {:conditions => ['categories.path LIKE ?', "%#{category.slug}%"]}  
31 - }  
32 -  
33 acts_as_filesystem 25 acts_as_filesystem
34 26
35 - has_many :article_categorizations, :dependent => :destroy 27 + has_many :article_categorizations
36 has_many :articles, :through => :article_categorizations 28 has_many :articles, :through => :article_categorizations
37 has_many :comments, :through => :articles 29 has_many :comments, :through => :articles
38 30
39 has_many :events, :through => :article_categorizations, :class_name => 'Event', :source => :article 31 has_many :events, :through => :article_categorizations, :class_name => 'Event', :source => :article
40 32
41 - has_many :profile_categorizations, :dependent => :destroy 33 + has_many :profile_categorizations
42 has_many :profiles, :through => :profile_categorizations, :source => :profile 34 has_many :profiles, :through => :profile_categorizations, :source => :profile
43 has_many :enterprises, :through => :profile_categorizations, :source => :profile, :class_name => 'Enterprise' 35 has_many :enterprises, :through => :profile_categorizations, :source => :profile, :class_name => 'Enterprise'
44 has_many :people, :through => :profile_categorizations, :source => :profile, :class_name => 'Person' 36 has_many :people, :through => :profile_categorizations, :source => :profile, :class_name => 'Person'
app/models/featured_products_block.rb
@@ -7,8 +7,9 @@ class FeaturedProductsBlock &lt; Block @@ -7,8 +7,9 @@ class FeaturedProductsBlock &lt; Block
7 7
8 before_save do |block| 8 before_save do |block|
9 if block.owner.kind_of?(Environment) && block.product_ids.blank? 9 if block.owner.kind_of?(Environment) && block.product_ids.blank?
10 - seed = block.owner.products.count  
11 - block.product_ids = block.owner.highlighted_products_with_image(:offset => (rand(seed) % (seed - block.groups_of * 3)), :limit => block.groups_of * 3).map(&:id) 10 + total = block.owner.products.count
  11 + offset = rand([(total - block.groups_of * 3) + 1, 1].max)
  12 + block.product_ids = block.owner.highlighted_products_with_image(:offset => offset, :limit => block.groups_of * 3).map(&:id)
12 end 13 end
13 block.groups_of = block.groups_of.to_i 14 block.groups_of = block.groups_of.to_i
14 end 15 end
app/models/person.rb
@@ -471,8 +471,9 @@ class Person &lt; Profile @@ -471,8 +471,9 @@ class Person &lt; Profile
471 Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.user_id = #{self.id} and action_tracker.verb != 'leave_scrap_to_self' and action_tracker.verb != 'add_member_in_community' ORDER BY updated_at DESC") 471 Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.user_id = #{self.id} and action_tracker.verb != 'leave_scrap_to_self' and action_tracker.verb != 'add_member_in_community' ORDER BY updated_at DESC")
472 end 472 end
473 473
  474 + # by default, all fields are private
474 def public_fields 475 def public_fields
475 - self.fields_privacy.nil? ? self.active_fields : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s) 476 + self.fields_privacy.nil? ? [] : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s)
476 end 477 end
477 478
478 protected 479 protected
app/models/region.rb
@@ -8,9 +8,9 @@ class Region &lt; Category @@ -8,9 +8,9 @@ class Region &lt; Category
8 validators.count > 0 8 validators.count > 0
9 end 9 end
10 10
11 - named_scope :with_validators, :group => 'id', 11 + named_scope :with_validators, :select => 'DISTINCT ON (categories.id) *',
12 :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)' 12 :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)'
13 - 13 +
14 end 14 end
15 15
16 require_dependency 'city' 16 require_dependency 'city'
app/sweepers/profile_sweeper.rb
@@ -4,7 +4,7 @@ class ProfileSweeper # &lt; ActiveRecord::Observer @@ -4,7 +4,7 @@ class ProfileSweeper # &lt; ActiveRecord::Observer
4 include SweeperHelper 4 include SweeperHelper
5 5
6 def after_update(profile) 6 def after_update(profile)
7 - expire_caches(profile) 7 + self.delay.expire_caches profile
8 end 8 end
9 9
10 def after_create(profile) 10 def after_create(profile)
app/views/cms/view.rhtml
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 <% end %> 41 <% end %>
42 42
43 <% @articles.each do |article| article = FilePresenter.for article %> 43 <% @articles.each do |article| article = FilePresenter.for article %>
44 - <tr> 44 + <tr title="<%= article.title%>" >
45 <td class="article-name"> 45 <td class="article-name">
46 <%= link_to_article(article) %> 46 <%= link_to_article(article) %>
47 </td> 47 </td>
app/views/profile/_person_profile.rhtml
@@ -18,18 +18,6 @@ @@ -18,18 +18,6 @@
18 <% cache_timeout(profile.relationships_cache_key, 4.hours) do %> 18 <% cache_timeout(profile.relationships_cache_key, 4.hours) do %>
19 <%= display_work_info profile %> 19 <%= display_work_info profile %>
20 20
21 - <% if !environment.enabled?('disable_asset_enterprises') && !profile.enterprises.empty? %>  
22 - <tr>  
23 - <th colspan='2'><%= __('Enterprises') %></th>  
24 - </tr>  
25 - <% profile.enterprises.includes(:environment,:domains, :preferred_domain).each do |item| %>  
26 - <tr>  
27 - <td></td>  
28 - <td><%= button 'menu-enterprise', item.name, item.url %></td>  
29 - </tr>  
30 - <% end %>  
31 - <% end %>  
32 -  
33 <tr> 21 <tr>
34 <th colspan='2'><%= _('Network')%></th> 22 <th colspan='2'><%= _('Network')%></th>
35 </tr> 23 </tr>
@@ -41,6 +29,12 @@ @@ -41,6 +29,12 @@
41 <td><%= __('Communities') + ':' %></td> 29 <td><%= __('Communities') + ':' %></td>
42 <td><%= link_to profile.communities.count, :controller => "profile", :action => 'communities' %></td> 30 <td><%= link_to profile.communities.count, :controller => "profile", :action => 'communities' %></td>
43 </tr> 31 </tr>
  32 + <% if environment.disabled?('disable_asset_enterprises') %>
  33 + <tr id="person-profile-network-enterprises">
  34 + <td><%= __('Enterprises') + ':' %></td>
  35 + <td><%= link_to profile.enterprises.count, :controller => "profile", :action => 'enterprises' %></td>
  36 + </tr>
  37 + <% end %>
44 38
45 <%= render :partial => 'common' %> 39 <%= render :partial => 'common' %>
46 40
app/views/profile_members/_members_list.rhtml
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <th><%= _('Actions') %></th> 10 <th><%= _('Actions') %></th>
11 </tr> 11 </tr>
12 <% collection.each do |m| %> 12 <% collection.each do |m| %>
13 - <tr> 13 + <tr title="<%= m.name %>">
14 <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td> 14 <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td>
15 <td> 15 <td>
16 <div class="members-buttons-cell"> 16 <div class="members-buttons-cell">
app/views/search/_full_article.html.erb
1 <li class="search-article-item article-item"> 1 <li class="search-article-item article-item">
2 - <%= link_to(article.title, article.url, :class => "search-result-title") %> 2 + <div>
  3 + <%= link_to(article.title, article.url, :class => "search-result-title") %>
  4 + </div>
  5 +
3 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
4 <%= render :partial => 'image', :object => article %> 7 <%= render :partial => 'image', :object => article %>
5 </div> 8 </div>
  9 +
6 <table class="noborder search-content-second-column"> 10 <table class="noborder search-content-second-column">
7 <%= render :partial => 'article_common', :object => article %> 11 <%= render :partial => 'article_common', :object => article %>
8 </table> 12 </table>
app/views/search/_full_blog.html.erb
1 <li class="search-blog article-item"> 1 <li class="search-blog article-item">
2 - <%= link_to blog.title, blog.view_url, :class => 'search-result-title' %> 2 + <div>
  3 + <%= link_to blog.title, blog.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
4 <%= render :partial => 'image', :object => blog %> 7 <%= render :partial => 'image', :object => blog %>
5 </div> 8 </div>
  9 +
6 <table class="noborder search-content-second-column"> 10 <table class="noborder search-content-second-column">
7 <tr class="search-blog-items"> 11 <tr class="search-blog-items">
8 <td class="search-field-label"><%= _("Last posts") %></td> 12 <td class="search-field-label"><%= _("Last posts") %></td>
app/views/search/_full_event.html.erb
1 <li class="search-event-item article-item"> 1 <li class="search-event-item article-item">
2 -<%= link_to(event.title, event.url, :class => "search-result-title") %>  
3 -<div class="search-content-first-column">  
4 - <%= render :partial => 'image', :object => event %>  
5 -</div>  
6 -<table class="noborder search-content-second-column">  
7 - <% if event.start_date %>  
8 - <tr class="search-article-event-date">  
9 - <td class="search-field-label"><%= _('Start date') %></td>  
10 - <td class="article-item-date"><%= event.start_date %></td>  
11 - </tr>  
12 - <% end %>  
13 - <% if event.end_date %>  
14 - <tr class="search-article-event-date">  
15 - <td class="search-field-label"><%= _('End date') %></td>  
16 - <td class="article-item-date"><%= event.end_date %></td>  
17 - </tr>  
18 - <% end %> 2 + <div>
  3 + <%= link_to(event.title, event.url, :class => "search-result-title") %>
  4 + </div>
19 5
20 - <%= render :partial => 'article_common', :object => event %>  
21 -</table>  
22 -<%= render :partial => 'article_last_change', :object => event %> 6 + <div class="search-content-first-column">
  7 + <%= render :partial => 'image', :object => event %>
  8 + </div>
23 9
24 -<div style="clear: both"></div> 10 + <table class="noborder search-content-second-column">
  11 + <% if event.start_date %>
  12 + <tr class="search-article-event-date">
  13 + <td class="search-field-label"><%= _('Start date') %></td>
  14 + <td class="article-item-date"><%= event.start_date %></td>
  15 + </tr>
  16 + <% end %>
  17 + <% if event.end_date %>
  18 + <tr class="search-article-event-date">
  19 + <td class="search-field-label"><%= _('End date') %></td>
  20 + <td class="article-item-date"><%= event.end_date %></td>
  21 + </tr>
  22 + <% end %>
  23 +
  24 + <%= render :partial => 'article_common', :object => event %>
  25 + </table>
  26 + <%= render :partial => 'article_last_change', :object => event %>
  27 +
  28 + <div style="clear: both"></div>
25 </li> 29 </li>
app/views/search/_full_folder.html.erb
1 <li class="search-folder-item article-item"> 1 <li class="search-folder-item article-item">
2 - <%= link_to folder.title, folder.view_url, :class => 'search-result-title' %> 2 + <div>
  3 + <%= link_to folder.title, folder.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
4 <%= render :partial => 'image', :object => folder %> 7 <%= render :partial => 'image', :object => folder %>
5 </div> 8 </div>
  9 +
6 <table class="noborder search-content-second-column"> 10 <table class="noborder search-content-second-column">
7 <tr class="search-folder-items"> 11 <tr class="search-folder-items">
8 <td class="search-field-label"><%= _("Last items") %></td> 12 <td class="search-field-label"><%= _("Last items") %></td>
app/views/search/_full_forum.html.erb
1 <li class="search-forum-item article-item"> 1 <li class="search-forum-item article-item">
2 - <%= link_to forum.title, forum.view_url, :class => 'search-result-title' %> 2 + <div>
  3 + <%= link_to forum.title, forum.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
4 <%= render :partial => 'image', :object => forum %> 7 <%= render :partial => 'image', :object => forum %>
5 </div> 8 </div>
  9 +
6 <table class="noborder search-content-second-column"> 10 <table class="noborder search-content-second-column">
7 <tr class="search-forum-items"> 11 <tr class="search-forum-items">
8 <td class="search-field-label"><%= _("Last topics") %></td> 12 <td class="search-field-label"><%= _("Last topics") %></td>
app/views/search/_full_gallery.html.erb
1 <li class="search-gallery article-item"> 1 <li class="search-gallery article-item">
2 - <%= link_to gallery.title, gallery.view_url, :class => 'search-result-title' %> 2 + <div>
  3 + <%= link_to gallery.title, gallery.view_url, :class => 'search-result-title' %>
  4 + </div>
  5 +
3 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
4 <%= render :partial => 'image', :object => gallery %> 7 <%= render :partial => 'image', :object => gallery %>
5 </div> 8 </div>
  9 +
6 <table class="noborder search-content-second-column"> 10 <table class="noborder search-content-second-column">
7 <%= render :partial => 'article_common', :object => gallery %> 11 <%= render :partial => 'article_common', :object => gallery %>
8 </table> 12 </table>
app/views/search/_full_text_article.html.erb
1 <li class="search-text-article-item article-item"> 1 <li class="search-text-article-item article-item">
2 - <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %> 2 + <div>
  3 + <%= link_to(text_article.title, text_article.url, :class => "search-result-title") %>
  4 + </div>
3 5
4 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
5 <%= render :partial => 'image', :object => text_article %> 7 <%= render :partial => 'image', :object => text_article %>
app/views/search/_full_uploaded_file.html.erb
1 <li class="search-uploaded-file-item article-item"> 1 <li class="search-uploaded-file-item article-item">
2 - <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %> 2 + <div>
  3 + <%= link_to uploaded_file.filename, uploaded_file.view_url, :class => 'search-result-title' %>
  4 + </div>
3 5
4 <div class="search-content-first-column"> 6 <div class="search-content-first-column">
5 <%= render :partial => 'image', :object => uploaded_file %> 7 <%= render :partial => 'image', :object => uploaded_file %>
app/views/shared/tiny_mce.rhtml
@@ -70,7 +70,7 @@ tinyMCE.init({ @@ -70,7 +70,7 @@ tinyMCE.init({
70 paste_insert_word_content_callback : "convertWord", 70 paste_insert_word_content_callback : "convertWord",
71 paste_use_dialog: false, 71 paste_use_dialog: false,
72 apply_source_formatting : true, 72 apply_source_formatting : true,
73 - extended_valid_elements : "applet[style|archive|codebase|code|height|width],comment,iframe[src|style|allowtransparency|frameborder|width|height|scrolling],embed[title|src|type|height|width]", 73 + extended_valid_elements : "applet[style|archive|codebase|code|height|width],comment,iframe[src|style|allowtransparency|frameborder|width|height|scrolling],embed[title|src|type|height|width],audio[controls|autoplay],video[controls|autoplay],source[src|type]",
74 content_css: '/stylesheets/tinymce.css,<%= macro_css_files %>', 74 content_css: '/stylesheets/tinymce.css,<%= macro_css_files %>',
75 language: <%= tinymce_language.inspect %>, 75 language: <%= tinymce_language.inspect %>,
76 entity_encoding: 'raw', 76 entity_encoding: 'raw',
config/environment.rb
@@ -85,10 +85,10 @@ Rails::Initializer.run do |config| @@ -85,10 +85,10 @@ Rails::Initializer.run do |config|
85 } 85 }
86 86
87 # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper 87 # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper
88 - config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars', 'scrolling', 'frameborder' 88 + config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars', 'scrolling', 'frameborder', 'controls', 'autoplay'
89 89
90 # Adds custom tags to the Set of allowed html tags for the #sanitize helper 90 # Adds custom tags to the Set of allowed html tags for the #sanitize helper
91 - config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe' 91 + config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe', 'audio', 'video', 'source'
92 92
93 # See Rails::Configuration for more options 93 # See Rails::Configuration for more options
94 94
@@ -221,7 +221,6 @@ ActiveRecord::Schema.define(:version =&gt; 20130711213046) do @@ -221,7 +221,6 @@ ActiveRecord::Schema.define(:version =&gt; 20130711213046) do
221 t.string "source_type" 221 t.string "source_type"
222 t.string "user_agent" 222 t.string "user_agent"
223 t.string "referrer" 223 t.string "referrer"
224 - t.integer "group_id"  
225 end 224 end
226 225
227 add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam" 226 add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam"
debian/changelog
  1 +noosfero (0.44.4) unstable; urgency=low
  2 +
  3 + * Bugfix release
  4 +
  5 + -- Rodrigo Souto <rodrigo@colivre.coop.br> Mon, 07 Oct 2013 13:38:31 -0300
  6 +
1 noosfero (0.44.3) unstable; urgency=low 7 noosfero (0.44.3) unstable; urgency=low
2 8
3 * Bugfixes release 9 * Bugfixes release
features/edit_article.feature
@@ -64,8 +64,8 @@ Feature: edit article @@ -64,8 +64,8 @@ Feature: edit article
64 And I fill in "Tag list" with "aurium, bug" 64 And I fill in "Tag list" with "aurium, bug"
65 And I press "Save" 65 And I press "Save"
66 And I go to /joaosilva/article-with-tags 66 And I go to /joaosilva/article-with-tags
67 - Then I should see "aurium" within "#article-tags a:first"  
68 - And I should see "bug" within "#article-tags a:last" 67 + Then I should see "aurium" within "#article-tags"
  68 + And I should see "bug" within "#article-tags"
69 69
70 Scenario: redirect to the created article 70 Scenario: redirect to the created article
71 Given I am on joaosilva's control panel 71 Given I am on joaosilva's control panel
features/last_administrator_leaving.feature
@@ -17,7 +17,7 @@ Feature: remove administrator role @@ -17,7 +17,7 @@ Feature: remove administrator role
17 Scenario: the last administrator removes his administrator role and must choose the new administrator 17 Scenario: the last administrator removes his administrator role and must choose the new administrator
18 Given "Maria Souza" is a member of "Nice people" 18 Given "Maria Souza" is a member of "Nice people"
19 And I am on Nice people's members management 19 And I am on Nice people's members management
20 - And I follow "Edit" 20 + And I follow "Edit" within "tr[title='Joao Silva']"
21 And I uncheck "Profile Administrator" 21 And I uncheck "Profile Administrator"
22 When I press "Save changes" 22 When I press "Save changes"
23 Then I should see "Since you are the last administrator, you must choose" 23 Then I should see "Since you are the last administrator, you must choose"
features/plugins.feature
@@ -22,27 +22,27 @@ Feature: plugins @@ -22,27 +22,27 @@ Feature: plugins
22 | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } | 22 | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } |
23 23
24 Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled 24 Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled
25 - Given plugin TestPlugin is enabled on environment 25 + Given plugin Test is enabled on environment
26 And I go to joaosilva's control panel 26 And I go to joaosilva's control panel
27 Then I should see "Test plugin button" 27 Then I should see "Test plugin button"
28 28
29 Scenario: a user must see the plugin\'s tab in in the profile if the plugin is enabled 29 Scenario: a user must see the plugin\'s tab in in the profile if the plugin is enabled
30 - Given plugin TestPlugin is enabled on environment 30 + Given plugin Test is enabled on environment
31 And I am on joaosilva's profile 31 And I am on joaosilva's profile
32 Then I should see "Test plugin tab" 32 Then I should see "Test plugin tab"
33 33
34 Scenario: a user must not see the plugin\'s button in the control panel if the plugin is disabled 34 Scenario: a user must not see the plugin\'s button in the control panel if the plugin is disabled
35 - Given plugin TestPlugin is disabled on environment 35 + Given plugin Test is disabled on environment
36 And I go to joaosilva's control panel 36 And I go to joaosilva's control panel
37 Then I should not see "Test plugin button" 37 Then I should not see "Test plugin button"
38 38
39 Scenario: a user must not see the plugin\'s tab in in the profile if the plugin is disabled 39 Scenario: a user must not see the plugin\'s tab in in the profile if the plugin is disabled
40 - Given plugin TestPlugin is disabled on environment 40 + Given plugin Test is disabled on environment
41 And I am on joaosilva's profile 41 And I am on joaosilva's profile
42 Then I should not see "Test plugin tab" 42 Then I should not see "Test plugin tab"
43 43
44 Scenario: an admin should be able to deactivate a plugin 44 Scenario: an admin should be able to deactivate a plugin
45 - Given plugin TestPlugin is enabled on environment 45 + Given plugin Test is enabled on environment
46 And I am logged in as admin 46 And I am logged in as admin
47 When I go to admin_user's control panel 47 When I go to admin_user's control panel
48 Then I should see "Test plugin button" 48 Then I should see "Test plugin button"
features/search_communities.feature
@@ -4,7 +4,8 @@ Feature: search communities @@ -4,7 +4,8 @@ Feature: search communities
4 In order to find ones that interest me 4 In order to find ones that interest me
5 5
6 Background: 6 Background:
7 - Given the following category 7 + Given plugin Solr is enabled on environment
  8 + And the following category
8 | name | 9 | name |
9 | social network | 10 | social network |
10 And the following community 11 And the following community
features/short_filename.feature
@@ -18,4 +18,4 @@ Feature: sitemap @@ -18,4 +18,4 @@ Feature: sitemap
18 Scenario: view the CMS 18 Scenario: view the CMS
19 Given I am logged in as "joaosilva" 19 Given I am logged in as "joaosilva"
20 When I am on /myprofile/joaosilva/cms 20 When I am on /myprofile/joaosilva/cms
21 - Then I should see "AGENDA_CULTURA_-_FEST(...).txt" 21 + Then I should see "AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_(...).txt"
features/step_definitions/noosfero_steps.rb
@@ -44,7 +44,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | @@ -44,7 +44,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
44 end 44 end
45 if category && !category.blank? 45 if category && !category.blank?
46 cat = Category.find_by_slug category 46 cat = Category.find_by_slug category
47 - organization.categories << cat 47 + ProfileCategorization.add_category_to_profile(cat, organization)
48 end 48 end
49 if img_name 49 if img_name
50 img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+img_name+'.png', 'image/png')) 50 img = Image.create!(:uploaded_data => fixture_file_upload('/files/'+img_name+'.png', 'image/png'))
features/step_definitions/plugin_steps.rb
@@ -23,6 +23,7 @@ end @@ -23,6 +23,7 @@ end
23 23
24 Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status| 24 Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status|
25 e = Environment.default 25 e = Environment.default
  26 + plugin = "#{plugin}Plugin"
26 if status == 'enabled' 27 if status == 'enabled'
27 e.enabled_plugins += [plugin] 28 e.enabled_plugins += [plugin]
28 else 29 else
lib/noosfero.rb
@@ -3,7 +3,7 @@ require &#39;fast_gettext&#39; @@ -3,7 +3,7 @@ require &#39;fast_gettext&#39;
3 3
4 module Noosfero 4 module Noosfero
5 PROJECT = 'noosfero' 5 PROJECT = 'noosfero'
6 - VERSION = '0.44.3' 6 + VERSION = '0.44.4'
7 7
8 def self.pattern_for_controllers_in_directory(dir) 8 def self.pattern_for_controllers_in_directory(dir)
9 disjunction = controllers_in_directory(dir).join('|') 9 disjunction = controllers_in_directory(dir).join('|')
lib/noosfero/plugin.rb
@@ -64,6 +64,9 @@ class Noosfero::Plugin @@ -64,6 +64,9 @@ class Noosfero::Plugin
64 require init.gsub(/.rb$/, '') if File.file? init 64 require init.gsub(/.rb$/, '') if File.file? init
65 end 65 end
66 66
  67 + # load extensions
  68 + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file }
  69 +
67 # load class 70 # load class
68 klass(plugin_name) 71 klass(plugin_name)
69 end 72 end
plugins/bsc/install.rb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +raise "Not ready yet"
plugins/bsc/lib/bsc_plugin.rb
1 -require_dependency 'bsc_plugin/ext/enterprise'  
2 -require_dependency 'bsc_plugin/ext/product'  
3 -  
4 class BscPlugin < Noosfero::Plugin 1 class BscPlugin < Noosfero::Plugin
5 2
6 Bsc 3 Bsc
plugins/comment_group/lib/comment_group_plugin.rb
1 -require_dependency 'comment_group_plugin/ext/article'  
2 -require_dependency 'comment_group_plugin/ext/comment'  
3 -  
4 class CommentGroupPlugin < Noosfero::Plugin 1 class CommentGroupPlugin < Noosfero::Plugin
5 2
6 def self.plugin_name 3 def self.plugin_name
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -require_dependency 'article'  
2 -  
3 -class Article  
4 -  
5 - #FIXME make this test  
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 -  
8 - #FIXME make this test  
9 - validate :not_empty_group_comments_removed  
10 -  
11 - #FIXME make this test  
12 - def not_empty_group_comments_removed  
13 - if body  
14 - groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq  
15 - groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i}  
16 - errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty?  
17 - end  
18 - end  
19 -  
20 -end  
21 -  
plugins/comment_group/lib/comment_group_plugin/ext/comment.rb
@@ -1,12 +0,0 @@ @@ -1,12 +0,0 @@
1 -require_dependency 'comment'  
2 -  
3 -class Comment  
4 -  
5 - named_scope :without_group, :conditions => {:group_id => nil }  
6 -  
7 - named_scope :in_group, lambda { |group_id| {  
8 - :conditions => ['group_id = ?', group_id]  
9 - }  
10 - }  
11 -  
12 -end  
plugins/comment_group/lib/ext/article.rb 0 → 100644
@@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
  1 +require_dependency 'article'
  2 +
  3 +class Article
  4 +
  5 + #FIXME make this test
  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 +
  8 + #FIXME make this test
  9 + validate :not_empty_group_comments_removed
  10 +
  11 + #FIXME make this test
  12 + def not_empty_group_comments_removed
  13 + if body
  14 + groups_with_comments = group_comments.collect {|comment| comment.group_id}.uniq
  15 + groups = Hpricot(body.to_s).search('.macro').collect{|element| element['data-macro-group_id'].to_i}
  16 + errors.add_to_base(N_('Not empty group comment cannot be removed')) unless (groups_with_comments-groups).empty?
  17 + end
  18 + end
  19 +
  20 +end
  21 +
plugins/comment_group/lib/ext/comment.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +require_dependency 'comment'
  2 +
  3 +class Comment
  4 +
  5 + named_scope :without_group, :conditions => {:group_id => nil }
  6 +
  7 + named_scope :in_group, lambda { |group_id| {
  8 + :conditions => ['group_id = ?', group_id]
  9 + }
  10 + }
  11 +
  12 +end
plugins/comment_group/test/unit/comment_group_plugin_test.rb
@@ -10,15 +10,17 @@ class CommentGroupPluginTest &lt; ActiveSupport::TestCase @@ -10,15 +10,17 @@ class CommentGroupPluginTest &lt; ActiveSupport::TestCase
10 10
11 attr_reader :environment 11 attr_reader :environment
12 12
13 - should 'filter_comments returns all the comments wihout group of an article passed as parameter' do  
14 - article = fast_create(Article)  
15 - c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)  
16 - c2 = fast_create(Comment, :source_id => article.id)  
17 - c3 = fast_create(Comment, :source_id => article.id)  
18 -  
19 - plugin = CommentGroupPlugin.new  
20 - assert_equal [], [c2, c3] - plugin.filter_comments(article.comments)  
21 - assert_equal [], plugin.filter_comments(article.comments) - [c2, c3]  
22 - end 13 +#FIXME Obsolete test
  14 +#
  15 +# should 'filter_comments returns all the comments wihout group of an article passed as parameter' do
  16 +# article = fast_create(Article)
  17 +# c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
  18 +# c2 = fast_create(Comment, :source_id => article.id)
  19 +# c3 = fast_create(Comment, :source_id => article.id)
  20 +#
  21 +# plugin = CommentGroupPlugin.new
  22 +# assert_equal [], [c2, c3] - plugin.filter_comments(article.comments)
  23 +# assert_equal [], plugin.filter_comments(article.comments) - [c2, c3]
  24 +# end
23 25
24 end 26 end
plugins/custom_forms/db/migrate/20130822001407_set_position_to_existent_custom_forms_plugin_fields.rb 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +class SetPositionToExistentCustomFormsPluginFields < ActiveRecord::Migration
  2 + def self.up
  3 + update("UPDATE custom_forms_plugin_fields SET position = 0 WHERE position IS NULL")
  4 + end
  5 +
  6 + def self.down
  7 + say("Nothing to undo (cannot recover the data)")
  8 + end
  9 +end
plugins/custom_forms/lib/custom_forms_plugin.rb
1 -require 'ext/role_assignment_trigger'  
2 -  
3 class CustomFormsPlugin < Noosfero::Plugin 1 class CustomFormsPlugin < Noosfero::Plugin
4 2
5 def self.plugin_name 3 def self.plugin_name
plugins/custom_forms/lib/custom_forms_plugin/field.rb
@@ -15,8 +15,12 @@ class CustomFormsPlugin::Field &lt; ActiveRecord::Base @@ -15,8 +15,12 @@ class CustomFormsPlugin::Field &lt; ActiveRecord::Base
15 15
16 before_create do |field| 16 before_create do |field|
17 if field.form.fields.exists? 17 if field.form.fields.exists?
18 - field.position = field.form.fields.order('position').last.position + 1 18 + field.position = field.form.fields.order(:position).last.position + 1
19 end 19 end
20 end 20 end
  21 +
  22 + def position
  23 + self[:position] || 0
  24 + end
21 end 25 end
22 26
plugins/custom_forms/test/unit/custom_forms_plugin/field_test.rb
@@ -81,5 +81,17 @@ class CustomFormsPlugin::FieldTest &lt; ActiveSupport::TestCase @@ -81,5 +81,17 @@ class CustomFormsPlugin::FieldTest &lt; ActiveSupport::TestCase
81 assert_equal 1, field_1.position 81 assert_equal 1, field_1.position
82 assert_equal 2, field_2.position 82 assert_equal 2, field_2.position
83 end 83 end
  84 +
  85 + should 'not crash when adding new fields on a form with fields without position' do
  86 + form = CustomFormsPlugin::Form.create(:name => 'Free Software', :profile => fast_create(Profile))
  87 + field_0 = CustomFormsPlugin::Field.create(:name => 'License', :form => form)
  88 + field_0.position = nil
  89 + field_0.save
  90 +
  91 + assert_nothing_raised do
  92 + field_1 = CustomFormsPlugin::Field.create!(:name => 'URL', :form => form)
  93 + end
  94 + end
  95 +
84 end 96 end
85 97
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
@@ -41,7 +41,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -41,7 +41,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
41 Article.delete_all 41 Article.delete_all
42 get :index, :block_id => block.id 42 get :index, :block_id => block.id
43 json_response = ActiveSupport::JSON.decode(@response.body) 43 json_response = ActiveSupport::JSON.decode(@response.body)
44 - assert_equal [], json_response 44 + assert_equivalent [], json_response
45 end 45 end
46 46
47 should 'index action returns an json with node content' do 47 should 'index action returns an json with node content' do
@@ -53,7 +53,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -53,7 +53,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
53 expected_json = {'data' => article.title} 53 expected_json = {'data' => article.title}
54 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} 54 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
55 55
56 - assert_equal [expected_json], json_response 56 + assert_equivalent [expected_json], json_response
57 end 57 end
58 58
59 should 'index action returns an json with node checked if the node is in the nodes list' do 59 should 'index action returns an json with node checked if the node is in the nodes list' do
@@ -68,7 +68,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -68,7 +68,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} 68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
69 expected_json['attr'].merge!({'class' => 'jstree-checked'}) 69 expected_json['attr'].merge!({'class' => 'jstree-checked'})
70 70
71 - assert_equal [expected_json], json_response 71 + assert_equivalent [expected_json], json_response
72 end 72 end
73 73
74 should 'index action returns an json with node undetermined if the node is in the parent nodes list' do 74 should 'index action returns an json with node undetermined if the node is in the parent nodes list' do
@@ -84,7 +84,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -84,7 +84,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) 84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'})
85 expected_json['children'] = [] 85 expected_json['children'] = []
86 86
87 - assert_equal [expected_json], json_response 87 + assert_equivalent [expected_json], json_response
88 end 88 end
89 89
90 should 'index action returns an json with node closed if the node has article with children' do 90 should 'index action returns an json with node closed if the node has article with children' do
@@ -98,7 +98,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -98,7 +98,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
98 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} 98 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
99 expected_json['state'] = 'closed' 99 expected_json['state'] = 'closed'
100 100
101 - assert_equal [expected_json], json_response 101 + assert_equivalent [expected_json], json_response
102 end 102 end
103 103
104 should 'index action returns an json with all the children nodes if some parent is in the parents list' do 104 should 'index action returns an json with all the children nodes if some parent is in the parents list' do
@@ -121,7 +121,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -121,7 +121,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
121 expected_json['children'] = children 121 expected_json['children'] = children
122 expected_json['state'] = 'closed' 122 expected_json['state'] = 'closed'
123 123
124 - assert_equal [expected_json], json_response 124 + assert_equivalent [expected_json], json_response
125 end 125 end
126 126
127 should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do 127 should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
@@ -151,7 +151,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -151,7 +151,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
151 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} 151 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
152 expected_json.push(value) 152 expected_json.push(value)
153 153
154 - assert_equal expected_json, json_response 154 + assert_equivalent expected_json, json_response
155 end 155 end
156 156
157 should 'index action returns an json without children nodes if the parent is not in the parents list' do 157 should 'index action returns an json without children nodes if the parent is not in the parents list' do
@@ -173,7 +173,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase @@ -173,7 +173,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
173 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} 173 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
174 expected_json.push(value) 174 expected_json.push(value)
175 175
176 - assert_equal expected_json, json_response 176 + assert_equivalent expected_json, json_response
177 end 177 end
178 178
179 end 179 end
plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
@@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
41 Article.delete_all 41 Article.delete_all
42 get :index, :block_id => block.id, :profile => profile.identifier 42 get :index, :block_id => block.id, :profile => profile.identifier
43 json_response = ActiveSupport::JSON.decode(@response.body) 43 json_response = ActiveSupport::JSON.decode(@response.body)
44 - assert_equal [], json_response 44 + assert_equivalent [], json_response
45 end 45 end
46 46
47 should 'index action returns an json with node content' do 47 should 'index action returns an json with node content' do
@@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
53 expected_json = {'data' => article.title} 53 expected_json = {'data' => article.title}
54 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} 54 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
55 55
56 - assert_equal [expected_json], json_response 56 + assert_equivalent [expected_json], json_response
57 end 57 end
58 58
59 should 'index action returns an json with node checked if the node is in the nodes list' do 59 should 'index action returns an json with node checked if the node is in the nodes list' do
@@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} 68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
69 expected_json['attr'].merge!({'class' => 'jstree-checked'}) 69 expected_json['attr'].merge!({'class' => 'jstree-checked'})
70 70
71 - assert_equal [expected_json], json_response 71 + assert_equivalent [expected_json], json_response
72 end 72 end
73 73
74 should 'index action returns an json with node undetermined if the node is in the parent nodes list' do 74 should 'index action returns an json with node undetermined if the node is in the parent nodes list' do
@@ -84,7 +84,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -84,7 +84,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) 84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'})
85 expected_json['children'] = [] 85 expected_json['children'] = []
86 86
87 - assert_equal [expected_json], json_response 87 + assert_equivalent [expected_json], json_response
88 end 88 end
89 89
90 should 'index action returns an json with node closed if the node has article with children' do 90 should 'index action returns an json with node closed if the node has article with children' do
@@ -99,7 +99,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -99,7 +99,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
99 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} 99 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
100 expected_json['state'] = 'closed' 100 expected_json['state'] = 'closed'
101 101
102 - assert_equal [expected_json], json_response 102 + assert_equivalent [expected_json], json_response
103 end 103 end
104 104
105 should 'index action returns an json with all the children nodes if some parent is in the parents list' do 105 should 'index action returns an json with all the children nodes if some parent is in the parents list' do
@@ -122,7 +122,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -122,7 +122,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
122 expected_json['children'] = children 122 expected_json['children'] = children
123 expected_json['state'] = 'closed' 123 expected_json['state'] = 'closed'
124 124
125 - assert_equal [expected_json], json_response 125 + assert_equivalent [expected_json], json_response
126 end 126 end
127 127
128 should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do 128 should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do
@@ -152,7 +152,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -152,7 +152,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
152 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} 152 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
153 expected_json.push(value) 153 expected_json.push(value)
154 154
155 - assert_equal expected_json, json_response 155 + assert_equivalent expected_json, json_response
156 end 156 end
157 157
158 should 'index action returns an json without children nodes if the parent is not in the parents list' do 158 should 'index action returns an json without children nodes if the parent is not in the parents list' do
@@ -174,7 +174,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase @@ -174,7 +174,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
174 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} 174 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
175 expected_json.push(value) 175 expected_json.push(value)
176 176
177 - assert_equal expected_json, json_response 177 + assert_equivalent expected_json, json_response
178 end 178 end
179 179
180 end 180 end
plugins/foo/lib/ext/profile.rb 0 → 100644
@@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
  1 +require_dependency 'profile'
  2 +
  3 +Profile.class_eval do
  4 + def bar
  5 + end
  6 +end
plugins/foo/lib/foo_plugin.rb
1 -require_dependency 'foo_plugin/ext/profile'  
2 -  
3 class FooPlugin < Noosfero::Plugin 1 class FooPlugin < Noosfero::Plugin
4 2
5 def self.plugin_name 3 def self.plugin_name
plugins/foo/lib/foo_plugin/ext/profile.rb
@@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
1 -require_dependency 'profile'  
2 -  
3 -Profile.class_eval do  
4 - def bar  
5 - end  
6 -end  
plugins/google_analytics/lib/google_analytics_plugin.rb
1 -require_dependency File.dirname(__FILE__) + '/ext/profile'  
2 -  
3 class GoogleAnalyticsPlugin < Noosfero::Plugin 1 class GoogleAnalyticsPlugin < Noosfero::Plugin
4 2
5 include ActionView::Helpers::JavaScriptHelper 3 include ActionView::Helpers::JavaScriptHelper
plugins/ldap/dependencies.rb
  1 +require 'rubygems'
1 require 'net/ldap' 2 require 'net/ldap'
plugins/ldap/install.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +system "gem install --user-install net-ldap -v 0.3.1"
  2 +puts "\nWARNING: This plugin is not setting up a ldap test server automatically.
  3 +Some tests may not be running. If you want to fully test this plugin, please
  4 +setup the ldap test server and make the proper configurations on
  5 +fixtures/ldap.yml.\n\n"
plugins/ldap/lib/ldap_plugin.rb
1 -require_dependency File.dirname(__FILE__) + '/ext/environment'  
2 require File.dirname(__FILE__) + '/ldap_authentication.rb' 1 require File.dirname(__FILE__) + '/ldap_authentication.rb'
3 2
4 -  
5 class LdapPlugin < Noosfero::Plugin 3 class LdapPlugin < Noosfero::Plugin
6 4
7 def self.plugin_name 5 def self.plugin_name
plugins/mezuro/install.rb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +raise "Not ready yet"
plugins/pg_search/lib/pg_search_plugin.rb
1 -require 'ext/active_record'  
2 -  
3 class PgSearchPlugin < Noosfero::Plugin 1 class PgSearchPlugin < Noosfero::Plugin
4 2
5 def self.plugin_name 3 def self.plugin_name
plugins/require_auth_to_comment/lib/ext/profile.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +require_dependency 'profile'
  2 +
  3 +class Profile
  4 + settings_items :allow_unauthenticated_comments, :type => :boolean
  5 +end
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
1 -require_dependency 'require_auth_to_comment_plugin/ext/profile'  
2 -  
3 class RequireAuthToCommentPlugin < Noosfero::Plugin 1 class RequireAuthToCommentPlugin < Noosfero::Plugin
4 2
5 include ActionView::Helpers::TagHelper 3 include ActionView::Helpers::TagHelper
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin/ext/profile.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -require_dependency 'profile'  
2 -  
3 -class Profile  
4 - settings_items :allow_unauthenticated_comments, :type => :boolean  
5 -end  
plugins/send_email/features/send_email_plugin.feature
@@ -7,7 +7,7 @@ Feature: send_email_plugin @@ -7,7 +7,7 @@ Feature: send_email_plugin
7 And I am logged in as "joaosilva" 7 And I am logged in as "joaosilva"
8 8
9 Scenario: expand macro in article content 9 Scenario: expand macro in article content
10 - Given plugin SendEmailPlugin is enabled on environment 10 + Given plugin SendEmail is enabled on environment
11 And the following articles 11 And the following articles
12 | owner | name | body | 12 | owner | name | body |
13 | joaosilva | sample-article | URL path to {sendemail} action | 13 | joaosilva | sample-article | URL path to {sendemail} action |
@@ -15,7 +15,7 @@ Feature: send_email_plugin @@ -15,7 +15,7 @@ Feature: send_email_plugin
15 Then I should see "URL path to /profile/joaosilva/plugin/send_email/deliver action" 15 Then I should see "URL path to /profile/joaosilva/plugin/send_email/deliver action"
16 16
17 Scenario: expand macro in block content 17 Scenario: expand macro in block content
18 - Given plugin SendEmailPlugin is enabled on environment 18 + Given plugin SendEmail is enabled on environment
19 And the following blocks 19 And the following blocks
20 | owner | type | html | 20 | owner | type | html |
21 | joaosilva | RawHTMLBlock | URL path to {sendemail} action | 21 | joaosilva | RawHTMLBlock | URL path to {sendemail} action |
plugins/shopping_cart/controllers/shopping_cart_plugin_myprofile_controller.rb
@@ -63,6 +63,7 @@ class ShoppingCartPluginMyprofileController &lt; MyProfileController @@ -63,6 +63,7 @@ class ShoppingCartPluginMyprofileController &lt; MyProfileController
63 63
64 def treat_delivery_options(params) 64 def treat_delivery_options(params)
65 result = {} 65 result = {}
  66 + return result if params.nil? || params[:delivery_options].nil?
66 params[:options].size.times do |counter| 67 params[:options].size.times do |counter|
67 if params[:options][counter].present? && params[:prices][counter].present? 68 if params[:options][counter].present? && params[:prices][counter].present?
68 result[params[:options][counter]] = params[:prices][counter] 69 result[params[:options][counter]] = params[:prices][counter]
plugins/shopping_cart/lib/ext/enterprise.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +require_dependency 'enterprise'
  2 +
  3 +class Enterprise
  4 + has_many :orders, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'seller_id'
  5 +end
plugins/shopping_cart/lib/ext/person.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +require_dependency 'person'
  2 +
  3 +class Person
  4 + has_many :purchases, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'customer_id'
  5 +end
plugins/shopping_cart/lib/shopping_cart_plugin.rb
1 -require_dependency 'shopping_cart_plugin/ext/enterprise'  
2 -require_dependency 'shopping_cart_plugin/ext/person'  
3 -  
4 class ShoppingCartPlugin < Noosfero::Plugin 1 class ShoppingCartPlugin < Noosfero::Plugin
5 2
6 class << self 3 class << self
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -require_dependency 'enterprise'  
2 -  
3 -class Enterprise  
4 - has_many :orders, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'seller_id'  
5 -end  
plugins/shopping_cart/lib/shopping_cart_plugin/ext/person.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -require_dependency 'person'  
2 -  
3 -class Person  
4 - has_many :purchases, :class_name => "ShoppingCartPlugin::PurchaseOrder", :foreign_key => 'customer_id'  
5 -end  
plugins/shopping_cart/test/unit/shopping_cart_plugin/cart_helper_test.rb
@@ -38,7 +38,7 @@ class ShoppingCartPlugin::CartHelperTest &lt; ActiveSupport::TestCase @@ -38,7 +38,7 @@ class ShoppingCartPlugin::CartHelperTest &lt; ActiveSupport::TestCase
38 value = 13.7 38 value = 13.7
39 environment = Environment.default 39 environment = Environment.default
40 40
41 - assert_equal "#{environment.currency_unit} 13#{environment.currency_separator}70", float_to_currency_cart(value,environment) 41 + assert_equal "#{environment.currency_unit}13#{environment.currency_separator}70", float_to_currency_cart(value,environment)
42 end 42 end
43 43
44 end 44 end
plugins/shopping_cart/test/unit/shopping_cart_plugin_test.rb
@@ -19,10 +19,9 @@ class ShoppingCartPluginTest &lt; ActiveSupport::TestCase @@ -19,10 +19,9 @@ class ShoppingCartPluginTest &lt; ActiveSupport::TestCase
19 end 19 end
20 20
21 should 'not add button if product unavailable' do 21 should 'not add button if product unavailable' do
22 - product = fast_create(Product, :available => false)  
23 - enterprise = mock() 22 + enterprise = fast_create(:enterprise)
  23 + product = fast_create(Product, :available => false, :enterprise_id => enterprise.id)
24 enterprise.stubs(:shopping_cart).returns(true) 24 enterprise.stubs(:shopping_cart).returns(true)
25 - product.stubs(:enterprise).returns(enterprise)  
26 25
27 assert_nil shopping_cart.add_to_cart_button(product) 26 assert_nil shopping_cart.add_to_cart_button(product)
28 end 27 end
plugins/solr/features/.search_products.feature.swp
No preview for this file type
plugins/solr/features/search_contents.feature
@@ -5,6 +5,7 @@ Feature: search contents @@ -5,6 +5,7 @@ Feature: search contents
5 5
6 Background: 6 Background:
7 Given the search index is empty 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 And the following users 9 And the following users
9 Given the following users 10 Given the following users
10 | login | name | 11 | login | name |
plugins/solr/features/search_enterprises.feature
@@ -5,6 +5,7 @@ Feature: search enterprises @@ -5,6 +5,7 @@ Feature: search enterprises
5 5
6 Background: 6 Background:
7 Given the search index is empty 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 And the following enterprises 9 And the following enterprises
9 | identifier | name | img | 10 | identifier | name | img |
10 | shop1 | Shoes shop | shoes | 11 | shop1 | Shoes shop | shoes |
@@ -12,6 +13,7 @@ Feature: search enterprises @@ -12,6 +13,7 @@ Feature: search enterprises
12 And the following categories as facets 13 And the following categories as facets
13 | name | 14 | name |
14 | Temáticas | 15 | Temáticas |
  16 +
15 Scenario: see default facets when searching 17 Scenario: see default facets when searching
16 When I go to the search enterprises page 18 When I go to the search enterprises page
17 And I fill in "search-input" with "shoes" 19 And I fill in "search-input" with "shoes"
@@ -34,10 +36,10 @@ Feature: search enterprises @@ -34,10 +36,10 @@ Feature: search enterprises
34 When I go to the search enterprises page 36 When I go to the search enterprises page
35 And I fill in "search-input" with "Artesanato" 37 And I fill in "search-input" with "Artesanato"
36 And I press "Search" 38 And I press "Search"
37 - Then I should see "Pres. Prudente" within "#facet-menu-f_region"  
38 - And I should see ", SP" within "#facet-menu-f_region"  
39 - And I should see "City" within ".search-enterprise-region-label"  
40 - And I should see "Pres. Prudente, SP" within ".search-enterprise-region-name" 39 + Then I should see "Pres. Prudente" within "#facet-menu-solr_plugin_f_region"
  40 + And I should see ", SP" within "#facet-menu-solr_plugin_f_region"
  41 + And I should see "City" within ".facet-menu-label"
  42 + And I should see "Pres. Prudente, SP" within ".facet-menu-item"
41 43
42 Scenario: find enterprise by region 44 Scenario: find enterprise by region
43 Given the following cities 45 Given the following cities
plugins/solr/features/search_people.feature
@@ -5,6 +5,7 @@ Feature: search people @@ -5,6 +5,7 @@ Feature: search people
5 5
6 Background: 6 Background:
7 Given the search index is empty 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 And the following users 9 And the following users
9 | login | name | 10 | login | name |
10 | joaosilva | Joao Silva | 11 | joaosilva | Joao Silva |
plugins/solr/features/search_products.feature
@@ -5,6 +5,7 @@ Feature: search products @@ -5,6 +5,7 @@ Feature: search products
5 5
6 Background: 6 Background:
7 Given the search index is empty 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 And feature "disable_asset_products" is disabled on environment 9 And feature "disable_asset_products" is disabled on environment
9 And the following enterprises 10 And the following enterprises
10 | identifier | name | 11 | identifier | name |
plugins/solr/features/step_definitions/solr_steps.rb
@@ -13,6 +13,6 @@ Given /^the following categories as facets$/ do |table| @@ -13,6 +13,6 @@ Given /^the following categories as facets$/ do |table|
13 ids << cat.id 13 ids << cat.id
14 end 14 end
15 env = Environment.default 15 env = Environment.default
16 - env.top_level_category_as_facet_ids = ids 16 + env.solr_plugin_top_level_category_as_facet_ids = ids
17 env.save! 17 env.save!
18 end 18 end
plugins/solr/install.rb 0 → 100644
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
  1 +raise "Not ready yet. Some tests are failing."
  2 +require 'rubygems'
  3 +require 'rake'
  4 +
  5 +tasks_dir = File.join(File.dirname(__FILE__), 'vendor', 'plugins', 'acts_as_solr_reloaded', 'lib', 'tasks', '*.rake')
  6 +
  7 +Dir[tasks_dir].each do |file|
  8 + load file
  9 +end
  10 +
  11 +begin
  12 + Rake::Task['solr:download'].invoke
  13 +rescue Exception => exception
  14 +end
plugins/solr/lib/.solr_plugin.rb.swp
No preview for this file type
plugins/solr/lib/solr_plugin.rb
@@ -6,8 +6,6 @@ class SolrPlugin &lt; Noosfero::Plugin @@ -6,8 +6,6 @@ class SolrPlugin &lt; Noosfero::Plugin
6 6
7 include SolrPlugin::SearchHelper 7 include SolrPlugin::SearchHelper
8 8
9 - delegate :params, :current_user, :to => :context  
10 -  
11 def self.plugin_name 9 def self.plugin_name
12 "Solr" 10 "Solr"
13 end 11 end
@@ -28,11 +26,16 @@ class SolrPlugin &lt; Noosfero::Plugin @@ -28,11 +26,16 @@ class SolrPlugin &lt; Noosfero::Plugin
28 return if empty_query?(query, category) && klass != Product 26 return if empty_query?(query, category) && klass != Product
29 27
30 solr_options = solr_options(class_asset(klass), category) 28 solr_options = solr_options(class_asset(klass), category)
31 - user = context.send(:logged_in?) ? context.send(:user) : nil  
32 solr_options.merge!(products_options(user)) if klass == Product && empty_query?(query, category) 29 solr_options.merge!(products_options(user)) if klass == Product && empty_query?(query, category)
33 klass.find_by_contents(query, paginate_options, solr_options.merge(options)) 30 klass.find_by_contents(query, paginate_options, solr_options.merge(options))
34 end 31 end
35 32
36 -end 33 + def method_missing method, *args, &block
  34 + if self.context.respond_to? method
  35 + self.context.send method, *args, &block
  36 + else
  37 + super method, *args, &block
  38 + end
  39 + end
37 40
38 -Dir[File.join(SolrPlugin.root_path, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } 41 +end
plugins/solr/lib/solr_plugin/.search_helper.rb.swp
No preview for this file type
plugins/solr/lib/solr_plugin/search_helper.rb
@@ -54,7 +54,7 @@ module SolrPlugin::SearchHelper @@ -54,7 +54,7 @@ module SolrPlugin::SearchHelper
54 end 54 end
55 55
56 def results_only? 56 def results_only?
57 - context.params[:action] == 'index' 57 + params[:action] == 'index'
58 end 58 end
59 59
60 def empty_query?(query, category) 60 def empty_query?(query, category)
@@ -84,18 +84,18 @@ module SolrPlugin::SearchHelper @@ -84,18 +84,18 @@ module SolrPlugin::SearchHelper
84 solr_options = {} 84 solr_options = {}
85 if !multiple_search? 85 if !multiple_search?
86 if !results_only? and asset_class.respond_to? :facets 86 if !results_only? and asset_class.respond_to? :facets
87 - solr_options.merge! asset_class.facets_find_options(context.params[:facet]) 87 + solr_options.merge! asset_class.facets_find_options(params[:facet])
88 solr_options[:all_facets] = true 88 solr_options[:all_facets] = true
89 end 89 end
90 solr_options[:filter_queries] ||= [] 90 solr_options[:filter_queries] ||= []
91 solr_options[:filter_queries] += filters(asset) 91 solr_options[:filter_queries] += filters(asset)
92 - solr_options[:filter_queries] << "environment_id:#{context.environment.id}" 92 + solr_options[:filter_queries] << "environment_id:#{environment.id}"
93 solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category 93 solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category
94 94
95 solr_options[:boost_functions] ||= [] 95 solr_options[:boost_functions] ||= []
96 - context.params[:order_by] = nil if context.params[:order_by] == 'none'  
97 - if context.params[:order_by]  
98 - order = SortOptions[asset][context.params[:order_by].to_sym] 96 + params[:order_by] = nil if params[:order_by] == 'none'
  97 + if params[:order_by]
  98 + order = SortOptions[asset][params[:order_by].to_sym]
99 raise "Unknown order by" if order.nil? 99 raise "Unknown order by" if order.nil?
100 order[:solr_opts].each do |opt, value| 100 order[:solr_opts].each do |opt, value|
101 solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value 101 solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value
plugins/solr/public/style.css
1 .controller-search #search-column-right .search-field .formfield { 1 .controller-search #search-column-right .search-field .formfield {
2 width: 594px; 2 width: 594px;
3 - display: inline-block; 3 + display: inline;
4 } 4 }
5 5
6 #search-column-right .search-customize-options { 6 #search-column-right .search-customize-options {
7 - position: absolute;  
8 margin: 0; 7 margin: 0;
9 padding: 5px 0; 8 padding: 5px 0;
10 - bottom: 0;  
11 - left: 0;  
12 } 9 }
13 10
14 #search-column-right .search-results-box .vcard { 11 #search-column-right .search-results-box .vcard {
plugins/solr/test/functional/.search_controller_test.rb.swp
No preview for this file type
plugins/solr/views/search/.communities.rhtml.swp
No preview for this file type
plugins/solr/views/search/.people.rhtml.swp
No preview for this file type
plugins/solr/views/search/_facets.html.erb
1 -<% if logged_in? %>  
2 - <% button_bar do %>  
3 - <%# FIXME shouldn't the user create the community in the current environment instead of going to its home environment? %>  
4 - <%= button(:add, __('New community'), user.url.merge(:controller => 'memberships', :action => 'new_community', :profile => user.identifier)) if @asset == :communities %>  
5 - <%= button(:add, __('New enterprise'), {:controller => 'enterprise_registration'}) if @asset == :enterprises && environment.enabled?('enterprise_registration') %>  
6 - <% end %>  
7 -<% end %>  
8 <% if !@empty_query %> 1 <% if !@empty_query %>
9 <%= facets_menu(@asset, @facets) %> 2 <%= facets_menu(@asset, @facets) %>
10 <% end %> 3 <% end %>
  4 +
plugins/solr/views/search/search_page.html.erb
@@ -3,17 +3,13 @@ @@ -3,17 +3,13 @@
3 3
4 <%= search_page_title( @titles[@asset], @category ) %> 4 <%= search_page_title( @titles[@asset], @category ) %>
5 5
6 -<% if !@empty_query %>  
7 - <div id='search-column-left'>  
8 - <%= render :partial => 'facets' %>  
9 - </div> 6 +<div id='search-column-left'>
  7 + <%= render :partial => 'facets' if !@empty_query %>
  8 +</div>
10 9
11 - <div id='search-column-right'>  
12 - <%= render :partial => 'results' %>  
13 - </div>  
14 -<% else %> 10 +<div id='search-column-right'>
15 <%= render :partial => 'results' %> 11 <%= render :partial => 'results' %>
16 -<% end %> 12 +</div>
17 13
18 <div style="clear: both"></div> 14 <div style="clear: both"></div>
19 15
plugins/spaminator/lib/spaminator_plugin/spaminator.rb
@@ -70,17 +70,17 @@ class SpaminatorPlugin::Spaminator @@ -70,17 +70,17 @@ class SpaminatorPlugin::Spaminator
70 self.class.log("Starting to process all comments") 70 self.class.log("Starting to process all comments")
71 comments = comments_to_process 71 comments = comments_to_process
72 total = comments.count 72 total = comments.count
73 - pbar = ProgressBar.new("☢ Comments", total) 73 + pbar = ProgressBar.new("☢ Comments", total) if Rails.env.development?
74 comments.each do |comment| 74 comments.each do |comment|
75 begin 75 begin
76 process_comment(comment) 76 process_comment(comment)
77 rescue 77 rescue
78 register_fail(:comments, comment) 78 register_fail(:comments, comment)
79 end 79 end
80 - pbar.inc 80 + pbar.inc if Rails.env.development?
81 end 81 end
82 @report.processed_comments = total 82 @report.processed_comments = total
83 - pbar.finish 83 + pbar.finish if Rails.env.development?
84 self.class.log("All comments processed") 84 self.class.log("All comments processed")
85 end 85 end
86 86
@@ -88,14 +88,14 @@ class SpaminatorPlugin::Spaminator @@ -88,14 +88,14 @@ class SpaminatorPlugin::Spaminator
88 self.class.log("Starting to process all people") 88 self.class.log("Starting to process all people")
89 people = people_to_process 89 people = people_to_process
90 total = people.count 90 total = people.count
91 - pbar = ProgressBar.new("☢ People", total) 91 + pbar = ProgressBar.new("☢ People", total) if Rails.env.development?
92 people.find_each do |person| 92 people.find_each do |person|
93 process_person_by_comments(person) 93 process_person_by_comments(person)
94 process_person_by_no_network(person) 94 process_person_by_no_network(person)
95 - pbar.inc 95 + pbar.inc if Rails.env.development?
96 end 96 end
97 @report.processed_people = total 97 @report.processed_people = total
98 - pbar.finish 98 + pbar.finish if Rails.env.development?
99 self.class.log("All people processed") 99 self.class.log("All people processed")
100 end 100 end
101 101
plugins/stoa/controllers/stoa_plugin_controller.rb
@@ -40,7 +40,7 @@ class StoaPluginController &lt; PublicController @@ -40,7 +40,7 @@ class StoaPluginController &lt; PublicController
40 40
41 def check_cpf 41 def check_cpf
42 begin 42 begin
43 - render :text => { :exists => !StoaPlugin::UspUser.find_by_codpes(params[:usp_id]).cpf.blank? }.to_json 43 + render :text => { :exists => StoaPlugin::UspUser.find_by_codpes(params[:usp_id]).cpf.present? }.to_json
44 rescue Exception => exception 44 rescue Exception => exception
45 render :text => { :exists => false, :error => {:message => exception.to_s, :backtrace => exception.backtrace} }.to_json 45 render :text => { :exists => false, :error => {:message => exception.to_s, :backtrace => exception.backtrace} }.to_json
46 end 46 end
plugins/stoa/install.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +require 'fileutils'
  2 +
  3 +config_path = File.join('plugins', 'stoa', 'config.yml')
  4 +config_template = File.join('plugins', 'stoa', 'config.yml.dist')
  5 +FileUtils.cp(config_template, config_path) if !File.exist?(config_path)
plugins/stoa/lib/ext/person.rb
@@ -16,7 +16,7 @@ class Person @@ -16,7 +16,7 @@ class Person
16 end 16 end
17 17
18 def invitation_task 18 def invitation_task
19 - Task.pending.find(:first, :conditions => {:code => invitation_code}) ||  
20 - Task.finished.find(:first, :conditions => {:code => invitation_code, :target_id => id}) 19 + Task.pending.find(:first, :conditions => {:code => invitation_code.to_s}) ||
  20 + Task.finished.find(:first, :conditions => {:code => invitation_code.to_s, :target_id => id})
21 end 21 end
22 end 22 end
plugins/stoa/lib/stoa_plugin.rb
1 require_dependency 'person' 1 require_dependency 'person'
2 -require_dependency 'ext/person'  
3 2
4 class StoaPlugin < Noosfero::Plugin 3 class StoaPlugin < Noosfero::Plugin
5 4
plugins/stoa/test/functional/profile_editor_controller_test.rb
@@ -36,7 +36,7 @@ class StoaPluginProfileEditorControllerTest &lt; ActionController::TestCase @@ -36,7 +36,7 @@ class StoaPluginProfileEditorControllerTest &lt; ActionController::TestCase
36 end 36 end
37 37
38 should 'not display field if profile is an organization' do 38 should 'not display field if profile is an organization' do
39 - organization = fast_create(Organization) 39 + organization = fast_create(Community)
40 organization.add_admin @person 40 organization.add_admin @person
41 get :edit, :profile => organization.identifier 41 get :edit, :profile => organization.identifier
42 assert_no_tag_in_string @response.body, :tag => 'label', :content => /USP number/, :attributes => { :for => 'usp_id_field' } 42 assert_no_tag_in_string @response.body, :tag => 'label', :content => /USP number/, :attributes => { :for => 'usp_id_field' }
plugins/stoa/test/functional/stoa_plugin_controller_test.rb
@@ -12,27 +12,12 @@ class StoaPluginControllerTest &lt; ActionController::TestCase @@ -12,27 +12,12 @@ class StoaPluginControllerTest &lt; ActionController::TestCase
12 @controller = StoaPluginController.new 12 @controller = StoaPluginController.new
13 @request = ActionController::TestRequest.new 13 @request = ActionController::TestRequest.new
14 @response = ActionController::TestResponse.new 14 @response = ActionController::TestResponse.new
15 - @db = Tempfile.new('stoa-test')  
16 - configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path}  
17 - ActiveRecord::Base.establish_connection(:stoa)  
18 - ActiveRecord::Schema.verbose = false  
19 - ActiveRecord::Schema.create_table "pessoa" do |t|  
20 - t.integer "codpes"  
21 - t.text "numcpf"  
22 - t.date "dtanas"  
23 - end  
24 - ActiveRecord::Base.establish_connection(:test) 15 + ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => ':memory:', :verbosity => 'quiet'}
25 env = Environment.default 16 env = Environment.default
26 env.enable_plugin(StoaPlugin.name) 17 env.enable_plugin(StoaPlugin.name)
27 env.enable('skip_new_user_email_confirmation') 18 env.enable('skip_new_user_email_confirmation')
28 env.save! 19 env.save!
29 @user = create_user_full('real_user', {:password => '123456', :password_confirmation => '123456'}, {:usp_id => 9999999}) 20 @user = create_user_full('real_user', {:password => '123456', :password_confirmation => '123456'}, {:usp_id => 9999999})
30 - StoaPlugin::UspUser.create!(:codpes => 12345678, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30')  
31 - end  
32 -  
33 - def teardown  
34 - @db.unlink  
35 - @user.destroy  
36 end 21 end
37 22
38 attr_accessor :user 23 attr_accessor :user
@@ -70,23 +55,39 @@ class StoaPluginControllerTest &lt; ActionController::TestCase @@ -70,23 +55,39 @@ class StoaPluginControllerTest &lt; ActionController::TestCase
70 end 55 end
71 56
72 should 'check valid usp id' do 57 should 'check valid usp id' do
73 - get :check_usp_id, :usp_id => '12345678' 58 + usp_id = '12345678'
  59 + StoaPlugin::UspUser.stubs(:exists?).with(usp_id).returns(true)
  60 + get :check_usp_id, :usp_id => usp_id
74 assert json_response['exists'] 61 assert json_response['exists']
75 end 62 end
76 63
77 should 'check invalid usp id' do 64 should 'check invalid usp id' do
78 - get :check_usp_id, :usp_id => '87654321' 65 + usp_id = '87654321'
  66 + StoaPlugin::UspUser.stubs(:exists?).with(usp_id).returns(false)
  67 + get :check_usp_id, :usp_id => usp_id
79 assert !json_response['exists'] 68 assert !json_response['exists']
80 end 69 end
81 70
82 should 'check existent cpf' do 71 should 'check existent cpf' do
83 - get :check_cpf, :usp_id => '12345678' 72 + usp_id = '12345678'
  73 + user = mock
  74 + user.stubs(:cpf).returns('12345678')
  75 + StoaPlugin::UspUser.stubs(:find_by_codpes).with(usp_id).returns(user)
  76 + get :check_cpf, :usp_id => usp_id
84 assert json_response['exists'] 77 assert json_response['exists']
85 end 78 end
86 79
87 should 'check not existent cpf' do 80 should 'check not existent cpf' do
88 - StoaPlugin::UspUser.create(:codpes => 87654321, :birth_date => '1970-01-30')  
89 - get :check_cpf, :usp_id => '87654321' 81 + usp_id_with_cpf = '12345678'
  82 + user_with_cpf = mock
  83 + user_with_cpf.stubs(:cpf).returns('12345678')
  84 + StoaPlugin::UspUser.stubs(:find_by_codpes).with(usp_id_with_cpf).returns(user_with_cpf)
  85 + get :check_cpf, :usp_id => usp_id_with_cpf
  86 + usp_id_without_cpf = '87654321'
  87 + user_without_cpf = mock
  88 + user_with_cpf.stubs(:cpf).returns(nil)
  89 + StoaPlugin::UspUser.stubs(:find_by_codpes).with(usp_id_without_cpf).returns(user_without_cpf)
  90 + get :check_cpf, :usp_id => usp_id_without_cpf
90 assert !json_response['exists'] 91 assert !json_response['exists']
91 end 92 end
92 93
plugins/sub_organizations/lib/ext/create_enterprise.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +require_dependency 'create_enterprise'
  2 +
  3 +class CreateEnterprise
  4 + settings_items :sub_organizations_plugin_parent_to_be
  5 +end
plugins/sub_organizations/lib/ext/organization.rb 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +require_dependency 'organization'
  2 +class Organization
  3 + settings_items :sub_organizations_plugin_parent_to_be
  4 +
  5 + after_create do |organization|
  6 + if organization.sub_organizations_plugin_parent_to_be.present?
  7 + parent = Organization.find(organization.sub_organizations_plugin_parent_to_be)
  8 + SubOrganizationsPlugin::Relation.add_children(parent,organization)
  9 + end
  10 + end
  11 +
  12 + FIELDS << 'sub_organizations_plugin_parent_to_be'
  13 +end
plugins/sub_organizations/lib/sub_organizations_plugin.rb
1 -require_dependency 'sub_organizations_plugin/ext/organization'  
2 -require_dependency 'sub_organizations_plugin/ext/create_enterprise'  
3 -  
4 class SubOrganizationsPlugin < Noosfero::Plugin 1 class SubOrganizationsPlugin < Noosfero::Plugin
5 2
6 def self.plugin_name 3 def self.plugin_name
plugins/sub_organizations/lib/sub_organizations_plugin/ext/create_enterprise.rb
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -require_dependency 'create_enterprise'  
2 -  
3 -class CreateEnterprise  
4 - settings_items :sub_organizations_plugin_parent_to_be  
5 -end  
plugins/sub_organizations/lib/sub_organizations_plugin/ext/organization.rb
@@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
1 -require_dependency 'organization'  
2 -class Organization  
3 - settings_items :sub_organizations_plugin_parent_to_be  
4 -  
5 - after_create do |organization|  
6 - if organization.sub_organizations_plugin_parent_to_be.present?  
7 - parent = Organization.find(organization.sub_organizations_plugin_parent_to_be)  
8 - SubOrganizationsPlugin::Relation.add_children(parent,organization)  
9 - end  
10 - end  
11 -  
12 - FIELDS << 'sub_organizations_plugin_parent_to_be'  
13 -end  
plugins/tolerance_time/lib/tolerance_time_plugin.rb
1 -require_dependency 'ext/article'  
2 -require_dependency 'ext/comment'  
3 -  
4 class ToleranceTimePlugin < Noosfero::Plugin 1 class ToleranceTimePlugin < Noosfero::Plugin
5 2
6 def self.plugin_name 3 def self.plugin_name
plugins/work_assignment/lib/work_assignment_plugin.rb
1 -require_dependency 'ext/uploaded_file'  
2 -  
3 class WorkAssignmentPlugin < Noosfero::Plugin 1 class WorkAssignmentPlugin < Noosfero::Plugin
4 2
5 def self.plugin_name 3 def self.plugin_name
@@ -32,7 +30,9 @@ class WorkAssignmentPlugin &lt; Noosfero::Plugin @@ -32,7 +30,9 @@ class WorkAssignmentPlugin &lt; Noosfero::Plugin
32 end 30 end
33 31
34 def content_remove_upload(content) 32 def content_remove_upload(content)
35 - !content.profile.members.include?(context.send(:user)) 33 + if content.kind_of?(WorkAssignmentPlugin::WorkAssignment)
  34 + !content.profile.members.include?(context.send(:user))
  35 + end
36 end 36 end
37 37
38 def content_viewer_controller_filters 38 def content_viewer_controller_filters