diff --git a/app/models/card/not_now.rb b/app/models/card/not_now.rb index 456ff2751..dcd16a86d 100644 --- a/app/models/card/not_now.rb +++ b/app/models/card/not_now.rb @@ -1,3 +1,4 @@ class Card::NotNow < ApplicationRecord belongs_to :card, class_name: "::Card", touch: true + belongs_to :user, optional: true end diff --git a/app/models/card/postponable.rb b/app/models/card/postponable.rb index 486960f6a..2ad6b1b14 100644 --- a/app/models/card/postponable.rb +++ b/app/models/card/postponable.rb @@ -24,12 +24,12 @@ module Card::Postponable open? && published? && !postponed? end - def postpone + def postpone(user: Current.user) transaction do send_back_to_triage reopen activity_spike&.destroy - create_not_now! unless postponed? + create_not_now!(user: user) unless postponed? end end diff --git a/app/views/cards/display/common/_background.html.erb b/app/views/cards/display/common/_background.html.erb index 05ba7f338..e2531886c 100644 --- a/app/views/cards/display/common/_background.html.erb +++ b/app/views/cards/display/common/_background.html.erb @@ -10,7 +10,7 @@
Not Now <%= card.postponed_at.strftime("%b %d, %Y") %> - by <%# card.postponed_by.familiar_name %> + by <%= card.postponed_by.familiar_name %>
<% end %> diff --git a/db/migrate/20251015112653_add_creator_to_card_not_nows.rb b/db/migrate/20251015112653_add_creator_to_card_not_nows.rb new file mode 100644 index 000000000..747a347b9 --- /dev/null +++ b/db/migrate/20251015112653_add_creator_to_card_not_nows.rb @@ -0,0 +1,5 @@ +class AddCreatorToCardNotNows < ActiveRecord::Migration[8.1] + def change + add_reference :card_not_nows, :creator, null: false, foreign_key: { to_table: :users } + end +end diff --git a/db/migrate/20251015114014_rename_creator_to_user_in_card_not_nows.rb b/db/migrate/20251015114014_rename_creator_to_user_in_card_not_nows.rb new file mode 100644 index 000000000..5092aae67 --- /dev/null +++ b/db/migrate/20251015114014_rename_creator_to_user_in_card_not_nows.rb @@ -0,0 +1,5 @@ +class RenameCreatorToUserInCardNotNows < ActiveRecord::Migration[8.1] + def change + rename_column :card_not_nows, :creator_id, :user_id + end +end diff --git a/db/schema.rb b/db/schema.rb index d84722ea0..c0560eb47 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_07_084223) do +ActiveRecord::Schema[8.1].define(version: 2025_10_15_114014) do create_table "accesses", force: :cascade do |t| t.datetime "accessed_at" t.integer "collection_id", null: false @@ -135,7 +135,9 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_07_084223) do t.integer "card_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "user_id", null: false t.index ["card_id"], name: "index_card_not_nows_on_card_id", unique: true + t.index ["user_id"], name: "index_card_not_nows_on_user_id" end create_table "cards", force: :cascade do |t| @@ -508,6 +510,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_07_084223) do add_foreign_key "card_activity_spikes", "cards" add_foreign_key "card_goldnesses", "cards" add_foreign_key "card_not_nows", "cards" + add_foreign_key "card_not_nows", "users" add_foreign_key "cards", "columns" add_foreign_key "closures", "cards" add_foreign_key "closures", "users" diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 84068a62f..60d09eac2 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -438,6 +438,7 @@ columns: - *5 - *6 - *9 + - *18 cards: - *24 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -1963,6 +1964,22 @@ indexes: nulls_not_distinct: comment: valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: card_not_nows + name: index_card_not_nows_on_user_id + unique: false + columns: + - user_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true cards: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: cards @@ -3148,4 +3165,4 @@ indexes: nulls_not_distinct: comment: valid: true -version: 20251007084223 +version: 20251015114014 diff --git a/test/models/card/postponable_test.rb b/test/models/card/postponable_test.rb index b4a183437..89f3179ae 100644 --- a/test/models/card/postponable_test.rb +++ b/test/models/card/postponable_test.rb @@ -22,6 +22,8 @@ class Card::PostponableTest < ActiveSupport::TestCase assert_changes -> { card.reload.postponed? }, to: true do card.postpone end + + assert_equal users(:david), card.not_now.user end test "scopes" do