Stop logging the namespace

This commit is contained in:
Ryan Buckley 2015-12-11 23:13:18 -08:00
parent baaa98e04e
commit 9a0326ff09
2 changed files with 4 additions and 6 deletions

View File

@ -92,9 +92,7 @@ class Grape::Middleware::Logger < Grape::Middleware::Globals
def processed_by
endpoint = env[Grape::Env::API_ENDPOINT]
parts = endpoint.options[:for].to_s
parts << endpoint.namespace if endpoint.namespace != BACKSLASH
parts << '#'.freeze << endpoint.options[:path].map { |path| path.to_s.sub(BACKSLASH, '') }.join(BACKSLASH)
endpoint.options[:for].to_s << '#'.freeze << endpoint.options[:path].map { |path| path.to_s.sub(BACKSLASH, '') }.join(BACKSLASH)
end
def default_logger

View File

@ -28,15 +28,15 @@ describe Grape::Middleware::Logger, type: :integration do
context 'namespacing' do
let(:grape_endpoint) { build(:namespaced_endpoint) }
it 'designates the namespace with a slash' do
expect(subject.processed_by).to eq 'TestAPI/admin#users'
it 'ignores the namespacing' do
expect(subject.processed_by).to eq 'TestAPI#users'
end
context 'with more complex route' do
let(:grape_endpoint) { build(:namespaced_endpoint, :complex) }
it 'only escapes the first slash and leaves the rest of the untouched' do
expect(subject.processed_by).to eq 'TestAPI/admin#users/:name/profile'
expect(subject.processed_by).to eq 'TestAPI#users/:name/profile'
end
end
end