Skip to content
Snippets Groups Projects
Commit 9222c26e authored by ThibG's avatar ThibG Committed by Eugen Rochko
Browse files

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

parent 94439a1d
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,10 @@ class User < ApplicationRecord ...@@ -114,6 +114,10 @@ class User < ApplicationRecord
end end
def invited? def invited?
invite_id.present?
end
def valid_invitation?
invite_id.present? && invite.valid_for_use? invite_id.present? && invite.valid_for_use?
end end
...@@ -274,7 +278,7 @@ class User < ApplicationRecord ...@@ -274,7 +278,7 @@ class User < ApplicationRecord
private private
def set_approved def set_approved
self.approved = open_registrations? || invited? || external? self.approved = open_registrations? || valid_invitation? || external?
end end
def open_registrations? def open_registrations?
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class BlacklistedEmailValidator < ActiveModel::Validator class BlacklistedEmailValidator < ActiveModel::Validator
def validate(user) def validate(user)
return if user.invited? return if user.valid_invitation?
@email = user.email @email = user.email
......
...@@ -8,7 +8,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do ...@@ -8,7 +8,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do
let(:errors) { double(add: nil) } let(:errors) { double(add: nil) }
before do 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 } allow_any_instance_of(described_class).to receive(:blocked_email?) { blocked_email }
described_class.new.validate(user) described_class.new.validate(user)
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment