Sha256: f5ae170cb72fbe45bd402e19604c6b444d5a6128da020353fc35c9b97d4ee7ae
Contents?: true
Size: 1.39 KB
Versions: 67
Compression:
Stored size: 1.39 KB
Contents
require 'spec_helper' describe Appsignal::EventFormatter::ElasticSearch::SearchFormatter do let(:klass) { Appsignal::EventFormatter::ElasticSearch::SearchFormatter } let(:formatter) { klass.new } it "should register query.moped" do expect( Appsignal::EventFormatter.registered?('search.elasticsearch', klass) ).to be_true end describe "#format" do let(:payload) do { :name => 'Search', :klass => 'User', :search => {:index => 'users', :type => 'user', :q => 'John Doe'} } end it "should return a payload with name and sanitized body" do expect( formatter.format(payload) ).to eql([ "Search: User", "{:index=>\"users\", :type=>\"user\", :q=>\"?\"}" ]) end end describe "#sanitized_search" do let(:search) do { :index => 'users', :type => 'user', :q => 'John Doe', :other => 'Other' } end it "should sanitize non-whitelisted params" do expect( formatter.sanitized_search(search) ).to eql({:index => 'users', :type => 'user', :q => '?', :other => '?'}) end it "should return nil string when search is nil" do expect( formatter.sanitized_search(nil) ).to be_nil end it "should return nil string when search is not a hash" do expect( formatter.sanitized_search([]) ).to be_nil end end end
Version data entries
67 entries across 67 versions & 1 rubygems