diff --git a/lib/modules/observers/activity_feed/comment.rb b/lib/modules/observers/activity_feed/comment.rb index 8a12429a5..0327fcb12 100644 --- a/lib/modules/observers/activity_feed/comment.rb +++ b/lib/modules/observers/activity_feed/comment.rb @@ -3,7 +3,7 @@ module Modules::Observers::ActivityFeed::Comment extend ActiveSupport::Concern included do - after_commit :new_comment_notifications, :on => :create, :unless => :automatic? + after_commit :new_comment_notifications, :on => :create # dont remove outdated issues link after_update -> { Comment.create_link_on_issues_from_item(self) } end @@ -11,6 +11,7 @@ module Modules::Observers::ActivityFeed::Comment private def new_comment_notifications + return if automatic? if issue_comment? commentable.subscribes.each do |subscribe| if user_id != subscribe.user_id diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb index 76119494c..fdfb51a9c 100644 --- a/spec/factories/comments.rb +++ b/spec/factories/comments.rb @@ -5,5 +5,6 @@ FactoryGirl.define do association :user, :factory => :user association :commentable, :factory => :issue project { |c| c.commentable.project } + after(:create) { |c| c.send(:new_comment_notifications) } end end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index a76caea56..1bacc7763 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -7,5 +7,6 @@ FactoryGirl.define do association :user, :factory => :user association :assignee, :factory => :user status "open" + after(:create) { |i| i.send(:new_issue_notifications) } end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 8f8d138a9..37dab7ef1 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -7,6 +7,7 @@ FactoryGirl.define do password '123456' password_confirmation {|u| u.password} confirmed_at { Time.now.utc } + after(:create) { |u| u.send(:new_user_notification) } end factory :admin, :parent => :user do diff --git a/spec/lib/observers/activity_feed/comment_spec.rb b/spec/lib/observers/activity_feed/comment_spec.rb deleted file mode 100644 index 84b5065d5..000000000 --- a/spec/lib/observers/activity_feed/comment_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe Modules::Observers::ActivityFeed::Comment do - self.use_transactional_fixtures = false - before { stub_symlink_methods } - - it 'sends a notification email after create a issue comment' do - comment = FactoryGirl.build(:comment) - mailer = mock!.deliver - mock(UserMailer).new_comment_notification(comment, comment.commentable.assignee) { mailer } - comment.save - end -end diff --git a/spec/lib/observers/activity_feed/issue_spec.rb b/spec/lib/observers/activity_feed/issue_spec.rb deleted file mode 100644 index be287e73b..000000000 --- a/spec/lib/observers/activity_feed/issue_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe Modules::Observers::ActivityFeed::Issue do - self.use_transactional_fixtures = false - before { stub_symlink_methods } - - it 'sends a notification email after create' do - issue = FactoryGirl.build(:issue, :assignee => nil) - mailer = mock!.deliver - mock(UserMailer).new_issue_notification(issue, issue.project.owner) { mailer } - issue.save - end - - it 'does not send a notification email after update' do - issue = FactoryGirl.create(:issue, :assignee => nil) - issue.title = 'new title' - dont_allow(UserMailer).new_issue_notification - issue.save - end - - it 'sends a notification email after a assignee of issue has been changed' do - user = FactoryGirl.create(:user) - issue = FactoryGirl.build(:issue, :assignee => nil) - issue.assignee = user - mailer = mock!.deliver - mock(UserMailer).issue_assign_notification(issue, user) { mailer } - issue.save - end -end diff --git a/spec/models/comment_for_commit_spec.rb b/spec/models/comment_for_commit_spec.rb index 1d779ef0d..9972a699a 100644 --- a/spec/models/comment_for_commit_spec.rb +++ b/spec/models/comment_for_commit_spec.rb @@ -37,7 +37,6 @@ def should_not_send_email(args={}) end describe Comment do - self.use_transactional_fixtures = false before { stub_symlink_methods } context 'for global admin user' do before(:each) do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 51b7eb5a9..2226a8c13 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -19,7 +19,6 @@ def create_comment_in_issue issue, body end describe Comment do - self.use_transactional_fixtures = false before { stub_symlink_methods } context 'for global admin user' do before(:each) do diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index a8635a625..1777fcc92 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -13,7 +13,6 @@ def create_issue issue_owner end describe Issue do - self.use_transactional_fixtures = false before do stub_symlink_methods any_instance_of(Project, :versions => ['v1.0', 'v2.0']) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f5c167bfa..c233dd750 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,7 +30,6 @@ RSpec.configure do |config| config.before(:all) { init_test_root } config.after(:all) { clear_test_root } - config.after(:all) { User.destroy_all } end def set_session_for(user=nil)