From 1efbdb2d6c6b0853087f12e50878bd64f9f02cda Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Fri, 5 Jan 2024 13:04:06 +0300 Subject: [PATCH] Add closed_by attribute to :closed note factory trait --- test/controllers/notes_controller_test.rb | 4 +--- test/factories/notes.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 5cffbd702..b2f14a127 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -144,9 +144,7 @@ class NotesControllerTest < ActionDispatch::IntegrationTest def test_read_closed_note user = create(:user) - closed_note = create(:note_with_comments, :status => "closed", :closed_at => Time.now.utc, :comments_count => 2) do |note| - create(:note_comment, :event => "closed", :note => note, :author => user) - end + closed_note = create(:note_with_comments, :closed, :closed_by => user, :comments_count => 2) browse_check :note_path, closed_note.id, "notes/show" assert_select "div.note-comments ul li", :count => 2 diff --git a/test/factories/notes.rb b/test/factories/notes.rb index 63dcd7804..ab7d5df56 100644 --- a/test/factories/notes.rb +++ b/test/factories/notes.rb @@ -5,11 +5,15 @@ FactoryBot.define do # tile { QuadTile.tile_for_point(1,1) } trait :closed do + transient do + closed_by { nil } + end + status { "closed" } closed_at { Time.now.utc } - after(:create) do |note| - create(:note_comment, :body => "Closing comment", :event => "closed", :note => note) + after(:create) do |note, context| + create(:note_comment, :author => context.closed_by, :body => "Closing comment", :event => "closed", :note => note) end end -- 2.45.1