diff --git a/app/models/user.rb b/app/models/user.rb index 7fb19c411e9460c0c9fd106f09d912c1adc73626..8c2810e759005ab918bd47028cb2ce660635c9b2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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" diff --git a/db/migrate/20150209230946_disable_mail_for_closed_account.rb b/db/migrate/20150209230946_disable_mail_for_closed_account.rb new file mode 100644 index 0000000000000000000000000000000000000000..575b16cfcd186f7c1d388f80e82cd078f7eb8ee4 --- /dev/null +++ b/db/migrate/20150209230946_disable_mail_for_closed_account.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 67a80297415c2547492597150cb4f02085f848b9..c8edada902420ac81b2a83a8f0a684e3a3cd6f15 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 33be531b013406ae1a190af685d3458ba683e858..37ad3a8e025a6c8e87bf0f46d28a447cdd1e6035 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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