Browse Source

Fix “invited by” not showing up for invited accounts in admin interface (#10791)

pull/3/head
ThibG 1 month ago
parent
commit
ae18386558

+ 5
- 1
app/models/user.rb View File

@@ -114,6 +114,10 @@ class User < ApplicationRecord
114 114
   end
115 115
 
116 116
   def invited?
117
+    invite_id.present?
118
+  end
119
+
120
+  def valid_invitation?
117 121
     invite_id.present? && invite.valid_for_use?
118 122
   end
119 123
 
@@ -274,7 +278,7 @@ class User < ApplicationRecord
274 278
   private
275 279
 
276 280
   def set_approved
277
-    self.approved = open_registrations? || invited? || external?
281
+    self.approved = open_registrations? || valid_invitation? || external?
278 282
   end
279 283
 
280 284
   def open_registrations?

+ 1
- 1
app/validators/blacklisted_email_validator.rb View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 class BlacklistedEmailValidator < ActiveModel::Validator
4 4
   def validate(user)
5
-    return if user.invited?
5
+    return if user.valid_invitation?
6 6
 
7 7
     @email = user.email
8 8
 

+ 1
- 1
spec/validators/blacklisted_email_validator_spec.rb View File

@@ -8,7 +8,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
8 8
     let(:errors) { double(add: nil) }
9 9
 
10 10
     before do
11
-      allow(user).to receive(:invited?) { false }
11
+      allow(user).to receive(:valid_invitation?) { false }
12 12
       allow_any_instance_of(described_class).to receive(:blocked_email?) { blocked_email }
13 13
       described_class.new.validate(user)
14 14
     end

Loading…
Cancel
Save