From e54b9d0d59e2a080e82aa7dcddf0a1b5171ae0c3 Mon Sep 17 00:00:00 2001 From: James Rose Date: Fri, 23 Sep 2022 12:16:44 +0100 Subject: [PATCH] We don't need a getter for old_user_id on User --- app/models/user.rb | 6 +----- db/schema.rb | 2 +- spec/models/user_spec.rb | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 50db816e7..40a430489 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -113,12 +113,8 @@ class User < ApplicationRecord end end - def old_user_id - legacy_users&.first&.old_user_id || read_attribute(:old_user_id) - end - def was_migrated_from_softwire? - old_user_id.present? + legacy_users.any? || old_user_id.present? end def send_confirmation_instructions diff --git a/db/schema.rb b/db/schema.rb index 0af743586..a0f222232 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -332,8 +332,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_23_093628) do t.string "purchid" t.integer "type" t.integer "ownershipsch" - t.integer "jointpur" t.string "othtype" + t.integer "jointpur" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index bad70e31e..450e334a7 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -75,11 +75,7 @@ RSpec.describe User, type: :model do end it "can have one or more legacy users" do - expect(user.old_user_id).to eq("3") - - user.legacy_users.destroy_all - user.update!(old_user_id: "2") - expect(user.old_user_id).to eq("2") + expect(user.legacy_users.size).to eq(1) end it "is confirmable" do