Skip to content
Extraits de code Groupes Projets
Valider f6e43ce1 rédigé par echarp's avatar echarp
Parcourir les fichiers

Organisation submitter is set to the contact if empty

parent cbba590d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -35,31 +35,29 @@ class Orga < ActiveRecord::Base ...@@ -35,31 +35,29 @@ class Orga < ActiveRecord::Base
scope :geo, -> { where 'latitude is not null and longitude is not null' } scope :geo, -> { where 'latitude is not null and longitude is not null' }
before_validation do before_validation do
unless submitter.blank? # Populate submitter using contact info if absent
self.secret ||= SecureRandom.urlsafe_base64(32)[0...32] self.submitter ||= contact
end self.secret ||= SecureRandom.urlsafe_base64(32)[0...32]
self.submission_time ||= Time.zone.now self.submission_time ||= Time.zone.now
end end
after_create do after_create do
send_secret unless submitter.blank? send_secret
# Send email to moderators when an new orga is received # Send email to moderators when an new orga is received
ModerationorgaMailer.create(self).deliver_now! ModerationorgaMailer.create(self).deliver_now!
end end
after_update do after_update do
unless submitter.blank? send_secret if secret_changed? || submitter_changed?
send_secret if secret_changed?
if moderated_changed?
if moderated_changed? OrgaMailer.accept(self).deliver_now!
OrgaMailer.accept(self).deliver_now! # Send email to moderators when an orga is accepted
# Send email to moderators when an orga is accepted ModerationorgaMailer.accept(self).deliver_now!
ModerationorgaMailer.accept(self).deliver_now! else
else OrgaMailer.update(self).deliver_now!
OrgaMailer.update(self).deliver_now! # Send email to moderators when an orga is updated
# Send email to moderators when an orga is updated ModerationorgaMailer.update(self).deliver_now!
ModerationorgaMailer.update(self).deliver_now!
end
end end
end end
......
...@@ -20,17 +20,6 @@ class OrgaTest < ActiveSupport::TestCase ...@@ -20,17 +20,6 @@ class OrgaTest < ActiveSupport::TestCase
tags: 'hello world' tags: 'hello world'
) )
end end
assert_difference 'ActionMailer::Base.deliveries.size', 1 do
Orga.create!(
kind: Kind.first,
name: 'Tested organisation',
url: 'http://example.com',
region: Region.first,
contact: 'contact@example.com',
tags: 'hello world'
)
end
end end
test 'set and send secret' do test 'set and send secret' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter