From 1209d51a7f8fa7f570ff4843af48a47aee4b6524 Mon Sep 17 00:00:00 2001
From: Jarek Radosz <jradosz@gmail.com>
Date: Fri, 22 Apr 2022 11:17:10 +0200
Subject: [PATCH] DEV: Don't use `Dir.chdir()` (#16535)

`system()` provides `chdir:` option for that.
---
 lib/tasks/qunit.rake | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/lib/tasks/qunit.rake b/lib/tasks/qunit.rake
index d54f9ed8a8f..be5f6654b53 100644
--- a/lib/tasks/qunit.rake
+++ b/lib/tasks/qunit.rake
@@ -1,7 +1,6 @@
 # frozen_string_literal: true
 
 desc "Runs the qunit test suite"
-
 task "qunit:test", [:timeout, :qunit_path] do |_, args|
   require "socket"
   require "chrome_installed_checker"
@@ -107,11 +106,9 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
     puts "Rails server is warmed up"
 
     if ember_cli
-      Dir.chdir("#{Rails.root}/app/assets/javascripts/discourse") do # rubocop:disable Discourse/NoChdir because this is not part of the app
-        cmd = ["env", "UNICORN_PORT=#{unicorn_port}", "yarn", "ember", "test", "--query", query]
-        cmd += ["--test-page", qunit_path.delete_prefix("/")] if qunit_path
-        system(*cmd)
-      end
+      cmd = ["env", "UNICORN_PORT=#{unicorn_port}", "yarn", "ember", "test", "--query", query]
+      cmd += ["--test-page", qunit_path.delete_prefix("/")] if qunit_path
+      system(*cmd, chdir: "#{Rails.root}/app/assets/javascripts/discourse")
     else
       cmd = "node #{test_path}/run-qunit.js http://localhost:#{port}#{qunit_path}"
       cmd += "?#{query.gsub('+', '%20').gsub("&", '\\\&')}"
@@ -131,5 +128,4 @@ task "qunit:test", [:timeout, :qunit_path] do |_, args|
     puts "\nTests Failed"
     exit(1)
   end
-
 end