Skip to content
Open
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
5 changes: 3 additions & 2 deletions lib/gruf/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ def reset
self.hooks = ::Gruf::Hooks::Registry.new
self.root_path = ::Rails.root.to_s.chomp('/') if defined?(::Rails)
determine_loggers
self.ssl_crt_file = "#{root_path}config/ssl/#{environment}.crt"
self.ssl_key_file = "#{root_path}config/ssl/#{environment}.key"
ssl_path = root_path.to_s.empty? ? 'config/ssl' : "#{root_path}/config/ssl"
self.ssl_crt_file = "#{ssl_path}/#{environment}.crt"
self.ssl_key_file = "#{ssl_path}/#{environment}.key"
cp = ::ENV.fetch('GRUF_CONTROLLERS_PATH', 'app/rpc').to_s
self.controllers_path = root_path.to_s.empty? ? cp : "#{root_path}/#{cp}"
self.backtrace_on_error = ::ENV.fetch('GRPC_BACKTRACE_ON_ERROR', 0).to_i.positive?
Expand Down
22 changes: 22 additions & 0 deletions spec/gruf/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ class TestConfiguration
obj.reset
expect(subject).not_to eq 'test.dev'
end

context 'when a Rails root path is configured' do
before do
stub_const('Rails', double(root: '/app/', logger: nil, env: 'production'))
end

it 'joins the SSL paths with the root path separator' do
obj.reset

expect(obj.ssl_crt_file).to eq '/app/config/ssl/production.crt'
expect(obj.ssl_key_file).to eq '/app/config/ssl/production.key'
end
end

context 'when no Rails root path is configured' do
it 'keeps the SSL paths relative' do
obj.reset

expect(obj.ssl_crt_file).to eq "config/ssl/#{obj.send(:environment)}.crt"
expect(obj.ssl_key_file).to eq "config/ssl/#{obj.send(:environment)}.key"
end
end
end

describe '.environment' do
Expand Down