Browse Source

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

feature_machine_registration_task
ThibG Eugen Rochko 1 year ago
parent
commit
9222c26e19
3 changed files with 7 additions and 3 deletions
  1. +5
    -1
      app/models/user.rb
  2. +1
    -1
      app/validators/blacklisted_email_validator.rb
  3. +1
    -1
      spec/validators/blacklisted_email_validator_spec.rb

+ 5
- 1
app/models/user.rb View 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?


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

@@ -2,7 +2,7 @@

class BlacklistedEmailValidator < ActiveModel::Validator
def validate(user)
return if user.invited?
return if user.valid_invitation?

@email = user.email



+ 1
- 1
spec/validators/blacklisted_email_validator_spec.rb View 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


Loading…
Cancel
Save