Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ ## Refactor * Add unique index to poll participations on `poll_id` and `author_id` [#7798](https://github.com/diaspora/diaspora/pull/7798) * Add 'completed at' date to account migrations [#7805](https://github.com/diaspora/diaspora/pull/7805) ## Bug fixes Loading app/models/account_migration.rb +2 −1 Original line number Diff line number Diff line Loading @@ -40,10 +40,11 @@ class AccountMigration < ApplicationRecord dispatch if locally_initiated? dispatch_contacts if remotely_initiated? update(completed_at: Time.zone.now) end def performed? old_person.closed_account? !completed_at.nil? end # We assume that migration message subscribers are people that are subscribed to a new user profile updates. Loading db/migrate/20180430134444_add_completed_at_to_account_migration.rb 0 → 100644 +19 −0 Original line number Diff line number Diff line # frozen_string_literal: true class AddCompletedAtToAccountMigration < ActiveRecord::Migration[5.1] def change add_column :account_migrations, :completed_at, :datetime, default: nil reversible do |change| change.up do set_completed_at_for_closed_accounts end end end def set_completed_at_for_closed_accounts # rubocop:disable Rails/SkipsModelValidations AccountMigration.joins(:old_person).where(people: {closed_account: true}).update_all(completed_at: Time.zone.now) # rubocop:enable Rails/SkipsModelValidations end end spec/models/account_migration_spec.rb +8 −3 Original line number Diff line number Diff line Loading @@ -61,9 +61,14 @@ describe AccountMigration, type: :model do }.to change(account_migration, :performed?).to be_truthy end it "calls old_person.closed_account?" do expect(account_migration.old_person).to receive(:closed_account?) account_migration.performed? it "is truthy when completed_at is set" do expect(FactoryGirl.create(:account_migration, completed_at: Time.zone.now).performed?).to be_truthy end it "is falsey when completed_at is null" do account_migration = FactoryGirl.create(:account_migration, completed_at: nil) account_migration.old_person.lock_access! expect(account_migration.performed?).to be_falsey end end Loading Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ ## Refactor * Add unique index to poll participations on `poll_id` and `author_id` [#7798](https://github.com/diaspora/diaspora/pull/7798) * Add 'completed at' date to account migrations [#7805](https://github.com/diaspora/diaspora/pull/7805) ## Bug fixes Loading
app/models/account_migration.rb +2 −1 Original line number Diff line number Diff line Loading @@ -40,10 +40,11 @@ class AccountMigration < ApplicationRecord dispatch if locally_initiated? dispatch_contacts if remotely_initiated? update(completed_at: Time.zone.now) end def performed? old_person.closed_account? !completed_at.nil? end # We assume that migration message subscribers are people that are subscribed to a new user profile updates. Loading
db/migrate/20180430134444_add_completed_at_to_account_migration.rb 0 → 100644 +19 −0 Original line number Diff line number Diff line # frozen_string_literal: true class AddCompletedAtToAccountMigration < ActiveRecord::Migration[5.1] def change add_column :account_migrations, :completed_at, :datetime, default: nil reversible do |change| change.up do set_completed_at_for_closed_accounts end end end def set_completed_at_for_closed_accounts # rubocop:disable Rails/SkipsModelValidations AccountMigration.joins(:old_person).where(people: {closed_account: true}).update_all(completed_at: Time.zone.now) # rubocop:enable Rails/SkipsModelValidations end end
spec/models/account_migration_spec.rb +8 −3 Original line number Diff line number Diff line Loading @@ -61,9 +61,14 @@ describe AccountMigration, type: :model do }.to change(account_migration, :performed?).to be_truthy end it "calls old_person.closed_account?" do expect(account_migration.old_person).to receive(:closed_account?) account_migration.performed? it "is truthy when completed_at is set" do expect(FactoryGirl.create(:account_migration, completed_at: Time.zone.now).performed?).to be_truthy end it "is falsey when completed_at is null" do account_migration = FactoryGirl.create(:account_migration, completed_at: nil) account_migration.old_person.lock_access! expect(account_migration.performed?).to be_falsey end end Loading