diff --git a/app/models/user.rb b/app/models/user.rb index 6c9c3cce9..887547188 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -655,35 +655,6 @@ class User < ActiveRecord::Base end end - module DeletionMethods - def delete! - scramble_password - remove_all_favorites - rename_for_delete - end - - def rename_for_delete - alt_name = "user#{id}" - n = 0 - while User.where(:name => alt_name).exists? - alt_name = "user#{id}_#{n}" - n += 1 - end - update_attribute(:name, alt_name) - - end - - def scramble_password - update_attribute(:bcrypt_password_hash, User.bcrypt(SecureRandom.hex(16))) - end - - def remove_all_favorites - Post.tag_match("fav:#{name}").find_each do |post| - Favorite.remove(post, self) - end - end - end - include BanMethods include NameMethods include PasswordMethods @@ -698,7 +669,6 @@ class User < ActiveRecord::Base include ApiMethods include CountMethods extend SearchMethods - include DeletionMethods def initialize_default_image_size self.default_image_size = "large" diff --git a/test/factories/note.rb b/test/factories/note.rb index 90e0f6958..01d4b6508 100644 --- a/test/factories/note.rb +++ b/test/factories/note.rb @@ -2,10 +2,10 @@ FactoryGirl.define do factory(:note) do creator :factory => :user post - x 0 - y 0 - width 0 - height 0 + x 1 + y 1 + width 1 + height 1 is_active true body {Faker::Lorem.sentences.join(" ")} updater_id :factory => :user diff --git a/test/unit/note_test.rb b/test/unit/note_test.rb index 12b6b57ed..cc95acc7f 100644 --- a/test/unit/note_test.rb +++ b/test/unit/note_test.rb @@ -132,9 +132,9 @@ class NoteTest < ActiveSupport::TestCase context "when notes have been vandalized by one user" do setup do @vandal = FactoryGirl.create(:user) - @note = FactoryGirl.create(:note, :x => 100, :y => 100) + @note = FactoryGirl.create(:note, :x => 5, :y => 5) CurrentUser.scoped(@vandal, "127.0.0.1") do - @note.update_attributes(:x => 2000, :y => 2000) + @note.update_attributes(:x => 10, :y => 10) end end @@ -142,8 +142,8 @@ class NoteTest < ActiveSupport::TestCase should "revert any affected notes" do Note.undo_changes_by_user(@vandal.id) @note.reload - assert_equal(100, @note.x) - assert_equal(100, @note.y) + assert_equal(5, @note.x) + assert_equal(5, @note.y) end end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index acdffb00f..7f2f33bee 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -14,29 +14,6 @@ class UserTest < ActiveSupport::TestCase CurrentUser.ip_addr = nil end - context "that has been deleted" do - setup do - @post = FactoryGirl.create(:post) - Favorite.add(@post, @user) - @user.delete! - @post.reload - end - - should "rename the user" do - assert_equal("user#{@user.id}", @user.name) - end - - should "remove all favorites" do - assert_equal(0, @user.favorite_count) - assert_equal(0, Favorite.for_user(@user.id).count) - assert_equal("", @post.fav_string) - end - - should "reset the password" do - assert_nil(User.authenticate(@user.name, "password")) - end - end - context "favoriting a post" do setup do @user.update_column(:favorite_count, 999)