]> git.openstreetmap.org Git - rails.git/commitdiff
Ensure that deactivate isn't available in production
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 2 Feb 2022 17:47:45 +0000 (17:47 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 2 Feb 2022 17:48:17 +0000 (17:48 +0000)
It's only used as a workaround for factories not being able to create
pending users while keeping active as the default

app/models/user.rb

index cc12adecc467c66a39aab7adab446cc0d4a5ccfb..722d65302a3f155a1770cf3391413ee7ad12e8df 100644 (file)
@@ -172,8 +172,10 @@ class User < ApplicationRecord
     end
 
     # Used in test suite, not something that we would normally need to do.
-    event :deactivate do
-      transitions :from => :active, :to => :pending
+    if Rails.env.test?
+      event :deactivate do
+        transitions :from => :active, :to => :pending
+      end
     end
 
     # To confirm an account is used to override the spam scoring