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
AUTHORS
... ... @@ -44,6 +44,7 @@ Antonio Terceiro <terceiro@colivre.coop.br>
44 44 Aurelio A. Heckert <aurelio@colivre.coop.br>
45 45 Braulio Bhavamitra <brauliobo@gmail.com>
46 46 Bráulio Bhavamitra <brauliobo@gmail.com>
  47 +Braulio Bhavamitra <braulio@eita.org.br>
47 48 Caio <caio.csalgado@gmail.com>
48 49 Caio + Diego + Pedro + João <caio.csalgado@gmail.com>
49 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 148 João M. M. Silva + Renan Teruo <jaodsilv@linux.ime.usp.br>
148 149 Joenio Costa <joenio@colivre.coop.br>
149 150 Josef Spillner <josef.spillner@tu-dresden.de>
  151 +Junior Silva <juniorsilva7@juniorsilva-Aspire-5750Z.(none)>
150 152 Keilla Menezes <keilla@colivre.coop.br>
151 153 Larissa Reis <larissa@colivre.coop.br>
152 154 Larissa Reis <reiss.larissa@gmail.com>
... ...
app/helpers/boxes_helper.rb
... ... @@ -99,9 +99,9 @@ module BoxesHelper
99 99 unless block.visible?
100 100 options[:title] = _("This block is invisible. Your visitors will not see it.")
101 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 105 box_decorator.block_target(block.box, block) +
106 106 content_tag('div',
107 107 content_tag('div',
... ...
app/helpers/cms_helper.rb
... ... @@ -28,7 +28,7 @@ module CmsHelper
28 28 end
29 29  
30 30 def link_to_article(article)
31   - article_name = short_filename(article.title, 30)
  31 + article_name = article.title
32 32 if article.folder?
33 33 link_to article_name, {:action => 'view', :id => article.id}, :class => icon_for_article(article)
34 34 else
... ...
app/models/action_tracker_notification.rb
... ... @@ -3,7 +3,7 @@ class ActionTrackerNotification &lt; ActiveRecord::Base
3 3 belongs_to :profile
4 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 8 validates_presence_of :profile_id, :action_tracker_id
9 9 validates_uniqueness_of :action_tracker_id, :scope => :profile_id
... ...
app/models/article.rb
... ... @@ -57,7 +57,7 @@ class Article &lt; ActiveRecord::Base
57 57 has_many :article_categorizations, :conditions => [ 'articles_categories.virtual = ?', false ]
58 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 61 has_many :categories_including_virtual, :through => :article_categorizations_including_virtual, :source => :category
62 62  
63 63 acts_as_having_settings :field => :setting
... ...
app/models/category.rb
... ... @@ -22,23 +22,15 @@ class Category &lt; ActiveRecord::Base
22 22  
23 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 25 acts_as_filesystem
34 26  
35   - has_many :article_categorizations, :dependent => :destroy
  27 + has_many :article_categorizations
36 28 has_many :articles, :through => :article_categorizations
37 29 has_many :comments, :through => :articles
38 30  
39 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 34 has_many :profiles, :through => :profile_categorizations, :source => :profile
43 35 has_many :enterprises, :through => :profile_categorizations, :source => :profile, :class_name => 'Enterprise'
44 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 7  
8 8 before_save do |block|
9 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 13 end
13 14 block.groups_of = block.groups_of.to_i
14 15 end
... ...
app/models/person.rb
... ... @@ -471,8 +471,9 @@ class Person &lt; Profile
471 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 472 end
473 473  
  474 + # by default, all fields are private
474 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 477 end
477 478  
478 479 protected
... ...
app/models/region.rb
... ... @@ -8,9 +8,9 @@ class Region &lt; Category
8 8 validators.count > 0
9 9 end
10 10  
11   - named_scope :with_validators, :group => 'id',
  11 + named_scope :with_validators, :select => 'DISTINCT ON (categories.id) *',
12 12 :joins => 'INNER JOIN region_validators on (region_validators.region_id = categories.id)'
13   -
  13 +
14 14 end
15 15  
16 16 require_dependency 'city'
... ...
app/sweepers/profile_sweeper.rb
... ... @@ -4,7 +4,7 @@ class ProfileSweeper # &lt; ActiveRecord::Observer
4 4 include SweeperHelper
5 5  
6 6 def after_update(profile)
7   - expire_caches(profile)
  7 + self.delay.expire_caches profile
8 8 end
9 9  
10 10 def after_create(profile)
... ...
app/views/cms/view.rhtml
... ... @@ -41,7 +41,7 @@
41 41 <% end %>
42 42  
43 43 <% @articles.each do |article| article = FilePresenter.for article %>
44   - <tr>
  44 + <tr title="<%= article.title%>" >
45 45 <td class="article-name">
46 46 <%= link_to_article(article) %>
47 47 </td>
... ...
app/views/profile/_person_profile.rhtml
... ... @@ -18,18 +18,6 @@
18 18 <% cache_timeout(profile.relationships_cache_key, 4.hours) do %>
19 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 21 <tr>
34 22 <th colspan='2'><%= _('Network')%></th>
35 23 </tr>
... ... @@ -41,6 +29,12 @@
41 29 <td><%= __('Communities') + ':' %></td>
42 30 <td><%= link_to profile.communities.count, :controller => "profile", :action => 'communities' %></td>
43 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 39 <%= render :partial => 'common' %>
46 40  
... ...
app/views/profile_members/_members_list.rhtml
... ... @@ -10,7 +10,7 @@
10 10 <th><%= _('Actions') %></th>
11 11 </tr>
12 12 <% collection.each do |m| %>
13   - <tr>
  13 + <tr title="<%= m.name %>">
14 14 <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td>
15 15 <td>
16 16 <div class="members-buttons-cell">
... ...
app/views/search/_full_article.html.erb
1 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 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => article %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <%= render :partial => 'article_common', :object => article %>
8 12 </table>
... ...
app/views/search/_full_blog.html.erb
1 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 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => blog %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <tr class="search-blog-items">
8 12 <td class="search-field-label"><%= _("Last posts") %></td>
... ...
app/views/search/_full_event.html.erb
1 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 29 </li>
... ...
app/views/search/_full_folder.html.erb
1 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 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => folder %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <tr class="search-folder-items">
8 12 <td class="search-field-label"><%= _("Last items") %></td>
... ...
app/views/search/_full_forum.html.erb
1 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 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => forum %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <tr class="search-forum-items">
8 12 <td class="search-field-label"><%= _("Last topics") %></td>
... ...
app/views/search/_full_gallery.html.erb
1 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 6 <div class="search-content-first-column">
4 7 <%= render :partial => 'image', :object => gallery %>
5 8 </div>
  9 +
6 10 <table class="noborder search-content-second-column">
7 11 <%= render :partial => 'article_common', :object => gallery %>
8 12 </table>
... ...
app/views/search/_full_text_article.html.erb
1 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 6 <div class="search-content-first-column">
5 7 <%= render :partial => 'image', :object => text_article %>
... ...
app/views/search/_full_uploaded_file.html.erb
1 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 6 <div class="search-content-first-column">
5 7 <%= render :partial => 'image', :object => uploaded_file %>
... ...
app/views/shared/tiny_mce.rhtml
... ... @@ -70,7 +70,7 @@ tinyMCE.init({
70 70 paste_insert_word_content_callback : "convertWord",
71 71 paste_use_dialog: false,
72 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 74 content_css: '/stylesheets/tinymce.css,<%= macro_css_files %>',
75 75 language: <%= tinymce_language.inspect %>,
76 76 entity_encoding: 'raw',
... ...
config/environment.rb
... ... @@ -85,10 +85,10 @@ Rails::Initializer.run do |config|
85 85 }
86 86  
87 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 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 93 # See Rails::Configuration for more options
94 94  
... ...
db/schema.rb
... ... @@ -221,7 +221,6 @@ ActiveRecord::Schema.define(:version =&gt; 20130711213046) do
221 221 t.string "source_type"
222 222 t.string "user_agent"
223 223 t.string "referrer"
224   - t.integer "group_id"
225 224 end
226 225  
227 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 7 noosfero (0.44.3) unstable; urgency=low
2 8  
3 9 * Bugfixes release
... ...
features/edit_article.feature
... ... @@ -64,8 +64,8 @@ Feature: edit article
64 64 And I fill in "Tag list" with "aurium, bug"
65 65 And I press "Save"
66 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 70 Scenario: redirect to the created article
71 71 Given I am on joaosilva's control panel
... ...
features/last_administrator_leaving.feature
... ... @@ -17,7 +17,7 @@ Feature: remove administrator role
17 17 Scenario: the last administrator removes his administrator role and must choose the new administrator
18 18 Given "Maria Souza" is a member of "Nice people"
19 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 21 And I uncheck "Profile Administrator"
22 22 When I press "Save changes"
23 23 Then I should see "Since you are the last administrator, you must choose"
... ...
features/plugins.feature
... ... @@ -22,27 +22,27 @@ Feature: plugins
22 22 | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } |
23 23  
24 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 26 And I go to joaosilva's control panel
27 27 Then I should see "Test plugin button"
28 28  
29 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 31 And I am on joaosilva's profile
32 32 Then I should see "Test plugin tab"
33 33  
34 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 36 And I go to joaosilva's control panel
37 37 Then I should not see "Test plugin button"
38 38  
39 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 41 And I am on joaosilva's profile
42 42 Then I should not see "Test plugin tab"
43 43  
44 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 46 And I am logged in as admin
47 47 When I go to admin_user's control panel
48 48 Then I should see "Test plugin button"
... ...
features/search_communities.feature
... ... @@ -4,7 +4,8 @@ Feature: search communities
4 4 In order to find ones that interest me
5 5  
6 6 Background:
7   - Given the following category
  7 + Given plugin Solr is enabled on environment
  8 + And the following category
8 9 | name |
9 10 | social network |
10 11 And the following community
... ...
features/short_filename.feature
... ... @@ -18,4 +18,4 @@ Feature: sitemap
18 18 Scenario: view the CMS
19 19 Given I am logged in as "joaosilva"
20 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 44 end
45 45 if category && !category.blank?
46 46 cat = Category.find_by_slug category
47   - organization.categories << cat
  47 + ProfileCategorization.add_category_to_profile(cat, organization)
48 48 end
49 49 if img_name
50 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 23  
24 24 Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status|
25 25 e = Environment.default
  26 + plugin = "#{plugin}Plugin"
26 27 if status == 'enabled'
27 28 e.enabled_plugins += [plugin]
28 29 else
... ...
lib/noosfero.rb
... ... @@ -3,7 +3,7 @@ require &#39;fast_gettext&#39;
3 3  
4 4 module Noosfero
5 5 PROJECT = 'noosfero'
6   - VERSION = '0.44.3'
  6 + VERSION = '0.44.4'
7 7  
8 8 def self.pattern_for_controllers_in_directory(dir)
9 9 disjunction = controllers_in_directory(dir).join('|')
... ...
lib/noosfero/plugin.rb
... ... @@ -64,6 +64,9 @@ class Noosfero::Plugin
64 64 require init.gsub(/.rb$/, '') if File.file? init
65 65 end
66 66  
  67 + # load extensions
  68 + Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file }
  69 +
67 70 # load class
68 71 klass(plugin_name)
69 72 end
... ...
plugins/bsc/install.rb 0 → 100644
... ... @@ -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 1 class BscPlugin < Noosfero::Plugin
5 2  
6 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 1 class CommentGroupPlugin < Noosfero::Plugin
5 2  
6 3 def self.plugin_name
... ...
plugins/comment_group/lib/comment_group_plugin/ext/article.rb
... ... @@ -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   -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 @@
  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 @@
  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 10  
11 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 26 end
... ...
plugins/custom_forms/db/migrate/20130822001407_set_position_to_existent_custom_forms_plugin_fields.rb 0 → 100644
... ... @@ -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 1 class CustomFormsPlugin < Noosfero::Plugin
4 2  
5 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 15  
16 16 before_create do |field|
17 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 19 end
20 20 end
  21 +
  22 + def position
  23 + self[:position] || 0
  24 + end
21 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 81 assert_equal 1, field_1.position
82 82 assert_equal 2, field_2.position
83 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 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 41 Article.delete_all
42 42 get :index, :block_id => block.id
43 43 json_response = ActiveSupport::JSON.decode(@response.body)
44   - assert_equal [], json_response
  44 + assert_equivalent [], json_response
45 45 end
46 46  
47 47 should 'index action returns an json with node content' do
... ... @@ -53,7 +53,7 @@ class DisplayContentPluginAdminControllerTest &lt; ActionController::TestCase
53 53 expected_json = {'data' => article.title}
54 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 57 end
58 58  
59 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 68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
69 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 72 end
73 73  
74 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 84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'})
85 85 expected_json['children'] = []
86 86  
87   - assert_equal [expected_json], json_response
  87 + assert_equivalent [expected_json], json_response
88 88 end
89 89  
90 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 98 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
99 99 expected_json['state'] = 'closed'
100 100  
101   - assert_equal [expected_json], json_response
  101 + assert_equivalent [expected_json], json_response
102 102 end
103 103  
104 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 121 expected_json['children'] = children
122 122 expected_json['state'] = 'closed'
123 123  
124   - assert_equal [expected_json], json_response
  124 + assert_equivalent [expected_json], json_response
125 125 end
126 126  
127 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 151 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
152 152 expected_json.push(value)
153 153  
154   - assert_equal expected_json, json_response
  154 + assert_equivalent expected_json, json_response
155 155 end
156 156  
157 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 173 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
174 174 expected_json.push(value)
175 175  
176   - assert_equal expected_json, json_response
  176 + assert_equivalent expected_json, json_response
177 177 end
178 178  
179 179 end
... ...
plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
... ... @@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
41 41 Article.delete_all
42 42 get :index, :block_id => block.id, :profile => profile.identifier
43 43 json_response = ActiveSupport::JSON.decode(@response.body)
44   - assert_equal [], json_response
  44 + assert_equivalent [], json_response
45 45 end
46 46  
47 47 should 'index action returns an json with node content' do
... ... @@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest &lt; ActionController::TestCase
53 53 expected_json = {'data' => article.title}
54 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 57 end
58 58  
59 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 68 expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id}
69 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 72 end
73 73  
74 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 84 expected_json['attr'].merge!({'class' => 'jstree-undetermined'})
85 85 expected_json['children'] = []
86 86  
87   - assert_equal [expected_json], json_response
  87 + assert_equivalent [expected_json], json_response
88 88 end
89 89  
90 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 99 expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id}
100 100 expected_json['state'] = 'closed'
101 101  
102   - assert_equal [expected_json], json_response
  102 + assert_equivalent [expected_json], json_response
103 103 end
104 104  
105 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 122 expected_json['children'] = children
123 123 expected_json['state'] = 'closed'
124 124  
125   - assert_equal [expected_json], json_response
  125 + assert_equivalent [expected_json], json_response
126 126 end
127 127  
128 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 152 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
153 153 expected_json.push(value)
154 154  
155   - assert_equal expected_json, json_response
  155 + assert_equivalent expected_json, json_response
156 156 end
157 157  
158 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 174 value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id}
175 175 expected_json.push(value)
176 176  
177   - assert_equal expected_json, json_response
  177 + assert_equivalent expected_json, json_response
178 178 end
179 179  
180 180 end
... ...
plugins/foo/lib/ext/profile.rb 0 → 100644
... ... @@ -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 1 class FooPlugin < Noosfero::Plugin
4 2  
5 3 def self.plugin_name
... ...
plugins/foo/lib/foo_plugin/ext/profile.rb
... ... @@ -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 1 class GoogleAnalyticsPlugin < Noosfero::Plugin
4 2  
5 3 include ActionView::Helpers::JavaScriptHelper
... ...
plugins/ldap/dependencies.rb
  1 +require 'rubygems'
1 2 require 'net/ldap'
... ...
plugins/ldap/install.rb 0 → 100644
... ... @@ -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 1 require File.dirname(__FILE__) + '/ldap_authentication.rb'
3 2  
4   -
5 3 class LdapPlugin < Noosfero::Plugin
6 4  
7 5 def self.plugin_name
... ...
plugins/mezuro/install.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +raise "Not ready yet"
... ...
plugins/pg_search/lib/pg_search_plugin.rb
1   -require 'ext/active_record'
2   -
3 1 class PgSearchPlugin < Noosfero::Plugin
4 2  
5 3 def self.plugin_name
... ...
plugins/require_auth_to_comment/lib/ext/profile.rb 0 → 100644
... ... @@ -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 1 class RequireAuthToCommentPlugin < Noosfero::Plugin
4 2  
5 3 include ActionView::Helpers::TagHelper
... ...
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin/ext/profile.rb
... ... @@ -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 And I am logged in as "joaosilva"
8 8  
9 9 Scenario: expand macro in article content
10   - Given plugin SendEmailPlugin is enabled on environment
  10 + Given plugin SendEmail is enabled on environment
11 11 And the following articles
12 12 | owner | name | body |
13 13 | joaosilva | sample-article | URL path to {sendemail} action |
... ... @@ -15,7 +15,7 @@ Feature: send_email_plugin
15 15 Then I should see "URL path to /profile/joaosilva/plugin/send_email/deliver action"
16 16  
17 17 Scenario: expand macro in block content
18   - Given plugin SendEmailPlugin is enabled on environment
  18 + Given plugin SendEmail is enabled on environment
19 19 And the following blocks
20 20 | owner | type | html |
21 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 63  
64 64 def treat_delivery_options(params)
65 65 result = {}
  66 + return result if params.nil? || params[:delivery_options].nil?
66 67 params[:options].size.times do |counter|
67 68 if params[:options][counter].present? && params[:prices][counter].present?
68 69 result[params[:options][counter]] = params[:prices][counter]
... ...
plugins/shopping_cart/lib/ext/enterprise.rb 0 → 100644
... ... @@ -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 @@
  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 1 class ShoppingCartPlugin < Noosfero::Plugin
5 2  
6 3 class << self
... ...
plugins/shopping_cart/lib/shopping_cart_plugin/ext/enterprise.rb
... ... @@ -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   -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 38 value = 13.7
39 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 42 end
43 43  
44 44 end
... ...
plugins/shopping_cart/test/unit/shopping_cart_plugin_test.rb
... ... @@ -19,10 +19,9 @@ class ShoppingCartPluginTest &lt; ActiveSupport::TestCase
19 19 end
20 20  
21 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 24 enterprise.stubs(:shopping_cart).returns(true)
25   - product.stubs(:enterprise).returns(enterprise)
26 25  
27 26 assert_nil shopping_cart.add_to_cart_button(product)
28 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 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And the following users
9 10 Given the following users
10 11 | login | name |
... ...
plugins/solr/features/search_enterprises.feature
... ... @@ -5,6 +5,7 @@ Feature: search enterprises
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And the following enterprises
9 10 | identifier | name | img |
10 11 | shop1 | Shoes shop | shoes |
... ... @@ -12,6 +13,7 @@ Feature: search enterprises
12 13 And the following categories as facets
13 14 | name |
14 15 | Temáticas |
  16 +
15 17 Scenario: see default facets when searching
16 18 When I go to the search enterprises page
17 19 And I fill in "search-input" with "shoes"
... ... @@ -34,10 +36,10 @@ Feature: search enterprises
34 36 When I go to the search enterprises page
35 37 And I fill in "search-input" with "Artesanato"
36 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 44 Scenario: find enterprise by region
43 45 Given the following cities
... ...
plugins/solr/features/search_people.feature
... ... @@ -5,6 +5,7 @@ Feature: search people
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And the following users
9 10 | login | name |
10 11 | joaosilva | Joao Silva |
... ...
plugins/solr/features/search_products.feature
... ... @@ -5,6 +5,7 @@ Feature: search products
5 5  
6 6 Background:
7 7 Given the search index is empty
  8 + And plugin Solr is enabled on environment
8 9 And feature "disable_asset_products" is disabled on environment
9 10 And the following enterprises
10 11 | identifier | name |
... ...
plugins/solr/features/step_definitions/solr_steps.rb
... ... @@ -13,6 +13,6 @@ Given /^the following categories as facets$/ do |table|
13 13 ids << cat.id
14 14 end
15 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 17 env.save!
18 18 end
... ...
plugins/solr/install.rb 0 → 100644
... ... @@ -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 6  
7 7 include SolrPlugin::SearchHelper
8 8  
9   - delegate :params, :current_user, :to => :context
10   -
11 9 def self.plugin_name
12 10 "Solr"
13 11 end
... ... @@ -28,11 +26,16 @@ class SolrPlugin &lt; Noosfero::Plugin
28 26 return if empty_query?(query, category) && klass != Product
29 27  
30 28 solr_options = solr_options(class_asset(klass), category)
31   - user = context.send(:logged_in?) ? context.send(:user) : nil
32 29 solr_options.merge!(products_options(user)) if klass == Product && empty_query?(query, category)
33 30 klass.find_by_contents(query, paginate_options, solr_options.merge(options))
34 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 54 end
55 55  
56 56 def results_only?
57   - context.params[:action] == 'index'
  57 + params[:action] == 'index'
58 58 end
59 59  
60 60 def empty_query?(query, category)
... ... @@ -84,18 +84,18 @@ module SolrPlugin::SearchHelper
84 84 solr_options = {}
85 85 if !multiple_search?
86 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 88 solr_options[:all_facets] = true
89 89 end
90 90 solr_options[:filter_queries] ||= []
91 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 93 solr_options[:filter_queries] << asset_class.facet_category_query.call(category) if category
94 94  
95 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 99 raise "Unknown order by" if order.nil?
100 100 order[:solr_opts].each do |opt, value|
101 101 solr_options[opt] = value.is_a?(Proc) ? instance_eval(&value) : value
... ...
plugins/solr/public/style.css
1 1 .controller-search #search-column-right .search-field .formfield {
2 2 width: 594px;
3   - display: inline-block;
  3 + display: inline;
4 4 }
5 5  
6 6 #search-column-right .search-customize-options {
7   - position: absolute;
8 7 margin: 0;
9 8 padding: 5px 0;
10   - bottom: 0;
11   - left: 0;
12 9 }
13 10  
14 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 1 <% if !@empty_query %>
9 2 <%= facets_menu(@asset, @facets) %>
10 3 <% end %>
  4 +
... ...
plugins/solr/views/search/search_page.html.erb
... ... @@ -3,17 +3,13 @@
3 3  
4 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 11 <%= render :partial => 'results' %>
16   -<% end %>
  12 +</div>
17 13  
18 14 <div style="clear: both"></div>
19 15  
... ...
plugins/spaminator/lib/spaminator_plugin/spaminator.rb
... ... @@ -70,17 +70,17 @@ class SpaminatorPlugin::Spaminator
70 70 self.class.log("Starting to process all comments")
71 71 comments = comments_to_process
72 72 total = comments.count
73   - pbar = ProgressBar.new("☢ Comments", total)
  73 + pbar = ProgressBar.new("☢ Comments", total) if Rails.env.development?
74 74 comments.each do |comment|
75 75 begin
76 76 process_comment(comment)
77 77 rescue
78 78 register_fail(:comments, comment)
79 79 end
80   - pbar.inc
  80 + pbar.inc if Rails.env.development?
81 81 end
82 82 @report.processed_comments = total
83   - pbar.finish
  83 + pbar.finish if Rails.env.development?
84 84 self.class.log("All comments processed")
85 85 end
86 86  
... ... @@ -88,14 +88,14 @@ class SpaminatorPlugin::Spaminator
88 88 self.class.log("Starting to process all people")
89 89 people = people_to_process
90 90 total = people.count
91   - pbar = ProgressBar.new("☢ People", total)
  91 + pbar = ProgressBar.new("☢ People", total) if Rails.env.development?
92 92 people.find_each do |person|
93 93 process_person_by_comments(person)
94 94 process_person_by_no_network(person)
95   - pbar.inc
  95 + pbar.inc if Rails.env.development?
96 96 end
97 97 @report.processed_people = total
98   - pbar.finish
  98 + pbar.finish if Rails.env.development?
99 99 self.class.log("All people processed")
100 100 end
101 101  
... ...
plugins/stoa/controllers/stoa_plugin_controller.rb
... ... @@ -40,7 +40,7 @@ class StoaPluginController &lt; PublicController
40 40  
41 41 def check_cpf
42 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 44 rescue Exception => exception
45 45 render :text => { :exists => false, :error => {:message => exception.to_s, :backtrace => exception.backtrace} }.to_json
46 46 end
... ...
plugins/stoa/install.rb 0 → 100644
... ... @@ -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 16 end
17 17  
18 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 21 end
22 22 end
... ...
plugins/stoa/lib/stoa_plugin.rb
1 1 require_dependency 'person'
2   -require_dependency 'ext/person'
3 2  
4 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 36 end
37 37  
38 38 should 'not display field if profile is an organization' do
39   - organization = fast_create(Organization)
  39 + organization = fast_create(Community)
40 40 organization.add_admin @person
41 41 get :edit, :profile => organization.identifier
42 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 12 @controller = StoaPluginController.new
13 13 @request = ActionController::TestRequest.new
14 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 16 env = Environment.default
26 17 env.enable_plugin(StoaPlugin.name)
27 18 env.enable('skip_new_user_email_confirmation')
28 19 env.save!
29 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 21 end
37 22  
38 23 attr_accessor :user
... ... @@ -70,23 +55,39 @@ class StoaPluginControllerTest &lt; ActionController::TestCase
70 55 end
71 56  
72 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 61 assert json_response['exists']
75 62 end
76 63  
77 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 68 assert !json_response['exists']
80 69 end
81 70  
82 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 77 assert json_response['exists']
85 78 end
86 79  
87 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 91 assert !json_response['exists']
91 92 end
92 93  
... ...
plugins/sub_organizations/lib/ext/create_enterprise.rb 0 → 100644
... ... @@ -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 @@
  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 1 class SubOrganizationsPlugin < Noosfero::Plugin
5 2  
6 3 def self.plugin_name
... ...
plugins/sub_organizations/lib/sub_organizations_plugin/ext/create_enterprise.rb
... ... @@ -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   -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 1 class ToleranceTimePlugin < Noosfero::Plugin
5 2  
6 3 def self.plugin_name
... ...
plugins/work_assignment/lib/work_assignment_plugin.rb
1   -require_dependency 'ext/uploaded_file'
2   -
3 1 class WorkAssignmentPlugin < Noosfero::Plugin
4 2  
5 3 def self.plugin_name
... ... @@ -32,7 +30,9 @@ class WorkAssignmentPlugin &lt; Noosfero::Plugin
32 30 end
33 31  
34 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 36 end
37 37  
38 38 def content_viewer_controller_filters
... ...
plugins/work_assignment/test/functional/content_viewer_controller_test.rb
... ... @@ -10,6 +10,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
10 10 @controller = ContentViewerController.new
11 11 @request = ActionController::TestRequest.new
12 12 @response = ActionController::TestResponse.new
  13 + @profile = create_user('testinguser').person
13 14  
14 15 @organization = fast_create(Organization)
15 16 @work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => @organization)
... ... @@ -19,7 +20,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
19 20 @environment.save!
20 21 login_as(:test_user)
21 22 end
22   - attr_reader :organization, :person, :work_assignment
  23 + attr_reader :organization, :person, :profile, :work_assignment
23 24  
24 25 should 'can download work_assignment' do
25 26 random_member = fast_create(Person)
... ... @@ -38,4 +39,11 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
38 39 assert_response :success
39 40 end
40 41  
  42 + should "display 'Upload files' when create children of image gallery" do
  43 + login_as(profile.identifier)
  44 + f = Gallery.create!(:name => 'gallery', :profile => profile)
  45 + xhr :get, :view_page, :profile => profile.identifier, :page => f.explode_path, :toolbar => true
  46 + assert_tag :tag => 'a', :content => 'Upload files', :attributes => {:href => /parent_id=#{f.id}/}
  47 + end
  48 +
41 49 end
... ...
public/stylesheets/application.css
... ... @@ -1448,7 +1448,9 @@ a.comment-picture {
1448 1448 display: inline;
1449 1449 }
1450 1450 #content #boxes .box-1 .article-block img,
1451   -#content #article .article-body img {
  1451 +#content #article .article-body img,
  1452 +#content #article .article-body video,
  1453 +#content #article .article-body audio {
1452 1454 max-width: 100%;
1453 1455 height: auto;
1454 1456 }
... ... @@ -3099,15 +3101,38 @@ div#activation_enterprise label, div#activation_enterprise input, div#activation
3099 3101  
3100 3102 /* ==> public/stylesheets/controller_cms.css <== */
3101 3103  
  3104 +table.cms-articles {
  3105 + table-layout: fixed;
  3106 + width: 100%;
  3107 +}
  3108 +
  3109 +table.cms-articles td:first-child,
  3110 +table.cms-articles th:first-child {
  3111 + width: 50%;
  3112 +}
  3113 +
  3114 +table.cms-articles td:nth-child(2) {
  3115 + font-size: 10px;
  3116 +}
  3117 +
  3118 +table.cms-articles td:last-child,
  3119 +table.cms-articles th:last-child {
  3120 + width: 121px;
  3121 +}
3102 3122  
3103 3123 table.cms-articles img {
3104 3124 width: 16px;
3105 3125 height: 16px;
3106 3126 }
  3127 +
3107 3128 table.cms-articles a.icon {
3108 3129 display: block;
3109 3130 border: none;
  3131 + white-space: nowrap;
  3132 + overflow: hidden;
  3133 + text-overflow: ellipsis;
3110 3134 }
  3135 +
3111 3136 table.cms-articles a.icon, table.cms-articles a.icon-parent-folder {
3112 3137 padding: 0px 0px 3px 20px;
3113 3138 background-repeat: no-repeat;
... ... @@ -3116,6 +3141,17 @@ table.cms-articles .icon:hover {
3116 3141 background-color: transparent;
3117 3142 }
3118 3143  
  3144 +#content table.cms-articles .button:hover,
  3145 +#content table.cms-articles .button {
  3146 + margin: 0;
  3147 + float: left;
  3148 + border-right: none;
  3149 +}
  3150 +
  3151 +#content table.cms-articles .button:last-child {
  3152 + border-right: 1px solid #ccc;
  3153 +}
  3154 +
3119 3155 .select-article-type {
3120 3156 padding: 5px 20px;
3121 3157 width: 455px;
... ...
public/stylesheets/search.css
... ... @@ -753,19 +753,13 @@ li.search-product-item hr {
753 753 .search-content-first-column {
754 754 width: 130px;
755 755 min-height: 98px;
756   - position: absolute;
757   -}
758   -.search-gallery .search-content-first-column {
759   - width: 190px;
  756 + float: left;
760 757 }
761 758  
762 759 .search-content-second-column {
763 760 margin-left: 140px;
764 761 width: auto;
765 762 }
766   -.search-gallery .search-content-second-column {
767   - margin-left: 200px;
768   -}
769 763  
770 764 .search-content-second-column tr:hover {
771 765 background-color: none;
... ... @@ -789,7 +783,7 @@ ul.clean-list .search-content-second-column {
789 783 width:795px;
790 784 }
791 785 ul.clean-list .search-gallery-content {
792   - width:655px
  786 + width:655px;
793 787 }
794 788 a.search-image-pic {
795 789 border: 1px solid #F2F2F2;
... ... @@ -819,7 +813,7 @@ a.search-image-pic {
819 813 font-weight: bold;
820 814 text-transform: uppercase;
821 815 letter-spacing: 1px;
822   - user-select: none;
  816 + user-select: none;
823 817 border-radius: 5px;
824 818 -moz-user-select: none;
825 819 -khtml-user-select: none;
... ... @@ -844,8 +838,9 @@ a.search-image-pic {
844 838 .search-gallery .search-gallery-items {
845 839 float: left;
846 840 margin: 0;
847   - min-width: 130px;
  841 + width: 130px;
848 842 position: relative;
  843 + overflow: hidden;
849 844 }
850 845  
851 846 .search-gallery .search-gallery-items a.search-image-pic {
... ...
script/install-dependencies/debian-squeeze.sh
... ... @@ -4,7 +4,7 @@ run sudo apt-get -y install $runtime_dependencies
4 4 sudo apt-get -y install iceweasel || sudo apt-get -y install firefox
5 5  
6 6 # needed for development
7   -run sudo apt-get -y install libtidy-ruby libhpricot-ruby libmocha-ruby imagemagick po4a xvfb libxml2-dev libxslt-dev
  7 +run sudo apt-get -y install libtidy-ruby libhpricot-ruby libmocha-ruby imagemagick po4a xvfb libxml2-dev libxslt-dev postgresql
8 8 gem which bundler >/dev/null 2>&1 || gem_install bundler
9 9 setup_rubygems_path
10 10 run bundle install
... ...
script/noosfero-plugins
... ... @@ -86,12 +86,18 @@ _enable(){
86 86 echo "E: $plugin plugin does not exist!"
87 87 return
88 88 fi
89   - dependencies_ok=true
90   - dependencies_file="$source/dependencies.rb"
91   - if ! run $dependencies_file; then
92   - dependencies_ok=false
  89 + installation_ok=true
  90 + installation_file="$source/install.rb"
  91 + if ! run $installation_file; then
  92 + installation_ok=false
  93 + else
  94 + dependencies_ok=true
  95 + dependencies_file="$source/dependencies.rb"
  96 + if ! run $dependencies_file; then
  97 + dependencies_ok=false
  98 + fi
93 99 fi
94   - if [ "$dependencies_ok" = true ]; then
  100 + if [ "$installation_ok" = true ] && [ "$dependencies_ok" = true ]; then
95 101 ln -s "$source" "$target"
96 102 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
97 103 plugins_features_dir="$NOOSFERO_DIR/features/plugins"
... ... @@ -100,7 +106,9 @@ _enable(){
100 106 _say "$plugin enabled"
101 107 run "$source/after_enable.rb"
102 108 needs_migrate=true
103   - else
  109 + elif [ "$installation_ok" = false ]; then
  110 + echo "W: failed to install $plugin; not enabling"
  111 + elif [ "$dependencies_ok" = false ]; then
104 112 echo "W: failed to load dependencies for $plugin; not enabling"
105 113 fi
106 114 fi
... ...
script/quick-start
... ... @@ -67,7 +67,10 @@ else
67 67 fi
68 68  
69 69 # create the database with sample data
70   -run cp config/database.yml.sqlite3 config/database.yml
  70 +run cp config/database.yml.pgsql config/database.yml
  71 +sudo -u postgres createuser $USER --no-superuser --createdb --no-createrole
  72 +sed -ri "s/username: noosfero/username: $USER/"
  73 +sudo -u postgres createdb noosfero_development -O $USER
71 74 run rake db:schema:load
72 75 run rake db:data:minimal
73 76 run rake db:test:prepare
... ...
test/functional/account_controller_test.rb
... ... @@ -190,7 +190,7 @@ class AccountControllerTest &lt; ActionController::TestCase
190 190 post :change_password, :current_password => 'test', :new_password => 'blabla', :new_password_confirmation => 'blabla'
191 191 assert_response :redirect
192 192 assert_redirected_to :action => 'index'
193   - assert User.find_by_login('ze').authenticated?('blabla')
  193 + assert assigns(:current_user).authenticated?('blabla')
194 194 assert_equal users(:ze), @controller.send(:current_user)
195 195 end
196 196  
... ...
test/functional/profile_controller_test.rb
... ... @@ -308,7 +308,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
308 308  
309 309 should 'not display contact us for non-enterprises' do
310 310 @profile.boxes.first.blocks << block = ProfileInfoBlock.create!
311   - get :profile_info, :profile => @profile, :block_id => block.id
  311 + get :profile_info, :profile => @profile.identifier, :block_id => block.id
312 312 assert_no_match /\/contact\/#{@profile.identifier}\/new/, @response.body
313 313 end
314 314  
... ... @@ -987,12 +987,12 @@ class ProfileControllerTest &lt; ActionController::TestCase
987 987 @controller.stubs(:current_user).returns(user)
988 988 Person.any_instance.stubs(:follows?).returns(true)
989 989 get :index, :profile => c.identifier
990   - assert_equal [s2,s3], assigns(:activities)
  990 + assert_equivalent [s2,s3], assigns(:activities)
991 991 end
992 992  
993 993 should 'the activities be paginated in people profiles' do
994 994 p1 = Person.first
995   - 40.times{fast_create(Scrap, :sender_id => p1.id, :created_at => Time.now)}
  995 + 40.times{fast_create(Scrap, :receiver_id => p1.id, :created_at => Time.now)}
996 996  
997 997 @controller.stubs(:logged_in?).returns(true)
998 998 user = mock()
... ... @@ -1606,4 +1606,25 @@ class ProfileControllerTest &lt; ActionController::TestCase
1606 1606 assert_no_match /Test enterprise_2/, links.to_s
1607 1607 end
1608 1608 end
  1609 +
  1610 + should 'show enterprises field if enterprises are enabled on environment' do
  1611 + person = fast_create(Person)
  1612 + environment = person.environment
  1613 + environment.disable('disable_asset_enterprises')
  1614 + environment.save!
  1615 +
  1616 + get :index, :profile => person.identifier
  1617 + assert_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" }
  1618 + end
  1619 +
  1620 + should 'not show enterprises field if enterprises are disabled on environment' do
  1621 + person = fast_create(Person)
  1622 + environment = person.environment
  1623 + environment.enable('disable_asset_enterprises')
  1624 + environment.save!
  1625 +
  1626 + get :index, :profile => person.identifier
  1627 + assert_no_tag :tag => 'tr', :attributes => { :id => "person-profile-network-enterprises" }
  1628 + end
  1629 +
1609 1630 end
... ...
test/functional/search_controller_test.rb
... ... @@ -425,7 +425,7 @@ class SearchControllerTest &lt; ActionController::TestCase
425 425 should 'show link to article asset in the see all foot link of the articles block in the category page' do
426 426 (1..SearchController::MULTIPLE_SEARCH_LIMIT+1).each do |i|
427 427 a = create_user("test#{i}").person.articles.create!(:name => "article #{i} to be found")
428   - a.categories << @category
  428 + ArticleCategorization.add_category_to_article(@category, a)
429 429 end
430 430  
431 431 get :category_index, :category_path => [ 'my-category' ]
... ... @@ -608,11 +608,11 @@ class SearchControllerTest &lt; ActionController::TestCase
608 608  
609 609 get :tag, :tag => 'two'
610 610  
611   - assert_equal [a, a2], assigns(:searches)[:tag][:results]
  611 + assert_equivalent [a, a2], assigns(:searches)[:tag][:results]
612 612  
613 613 get :tag, :tag => 'one'
614 614  
615   - assert_equal [a], assigns(:searches)[:tag][:results]
  615 + assert_equivalent [a], assigns(:searches)[:tag][:results]
616 616 end
617 617  
618 618 should 'not show assets from other environments' do
... ...
test/integration/assets_menu_test.rb
... ... @@ -17,7 +17,8 @@ class AssetsMenuTest &lt; ActionController::IntegrationTest
17 17  
18 18 should 'link to assets inside category root' do
19 19 (1..SearchController::MULTIPLE_SEARCH_LIMIT+1).each do |i|
20   - ent = @category.enterprises.create! :identifier => "ent#{i}", :name => "enterprise#{i}"
  20 + enterprise = Enterprise.create! :identifier => "ent#{i}", :name => "enterprise#{i}"
  21 + ProfileCategorization.add_category_to_profile(@category, enterprise)
21 22 end
22 23  
23 24 get '/cat/parent-category/category-a'
... ...
test/integration/performance_test.rb
... ... @@ -52,28 +52,6 @@ class PerformanceTest &lt; ActionController::IntegrationTest
52 52 a2 = (time2.total - time1.total)/50.0
53 53 assert a1 > a2*FACTOR, "#{a1} should be larger than #{a2} by at least a factor of #{FACTOR}"
54 54 end
55   -
56   - should 'not have a linear increase in time to save enterprise due to amount of products' do
57   - $DISABLE_DELAYED_JOB_TEST_ENV_RUN = true
58   - enterprise0 = Enterprise.create!(:name => 'Enterprise 0', :identifier => 'enterprise0')
59   - enterprise1 = Enterprise.create!(:name => 'Enterprise 1', :identifier => 'enterprise1')
60   - enterprise2 = Enterprise.create!(:name => 'Enterprise 2', :identifier => 'enterprise2')
61   -
62   - create_products(enterprise1,25)
63   - create_products(enterprise2,50)
64   -
65   - enterprise0.reload
66   - enterprise1.reload
67   - enterprise2.reload
68   -
69   - time0 = (Benchmark.measure { 10.times { enterprise0.save! } }).total
70   - time1 = (Benchmark.measure { 10.times { enterprise1.save! } }).total
71   - time2 = (Benchmark.measure { 10.times { enterprise2.save! } }).total
72   -
73   - assert (time1 - time0) < time0*0.5
74   - assert (time2 - time0) < time0*0.5
75   - end
76   -
77 55 protected
78 56  
79 57 def create_profile(name)
... ... @@ -91,13 +69,5 @@ class PerformanceTest &lt; ActionController::IntegrationTest
91 69 end
92 70 end
93 71  
94   - def create_products(enterprise,n)
95   - number = Product.all.count
96   - pc = ProductCategory.create!(:name => "Any Category #{n}", :environment => Environment.default)
97   - n.times do |i|
98   - Product.create!(:enterprise => enterprise, :product_category => pc, :name => "Product #{i+number+1}")
99   - end
100   - end
101   -
102 72 end
103 73  
... ...
test/unit/acts_as_filesystem_test.rb
... ... @@ -80,7 +80,11 @@ class ActsAsFilesystemTest &lt; ActiveSupport::TestCase
80 80 article2 = Article.create!(:name => 'article 2', :profile => profile, :parent => folder)
81 81 folder.reload
82 82  
83   - assert_equal [folder, article1, article2], folder.map_traversal
  83 + items = folder.map_traversal
  84 +
  85 + assert_includes items, folder
  86 + assert_includes items, article1
  87 + assert_includes items, article2
84 88 end
85 89  
86 90 should 'allow dots in slug' do
... ...
test/unit/article_test.rb
... ... @@ -165,21 +165,6 @@ class ArticleTest &lt; ActiveSupport::TestCase
165 165 end
166 166 end
167 167  
168   - should 'search for recent documents' do
169   - other_profile = create_user('otherpropfile').person
170   -
171   - first = fast_create(TextArticle, :profile_id => profile.id, :name => 'first')
172   - second = fast_create(TextArticle, :profile_id => profile.id, :name => 'second')
173   - third = fast_create(TextArticle, :profile_id => profile.id, :name => 'third')
174   - fourth = fast_create(TextArticle, :profile_id => profile.id, :name => 'fourth')
175   - fifth = fast_create(TextArticle, :profile_id => profile.id, :name => 'fifth')
176   -
177   - other_first = other_profile.articles.build(:name => 'first'); other_first.save!
178   -
179   - assert_equal [other_first, fifth, fourth], Article.recent(3)
180   - assert_equal [other_first, fifth, fourth, third, second, first], Article.recent(6)
181   - end
182   -
183 168 should 'not show private documents as recent' do
184 169 p = create_user('usr1').person
185 170 Article.destroy_all
... ... @@ -342,16 +327,15 @@ class ArticleTest &lt; ActiveSupport::TestCase
342 327  
343 328 should 'list most commented articles' do
344 329 Article.delete_all
345   - (1..4).each do |n|
346   - create(TextileArticle, :name => "art #{n}", :profile_id => profile.id)
347   - end
348   - first_article = profile.articles.first
349   - 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => first_article).save! }
  330 + a1 = create(TextileArticle, :name => "art 1", :profile_id => profile.id)
  331 + a2 = create(TextileArticle, :name => "art 2", :profile_id => profile.id)
  332 + a3 = create(TextileArticle, :name => "art 3", :profile_id => profile.id)
  333 +
  334 + 2.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a2).save! }
  335 + 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => a3).save! }
350 336  
351   - last_article = profile.articles.last
352   - 4.times { Comment.create(:title => 'test', :body => 'asdsad', :author => profile, :source => last_article).save! }
353 337 # should respect the order (more commented comes first)
354   - assert_equal [last_article, first_article], profile.articles.most_commented(2)
  338 + assert_equal [a3, a2, a1], profile.articles.most_commented(3)
355 339 end
356 340  
357 341 should 'identify itself as a non-folder' do
... ... @@ -449,8 +433,15 @@ class ArticleTest &lt; ActiveSupport::TestCase
449 433 owner = create_user('testuser').person
450 434 art = owner.articles.create!(:name => 'ytest')
451 435 art.category_ids = [c2,c3,c3].map(&:id)
452   - assert_equal [c2, c3], art.categories(true)
453   - assert_equal [c2, c1, c3], art.categories_including_virtual(true)
  436 +
  437 + categories = art.categories(true)
  438 + categories_including_virtual = art.categories_including_virtual(true)
  439 + assert_not_includes categories, c1
  440 + assert_includes categories, c2
  441 + assert_includes categories, c3
  442 + assert_includes categories_including_virtual, c1
  443 + assert_includes categories_including_virtual, c2
  444 + assert_includes categories_including_virtual, c3
454 445 end
455 446  
456 447 should 'not accept Product category as category' do
... ... @@ -1305,11 +1296,15 @@ class ArticleTest &lt; ActiveSupport::TestCase
1305 1296  
1306 1297 should 'rotate translations when root article is destroyed' do
1307 1298 native_article = fast_create(Article, :language => 'pt', :profile_id => @profile.id)
1308   - translation1 = fast_create(Article, :language => 'en', :translation_of_id => native_article.id, :profile_id => @profile.id)
1309   - translation2 = fast_create(Article, :language => 'es', :translation_of_id => native_article.id, :profile_id => @profile.id)
  1299 + fast_create(Article, :language => 'en', :translation_of_id => native_article.id, :profile_id => @profile.id)
  1300 + fast_create(Article, :language => 'es', :translation_of_id => native_article.id, :profile_id => @profile.id)
  1301 +
  1302 + new_root = native_article.translations.first
  1303 + child = (native_article.translations - [new_root]).first
1310 1304 native_article.destroy
1311   - assert translation1.translation_of.nil?
1312   - assert translation1.translations.include?(translation2)
  1305 +
  1306 + assert new_root.translation_of.nil?
  1307 + assert new_root.translations.include?(child)
1313 1308 end
1314 1309  
1315 1310 should 'rotate one translation when root article is destroyed' do
... ... @@ -1569,7 +1564,7 @@ class ArticleTest &lt; ActiveSupport::TestCase
1569 1564 c4 = fast_create(RssFeed, :name => 'Testing article 4', :body => 'Article body 4', :profile_id => profile.id)
1570 1565 c5 = fast_create(TextileArticle, :name => 'Testing article 5', :body => 'Article body 5', :profile_id => profile.id)
1571 1566  
1572   - assert_equal [c1,c2,c5], Article.text_articles
  1567 + assert_equivalent [c1,c2,c5], Article.text_articles
1573 1568 end
1574 1569  
1575 1570 should 'delegate region info to profile' do
... ...
test/unit/category_test.rb
... ... @@ -350,7 +350,7 @@ class CategoryTest &lt; ActiveSupport::TestCase
350 350 p1.add_category c
351 351 p2 = create_user('testuser_2').person
352 352 p2.add_category c
353   - assert_equal [p1, p2], c.people
  353 + assert_equivalent [p1, p2], c.people
354 354 end
355 355  
356 356 should 'have communities' do
... ... @@ -359,7 +359,7 @@ class CategoryTest &lt; ActiveSupport::TestCase
359 359 c1.add_category c
360 360 c2 = fast_create(Community, :name => 'testcommunity_2')
361 361 c2.add_category c
362   - assert_equal [c1, c2], c.communities
  362 + assert_equivalent [c1, c2], c.communities
363 363 end
364 364  
365 365 should 'have products through enteprises' do
... ... @@ -488,12 +488,16 @@ class CategoryTest &lt; ActiveSupport::TestCase
488 488 end
489 489  
490 490 should 'paginate upcoming events' do
  491 + Event.destroy_all
491 492 category = Category.create!(:name => 'category1', :environment_id => Environment.default.id)
492 493 profile = fast_create(Profile)
493   - event1 = category.events.build(:name => 'event1', :start_date => Time.now, :profile => profile)
494   - event2 = category.events.build(:name => 'event2', :start_date => Time.now + 1.hour, :profile => profile)
495   - event3 = category.events.build(:name => 'event3', :start_date => Time.now + 1.day, :profile => profile)
496   - category.save!
  494 + event1 = Event.create!(:name => 'event1', :profile => profile, :start_date => Time.now)
  495 + event2 = Event.create!(:name => 'event2', :profile => profile, :start_date => Time.now + 1.day)
  496 + event3 = Event.create!(:name => 'event3', :profile => profile, :start_date => Time.now + 2.days)
  497 + ArticleCategorization.add_category_to_article(category, event1)
  498 + ArticleCategorization.add_category_to_article(category, event2)
  499 + ArticleCategorization.add_category_to_article(category, event3)
  500 +
497 501 assert_equal [event1, event2], category.upcoming_events(2)
498 502 end
499 503  
... ... @@ -537,38 +541,4 @@ class CategoryTest &lt; ActiveSupport::TestCase
537 541 assert_includes Category.on_level(parent.id), category
538 542 end
539 543  
540   - should 'list category sub-categories' do
541   - c1 = Category.create!(:name => 'Category 1', :environment => Environment.default)
542   - c2 = Category.create!(:name => 'Category 2', :environment => Environment.default)
543   - c3 = Category.create!(:name => 'Category 3', :environment => Environment.default, :parent_id => c1)
544   - c4 = Category.create!(:name => 'Category 4', :environment => Environment.default, :parent_id => c1)
545   - c5 = Category.create!(:name => 'Category 5', :environment => Environment.default, :parent_id => c3)
546   -
547   - sub_categories = Category.sub_categories(c1)
548   -
549   - assert ActiveRecord::NamedScope::Scope, sub_categories.class
550   - assert_not_includes sub_categories, c1
551   - assert_not_includes sub_categories, c2
552   - assert_includes sub_categories, c3
553   - assert_includes sub_categories, c4
554   - assert_includes sub_categories, c5
555   - end
556   -
557   - should 'list category sub-tree' do
558   - c1 = Category.create!(:name => 'Category 1', :environment => Environment.default)
559   - c2 = Category.create!(:name => 'Category 2', :environment => Environment.default)
560   - c3 = Category.create!(:name => 'Category 3', :environment => Environment.default, :parent_id => c1)
561   - c4 = Category.create!(:name => 'Category 4', :environment => Environment.default, :parent_id => c1)
562   - c5 = Category.create!(:name => 'Category 5', :environment => Environment.default, :parent_id => c3)
563   -
564   - sub_tree = Category.sub_tree(c1)
565   -
566   - assert ActiveRecord::NamedScope::Scope, sub_tree.class
567   - assert_includes sub_tree, c1
568   - assert_not_includes sub_tree, c2
569   - assert_includes sub_tree, c3
570   - assert_includes sub_tree, c4
571   - assert_includes sub_tree, c5
572   - end
573   -
574 544 end
... ...
test/unit/cms_helper_test.rb
... ... @@ -112,9 +112,6 @@ class CmsHelperTest &lt; ActiveSupport::TestCase
112 112  
113 113 result = display_delete_button(article)
114 114 end
115   -
116   - def link_to(text, *args); puts text; puts args.inspect; text; end
117   -
118 115 end
119 116  
120 117 module RssFeedHelper
... ...
test/unit/featured_products_block_test.rb
... ... @@ -129,7 +129,11 @@ class FeaturedProductsBlockTest &lt; ActiveSupport::TestCase
129 129 })
130 130 @environment.boxes.first.blocks<< block
131 131  
132   - assert_equal products, block.products_for_selection
  132 + products_for_selection = block.products_for_selection
  133 +
  134 + products.each do |product|
  135 + assert_includes products_for_selection, product
  136 + end
133 137 end
134 138  
135 139 end
... ...
test/unit/feed_handler_test.rb
... ... @@ -124,6 +124,8 @@ class FeedHandlerTest &lt; ActiveSupport::TestCase
124 124 # after disabled period, tries to process the container again
125 125 last_error = Time.now
126 126 Time.stubs(:now).returns(last_error + FeedHandler.disabled_period + 1.second)
  127 + handler.expects(:actually_process_container).with(container)
  128 + container.expects(:finish_fetch)
127 129 handler.process(container)
128 130  
129 131 assert container.enabled, 'must reenable container after <disabled_period> (%s)' % container_class
... ...
test/unit/organization_test.rb
... ... @@ -408,8 +408,10 @@ class OrganizationTest &lt; ActiveSupport::TestCase
408 408  
409 409 organization.affiliate(p1, role)
410 410 organization.affiliate(p2, role)
  411 + json = organization.members_by_role_to_json(role)
411 412  
412   - assert_match [{:id => p1.id, :name => p1.name}, {:id => p2.id, :name => p2.name}].to_json, organization.members_by_role_to_json(role)
  413 + assert_match ({:id => p1.id, :name => p1.name}).to_json, json
  414 + assert_match ({:id => p2.id, :name => p2.name}).to_json, json
413 415 end
414 416  
415 417 should 'disable organization' do
... ...
test/unit/person_test.rb
... ... @@ -55,7 +55,7 @@ class PersonTest &lt; ActiveSupport::TestCase
55 55  
56 56 p1 = u.person
57 57 assert_equal u, p1.user
58   -
  58 +
59 59 p2 = Person.new(:environment => Environment.default)
60 60 p2.user = u
61 61 assert !p2.valid?
... ... @@ -202,7 +202,7 @@ class PersonTest &lt; ActiveSupport::TestCase
202 202 should 'have friends' do
203 203 p1 = create_user('testuser1').person
204 204 p2 = create_user('testuser2').person
205   -
  205 +
206 206 p1.add_friend(p2)
207 207  
208 208 p1.friends.reload
... ... @@ -237,7 +237,7 @@ class PersonTest &lt; ActiveSupport::TestCase
237 237 p2 = create_user('testuser2').person
238 238 p3 = create_user('testuser3').person
239 239 p4 = create_user('testuser4').person
240   -
  240 +
241 241 p1.add_friend(p2, 'group1')
242 242 p1.add_friend(p3, 'group2')
243 243 p1.add_friend(p4, 'group1')
... ... @@ -248,7 +248,7 @@ class PersonTest &lt; ActiveSupport::TestCase
248 248 should 'not suggest duplicated friend groups' do
249 249 p1 = create_user('testuser1').person
250 250 p2 = create_user('testuser2').person
251   -
  251 +
252 252 p1.add_friend(p2, 'friends')
253 253  
254 254 assert_equal p1.suggested_friend_groups, p1.suggested_friend_groups.uniq
... ... @@ -307,7 +307,7 @@ class PersonTest &lt; ActiveSupport::TestCase
307 307 assert_equal 'my contact', person.contact_information
308 308 end
309 309  
310   - should 'provide desired info fields' do
  310 + should 'provide desired info fields' do
311 311 p = Person.new(:environment => Environment.default)
312 312 assert p.respond_to?(:photo)
313 313 assert p.respond_to?(:address)
... ... @@ -472,7 +472,7 @@ class PersonTest &lt; ActiveSupport::TestCase
472 472 should 'require custom_area_of_study if area_of_study is others' do
473 473 e = Environment.default
474 474 e.expects(:required_person_fields).returns(['area_of_study', 'custom_area_of_study']).at_least_once
475   -
  475 +
476 476 person = Person.new(:environment => e, :area_of_study => 'Others')
477 477 assert !person.valid?
478 478 assert person.errors.invalid?(:custom_area_of_study)
... ... @@ -507,7 +507,7 @@ class PersonTest &lt; ActiveSupport::TestCase
507 507 should 'not require custom_formation if formation is not others' do
508 508 e = Environment.default
509 509 e.expects(:required_person_fields).returns(['formation']).at_least_once
510   -
  510 +
511 511 person = Person.new(:environment => e, :formation => 'Agrometeorology')
512 512 assert !person.valid?
513 513 assert ! person.errors.invalid?(:custom_formation)
... ... @@ -819,7 +819,8 @@ class PersonTest &lt; ActiveSupport::TestCase
819 819 end
820 820  
821 821 should "the tracked action be notified to person friends and herself" do
822   - p1 = Person.first
  822 + Person.destroy_all
  823 + p1 = fast_create(Person)
823 824 p2 = fast_create(Person)
824 825 p3 = fast_create(Person)
825 826 p4 = fast_create(Person)
... ... @@ -829,14 +830,14 @@ class PersonTest &lt; ActiveSupport::TestCase
829 830 assert !p1.is_a_friend?(p3)
830 831 p1.add_friend(p4)
831 832 assert p1.is_a_friend?(p4)
832   -
833   - action_tracker = fast_create(ActionTracker::Record)
  833 +
  834 + action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id)
834 835 ActionTrackerNotification.delete_all
835   - count = ActionTrackerNotification.count
836 836 Delayed::Job.destroy_all
837   - Person.notify_activity(action_tracker)
838   - process_delayed_job_queue
839   - assert_equal count + 3, ActionTrackerNotification.count
  837 + assert_difference ActionTrackerNotification, :count, 3 do
  838 + Person.notify_activity(action_tracker)
  839 + process_delayed_job_queue
  840 + end
840 841 ActionTrackerNotification.all.map{|a|a.profile}.map do |profile|
841 842 [p1,p2,p4].include?(profile)
842 843 end
... ... @@ -853,7 +854,7 @@ class PersonTest &lt; ActiveSupport::TestCase
853 854 assert !p1.is_a_friend?(p3)
854 855 p1.add_friend(p4)
855 856 assert p1.is_a_friend?(p4)
856   -
  857 +
857 858 action_tracker = fast_create(ActionTracker::Record)
858 859  
859 860 assert_difference(Delayed::Job, :count, 1) do
... ... @@ -862,7 +863,7 @@ class PersonTest &lt; ActiveSupport::TestCase
862 863 end
863 864  
864 865 should "the tracked action notify friends with one delayed job process" do
865   - p1 = Person.first
  866 + p1 = fast_create(Person)
866 867 p2 = fast_create(Person)
867 868 p3 = fast_create(Person)
868 869 p4 = fast_create(Person)
... ... @@ -872,8 +873,8 @@ class PersonTest &lt; ActiveSupport::TestCase
872 873 assert !p1.is_a_friend?(p3)
873 874 p1.add_friend(p4)
874 875 assert p1.is_a_friend?(p4)
875   -
876   - action_tracker = fast_create(ActionTracker::Record)
  876 +
  877 + action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id)
877 878  
878 879 Delayed::Job.delete_all
879 880 assert_difference(Delayed::Job, :count, 1) do
... ... @@ -885,8 +886,9 @@ class PersonTest &lt; ActiveSupport::TestCase
885 886 end
886 887  
887 888 should "the community tracked action be notified to the author and to community members" do
888   - p1 = Person.first
  889 + Person.destroy_all
889 890 community = fast_create(Community)
  891 + p1 = fast_create(Person)
890 892 p2 = fast_create(Person)
891 893 p3 = fast_create(Person)
892 894  
... ... @@ -896,7 +898,7 @@ class PersonTest &lt; ActiveSupport::TestCase
896 898 assert p3.is_member_of?(community)
897 899 assert !p2.is_member_of?(community)
898 900 process_delayed_job_queue
899   -
  901 +
900 902 action_tracker = fast_create(ActionTracker::Record, :verb => 'create_article')
901 903 action_tracker.target = community
902 904 action_tracker.save!
... ... @@ -924,7 +926,7 @@ class PersonTest &lt; ActiveSupport::TestCase
924 926 community.add_member(p4)
925 927 assert p4.is_member_of?(community)
926 928 assert !p2.is_member_of?(community)
927   -
  929 +
928 930 action_tracker = fast_create(ActionTracker::Record)
929 931 article = mock()
930 932 action_tracker.stubs(:target).returns(article)
... ... @@ -1048,8 +1050,8 @@ class PersonTest &lt; ActiveSupport::TestCase
1048 1050 person_1.add_friend(person_2)
1049 1051 person_1.add_friend(person_3)
1050 1052 person_1.add_friend(person_4)
1051   - assert_equal [person_2, person_3, person_4], person_1.friends
1052   - assert_equal [person_2, person_4], person_1.friends.online
  1053 + assert_equivalent [person_2, person_3, person_4], person_1.friends
  1054 + assert_equivalent [person_2, person_4], person_1.friends.online
1053 1055 end
1054 1056  
1055 1057 should 'compose bare jabber id by login plus default hostname' do
... ... @@ -1222,9 +1224,11 @@ class PersonTest &lt; ActiveSupport::TestCase
1222 1224 end
1223 1225  
1224 1226 should 'return tracked_actions and scraps as activities' do
  1227 + ActionTracker::Record.destroy_all
1225 1228 person = fast_create(Person)
1226 1229 another_person = fast_create(Person)
1227 1230  
  1231 + UserStampSweeper.any_instance.stubs(:current_user).returns(another_person)
1228 1232 scrap = Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => person, :content => 'A scrap'))
1229 1233 UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once
1230 1234 article = TinyMceArticle.create!(:profile => person, :name => 'An article about free software')
... ... @@ -1233,12 +1237,14 @@ class PersonTest &lt; ActiveSupport::TestCase
1233 1237 end
1234 1238  
1235 1239 should 'not return tracked_actions and scraps from others as activities' do
  1240 + ActionTracker::Record.destroy_all
1236 1241 person = fast_create(Person)
1237 1242 another_person = fast_create(Person)
1238 1243  
1239 1244 person_scrap = Scrap.create!(defaults_for_scrap(:sender => person, :receiver => person, :content => 'A scrap from person'))
1240 1245 another_person_scrap = Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => another_person, :content => 'A scrap from another person'))
1241 1246  
  1247 + UserStampSweeper.any_instance.stubs(:current_user).returns(another_person)
1242 1248 TinyMceArticle.create!(:profile => another_person, :name => 'An article about free software from another person')
1243 1249 another_person_activity = ActionTracker::Record.last
1244 1250  
... ... @@ -1271,12 +1277,10 @@ class PersonTest &lt; ActiveSupport::TestCase
1271 1277 assert person.has_permission?('bli', Profile.new)
1272 1278 end
1273 1279  
1274   - should 'active fields are public if fields privacy is nil' do
  1280 + should 'active fields are private if fields privacy is nil' do
1275 1281 p = fast_create(Person)
1276 1282 p.expects(:fields_privacy).returns(nil)
1277   - f = %w(sex birth_date)
1278   - p.expects(:active_fields).returns(f)
1279   - assert_equal f, p.public_fields
  1283 + assert_equal [], p.public_fields
1280 1284 end
1281 1285  
1282 1286 should 'return public fields' do
... ...
test/unit/plugin_test.rb
... ... @@ -28,25 +28,6 @@ class PluginTest &lt; ActiveSupport::TestCase
28 28 assert_equal({:controller => 'plugin_test/plugin1_admin', :action => 'index'}, Plugin1.admin_url)
29 29 end
30 30  
31   - should 'filter comments with scope defined by plugin' do
32   - class Plugin1 < Noosfero::Plugin
33   - def filter_comments(scope)
34   - scope.without_spam
35   - end
36   - end
37   -
38   - article = fast_create(Article)
39   - c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
40   - c2 = fast_create(Comment, :source_id => article.id)
41   - c3 = fast_create(Comment, :source_id => article.id, :spam => true)
42   -
43   - plugin = Plugin1.new
44   - comments = plugin.filter_comments(article.comments)
45   - assert_includes comments, c1
46   - assert_includes comments, c2
47   - assert_not_includes comments, c3
48   - end
49   -
50 31 should 'returns empty hash for class method extra_blocks by default if no blocks are defined on plugin' do
51 32  
52 33 class SomePlugin1 < Noosfero::Plugin
... ...
test/unit/profile_test.rb
... ... @@ -517,7 +517,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
517 517  
518 518 should 'be able to create a profile with categories' do
519 519 pcat = create(Category)
520   - c1 = create(Category, :parent_id => pcat)
  520 + c1 = create(Category, :parent_id => pcat.id)
521 521 c2 = create(Category)
522 522  
523 523 profile = create(Profile, :category_ids => [c1.id, c2.id])
... ... @@ -713,8 +713,8 @@ class ProfileTest &lt; ActiveSupport::TestCase
713 713 c3 = fast_create(Category, :parent_id => c1.id)
714 714 profile = fast_create(Profile)
715 715 profile.category_ids = [c2,c3,c3].map(&:id)
716   - assert_equal [c2, c3], profile.categories(true)
717   - assert_equal [c2, c1, c3], profile.categories_including_virtual(true)
  716 + assert_equivalent [c2, c3], profile.categories(true)
  717 + assert_equivalent [c1, c2, c3], profile.categories_including_virtual(true)
718 718 end
719 719  
720 720 should 'not return nil members when a member is removed from system' do
... ...
test/unit/recent_documents_block_test.rb
... ... @@ -4,6 +4,7 @@ class RecentDocumentsBlockTest &lt; ActiveSupport::TestCase
4 4  
5 5 def setup
6 6 @profile = create_user('testinguser').person
  7 + @profile.articles.destroy_all
7 8 ['first', 'second', 'third', 'fourth', 'fifth'].each do |name|
8 9 @profile.articles << TextArticle.create(:name => name)
9 10 end
... ... @@ -24,7 +25,7 @@ class RecentDocumentsBlockTest &lt; ActiveSupport::TestCase
24 25  
25 26 should 'output list with links to recent documents' do
26 27 output = block.content
27   -
  28 +
28 29 assert_match /href=.*\/testinguser\/first/, output
29 30 assert_match /href=.*\/testinguser\/second/, output
30 31 assert_match /href=.*\/testinguser\/third/, output
... ...
test/unit/scrap_test.rb
1 1 require File.join(File.dirname(__FILE__), '..', 'test_helper')
2 2  
3 3 class ScrapTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + Person.delete_all
  7 + Scrap.delete_all
  8 + end
  9 +
4 10 should "have the content" do
5 11 s = Scrap.new
6 12 s.valid?
... ... @@ -81,7 +87,7 @@ class ScrapTest &lt; ActiveSupport::TestCase
81 87 end
82 88  
83 89 should "create the leave_scrap action tracker verb on scrap creation of one user to another" do
84   - p1 = ActionTracker::Record.current_user_from_model
  90 + p1 = fast_create(Person)
85 91 p2 = fast_create(Person)
86 92 s = Scrap.new
87 93 s.sender= p1
... ... @@ -98,7 +104,7 @@ class ScrapTest &lt; ActiveSupport::TestCase
98 104 end
99 105  
100 106 should "create the leave_scrap action tracker verb on scrap creation of one user to community" do
101   - p = Person.first
  107 + p = fast_create(Person)
102 108 c = fast_create(Community)
103 109 s = Scrap.new
104 110 s.sender= p
... ... @@ -116,11 +122,11 @@ class ScrapTest &lt; ActiveSupport::TestCase
116 122 end
117 123  
118 124 should "notify leave_scrap action tracker verb to friends and itself" do
119   - p1 = ActionTracker::Record.current_user_from_model
  125 + p1 = fast_create(Person)
120 126 p2 = fast_create(Person)
121 127 p1.add_friend(p2)
122   - ActionTrackerNotification.destroy_all
123   - Delayed::Job.destroy_all
  128 + ActionTrackerNotification.delete_all
  129 + Delayed::Job.delete_all
124 130 s = Scrap.new
125 131 s.sender= p1
126 132 s.receiver= p2
... ... @@ -134,11 +140,11 @@ class ScrapTest &lt; ActiveSupport::TestCase
134 140 end
135 141  
136 142 should "notify leave_scrap action tracker verb to members of the communities and the community itself" do
137   - p = Person.first
  143 + p = fast_create(Person)
138 144 c = fast_create(Community)
139 145 c.add_member(p)
140   - ActionTrackerNotification.destroy_all
141   - Delayed::Job.destroy_all
  146 + ActionTrackerNotification.delete_all
  147 + Delayed::Job.delete_all
142 148 s = Scrap.new
143 149 s.sender= p
144 150 s.receiver= c
... ... @@ -152,25 +158,25 @@ class ScrapTest &lt; ActiveSupport::TestCase
152 158 end
153 159  
154 160 should "create the leave_scrap_to_self action tracker verb on scrap creation of one user to itself" do
155   - p1 = Person.first
  161 + p = fast_create(Person)
156 162 s = Scrap.new
157   - s.sender= p1
158   - s.receiver= p1
  163 + s.sender= p
  164 + s.receiver= p
159 165 s.content = 'some content'
160 166 s.save!
161 167 ta = ActionTracker::Record.last
162 168 assert_equal s.content, ta.params['content']
163 169 assert_equal s.sender.name, ta.params['sender_name']
164 170 assert_equal 'leave_scrap_to_self', ta.verb
165   - assert_equal p1, ta.user
  171 + assert_equal p, ta.user
166 172 end
167 173  
168 174 should "notify leave_scrap_to_self action tracker verb to friends and itself" do
169   - p1 = Person.first
  175 + p1 = fast_create(Person)
170 176 p2 = fast_create(Person)
171 177 p1.add_friend(p2)
172   - ActionTrackerNotification.destroy_all
173   - Delayed::Job.destroy_all
  178 + ActionTrackerNotification.delete_all
  179 + Delayed::Job.delete_all
174 180 s = Scrap.new
175 181 s.sender= p1
176 182 s.receiver= p1
... ... @@ -200,7 +206,6 @@ class ScrapTest &lt; ActiveSupport::TestCase
200 206 end
201 207  
202 208 should "remove the replies is the root is removed" do
203   - Scrap.delete_all
204 209 s = fast_create(Scrap)
205 210 s1 = fast_create(Scrap, :scrap_id => s.id)
206 211 s2 = fast_create(Scrap, :scrap_id => s.id)
... ... @@ -211,11 +216,10 @@ class ScrapTest &lt; ActiveSupport::TestCase
211 216 end
212 217  
213 218 should "update the scrap on reply creation" do
214   - Scrap.delete_all
  219 + person = fast_create(Person)
215 220 s = fast_create(Scrap, :updated_at => DateTime.parse('2010-01-01'))
216 221 assert_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d')
217   - DateTime.stubs(:now).returns(DateTime.parse('2010-09-07'))
218   - s1 = Scrap.create(defaults_for_scrap(:scrap_id => s.id))
  222 + s1 = Scrap.create!(:content => 'some content', :sender => person, :receiver => person, :scrap_id => s.id)
219 223 s.reload
220 224 assert_not_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d')
221 225 end
... ...
test/unit/task_test.rb
... ... @@ -182,7 +182,7 @@ class TaskTest &lt; ActiveSupport::TestCase
182 182 t2.finish
183 183 t3 = Task.create!
184 184  
185   - assert_equal [t1,t3], Task.pending
  185 + assert_equivalent [t1,t3], Task.pending
186 186 end
187 187  
188 188 should 'be able to list finished tasks' do
... ... @@ -324,10 +324,10 @@ class TaskTest &lt; ActiveSupport::TestCase
324 324  
325 325 should 'order tasks by some attribute correctly' do
326 326 Task.destroy_all
327   - t1 = fast_create(Task, :status => 4, :created_at => 1)
328   - t2 = fast_create(Task, :status => 3, :created_at => 2)
329   - t3 = fast_create(Task, :status => 2, :created_at => 3)
330   - t4 = fast_create(Task, :status => 1, :created_at => 4)
  327 + t1 = fast_create(Task, :status => 4, :created_at => Time.now + 1.hour)
  328 + t2 = fast_create(Task, :status => 3, :created_at => Time.now + 2.hour)
  329 + t3 = fast_create(Task, :status => 2, :created_at => Time.now + 3.hour)
  330 + t4 = fast_create(Task, :status => 1, :created_at => Time.now + 4.hour)
331 331  
332 332 assert_equal [t1,t2,t3,t4], Task.order_by('created_at', 'asc')
333 333 assert_equal [t4,t3,t2,t1], Task.order_by('created_at', 'desc')
... ...
test/unit/tiny_mce_article_test.rb
... ... @@ -224,4 +224,16 @@ end
224 224 assert TinyMceArticle.new.tiny_mce?
225 225 end
226 226  
  227 + should 'not sanitize html5 audio tag on body' do
  228 + article = TinyMceArticle.create!(:name => 'html5 audio', :body => "Audio: <audio controls='controls'><source src='http://example.ogg' type='audio/ogg' />Audio not playing?.</audio>", :profile => profile)
  229 + assert_tag_in_string article.body, :tag => 'audio', :attributes => {:controls => 'controls'}
  230 + assert_tag_in_string article.body, :tag => 'source', :attributes => {:src => 'http://example.ogg', :type => 'audio/ogg'}
  231 + end
  232 +
  233 + should 'not sanitize html5 video tag on body' do
  234 + article = TinyMceArticle.create!(:name => 'html5 video', :body => "Video: <video controls='controls' autoplay='autoplay'><source src='http://example.ogv' type='video/ogg' />Video not playing?</video>", :profile => profile)
  235 + assert_tag_in_string article.body, :tag => 'video', :attributes => {:controls => 'controls', :autoplay => 'autoplay'}
  236 + assert_tag_in_string article.body, :tag => 'source', :attributes => {:src => 'http://example.ogv', :type => 'video/ogg'}
  237 + end
  238 +
227 239 end
... ...
test/unit/user_mailer_test.rb
... ... @@ -11,11 +11,9 @@ class UserMailerTest &lt; ActiveSupport::TestCase
11 11  
12 12 end
13 13  
14   -
15 14 should 'deliver activation email notify' do
16 15 assert_difference ActionMailer::Base.deliveries, :size do
17   - u = Person.find(:first).user
18   - u.environment = Environment.default
  16 + u = create_user('some_user')
19 17 User::Mailer.deliver_activation_email_notify(u)
20 18 end
21 19 end
... ...
test/unit/user_test.rb
... ... @@ -296,7 +296,8 @@ class UserTest &lt; ActiveSupport::TestCase
296 296 end
297 297  
298 298 should 'be able to use [] operator to find users by login' do
299   - assert_equal users(:ze), User['ze']
  299 + user = fast_create(User)
  300 + assert_equal user, User[user.login]
300 301 end
301 302  
302 303 should 'user has presence status to know when online or offline' do
... ...