diff --git a/app/models/orga.rb b/app/models/orga.rb index 9f7c8460..6e504f9f 100644 --- a/app/models/orga.rb +++ b/app/models/orga.rb @@ -43,6 +43,8 @@ class Orga < ActiveRecord::Base after_create do send_secret unless submitter.blank? + # Send email to moderators when an new orga is received + ModerationorgaMailer.create(self).deliver_now! end after_update do @@ -69,8 +71,6 @@ class Orga < ActiveRecord::Base def send_secret OrgaMailer.create(self).deliver_now! - # Send email to moderators when an new orga is received - ModerationorgaMailer.create(self).deliver_now! end def name_as_tag diff --git a/test/models/orga_test.rb b/test/models/orga_test.rb index 9524f9a2..21b1a46c 100644 --- a/test/models/orga_test.rb +++ b/test/models/orga_test.rb @@ -9,7 +9,7 @@ class OrgaTest < ActiveSupport::TestCase end test 'propose orga' do - assert_difference 'ActionMailer::Base.deliveries.size', 1 do + assert_difference 'ActionMailer::Base.deliveries.size', 2 do Orga.create!( kind: Kind.first, name: 'Tested organisation', @@ -20,7 +20,7 @@ class OrgaTest < ActiveSupport::TestCase ) end - assert_no_difference 'ActionMailer::Base.deliveries.size' do + assert_difference 'ActionMailer::Base.deliveries.size', 1 do Orga.create!( kind: Kind.first, name: 'Tested organisation', @@ -34,7 +34,7 @@ class OrgaTest < ActiveSupport::TestCase test 'set and send secret' do @orga = orgas(:two) assert_nil @orga.secret - assert_difference 'ActionMailer::Base.deliveries.size', 2 do + assert_difference 'ActionMailer::Base.deliveries.size', 3 do @orga.name = 'hop hop hop' @orga.save! end @@ -43,7 +43,7 @@ class OrgaTest < ActiveSupport::TestCase test 'edit orga' do @orga = orgas(:one) - assert_difference 'ActionMailer::Base.deliveries.size' do + assert_difference 'ActionMailer::Base.deliveries.size', 2 do @orga.name += ' addition added as an edit :)' @orga.save! end @@ -51,7 +51,7 @@ class OrgaTest < ActiveSupport::TestCase test 'accept orga' do @orga = orgas(:two) - assert_difference 'ActionMailer::Base.deliveries.size', 2 do + assert_difference 'ActionMailer::Base.deliveries.size', 3 do @orga.moderated = true @orga.save! end @@ -59,7 +59,7 @@ class OrgaTest < ActiveSupport::TestCase test 'refuse orga' do @orga = orgas(:two) - assert_difference 'ActionMailer::Base.deliveries.size' do + assert_difference 'ActionMailer::Base.deliveries.size', 2 do @orga.destroy! end end