From afea601d84eddcbfff771e29c54fcfc603268272 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Tue, 10 May 2022 15:03:48 +0100 Subject: [PATCH] Allow users to be marked as inactive --- db/migrate/20220510134721_add_inactive_users.rb | 5 +++++ db/schema.rb | 3 ++- spec/models/user_spec.rb | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20220510134721_add_inactive_users.rb diff --git a/db/migrate/20220510134721_add_inactive_users.rb b/db/migrate/20220510134721_add_inactive_users.rb new file mode 100644 index 000000000..453549a2c --- /dev/null +++ b/db/migrate/20220510134721_add_inactive_users.rb @@ -0,0 +1,5 @@ +class AddInactiveUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :active, :boolean, default: true + end +end diff --git a/db/schema.rb b/db/schema.rb index ba9001e74..669a9b325 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_05_10_091620) do +ActiveRecord::Schema[7.0].define(version: 2022_05_10_134721) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -339,6 +339,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_05_10_091620) do t.string "direct_otp" t.datetime "direct_otp_sent_at", precision: nil t.datetime "totp_timestamp", precision: nil + t.boolean "active", default: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["encrypted_otp_secret_key"], name: "index_users_on_encrypted_otp_secret_key", unique: true t.index ["organisation_id"], name: "index_users_on_organisation_id" diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index da518eb34..97b1fdaf1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -65,6 +65,10 @@ RSpec.describe User, type: :model do .to change { user.reload.is_data_protection_officer? }.from(false).to(true) end + it "is active by default" do + expect(user.active).to be true + end + it "does not require 2FA" do expect(user.need_two_factor_authentication?(nil)).to be false end