hato 0.0.6 → 0.0.7

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: ce9895dcdaf6ee77a09e2816cee3a20f5034194b
4
- data.tar.gz: 2bb1f36ebcd0e3f717bb9fdd0be0e4ec8f307edb
3
+ metadata.gz: 202679221627cc28218e8f0fb405f4961eaaea3d
4
+ data.tar.gz: e54790c53ba76c24dbfbb90bd6721090fcfcf96d
5
5
  SHA512:
6
- metadata.gz: 47208c46f29d95adcf2a3ba59d1423d483945e47927f84e341ff10327832f2387763719c2f0d23a55b26c51b7491f54d34f7ce81cb2ccc56f9af05d9cc2ef6e6
7
- data.tar.gz: 46e5c4c1a57c36a4b6ebb0b25807fba47975e22d54deb712f628a052e2a8e26d1d3106f912c5e07eb92830cea39f8d6e364e3d856be988730e72f3f15bd5945a
6
+ metadata.gz: c7915729dc929ede55d761e1308a78fbd08a713294b6e5297571f4a2d27d4c32f95e3a0b9c9b25ee07e09bf1cfcf11ed2dfeaa0e10f061083333df716a0a18f0
7
+ data.tar.gz: f1793d36de2b22e9e20d3332ff902922dab820a262d6463ad8326d1abc0ec110b6d4e6fac0da62de0dfb59cd5078bf08e77fd6d8dbe02d0ab9d121251c1f2bad
data/lib/hato/httpd.rb CHANGED
@@ -49,7 +49,8 @@ module Hato
49
49
  )
50
50
  end
51
51
 
52
- post '/webhook' do
52
+ post '/webhook/:owner/:repository' do
53
+ tag = ['webhook', params[:owner], params[:repository]].join('.')
53
54
  payload = params[:payload]
54
55
 
55
56
  if !payload
@@ -59,18 +60,6 @@ module Hato
59
60
  )
60
61
  end
61
62
 
62
- owner = payload['repository'] && payload['repository']['owner'] && payload['repository']['owner']['name']
63
- repository = payload['repository'] && payload['repository']['name']
64
-
65
- if owner && repository
66
- tag = ['webhook', owner, repository].join('.')
67
- else
68
- halt 400, JSON.dump(
69
- status: :error,
70
- message: 'Invalid JSON message: both `repository.owner.name` and `repository.name` are required',
71
- )
72
- end
73
-
74
63
  settings.observer.update(
75
64
  tag: tag,
76
65
  payload: payload,
data/lib/hato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hato
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -62,18 +62,8 @@ describe Hato::Httpd do
62
62
 
63
63
  describe 'webhook' do
64
64
  context 'success' do
65
- let(:payload) {
66
- {
67
- repository: {
68
- name: 'hato',
69
- owner: {
70
- name: 'kentaro',
71
- },
72
- }
73
- }
74
- }
75
65
  it 'should be success with correct payload' do
76
- post '/webhook', payload: payload, api_key: 'test'
66
+ post '/webhook/kentaro/hato', payload: {foo: 'bar'}, api_key: 'test'
77
67
  expect(last_response).to be_ok
78
68
  expect(last_response.body).to eq('{"status":"success","message":"Successfully sent the message you notified to me."}')
79
69
  end
@@ -81,22 +71,10 @@ describe Hato::Httpd do
81
71
 
82
72
  context 'error' do
83
73
  it 'should be error when payload is not passed' do
84
- post '/webhook', api_key: 'test'
74
+ post '/webhook/kentaro/hato', api_key: 'test'
85
75
  expect(last_response).to be_bad_request
86
76
  expect(last_response.body).to eq('{"status":"error","message":"Missing mandatory parameter: `payload`"}')
87
77
  end
88
-
89
- it 'should be error when repository.name is not passed' do
90
- post '/webhook', api_key: 'test', payload: {repository: {owner: {name: 'kentaro'}}}
91
- expect(last_response).to be_bad_request
92
- expect(last_response.body).to eq('{"status":"error","message":"Invalid JSON message: both `repository.owner.name` and `repository.name` are required"}')
93
- end
94
-
95
- it 'should be error when repository.owner.name is not passed' do
96
- post '/webhook', api_key: 'test', payload: {repository: {name: 'hato'}}
97
- expect(last_response).to be_bad_request
98
- expect(last_response.body).to eq('{"status":"error","message":"Invalid JSON message: both `repository.owner.name` and `repository.name` are required"}')
99
- end
100
78
  end
101
79
  end
102
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Kuribayashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra