]> cat aescling's git repositories - mastodon.git/commitdiff
Fix “invited by” not showing up for invited accounts in admin interface (#10791)
authorThibG <thib@sitedethib.com>
Sun, 19 May 2019 19:40:36 +0000 (21:40 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 19 May 2019 19:40:36 +0000 (21:40 +0200)
app/models/user.rb
app/validators/blacklisted_email_validator.rb
spec/validators/blacklisted_email_validator_spec.rb

index 6941b040de777f80abf5ed09fd9160d90cdbfc53..3d1eb5f206ddce6f0afa6554736930cf10e64476 100644 (file)
@@ -114,6 +114,10 @@ class User < ApplicationRecord
   end
 
   def invited?
+    invite_id.present?
+  end
+
+  def valid_invitation?
     invite_id.present? && invite.valid_for_use?
   end
 
@@ -274,7 +278,7 @@ class User < ApplicationRecord
   private
 
   def set_approved
-    self.approved = open_registrations? || invited? || external?
+    self.approved = open_registrations? || valid_invitation? || external?
   end
 
   def open_registrations?
index a288c20ef4bfaabc2dddffc291abd15627ae782c..0d01a1c47fb7fb842542a5d0981fcb547dd1d06b 100644 (file)
@@ -2,7 +2,7 @@
 
 class BlacklistedEmailValidator < ActiveModel::Validator
   def validate(user)
-    return if user.invited?
+    return if user.valid_invitation?
 
     @email = user.email
 
index 84b0107dd70bf972cee76ebbd0d622e9cfaef20f..ccc5dc0f485050fb017d3df4b9f8270250950bad 100644 (file)
@@ -8,7 +8,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
     let(:errors) { double(add: nil) }
 
     before do
-      allow(user).to receive(:invited?) { false }
+      allow(user).to receive(:valid_invitation?) { false }
       allow_any_instance_of(described_class).to receive(:blocked_email?) { blocked_email }
       described_class.new.validate(user)
     end