From da413e75403e3617db5538339f5508bbaa23f2a6 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 15 Oct 2025 16:15:56 -0500 Subject: [PATCH] Remove closure reasons --- app/controllers/cards/closures_controller.rb | 2 +- app/helpers/events_helper.rb | 2 +- app/helpers/notifications_helper.rb | 7 +- app/helpers/webhooks_helper.rb | 2 +- app/models/account.rb | 1 - app/models/card/closeable.rb | 4 +- app/models/card/eventable/system_commenter.rb | 2 +- app/models/closure/reason.rb | 27 ------ app/models/notification_pusher.rb | 2 +- app/views/cards/container/_closure.html.erb | 2 +- app/views/cards/triage/_columns.html.erb | 2 +- .../20251015204327_remove_closure_reasons.rb | 5 + ...51015205212_remove_reason_from_closures.rb | 5 + db/schema.rb | 20 ++-- db/schema_cache.yml | 92 +++++++++++++------ db/untenanted_schema.rb | 14 ++- .../cards/closures_controller_test.rb | 4 +- test/fixtures/closures.yml | 3 +- .../card/eventable/system_commenter_test.rb | 2 +- 19 files changed, 112 insertions(+), 86 deletions(-) delete mode 100644 app/models/closure/reason.rb create mode 100644 db/migrate/20251015204327_remove_closure_reasons.rb create mode 100644 db/migrate/20251015205212_remove_reason_from_closures.rb diff --git a/app/controllers/cards/closures_controller.rb b/app/controllers/cards/closures_controller.rb index c2df13433..b89395cd5 100644 --- a/app/controllers/cards/closures_controller.rb +++ b/app/controllers/cards/closures_controller.rb @@ -2,7 +2,7 @@ class Cards::ClosuresController < ApplicationController include CardScoped def create - @card.close(user: Current.user, reason: params[:reason]) + @card.close(user: Current.user) render_card_replacement end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index b037c63c4..031236b1c 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -84,7 +84,7 @@ module EventsHelper when "card_published" "#{h event_creator_name(event) } added #{h title }".html_safe when "card_closed" - "#{h event_creator_name(event) } closed #{h title }".html_safe + "#{h event_creator_name(event) } marked #{h title } as done".html_safe when "card_reopened" "#{h event_creator_name(event) } reopened #{h title }".html_safe when "card_due_date_added" diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index cd9e005a9..2f0456f78 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -10,12 +10,7 @@ module NotificationsHelper name = event.creator.name case event_notification_action(event) - when "card_closed" - if event.card.closure - "Closed as “#{event.card.closure.reason}” by #{name}" - else - "Closed by #{name}" - end + when "card_closed" then "Marked as “Done” by #{name}" when "card_reopened" then "Reopened by #{name}" when "card_published" then "Added by #{name}" when "comment_created" then comment_notification_body(event) diff --git a/app/helpers/webhooks_helper.rb b/app/helpers/webhooks_helper.rb index dfb61c922..42c12c404 100644 --- a/app/helpers/webhooks_helper.rb +++ b/app/helpers/webhooks_helper.rb @@ -1,7 +1,7 @@ module WebhooksHelper ACTION_LABELS = { card_assigned: "Card assigned", - card_closed: "Card closed", + card_closed: "Card marked as Done", card_collection_changed: "Card collection changed", card_due_date_added: "Card due date added", card_due_date_changed: "Card due date changed", diff --git a/app/models/account.rb b/app/models/account.rb index 5e97480ce..c7c00f979 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -17,7 +17,6 @@ class Account < ApplicationRecord def setup_basic_template user = User.first - Closure::Reason.create_defaults Collection.create!(name: "Cards", creator: user, all_access: true) end end diff --git a/app/models/card/closeable.rb b/app/models/card/closeable.rb index f9b045239..51852c9a5 100644 --- a/app/models/card/closeable.rb +++ b/app/models/card/closeable.rb @@ -28,10 +28,10 @@ module Card::Closeable closure&.created_at end - def close(user: Current.user, reason: Closure::Reason.default) + def close(user: Current.user) unless closed? transaction do - create_closure! user: user, reason: reason + create_closure! user: user track_event :closed, creator: user end end diff --git a/app/models/card/eventable/system_commenter.rb b/app/models/card/eventable/system_commenter.rb index 65a6b8a36..29f981173 100644 --- a/app/models/card/eventable/system_commenter.rb +++ b/app/models/card/eventable/system_commenter.rb @@ -19,7 +19,7 @@ class Card::Eventable::SystemCommenter when "card_unassigned" "#{event.creator.name} unassigned from #{event.assignees.pluck(:name).to_sentence}." when "card_closed" - "Closed as ‘#{ card.closure.reason }’ by #{ event.creator.name }" + "Marked as “Done” by #{ event.creator.name }" when "card_reopened" "Reopened by #{ event.creator.name }" when "card_title_changed" diff --git a/app/models/closure/reason.rb b/app/models/closure/reason.rb deleted file mode 100644 index f071901c1..000000000 --- a/app/models/closure/reason.rb +++ /dev/null @@ -1,27 +0,0 @@ -class Closure::Reason < ApplicationRecord - DEFAULT_LABELS = [ - "Completed", - "Duplicate", - "Maybe later", - "Working as intended", - "Not now" - ] - - FALLBACK_LABEL = "Done" - - class << self - def labels - pluck(:label).presence || [ FALLBACK_LABEL ] - end - - def default - labels.first - end - - def create_defaults - DEFAULT_LABELS.each do |label| - create! label: label - end - end - end -end diff --git a/app/models/notification_pusher.rb b/app/models/notification_pusher.rb index a5784cf2e..000a80fff 100644 --- a/app/models/notification_pusher.rb +++ b/app/models/notification_pusher.rb @@ -59,7 +59,7 @@ class NotificationPusher ) when "card_closed" base_payload.merge( - body: card.closure ? "Closed as \"#{card.closure.reason}\" by #{event.creator.name}" : "Closed by #{event.creator.name}" + body: card.closure ? "Marked as “Done” by #{event.creator.name}" : "Closed by #{event.creator.name}" ) when "card_reopened" base_payload.merge( diff --git a/app/views/cards/container/_closure.html.erb b/app/views/cards/container/_closure.html.erb index 80a8751a5..bad02f3cd 100644 --- a/app/views/cards/container/_closure.html.erb +++ b/app/views/cards/container/_closure.html.erb @@ -7,7 +7,7 @@ <% end %> <% else %> - <%= button_to card_closure_path(card, reason: "Done"), class: "btn borderless" do %> + <%= button_to card_closure_path(card), class: "btn borderless" do %> Mark as Done <% end %> <% if card.entropic? && card.open? %> diff --git a/app/views/cards/triage/_columns.html.erb b/app/views/cards/triage/_columns.html.erb index c77f06529..0222b48f6 100644 --- a/app/views/cards/triage/_columns.html.erb +++ b/app/views/cards/triage/_columns.html.erb @@ -17,7 +17,7 @@ <%= button_to_set_column card, column %> <% end %> - <%= button_to "Done", card_closure_path(card, reason: "Completed"), + <%= button_to "Done", card_closure_path(card), class: [ "card__column-name btn", { "card__column-name--current": card.closed? } ], role: "radio", aria: { checked: card.closed? }, diff --git a/db/migrate/20251015204327_remove_closure_reasons.rb b/db/migrate/20251015204327_remove_closure_reasons.rb new file mode 100644 index 000000000..6e376a222 --- /dev/null +++ b/db/migrate/20251015204327_remove_closure_reasons.rb @@ -0,0 +1,5 @@ +class RemoveClosureReasons < ActiveRecord::Migration[8.1] + def change + drop_table :closure_reasons + end +end diff --git a/db/migrate/20251015205212_remove_reason_from_closures.rb b/db/migrate/20251015205212_remove_reason_from_closures.rb new file mode 100644 index 000000000..1ca3f465d --- /dev/null +++ b/db/migrate/20251015205212_remove_reason_from_closures.rb @@ -0,0 +1,5 @@ +class RemoveReasonFromClosures < ActiveRecord::Migration[8.1] + def change + remove_column :closures, :reason + end +end diff --git a/db/schema.rb b/db/schema.rb index b6d4d1ffe..53935ecff 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[8.1].define(version: 2025_10_15_123003) do +ActiveRecord::Schema[8.1].define(version: 2025_10_15_205212) do create_table "accesses", force: :cascade do |t| t.datetime "accessed_at" t.integer "collection_id", null: false @@ -29,6 +29,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_15_123003) do t.integer "external_account_id" t.string "join_code" t.string "name", null: false + t.string "setup_status" t.datetime "updated_at", null: false t.index ["external_account_id"], name: "index_accounts_on_external_account_id", unique: true end @@ -162,16 +163,9 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_15_123003) do t.index ["filter_id"], name: "index_closers_filters_on_filter_id" end - create_table "closure_reasons", force: :cascade do |t| - t.datetime "created_at", null: false - t.string "label" - t.datetime "updated_at", null: false - end - create_table "closures", force: :cascade do |t| t.integer "card_id", null: false t.datetime "created_at", null: false - t.string "reason", null: false t.datetime "updated_at", null: false t.integer "user_id" t.index ["card_id", "created_at"], name: "index_closures_on_card_id_and_created_at" @@ -293,6 +287,15 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_15_123003) do t.index ["tag_id"], name: "index_filters_tags_on_tag_id" end + create_table "integrations", force: :cascade do |t| + t.datetime "created_at", null: false + t.text "data" + t.integer "owner_id", null: false + t.string "type" + t.datetime "updated_at", null: false + t.index ["owner_id"], name: "index_integrations_on_owner_id" + end + create_table "mentions", force: :cascade do |t| t.datetime "created_at", null: false t.integer "mentionee_id", null: false @@ -522,6 +525,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_15_123003) do add_foreign_key "conversation_messages", "conversations" add_foreign_key "conversations", "users" add_foreign_key "events", "collections" + add_foreign_key "integrations", "users", column: "owner_id" add_foreign_key "mentions", "users", column: "mentionee_id" add_foreign_key "mentions", "users", column: "mentioner_id" add_foreign_key "notification_bundles", "users" diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 68e51777c..de42a9e4f 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -133,6 +133,16 @@ columns: default_function: collation: comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: setup_status + cast_type: *7 + sql_type_metadata: *8 + 'null': true + default: + default_function: + collation: + comment: - *9 action_text_rich_texts: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -534,34 +544,10 @@ columns: collation: comment: - *20 - closure_reasons: - - *5 - - *6 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: label - cast_type: *7 - sql_type_metadata: *8 - 'null': true - default: - default_function: - collation: - comment: - - *9 closures: - *23 - *5 - *6 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: reason - cast_type: *7 - sql_type_metadata: *8 - 'null': false - default: - default_function: - collation: - comment: - *9 - *25 collection_publications: @@ -875,6 +861,40 @@ columns: default_function: collation: comment: + integrations: + - *5 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: data + cast_type: *15 + sql_type_metadata: *16 + 'null': true + default: + default_function: + collation: + comment: + - *6 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: owner_id + cast_type: *3 + sql_type_metadata: *4 + 'null': false + default: + default_function: + collation: + comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: type + cast_type: *7 + sql_type_metadata: *8 + 'null': true + default: + default_function: + collation: + comment: + - *9 mentions: - *5 - *6 @@ -1466,7 +1486,6 @@ primary_keys: card_not_nows: id cards: id closers_filters: - closure_reasons: id closures: id collection_publications: id collections: id @@ -1480,6 +1499,7 @@ primary_keys: events: id filters: id filters_tags: + integrations: id mentions: id notification_bundles: id notifications: id @@ -1520,7 +1540,6 @@ data_sources: card_not_nows: true cards: true closers_filters: true - closure_reasons: true closures: true collection_publications: true collections: true @@ -1534,6 +1553,7 @@ data_sources: events: true filters: true filters_tags: true + integrations: true mentions: true notification_bundles: true notifications: true @@ -2063,7 +2083,6 @@ indexes: nulls_not_distinct: comment: valid: true - closure_reasons: [] closures: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: closures @@ -2451,6 +2470,23 @@ indexes: nulls_not_distinct: comment: valid: true + integrations: + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: integrations + name: index_integrations_on_owner_id + unique: false + columns: + - owner_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true mentions: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: mentions @@ -3197,4 +3233,4 @@ indexes: nulls_not_distinct: comment: valid: true -version: 20251015123003 +version: 20251015205212 diff --git a/db/untenanted_schema.rb b/db/untenanted_schema.rb index d7f090873..1272ff070 100644 --- a/db/untenanted_schema.rb +++ b/db/untenanted_schema.rb @@ -10,12 +10,23 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2025_09_24_190729) do +ActiveRecord::Schema[8.1].define(version: 2025_10_07_112917) do create_table "identities", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false end + create_table "magic_links", force: :cascade do |t| + t.string "code" + t.datetime "created_at", null: false + t.datetime "expires_at" + t.integer "membership_id", null: false + t.datetime "updated_at", null: false + t.index ["code"], name: "index_magic_links_on_code", unique: true + t.index ["expires_at"], name: "index_magic_links_on_expires_at" + t.index ["membership_id"], name: "index_magic_links_on_membership_id" + end + create_table "memberships", force: :cascade do |t| t.string "account_name", null: false t.datetime "created_at", null: false @@ -29,5 +40,6 @@ ActiveRecord::Schema[8.1].define(version: 2025_09_24_190729) do t.index ["user_tenant", "user_id"], name: "index_memberships_on_user_tenant_and_user_id" end + add_foreign_key "magic_links", "memberships" add_foreign_key "memberships", "identities" end diff --git a/test/controllers/cards/closures_controller_test.rb b/test/controllers/cards/closures_controller_test.rb index 1e8f85871..73c1181e4 100644 --- a/test/controllers/cards/closures_controller_test.rb +++ b/test/controllers/cards/closures_controller_test.rb @@ -9,11 +9,9 @@ class Cards::ClosuresControllerTest < ActionDispatch::IntegrationTest card = cards(:logo) assert_changes -> { card.reload.closed? }, from: false, to: true do - post card_closure_path(card, reason: "Scope too big") + post card_closure_path(card) assert_card_container_rerendered(card) end - - assert_equal "Scope too big", card.closure.reason end test "destroy" do diff --git a/test/fixtures/closures.yml b/test/fixtures/closures.yml index 8ddfbbe4c..cf9593601 100644 --- a/test/fixtures/closures.yml +++ b/test/fixtures/closures.yml @@ -1,4 +1,3 @@ shipping: card: shipping - user: kevin - reason: Closed + user: kevin \ No newline at end of file diff --git a/test/models/card/eventable/system_commenter_test.rb b/test/models/card/eventable/system_commenter_test.rb index 6f125f869..2008c031c 100644 --- a/test/models/card/eventable/system_commenter_test.rb +++ b/test/models/card/eventable/system_commenter_test.rb @@ -22,7 +22,7 @@ class Card::Eventable::SystemCommenterTest < ActiveSupport::TestCase end test "card_closed" do - assert_system_comment "Closed as ‘Done’ by David" do + assert_system_comment "Marked as “Done” by David" do @card.close end end