diff --git a/lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb b/lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb index e9573bdb..6e80f0a5 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/support/rails_document_client.rb @@ -68,7 +68,10 @@ def generate_rails_document_urls(name) $stderr.puts("Fetching search index for Rails documentation") - response = Net::HTTP.get_response(URI("#{RAILS_DOC_HOST}/v#{RAILTIES_VERSION}/js/search_index.js")) + response = Net::HTTP.get_response( + URI("#{RAILS_DOC_HOST}/v#{RAILTIES_VERSION}/js/search_index.js"), + { "User-Agent" => "ruby-lsp-rails/#{RubyLsp::Rails::VERSION}" }, + ) body = case response when Net::HTTPSuccess diff --git a/test/ruby_lsp_rails/hover_test.rb b/test/ruby_lsp_rails/hover_test.rb index 83840fa8..bab6ad4a 100644 --- a/test/ruby_lsp_rails/hover_test.rb +++ b/test/ruby_lsp_rails/hover_test.rb @@ -12,7 +12,7 @@ class HoverTest < ActiveSupport::TestCase .with( headers: { "Host" => "api.rubyonrails.org", - "User-Agent" => "Ruby", + "User-Agent" => %r{^ruby-lsp-rails\/.*$}, }, ) .to_return(status: 200, body: body, headers: {})