]> source.dussan.org Git - redmine.git/commitdiff
Send journal notification after commit (#25794).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 May 2017 08:44:24 +0000 (08:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 27 May 2017 08:44:24 +0000 (08:44 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16573 e93f8b46-1217-0410-a6f0-8f06a7374b81

Gemfile
app/models/journal.rb
app/views/mailer/issue_edit.html.erb
test/functional/issues_controller_test.rb

diff --git a/Gemfile b/Gemfile
index 018be1d4e6d2f32e80c22acd154841b2e3c20b30..ccfc7633c37ff0f51c46ba28682a865d0720248b 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -91,6 +91,8 @@ group :test do
   gem "rails-dom-testing"
   gem "mocha"
   gem "simplecov", "~> 0.9.1", :require => false
+  # TODO: remove this after upgrading to Rails 5
+  gem "test_after_commit"
   # For running UI tests
   gem "capybara"
   gem "selenium-webdriver", "~> 2.53.4"
index 7d1a6eb346e7d7fc38802788223287142fc82718..369666b6febc541f3a02ee81078b07ba4744b643 100644 (file)
@@ -43,7 +43,7 @@ class Journal < ActiveRecord::Base
                                             " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct
 
   before_create :split_private_notes
-  after_create :send_notification
+  after_commit :send_notification, :on => :create
 
   scope :visible, lambda {|*args|
     user = args.shift || User.current
index d84f449232b89e27197a1fc8ab7031e7196f139d..b7fc18ed6123a9d3a7ac2501d55050e6d0287655 100644 (file)
@@ -4,7 +4,7 @@
 <%= l(:text_issue_updated, :id => link_to("##{@issue.id}", @issue_url), :author => h(@journal.user)).html_safe %>
 <hr />
 
-<ul class="details">
+<ul class="journal details">
 <% details_to_strings(@journal_details, false, :only_path => false).each do |string| %>
   <li><%= string %></li>
 <% end %>
index 49aeb08d0fa55418fb18a0d35e36c41952265eff..fef87a2c37487daaa49bb4b2193ce57c0e68c6ee 100644 (file)
@@ -3839,6 +3839,7 @@ class IssuesControllerTest < Redmine::ControllerTest
 
   def test_put_update_with_attachment_deletion_should_create_a_single_journal
     set_tmp_attachments_directory
+    ActionMailer::Base.deliveries.clear
     @request.session[:user_id] = 2
 
     journal = new_record(Journal) do
@@ -3853,6 +3854,12 @@ class IssuesControllerTest < Redmine::ControllerTest
     end
     assert_equal 'Removing attachments', journal.notes
     assert_equal 2, journal.details.count
+
+    assert_select_email do
+      assert_select 'ul.journal.details li', 2
+      assert_select 'del', :text => 'error281.txt'
+      assert_select 'del', :text => 'changeset_iso8859-1.diff'
+    end
   end
 
   def test_put_update_with_attachment_deletion_and_failure_should_preserve_selected_attachments