Skip to content

Commit

Permalink
Don't try get fixtures_paths from Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Jan 21, 2025
1 parent cd2e535 commit 140761e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1,094 deletions.
9 changes: 3 additions & 6 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def register_additional_file_watchers(global_state:, outgoing_queue:)
id: "workspace/didChangeWatchedFilesRails",
method: "workspace/didChangeWatchedFiles",
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
watchers: [structure_sql_file_watcher, fixture_file_watcher].compact,
watchers: [structure_sql_file_watcher, fixture_file_watcher],
),
),
],
Expand All @@ -239,13 +239,10 @@ def structure_sql_file_watcher
)
end

sig { returns(T.nilable(Interface::FileSystemWatcher)) }
sig { returns(Interface::FileSystemWatcher) }
def fixture_file_watcher
paths = @rails_runner_client.fixture_paths
return unless paths

Interface::FileSystemWatcher.new(
glob_pattern: "{#{paths.join(",")}}/**/*.{yml,yaml,yml.erb,yaml.erb}",
glob_pattern: "/fixtures/**/*.{yml,yaml,yml.erb,yaml.erb}",
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE,
)
end
Expand Down
4 changes: 0 additions & 4 deletions lib/ruby_lsp/ruby_lsp_rails/runner_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class EmptyMessageError < MessageError; end
sig { returns(String) }
attr_reader :rails_root

sig { returns(T.nilable(T::Array[String])) }
attr_reader :fixture_paths

sig { params(outgoing_queue: Thread::Queue).void }
def initialize(outgoing_queue)
@outgoing_queue = T.let(outgoing_queue, Thread::Queue)
Expand Down Expand Up @@ -92,7 +89,6 @@ def initialize(outgoing_queue)

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

unless ENV["RAILS_ENV"] == "test"
Expand Down
20 changes: 2 additions & 18 deletions lib/ruby_lsp/ruby_lsp_rails/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@
require "json"
require "open3"

# This replicates what Rails does internally
if defined?(ActiveRecord::Base)
ActiveSupport.on_load(:active_support_test_case) do
include ActiveRecord::TestFixtures

fixture_paths << "#{Rails.root}/test/fixtures/"
end
end

module RubyLsp
module Rails
module Common
Expand Down Expand Up @@ -132,15 +123,8 @@ def initialize(stdout: $stdout, override_default_output_device: true)
def start
load_routes
clear_file_system_resolver_hooks
# `fixtures_path` is only available in Rails 7.1 and later
# Prior to that it used `fixture_path` which we do not support.
fixtures_paths = ActiveSupport::TestCase.fixture_paths if ActiveSupport::TestCase.respond_to?(:fixture_paths)

send_result({
message: "ok",
root: ::Rails.root.to_s,
fixture_paths: fixtures_paths,
})

send_result({ message: "ok", root: ::Rails.root.to_s })

while @running
headers = @stdin.gets("\r\n\r\n")
Expand Down
Loading

0 comments on commit 140761e

Please sign in to comment.