DEV: Capture output in hashtags spec (#20773)

This commit is contained in:
Jarek Radosz 2023-03-23 02:47:14 +01:00 committed by GitHub
parent 4cb79ce8be
commit 627f69738f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -6,10 +6,10 @@ task "hashtags:mark_old_format_for_rebake" => :environment do
# on a schedule.
puts "Finding posts matching old format, this could take some time..."
posts_to_rebake = Post.where("cooked like '%class=\"hashtag\"%'")
STDOUT.puts(
puts(
"[!] You are about to mark #{posts_to_rebake.count} posts containing hashtags in the old format to rebake. [CTRL+c] to cancel, [ENTER] to continue",
)
STDIN.gets.chomp if !Rails.env.test?
posts_to_rebake.update_all(baked_version: 0)
puts "Done, rebakes will happen when periodal updates job runs."
puts "Done, rebakes will happen when periodical updates job runs."
end

View File

@ -24,7 +24,7 @@ RSpec.describe "tasks/hashtags" do
post_3 = Fabricate(:post, raw: "This is a cool #support hashtag")
SiteSetting.enable_experimental_hashtag_autocomplete = false
Rake::Task["hashtags:mark_old_format_for_rebake"].invoke
capture_stdout { Rake::Task["hashtags:mark_old_format_for_rebake"].invoke }
[post_1, post_2, post_3].each(&:reload)