Commit 10e51901d28867a01bc1857409e264674d68e390
Exists in
master
and in
23 other branches
Merge branch 'stable'
Showing
21 changed files
with
64 additions
and
85 deletions
Show diff stats
app/helpers/categories_helper.rb
| @@ -34,8 +34,7 @@ module CategoriesHelper | @@ -34,8 +34,7 @@ module CategoriesHelper | ||
| 34 | 34 | ||
| 35 | def select_category_type(field) | 35 | def select_category_type(field) |
| 36 | value = params[field] | 36 | value = params[field] |
| 37 | - types = TYPES.select { |title,typename| environment.category_types.include?(typename) } | ||
| 38 | - labelled_form_field(_('Type of category'), select_tag('type', options_for_select(types, value))) | 37 | + labelled_form_field(_('Type of category'), select_tag('type', options_for_select(TYPES, value))) |
| 39 | end | 38 | end |
| 40 | 39 | ||
| 41 | end | 40 | end |
app/models/comment.rb
| @@ -70,7 +70,7 @@ class Comment < ActiveRecord::Base | @@ -70,7 +70,7 @@ class Comment < ActiveRecord::Base | ||
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | after_create do |comment| | 72 | after_create do |comment| |
| 73 | - if comment.article.notify_comments? | 73 | + if comment.article.notify_comments? && !comment.article.profile.notification_emails.empty? |
| 74 | Comment::Notifier.deliver_mail(comment) | 74 | Comment::Notifier.deliver_mail(comment) |
| 75 | end | 75 | end |
| 76 | end | 76 | end |
| @@ -97,10 +97,7 @@ class Comment < ActiveRecord::Base | @@ -97,10 +97,7 @@ class Comment < ActiveRecord::Base | ||
| 97 | class Notifier < ActionMailer::Base | 97 | class Notifier < ActionMailer::Base |
| 98 | def mail(comment) | 98 | def mail(comment) |
| 99 | profile = comment.article.profile | 99 | profile = comment.article.profile |
| 100 | - email = profile.notification_emails | ||
| 101 | - return unless email | ||
| 102 | - recipients email | ||
| 103 | - | 100 | + recipients profile.notification_emails |
| 104 | from "#{profile.environment.name} <#{profile.environment.contact_email}>" | 101 | from "#{profile.environment.name} <#{profile.environment.contact_email}>" |
| 105 | subject _("[%s] you got a new comment!") % [profile.environment.name] | 102 | subject _("[%s] you got a new comment!") % [profile.environment.name] |
| 106 | body :recipient => profile.nickname || profile.name, | 103 | body :recipient => profile.nickname || profile.name, |
app/models/community.rb
app/models/environment.rb
| @@ -207,7 +207,6 @@ class Environment < ActiveRecord::Base | @@ -207,7 +207,6 @@ class Environment < ActiveRecord::Base | ||
| 207 | settings_items :layout_template, :type => String, :default => 'default' | 207 | settings_items :layout_template, :type => String, :default => 'default' |
| 208 | settings_items :homepage, :type => String | 208 | settings_items :homepage, :type => String |
| 209 | settings_items :description, :type => String, :default => '<div style="text-align: center"><a href="http://noosfero.org/"><img src="/images/noosfero-network.png" alt="Noosfero"/></a></div>' | 209 | settings_items :description, :type => String, :default => '<div style="text-align: center"><a href="http://noosfero.org/"><img src="/images/noosfero-network.png" alt="Noosfero"/></a></div>' |
| 210 | - settings_items :category_types, :type => Array, :default => ['Category'] | ||
| 211 | settings_items :enable_ssl | 210 | settings_items :enable_ssl |
| 212 | settings_items :local_docs, :type => Array, :default => [] | 211 | settings_items :local_docs, :type => Array, :default => [] |
| 213 | settings_items :news_amount_by_folder, :type => Integer, :default => 4 | 212 | settings_items :news_amount_by_folder, :type => Integer, :default => 4 |
app/models/event.rb
| @@ -120,10 +120,7 @@ class Event < Article | @@ -120,10 +120,7 @@ class Event < Article | ||
| 120 | true | 120 | true |
| 121 | end | 121 | end |
| 122 | 122 | ||
| 123 | - def translatable? | ||
| 124 | - true | ||
| 125 | - end | ||
| 126 | - | 123 | + include Noosfero::TranslatableContent |
| 127 | include MaybeAddHttp | 124 | include MaybeAddHttp |
| 128 | 125 | ||
| 129 | end | 126 | end |
app/models/organization.rb
| @@ -132,4 +132,8 @@ class Organization < Profile | @@ -132,4 +132,8 @@ class Organization < Profile | ||
| 132 | super({:domain => "conference.#{environment.default_hostname}"}.merge(options)) | 132 | super({:domain => "conference.#{environment.default_hostname}"}.merge(options)) |
| 133 | end | 133 | end |
| 134 | 134 | ||
| 135 | + def receives_scrap_notification? | ||
| 136 | + false | ||
| 137 | + end | ||
| 138 | + | ||
| 135 | end | 139 | end |
app/models/text_article.rb
| @@ -2,4 +2,6 @@ | @@ -2,4 +2,6 @@ | ||
| 2 | class TextArticle < Article | 2 | class TextArticle < Article |
| 3 | 3 | ||
| 4 | xss_terminate :only => [ :name, :abstract, :body ], :on => 'validation' | 4 | xss_terminate :only => [ :name, :abstract, :body ], :on => 'validation' |
| 5 | + | ||
| 6 | + include Noosfero::TranslatableContent | ||
| 5 | end | 7 | end |
app/models/textile_article.rb
app/models/tiny_mce_article.rb
app/views/categories/_form.rhtml
| @@ -9,11 +9,7 @@ | @@ -9,11 +9,7 @@ | ||
| 9 | <%= hidden_field_tag('parent_id', @category.parent.id) %> | 9 | <%= hidden_field_tag('parent_id', @category.parent.id) %> |
| 10 | <%= hidden_field_tag('parent_type', @category.parent.class.name) %> | 10 | <%= hidden_field_tag('parent_type', @category.parent.class.name) %> |
| 11 | <% else %> | 11 | <% else %> |
| 12 | - <% if environment.category_types.length > 1 %> | ||
| 13 | <%= select_category_type :type %> | 12 | <%= select_category_type :type %> |
| 14 | - <% else %> | ||
| 15 | - <%= hidden_field_tag('type', @category.class.name) %> | ||
| 16 | - <% end%> | ||
| 17 | <% end %> | 13 | <% end %> |
| 18 | <% end %> | 14 | <% end %> |
| 19 | 15 |
test/functional/categories_controller_test.rb
| @@ -155,28 +155,6 @@ class CategoriesControllerTest < Test::Unit::TestCase | @@ -155,28 +155,6 @@ class CategoriesControllerTest < Test::Unit::TestCase | ||
| 155 | assert_tag :tag => 'select', :attributes => { :name => "category[display_color]" } | 155 | assert_tag :tag => 'select', :attributes => { :name => "category[display_color]" } |
| 156 | end | 156 | end |
| 157 | 157 | ||
| 158 | - should 'not display category_type if only one category is available' do | ||
| 159 | - env.category_types = ['Category'] | ||
| 160 | - get :new | ||
| 161 | - | ||
| 162 | - assert_no_tag :tag => 'select', :attributes => { :name => "type" } | ||
| 163 | - end | ||
| 164 | - | ||
| 165 | - should 'have hidden_tag type if only one category is available' do | ||
| 166 | - env.category_types = ['Category'] | ||
| 167 | - env.save! | ||
| 168 | - get :new | ||
| 169 | - | ||
| 170 | - assert_tag :tag => 'input', :attributes => { :name => 'type', :value => "Category", :type => 'hidden' } | ||
| 171 | - end | ||
| 172 | - | ||
| 173 | - should 'display category_type if more than one category is available' do | ||
| 174 | - env.category_types = 'Category', 'ProductCategory' | ||
| 175 | - get :new | ||
| 176 | - | ||
| 177 | - assert_tag :tag => 'select', :attributes => { :name => "type" } | ||
| 178 | - end | ||
| 179 | - | ||
| 180 | should 'not list regions and product categories' do | 158 | should 'not list regions and product categories' do |
| 181 | Environment.default.categories.destroy_all | 159 | Environment.default.categories.destroy_all |
| 182 | c = Category.create!(:name => 'Regular category', :environment => Environment.default) | 160 | c = Category.create!(:name => 'Regular category', :environment => Environment.default) |
test/unit/categories_helper_test.rb
| @@ -11,7 +11,6 @@ class CategoriesHelperTest < Test::Unit::TestCase | @@ -11,7 +11,6 @@ class CategoriesHelperTest < Test::Unit::TestCase | ||
| 11 | def _(s); s; end | 11 | def _(s); s; end |
| 12 | 12 | ||
| 13 | should 'generate list of category types for selection' do | 13 | should 'generate list of category types for selection' do |
| 14 | - environment.category_types = ['Category', 'ProductCategory', 'Region'] | ||
| 15 | expects(:params).returns({'fieldname' => 'fieldvalue'}) | 14 | expects(:params).returns({'fieldname' => 'fieldvalue'}) |
| 16 | expects(:options_for_select).with([['General Category', 'Category'],[ 'Product Category', 'ProductCategory'],[ 'Region', 'Region' ]], 'fieldvalue').returns('OPTIONS') | 15 | expects(:options_for_select).with([['General Category', 'Category'],[ 'Product Category', 'ProductCategory'],[ 'Region', 'Region' ]], 'fieldvalue').returns('OPTIONS') |
| 17 | expects(:select_tag).with('type', 'OPTIONS').returns('TAG') | 16 | expects(:select_tag).with('type', 'OPTIONS').returns('TAG') |
| @@ -20,14 +19,4 @@ class CategoriesHelperTest < Test::Unit::TestCase | @@ -20,14 +19,4 @@ class CategoriesHelperTest < Test::Unit::TestCase | ||
| 20 | assert_equal 'RESULT', select_category_type('fieldname') | 19 | assert_equal 'RESULT', select_category_type('fieldname') |
| 21 | end | 20 | end |
| 22 | 21 | ||
| 23 | - should 'only list the available types' do | ||
| 24 | - environment.category_types = ['Category'] | ||
| 25 | - expects(:params).returns({'fieldname' => 'fieldvalue'}) | ||
| 26 | - expects(:options_for_select).with([['General Category', 'Category']], 'fieldvalue').returns('OPTIONS') | ||
| 27 | - expects(:select_tag).with('type', 'OPTIONS').returns('TAG') | ||
| 28 | - expects(:labelled_form_field).with(anything, 'TAG').returns('RESULT') | ||
| 29 | - | ||
| 30 | - assert_equal 'RESULT', select_category_type('fieldname') | ||
| 31 | - end | ||
| 32 | - | ||
| 33 | end | 22 | end |
test/unit/comment_notifier_test.rb
| @@ -56,6 +56,15 @@ class CommentNotifierTest < Test::Unit::TestCase | @@ -56,6 +56,15 @@ class CommentNotifierTest < Test::Unit::TestCase | ||
| 56 | assert_match /comment body/, sent.body | 56 | assert_match /comment body/, sent.body |
| 57 | end | 57 | end |
| 58 | 58 | ||
| 59 | + should 'not deliver mail if has no notification emails' do | ||
| 60 | + community = fast_create(Community) | ||
| 61 | + assert_equal [], community.notification_emails | ||
| 62 | + article = fast_create(Article, :name => 'Article test', :profile_id => community.id, :notify_comments => true) | ||
| 63 | + assert_no_difference ActionMailer::Base.deliveries, :size do | ||
| 64 | + article.comments << Comment.new(:author => @profile, :title => 'test comment', :body => 'there is no addresses to send notification') | ||
| 65 | + end | ||
| 66 | + end | ||
| 67 | + | ||
| 59 | private | 68 | private |
| 60 | 69 | ||
| 61 | def read_fixture(action) | 70 | def read_fixture(action) |
test/unit/enterprise_test.rb
| @@ -408,4 +408,9 @@ class EnterpriseTest < Test::Unit::TestCase | @@ -408,4 +408,9 @@ class EnterpriseTest < Test::Unit::TestCase | ||
| 408 | assert_equal false, e.send(:followed_by?,p2) | 408 | assert_equal false, e.send(:followed_by?,p2) |
| 409 | end | 409 | end |
| 410 | 410 | ||
| 411 | + should 'receive scrap notification' do | ||
| 412 | + enterprise = fast_create(Enterprise) | ||
| 413 | + assert_equal false, enterprise.receives_scrap_notification? | ||
| 414 | + end | ||
| 415 | + | ||
| 411 | end | 416 | end |
test/unit/environment_test.rb
| @@ -731,17 +731,6 @@ class EnvironmentTest < Test::Unit::TestCase | @@ -731,17 +731,6 @@ class EnvironmentTest < Test::Unit::TestCase | ||
| 731 | assert_equal ['contact_email'], env.required_community_fields | 731 | assert_equal ['contact_email'], env.required_community_fields |
| 732 | end | 732 | end |
| 733 | 733 | ||
| 734 | - should 'set category_types' do | ||
| 735 | - env = Environment.new | ||
| 736 | - env.category_types = ['Category', 'ProductCategory'] | ||
| 737 | - | ||
| 738 | - assert_equal ['Category', 'ProductCategory'], env.category_types | ||
| 739 | - end | ||
| 740 | - | ||
| 741 | - should 'have type /Category/ on category_types by default' do | ||
| 742 | - assert_equal ['Category'], Environment.new.category_types | ||
| 743 | - end | ||
| 744 | - | ||
| 745 | should 'has tasks' do | 734 | should 'has tasks' do |
| 746 | e = Environment.default | 735 | e = Environment.default |
| 747 | assert_nothing_raised do | 736 | assert_nothing_raised do |
test/unit/event_test.rb
| @@ -267,8 +267,7 @@ class EventTest < ActiveSupport::TestCase | @@ -267,8 +267,7 @@ class EventTest < ActiveSupport::TestCase | ||
| 267 | end | 267 | end |
| 268 | 268 | ||
| 269 | should 'be translatable' do | 269 | should 'be translatable' do |
| 270 | - e = Event.new | ||
| 271 | - assert e.translatable? | 270 | + assert_kind_of Noosfero::TranslatableContent, Event.new |
| 272 | end | 271 | end |
| 273 | 272 | ||
| 274 | end | 273 | end |
test/unit/text_article_test.rb
| @@ -39,4 +39,8 @@ class TextArticleTest < Test::Unit::TestCase | @@ -39,4 +39,8 @@ class TextArticleTest < Test::Unit::TestCase | ||
| 39 | assert_no_match /[<>]/, article.body | 39 | assert_no_match /[<>]/, article.body |
| 40 | end | 40 | end |
| 41 | 41 | ||
| 42 | + should 'be translatable' do | ||
| 43 | + assert_kind_of Noosfero::TranslatableContent, TextArticle.new | ||
| 44 | + end | ||
| 45 | + | ||
| 42 | end | 46 | end |
test/unit/textile_article_test.rb
| @@ -145,10 +145,4 @@ class TextileArticleTest < Test::Unit::TestCase | @@ -145,10 +145,4 @@ class TextileArticleTest < Test::Unit::TestCase | ||
| 145 | assert_equal false, a.advertise? | 145 | assert_equal false, a.advertise? |
| 146 | assert_equal false, a.is_trackable? | 146 | assert_equal false, a.is_trackable? |
| 147 | end | 147 | end |
| 148 | - | ||
| 149 | - should 'be translatable' do | ||
| 150 | - a = TextileArticle.new | ||
| 151 | - assert a.translatable? | ||
| 152 | - end | ||
| 153 | - | ||
| 154 | end | 148 | end |
test/unit/tiny_mce_article_test.rb
| @@ -236,9 +236,4 @@ class TinyMceArticleTest < Test::Unit::TestCase | @@ -236,9 +236,4 @@ class TinyMceArticleTest < Test::Unit::TestCase | ||
| 236 | assert_equal false, a.advertise? | 236 | assert_equal false, a.advertise? |
| 237 | assert_equal false, a.is_trackable? | 237 | assert_equal false, a.is_trackable? |
| 238 | end | 238 | end |
| 239 | - | ||
| 240 | - should 'be translatable' do | ||
| 241 | - a = TinyMceArticle.new | ||
| 242 | - assert a.translatable? | ||
| 243 | - end | ||
| 244 | end | 239 | end |
| @@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
| 2 | + | ||
| 3 | +class TranslatableContentTest < ActiveSupport::TestCase | ||
| 4 | + | ||
| 5 | + class Content | ||
| 6 | + attr_accessor :parent | ||
| 7 | + include Noosfero::TranslatableContent | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + def setup | ||
| 11 | + @content = Content.new | ||
| 12 | + end | ||
| 13 | + attr_reader :content | ||
| 14 | + | ||
| 15 | + should 'be translatable if no parent' do | ||
| 16 | + assert content.translatable? | ||
| 17 | + end | ||
| 18 | + | ||
| 19 | + should 'not be translatable if parent is a forum' do | ||
| 20 | + content.parent = Forum.new | ||
| 21 | + assert !content.translatable? | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + should 'be translatable if parent is not a forum' do | ||
| 25 | + content.parent = Blog.new | ||
| 26 | + assert content.translatable? | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | +end |