Set disable_mail to true
Add #clear_account! disable mail spec Add migration for disabling mail for all closed accounts Change migration to use #update_all for disable_mail attribute Add #clear_account! false fields spec
This commit is contained in:
parent
5af4324377
commit
f695b5d3e7
4 changed files with 23 additions and 2 deletions
|
|
@ -489,10 +489,10 @@ class User < ActiveRecord::Base
|
|||
self[field] = nil
|
||||
end
|
||||
[:getting_started,
|
||||
:disable_mail,
|
||||
:show_community_spotlight_in_stream].each do |field|
|
||||
self[field] = false
|
||||
end
|
||||
self[:disable_mail] = true
|
||||
self[:strip_exif] = true
|
||||
self[:email] = "deletedaccount_#{self[:id]}@example.org"
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
class DisableMailForClosedAccount < ActiveRecord::Migration
|
||||
def up
|
||||
User.joins(:person).where(people: {closed_account: true}).update_all(disable_mail: true)
|
||||
end
|
||||
|
||||
def down
|
||||
User.joins(:person).where(people: {closed_account: true}).update_all(disable_mail: false)
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150106050733) do
|
||||
ActiveRecord::Schema.define(version: 20150209230946) do
|
||||
|
||||
create_table "account_deletions", force: true do |t|
|
||||
t.string "diaspora_handle"
|
||||
|
|
|
|||
|
|
@ -962,6 +962,18 @@ describe User, :type => :model do
|
|||
expect(@user.send(attr.to_sym)).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
it 'disables mail' do
|
||||
@user.disable_mail = false
|
||||
@user.clear_account!
|
||||
expect(@user.reload.disable_mail).to be true
|
||||
end
|
||||
|
||||
it 'sets getting_started and show_community_spotlight_in_stream fields to false' do
|
||||
@user.clear_account!
|
||||
expect(@user.reload.getting_started).to be false
|
||||
expect(@user.reload.show_community_spotlight_in_stream).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#clearable_attributes" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue