Browse Source

Remove change_type attribute from organisation name changes

pull/3056/head
Manny Dinssa 2 weeks ago
parent
commit
f70f914063
  1. 1
      app/controllers/organisation_name_changes_controller.rb
  2. 7
      app/models/organisation_name_change.rb
  3. 1
      db/migrate/20250416111741_create_organisation_name_changes.rb
  4. 1
      db/schema.rb
  5. 1
      spec/factories/organisation_name_change.rb

1
app/controllers/organisation_name_changes_controller.rb

@ -4,7 +4,6 @@ class OrganisationNameChangesController < ApplicationController
def create
@organisation_name_change = @organisation.organisation_name_changes.new(organisation_name_change_params)
@organisation_name_change.change_type = :user_change
if @organisation_name_change.save
notice_message = @organisation_name_change.immediate_change ? "Name change saved successfully." : "Name change scheduled for #{@organisation_name_change.formatted_startdate}."

7
app/models/organisation_name_change.rb

@ -16,13 +16,6 @@ class OrganisationNameChange < ApplicationRecord
before_validation :set_startdate_if_immediate
CHANGE_TYPE = {
user_change: 1,
merge: 2, # Currently not used, we could differentiate name changes resulting from a merge
}.freeze
enum :change_type, CHANGE_TYPE, prefix: true
has_paper_trail
def status

1
db/migrate/20250416111741_create_organisation_name_changes.rb

@ -5,7 +5,6 @@ class CreateOrganisationNameChanges < ActiveRecord::Migration[7.0]
t.string :name, null: false
t.date :startdate, null: false
t.date :discarded_at
t.integer :change_type
t.timestamps
end

1
db/schema.rb

@ -502,7 +502,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_16_111741) do
t.string "name", null: false
t.date "startdate", null: false
t.date "discarded_at"
t.integer "change_type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["organisation_id", "startdate"], name: "index_org_name_changes_on_org_id_and_startdate", unique: true

1
spec/factories/organisation_name_change.rb

@ -4,7 +4,6 @@ FactoryBot.define do
name { "#{Faker::Name.name} Housing Org" }
immediate_change { true }
startdate { Time.zone.tomorrow }
change_type { :user_change }
trait :future_change do
immediate_change { false }

Loading…
Cancel
Save