-
Notifications
You must be signed in to change notification settings - Fork 32
Handle schema_dump_path
being unavailable in older Rails versions
#264
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
Conversation
schema_dump_path
being unavailable in older Rails versions
b58cd72
to
77150d4
Compare
@@ -26,7 +26,7 @@ class Server | |||
|
|||
extend T::Sig | |||
|
|||
sig { params(model_name: String).returns(T.nilable(T::Hash[Symbol, T.untyped])) } | |||
sig { params(model_name: String).returns(T::Hash[Symbol, T.untyped]) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realised that we always return a hash.
77150d4
to
739fba6
Compare
require "test_helper" | ||
require "ruby_lsp/ruby_lsp_rails/server" | ||
|
||
class ServerTest < ActiveSupport::TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vinistock since the server is in a different process, this needs to be tested differently from the other aspects in runner_client_test.rb
. But I think it would make sense to move some of the other tests to here too, and leave just #model returns information for the requested model
as an integration test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit to show how that would look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but let's put the server in an instance variable instead of doing Server.new
on every test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but let's put the server in an instance variable instead of doing Server.new
on every test.
schema_dump_path
being unavailable in older Rails versionsschema_dump_path
being unavailable in older Rails versions
1469313
to
4aadd0b
Compare
}, | ||
} | ||
|
||
if ActiveRecord::Tasks::DatabaseTasks.respond_to?(:schema_dump_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible we can make this also work in Rails 6 and earlier, if someone wants to open a PR.
4aadd0b
to
2749956
Compare
test "returns nil if model doesn't exist" do | ||
assert_nil @client.model("Foo") | ||
end | ||
|
||
test "returns nil if class is not a model" do | ||
assert_nil @client.model("Time") | ||
end | ||
|
||
test "returns nil if class is an abstract model" do | ||
assert_nil @client.model("ApplicationRecord") | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, restored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you restore all of them? I'm only seeing the abstract one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one, to validate the nil return. I don't think it's necessary to re-verify the behaviour already covered in server_test.rb
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. It's covered in the new test. 👍
require "test_helper" | ||
require "ruby_lsp/ruby_lsp_rails/server" | ||
|
||
class ServerTest < ActiveSupport::TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but let's put the server in an instance variable instead of doing Server.new
on every test.
require "test_helper" | ||
require "ruby_lsp/ruby_lsp_rails/server" | ||
|
||
class ServerTest < ActiveSupport::TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine, but let's put the server in an instance variable instead of doing Server.new
on every test.
562cdf1
to
efe472b
Compare
Closes #260. For older Rails versions we will show the fields but won't provide a link to the schema file.