Skip to content

Commit

Permalink
Fix “invited by” not showing up for invited accounts in admin interfa…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and Gargron committed May 19, 2019
1 parent 3294910 commit 9236119
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def confirmed?
end

def invited?
invite_id.present?
end

def valid_invitation?
invite_id.present? && invite.valid_for_use?
end

Expand Down Expand Up @@ -274,7 +278,7 @@ def send_devise_notification(notification, *args)
private

def set_approved
self.approved = open_registrations? || invited? || external?
self.approved = open_registrations? || valid_invitation? || external?
end

def open_registrations?
Expand Down
2 changes: 1 addition & 1 deletion app/validators/blacklisted_email_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

@email = user.email

Expand Down
2 changes: 1 addition & 1 deletion spec/validators/blacklisted_email_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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
Expand Down

0 comments on commit 9236119

Please sign in to comment.