Skip to content

Commit 140761e

Browse files
committed
Don't try get fixtures_paths from Rails
1 parent cd2e535 commit 140761e

File tree

5 files changed

+5
-1094
lines changed

5 files changed

+5
-1094
lines changed

lib/ruby_lsp/ruby_lsp_rails/addon.rb

+3-6
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def register_additional_file_watchers(global_state:, outgoing_queue:)
223223
id: "workspace/didChangeWatchedFilesRails",
224224
method: "workspace/didChangeWatchedFiles",
225225
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
226-
watchers: [structure_sql_file_watcher, fixture_file_watcher].compact,
226+
watchers: [structure_sql_file_watcher, fixture_file_watcher],
227227
),
228228
),
229229
],
@@ -239,13 +239,10 @@ def structure_sql_file_watcher
239239
)
240240
end
241241

242-
sig { returns(T.nilable(Interface::FileSystemWatcher)) }
242+
sig { returns(Interface::FileSystemWatcher) }
243243
def fixture_file_watcher
244-
paths = @rails_runner_client.fixture_paths
245-
return unless paths
246-
247244
Interface::FileSystemWatcher.new(
248-
glob_pattern: "{#{paths.join(",")}}/**/*.{yml,yaml,yml.erb,yaml.erb}",
245+
glob_pattern: "/fixtures/**/*.{yml,yaml,yml.erb,yaml.erb}",
249246
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
250247
)
251248
end

lib/ruby_lsp/ruby_lsp_rails/runner_client.rb

-4
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ class EmptyMessageError < MessageError; end
5151
sig { returns(String) }
5252
attr_reader :rails_root
5353

54-
sig { returns(T.nilable(T::Array[String])) }
55-
attr_reader :fixture_paths
56-
5754
sig { params(outgoing_queue: Thread::Queue).void }
5855
def initialize(outgoing_queue)
5956
@outgoing_queue = T.let(outgoing_queue, Thread::Queue)
@@ -92,7 +89,6 @@ def initialize(outgoing_queue)
9289

9390
initialize_response = T.must(read_response)
9491
@rails_root = T.let(initialize_response[:root], String)
95-
@fixture_paths = T.let(initialize_response[:fixture_paths], T.nilable(T::Array[String]))
9692
log_message("Finished booting Ruby LSP Rails server")
9793

9894
unless ENV["RAILS_ENV"] == "test"

lib/ruby_lsp/ruby_lsp_rails/server.rb

+2-18
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@
44
require "json"
55
require "open3"
66

7-
# This replicates what Rails does internally
8-
if defined?(ActiveRecord::Base)
9-
ActiveSupport.on_load(:active_support_test_case) do
10-
include ActiveRecord::TestFixtures
11-
12-
fixture_paths << "#{Rails.root}/test/fixtures/"
13-
end
14-
end
15-
167
module RubyLsp
178
module Rails
189
module Common
@@ -132,15 +123,8 @@ def initialize(stdout: $stdout, override_default_output_device: true)
132123
def start
133124
load_routes
134125
clear_file_system_resolver_hooks
135-
# `fixtures_path` is only available in Rails 7.1 and later
136-
# Prior to that it used `fixture_path` which we do not support.
137-
fixtures_paths = ActiveSupport::TestCase.fixture_paths if ActiveSupport::TestCase.respond_to?(:fixture_paths)
138-
139-
send_result({
140-
message: "ok",
141-
root: ::Rails.root.to_s,
142-
fixture_paths: fixtures_paths,
143-
})
126+
127+
send_result({ message: "ok", root: ::Rails.root.to_s })
144128

145129
while @running
146130
headers = @stdin.gets("\r\n\r\n")

0 commit comments

Comments
 (0)