diff --git a/app/models/agents/http_status_agent.rb b/app/models/agents/http_status_agent.rb index 090085f3..c2523f10 100644 --- a/app/models/agents/http_status_agent.rb +++ b/app/models/agents/http_status_agent.rb @@ -66,8 +66,8 @@ module Agents def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do - check_this_url event.payload[:url] || interpolated[:url], - header_array(event.payload[:headers_to_save] || interpolated[:headers_to_save]) + check_this_url interpolated[:url], + header_array(interpolated[:headers_to_save]) end end end diff --git a/spec/models/agents/http_status_agent_spec.rb b/spec/models/agents/http_status_agent_spec.rb index aba3d238..0e054c7b 100644 --- a/spec/models/agents/http_status_agent_spec.rb +++ b/spec/models/agents/http_status_agent_spec.rb @@ -5,10 +5,12 @@ describe 'HttpStatusAgent' do stub_request(:get, 'http://google.com/') end + let(:default_url) { 'http://google.com/' } + let(:agent_options) do { - url: 'http://google.com/', - headers_to_save: 'Server' + url: "{{ url | default: '#{default_url}' }}", + headers_to_save: '{{ headers_to_save }}', } end @@ -55,11 +57,10 @@ describe 'HttpStatusAgent' do describe "check" do let(:url) { "http://#{SecureRandom.uuid}/" } + let(:default_url) { url } + let(:agent_options) do - { - url: url, - headers_to_save: '' - } + super().merge(headers_to_save: '') end it "should check the url" do @@ -77,6 +78,7 @@ describe 'HttpStatusAgent' do describe "with an event with a successful ping" do let(:successful_url) { "http://#{SecureRandom.uuid}/" } + let(:default_url) { successful_url } let(:status_code) { 200 } let(:header) { 'X-Some-Header' } @@ -86,10 +88,6 @@ describe 'HttpStatusAgent' do stub_request(:get, successful_url).to_return(status: status_code) end - let(:agent_options) do - super().merge(url: successful_url) - end - let(:event_with_a_successful_ping) do Event.new(payload: { url: successful_url, headers_to_save: "" }) end