Merge pull request #4087 from jeremylan/bug_40489

Fixed anonymizer when 'full name required' setting is on
This commit is contained in:
Sam 2016-03-18 12:29:51 +11:00
commit 180888c020
2 changed files with 45 additions and 24 deletions

View file

@ -20,7 +20,7 @@ class UserAnonymizer
@user.reload
@user.password = SecureRandom.hex
@user.email = "#{@user.username}@example.com"
@user.name = nil
@user.name = SiteSetting.full_name_required ? @user.username : nil
@user.date_of_birth = nil
@user.title = nil
@user.uploaded_avatar_id = nil

View file

@ -32,6 +32,11 @@ describe UserAnonymizer do
expect(user.user_option.mailing_list_mode).to eq(false)
end
context "Site Settings do not require full name" do
before do
SiteSetting.full_name_required = false
end
it "resets profile to default values" do
user.update_attributes( name: "Bibi", date_of_birth: 19.years.ago, title: "Super Star" )
@ -59,6 +64,22 @@ describe UserAnonymizer do
expect(profile.bio_cooked_version).to eq(nil)
expect(profile.card_background).to eq(nil)
end
end
context "Site Settings require full name" do
before do
SiteSetting.full_name_required = true
end
it "changes name to anonymized username" do
user.update_attributes( name: "Bibi", date_of_birth: 19.years.ago, title: "Super Star" )
make_anonymous
user.reload
expect(user.name).to eq(user.username)
end
end
it "removes the avatar" do
upload = Fabricate(:upload, user: user)