File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 5
5
require "ruby_lsp/ruby_lsp_rails/server"
6
6
7
7
class ServerTest < ActiveSupport ::TestCase
8
+ setup do
9
+ @server = RubyLsp ::Rails ::Server . new
10
+ end
11
+
8
12
test "returns nil if model doesn't exist" do
9
- response = RubyLsp :: Rails :: Server . new . resolve_database_info_from_model ( "Foo" )
13
+ response = @server . resolve_database_info_from_model ( "Foo" )
10
14
assert_nil ( response . fetch ( :result ) )
11
15
end
12
16
13
17
test "returns nil if class is not a model" do
14
- response = RubyLsp :: Rails :: Server . new . resolve_database_info_from_model ( "Time" )
18
+ response = @server . resolve_database_info_from_model ( "Time" )
15
19
assert_nil ( response . fetch ( :result ) )
16
20
end
17
21
18
22
test "returns nil if class is an abstract model" do
19
- response = RubyLsp :: Rails :: Server . new . resolve_database_info_from_model ( "ApplicationRecord" )
23
+ response = @server . resolve_database_info_from_model ( "ApplicationRecord" )
20
24
assert_nil ( response . fetch ( :result ) )
21
25
end
22
26
23
27
test "handles older Rails version which don't have `schema_dump_path`" do
24
28
ActiveRecord ::Tasks ::DatabaseTasks . send ( :alias_method , :old_schema_dump_path , :schema_dump_path )
25
29
ActiveRecord ::Tasks ::DatabaseTasks . undef_method ( :schema_dump_path )
26
- response = RubyLsp :: Rails :: Server . new . resolve_database_info_from_model ( "User" )
30
+ response = @server . resolve_database_info_from_model ( "User" )
27
31
assert_nil ( response . fetch ( :result ) [ :schema_file ] )
28
32
ensure
29
33
ActiveRecord ::Tasks ::DatabaseTasks . send ( :alias_method , :schema_dump_path , :old_schema_dump_path )
You can’t perform that action at this time.
0 commit comments