Commit 10e51901d28867a01bc1857409e264674d68e390
Exists in
master
and in
28 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 | 34 | |
| 35 | 35 | def select_category_type(field) |
| 36 | 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 | 38 | end |
| 40 | 39 | |
| 41 | 40 | end | ... | ... |
app/models/comment.rb
| ... | ... | @@ -70,7 +70,7 @@ class Comment < ActiveRecord::Base |
| 70 | 70 | end |
| 71 | 71 | |
| 72 | 72 | after_create do |comment| |
| 73 | - if comment.article.notify_comments? | |
| 73 | + if comment.article.notify_comments? && !comment.article.profile.notification_emails.empty? | |
| 74 | 74 | Comment::Notifier.deliver_mail(comment) |
| 75 | 75 | end |
| 76 | 76 | end |
| ... | ... | @@ -97,10 +97,7 @@ class Comment < ActiveRecord::Base |
| 97 | 97 | class Notifier < ActionMailer::Base |
| 98 | 98 | def mail(comment) |
| 99 | 99 | profile = comment.article.profile |
| 100 | - email = profile.notification_emails | |
| 101 | - return unless email | |
| 102 | - recipients email | |
| 103 | - | |
| 100 | + recipients profile.notification_emails | |
| 104 | 101 | from "#{profile.environment.name} <#{profile.environment.contact_email}>" |
| 105 | 102 | subject _("[%s] you got a new comment!") % [profile.environment.name] |
| 106 | 103 | body :recipient => profile.nickname || profile.name, | ... | ... |
app/models/community.rb
app/models/environment.rb
| ... | ... | @@ -207,7 +207,6 @@ class Environment < ActiveRecord::Base |
| 207 | 207 | settings_items :layout_template, :type => String, :default => 'default' |
| 208 | 208 | settings_items :homepage, :type => String |
| 209 | 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 | 210 | settings_items :enable_ssl |
| 212 | 211 | settings_items :local_docs, :type => Array, :default => [] |
| 213 | 212 | settings_items :news_amount_by_folder, :type => Integer, :default => 4 | ... | ... |
app/models/event.rb
app/models/organization.rb
app/models/text_article.rb
app/models/textile_article.rb
app/models/tiny_mce_article.rb
app/views/categories/_form.rhtml
| ... | ... | @@ -9,11 +9,7 @@ |
| 9 | 9 | <%= hidden_field_tag('parent_id', @category.parent.id) %> |
| 10 | 10 | <%= hidden_field_tag('parent_type', @category.parent.class.name) %> |
| 11 | 11 | <% else %> |
| 12 | - <% if environment.category_types.length > 1 %> | |
| 13 | 12 | <%= select_category_type :type %> |
| 14 | - <% else %> | |
| 15 | - <%= hidden_field_tag('type', @category.class.name) %> | |
| 16 | - <% end%> | |
| 17 | 13 | <% end %> |
| 18 | 14 | <% end %> |
| 19 | 15 | ... | ... |
test/functional/categories_controller_test.rb
| ... | ... | @@ -155,28 +155,6 @@ class CategoriesControllerTest < Test::Unit::TestCase |
| 155 | 155 | assert_tag :tag => 'select', :attributes => { :name => "category[display_color]" } |
| 156 | 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 | 158 | should 'not list regions and product categories' do |
| 181 | 159 | Environment.default.categories.destroy_all |
| 182 | 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 | 11 | def _(s); s; end |
| 12 | 12 | |
| 13 | 13 | should 'generate list of category types for selection' do |
| 14 | - environment.category_types = ['Category', 'ProductCategory', 'Region'] | |
| 15 | 14 | expects(:params).returns({'fieldname' => 'fieldvalue'}) |
| 16 | 15 | expects(:options_for_select).with([['General Category', 'Category'],[ 'Product Category', 'ProductCategory'],[ 'Region', 'Region' ]], 'fieldvalue').returns('OPTIONS') |
| 17 | 16 | expects(:select_tag).with('type', 'OPTIONS').returns('TAG') |
| ... | ... | @@ -20,14 +19,4 @@ class CategoriesHelperTest < Test::Unit::TestCase |
| 20 | 19 | assert_equal 'RESULT', select_category_type('fieldname') |
| 21 | 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 | 22 | end | ... | ... |
test/unit/comment_notifier_test.rb
| ... | ... | @@ -56,6 +56,15 @@ class CommentNotifierTest < Test::Unit::TestCase |
| 56 | 56 | assert_match /comment body/, sent.body |
| 57 | 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 | 68 | private |
| 60 | 69 | |
| 61 | 70 | def read_fixture(action) | ... | ... |
test/unit/enterprise_test.rb
| ... | ... | @@ -408,4 +408,9 @@ class EnterpriseTest < Test::Unit::TestCase |
| 408 | 408 | assert_equal false, e.send(:followed_by?,p2) |
| 409 | 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 | 416 | end | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -731,17 +731,6 @@ class EnvironmentTest < Test::Unit::TestCase |
| 731 | 731 | assert_equal ['contact_email'], env.required_community_fields |
| 732 | 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 | 734 | should 'has tasks' do |
| 746 | 735 | e = Environment.default |
| 747 | 736 | assert_nothing_raised do | ... | ... |
test/unit/event_test.rb
test/unit/text_article_test.rb
test/unit/textile_article_test.rb
| ... | ... | @@ -145,10 +145,4 @@ class TextileArticleTest < Test::Unit::TestCase |
| 145 | 145 | assert_equal false, a.advertise? |
| 146 | 146 | assert_equal false, a.is_trackable? |
| 147 | 147 | end |
| 148 | - | |
| 149 | - should 'be translatable' do | |
| 150 | - a = TextileArticle.new | |
| 151 | - assert a.translatable? | |
| 152 | - end | |
| 153 | - | |
| 154 | 148 | end | ... | ... |
test/unit/tiny_mce_article_test.rb
| ... | ... | @@ -236,9 +236,4 @@ class TinyMceArticleTest < Test::Unit::TestCase |
| 236 | 236 | assert_equal false, a.advertise? |
| 237 | 237 | assert_equal false, a.is_trackable? |
| 238 | 238 | end |
| 239 | - | |
| 240 | - should 'be translatable' do | |
| 241 | - a = TinyMceArticle.new | |
| 242 | - assert a.translatable? | |
| 243 | - end | |
| 244 | 239 | end | ... | ... |
| ... | ... | @@ -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 | ... | ... |