lhc-core-interceptors 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1bcc91b0161bd232e2487449b928a351fcb92e7
4
- data.tar.gz: d1a91579f20175af675aa6455bbf2412c68eeee4
3
+ metadata.gz: 846a8d5619ee3ea84c7adfe04e967f37cb34f49a
4
+ data.tar.gz: 5e08294e64256b9adeb5040f369c2ae36bbc6f06
5
5
  SHA512:
6
- metadata.gz: 25ed9660ad091992ec955b65744ad9adde2b99cd18ca77f9d4e04e8c5c2923cd53e0aa869fc78bf83000f5fb75adbc14035e7f3c4c3d82013ea479a066307dfb
7
- data.tar.gz: 86d7df8895e1f7ce2c37a3d6859a2214580a3c96778c725f1b9d4e310be5237b36578da5e05d46e041af676353efd308b3e8777edeb6923c0b2f3177c1d928d9
6
+ metadata.gz: c182e664a63da4afcff74156c847dcd74303f6b32a2e893d91b17b3b9532cfa0e6b99cb649d379216c3512b3d9d0c58bb2eca10725671c7354dde993237bc546
7
+ data.tar.gz: 9d8f7cfba22dd40c1f78cb237677ef7ebf359fd401a8b7c40d5632b586271aaecaf846c9c5ff7de5fb2f628dc917a5df5b2807eab378fc20307198b86b54f45b
@@ -0,0 +1,16 @@
1
+ subcontexts:
2
+
3
+ - name: 'All rspec tests'
4
+
5
+ task-defaults:
6
+
7
+ scripts:
8
+
9
+ test:
10
+
11
+ body: |
12
+ #!/usr/bin/env bash
13
+ bundle exec rspec $CIDER_CI_TASK_FILE
14
+
15
+ _cider-ci_generate-tasks:
16
+ include-match: spec/.*_spec.rb
@@ -0,0 +1,27 @@
1
+ tests:
2
+
3
+ name: 'Tests'
4
+
5
+ run-on:
6
+ - type: branch
7
+ include-match: ^.*$
8
+
9
+ context:
10
+
11
+ _cider-ci_include:
12
+ - cider-ci/contexts/rspec.yml
13
+
14
+ task-defaults:
15
+
16
+ scripts:
17
+
18
+ bundle:
19
+ body: sed 's/^source.*/source "http\:\/\/52.29.7.59:9292"/g' Gemfile > Gemfile.tmp ; mv Gemfile.tmp Gemfile && bundle install
20
+
21
+ ruby-version:
22
+ body: ruby --version
23
+
24
+ test:
25
+ start-when:
26
+ - script: bundle
27
+ - script: ruby-version
data/cider-ci.yml ADDED
@@ -0,0 +1,3 @@
1
+ jobs:
2
+ _cider-ci_include:
3
+ - cider-ci/jobs/tests.yml
@@ -30,16 +30,22 @@ class LHC::Monitoring < LHC::Interceptor
30
30
  key = options(request.options)[:key]
31
31
  return key if key.present?
32
32
 
33
+ url = sanitize_url(request.url)
33
34
  key = [
34
35
  'lhc',
35
36
  Rails.application.class.parent_name.underscore,
36
37
  Rails.env,
37
- URI.parse(request.url).host.gsub(/\./, '_'),
38
+ URI.parse(url).host.gsub(/\./, '_'),
38
39
  request.method
39
40
  ]
40
41
  key.join('.')
41
42
  end
42
43
 
44
+ def sanitize_url(url)
45
+ return url if url.match(%r{https?://})
46
+ "http://#{url}"
47
+ end
48
+
43
49
  def options(input = {})
44
50
  options = {}
45
51
  FORWARDED_OPTIONS.each do |k, v|
@@ -1,3 +1,3 @@
1
1
  module LHCCoreInterceptors
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
@@ -3,11 +3,20 @@ require 'rails_helper'
3
3
  describe LHC::Monitoring do
4
4
 
5
5
  let(:stub) { stub_request(:get, 'http://local.ch').to_return(status: 200, body: 'The Website') }
6
+ let(:endpoint_configuration) { LHC.config.endpoint(:local, 'http://local.ch') }
7
+
8
+ module Statsd
9
+ def self.count(path, value)
10
+ end
11
+ def self.timing(path, value)
12
+ end
13
+ end
6
14
 
7
15
  before(:each) do
8
16
  LHC.config.interceptors = [LHC::Monitoring]
17
+ LHC::Monitoring.statsd = Statsd
9
18
  Rails.cache.clear
10
- LHC.config.endpoint(:local, 'http://local.ch')
19
+ endpoint_configuration
11
20
  end
12
21
 
13
22
  it 'does not report anything if no statsd is configured' do
@@ -17,17 +26,6 @@ describe LHC::Monitoring do
17
26
 
18
27
  context 'statsd configured' do
19
28
 
20
- module Statsd
21
- def self.count(path, value)
22
- end
23
- def self.timing(path, value)
24
- end
25
- end
26
-
27
- before(:each) do
28
- LHC::Monitoring.statsd = Statsd
29
- end
30
-
31
29
  it 'reports trial, response and timing by default ' do
32
30
  stub
33
31
  expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
@@ -59,7 +57,18 @@ describe LHC::Monitoring do
59
57
  expect(Statsd).to receive(:timing).with('defined_key.time', anything)
60
58
  LHC.get(:local, monitoring_key: 'defined_key')
61
59
  end
62
-
63
60
  end
64
61
 
62
+ context 'without protocol' do
63
+
64
+ let(:endpoint_configuration) { LHC.config.endpoint(:local, 'local.ch') }
65
+
66
+ it 'reports trial, response and timing by default ' do
67
+ stub
68
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.count', 1)
69
+ expect(Statsd).to receive(:count).with('lhc.dummy.test.local_ch.get.200', 1)
70
+ expect(Statsd).to receive(:timing).with('lhc.dummy.test.local_ch.get.time', anything)
71
+ LHC.get(:local)
72
+ end
73
+ end
65
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhc-core-interceptors
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - local.ch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lhc
@@ -120,6 +120,9 @@ files:
120
120
  - Gemfile
121
121
  - README.md
122
122
  - Rakefile
123
+ - cider-ci.yml
124
+ - cider-ci/contexts/rspec.yml
125
+ - cider-ci/jobs/tests.yml
123
126
  - lhc-core-interceptors.gemspec
124
127
  - lib/lhc-core-interceptors.rb
125
128
  - lib/lhc-core-interceptors/auth.rb