Skip to content

Only require parts of Rails actually needed #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ PATH
remote: .
specs:
ruby-lsp-rails (0.2.7)
rails (>= 6.0)
actionpack (>= 6.0)
activerecord (>= 6.0)
railties (>= 6.0)
ruby-lsp (>= 0.12.0, < 0.13.0)
sorbet-runtime (>= 0.5.9897)

Expand Down
1 change: 0 additions & 1 deletion bin/rails
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/engine/commands"
4 changes: 3 additions & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
Dir["{app,config,db,lib}/**/*", "LICENSE.txt", "Rakefile", "README.md"]
end

spec.add_dependency("rails", ">= 6.0")
spec.add_dependency("actionpack", ">= 6.0")
spec.add_dependency("activerecord", ">= 6.0")
spec.add_dependency("railties", ">= 6.0")
spec.add_dependency("ruby-lsp", ">= 0.12.0", "< 0.13.0")
spec.add_dependency("sorbet-runtime", ">= 0.5.9897")
end
7 changes: 0 additions & 7 deletions test/dummy/app/channels/application_cable/channel.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/dummy/app/channels/application_cable/connection.rb

This file was deleted.

10 changes: 0 additions & 10 deletions test/dummy/app/jobs/application_job.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/dummy/app/mailers/application_mailer.rb

This file was deleted.

12 changes: 11 additions & 1 deletion test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

require_relative "boot"

require "rails/all"
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Expand Down
6 changes: 3 additions & 3 deletions test/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
end

# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# config.action_mailer.raise_delivery_errors = false

config.action_mailer.perform_caching = false
# config.action_mailer.perform_caching = false

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
Expand Down
12 changes: 1 addition & 11 deletions test/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Eager loading loads your whole application. When running a single test locally,
# this probably isn't necessary. It's a good idea to do in a continuous integration
# system, or in some way before deploying your code.
config.eager_load = ENV["CI"].present?
config.eager_load = true

# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
Expand All @@ -36,16 +36,6 @@
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false

# Store uploaded files on the local file system in a temporary directory.
config.active_storage.service = :test

config.action_mailer.perform_caching = false

# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr

Expand Down
2 changes: 1 addition & 1 deletion test/ruby_lsp_rails/rack_app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RackAppTest < ActionDispatch::IntegrationTest
end

test "GET show returns not_found if class is not a model" do
get "/ruby_lsp_rails/models/ApplicationJob"
get "/ruby_lsp_rails/models/Time"
assert_response(:not_found)
end

Expand Down