mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Add guard to prevent a primary UserEmail from being reassigned.
This commit is contained in:
@@ -37,6 +37,18 @@ describe User do
|
||||
expect(user.errors.messages).to include(:primary_email)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when primary_email is being reassigned to another user' do
|
||||
it "should not be valid" do
|
||||
user2 = Fabricate.build(:user, email: nil)
|
||||
user.save!
|
||||
user2.primary_email = user.primary_email
|
||||
|
||||
expect(user2).to_not be_valid
|
||||
expect(user2.errors.messages).to include(:primary_email)
|
||||
expect(user2.primary_email.errors.messages).to include(:user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user