lita-travis 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lita/handlers/travis.rb +6 -15
- data/lita-travis.gemspec +3 -3
- data/locales/en.yml +0 -3
- data/spec/lita/handlers/travis_spec.rb +13 -33
- data/spec/spec_helper.rb +2 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88c770748392b7b5086b6c89694bce642cbc8128
|
4
|
+
data.tar.gz: 9787a09aa44ad5ebe43ee32d5ef4819db5926e25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e0d7dbcd66792787ec222046a088f350d0b76ab36be3b37e1d988facddeb2efe9ce0b06a65ad1097f5f1467290291c324f2b5a1d5b649015a984d27e195ac00
|
7
|
+
data.tar.gz: dcefccc5175a2385b09d5833cd3b57cf6898cfbe35c348ccb093a79a37dd3514681558009cbf6131f695308ed77e3a1ea9ec5ef4d8852666b844c096907ef597
|
data/lib/lita/handlers/travis.rb
CHANGED
@@ -6,11 +6,9 @@ module Lita
|
|
6
6
|
module Handlers
|
7
7
|
# Provides Travis CI webhooks for Lita.
|
8
8
|
class Travis < Handler
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
config.default_rooms = nil
|
13
|
-
end
|
9
|
+
config :token, type: String, required: true
|
10
|
+
config :repos, type: Hash, default: {}
|
11
|
+
config :default_rooms, type: [Array, String]
|
14
12
|
|
15
13
|
http.post "/travis", :receive
|
16
14
|
|
@@ -56,8 +54,8 @@ module Lita
|
|
56
54
|
end
|
57
55
|
|
58
56
|
def rooms_for_repo(repo)
|
59
|
-
rooms =
|
60
|
-
default_rooms =
|
57
|
+
rooms = config.repos[repo]
|
58
|
+
default_rooms = config.default_rooms
|
61
59
|
|
62
60
|
if rooms
|
63
61
|
Array(rooms)
|
@@ -70,14 +68,7 @@ module Lita
|
|
70
68
|
end
|
71
69
|
|
72
70
|
def validate_repo(repo, auth_hash)
|
73
|
-
|
74
|
-
|
75
|
-
unless token
|
76
|
-
Lita.logger.warn(t("no_token"))
|
77
|
-
return
|
78
|
-
end
|
79
|
-
|
80
|
-
unless Digest::SHA2.hexdigest("#{repo}#{token}") == auth_hash
|
71
|
+
unless Digest::SHA2.hexdigest("#{repo}#{config.token}") == auth_hash
|
81
72
|
Lita.logger.warn(t("auth_failed"), repo: repo)
|
82
73
|
return
|
83
74
|
end
|
data/lita-travis.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-travis"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "1.0.0"
|
4
4
|
spec.authors = ["Jimmy Cuadra"]
|
5
5
|
spec.email = ["jimmy@jimmycuadra.com"]
|
6
6
|
spec.description = %q{A Lita handler for receiving notifications from Travis CI.}
|
@@ -14,11 +14,11 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
-
spec.add_runtime_dependency "lita", ">=
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.0"
|
18
18
|
|
19
19
|
spec.add_development_dependency "bundler", "~> 1.3"
|
20
20
|
spec.add_development_dependency "rake"
|
21
|
-
spec.add_development_dependency "rspec", ">= 3.0.0
|
21
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
22
22
|
spec.add_development_dependency "simplecov"
|
23
23
|
spec.add_development_dependency "coveralls"
|
24
24
|
end
|
data/locales/en.yml
CHANGED
@@ -10,6 +10,3 @@ en:
|
|
10
10
|
no_room_configured: >-
|
11
11
|
Notification from Travis CI for %{repo} ignored because no rooms were specified in the
|
12
12
|
config.repos hash, and no default rooms were specified in config.default_rooms.
|
13
|
-
no_token: >-
|
14
|
-
Notification from Travis CI could not be validated because Lita.config.handlers.token
|
15
|
-
is not set.
|
@@ -1,17 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Lita::Handlers::Travis, lita_handler: true do
|
4
|
-
it {
|
5
|
-
|
6
|
-
describe ".default_config" do
|
7
|
-
it "sets token to nil" do
|
8
|
-
expect(Lita.config.handlers.travis.token).to be_nil
|
9
|
-
end
|
10
|
-
|
11
|
-
it "sets repos to an empty hash" do
|
12
|
-
expect(Lita.config.handlers.travis.repos).to eq({})
|
13
|
-
end
|
14
|
-
end
|
4
|
+
it { is_expected.to route_http(:post, "/travis").to(:receive) }
|
15
5
|
|
16
6
|
describe "#receive" do
|
17
7
|
let(:request) do
|
@@ -54,10 +44,14 @@ describe Lita::Handlers::Travis, lita_handler: true do
|
|
54
44
|
JSON
|
55
45
|
end
|
56
46
|
|
47
|
+
before do
|
48
|
+
registry.config.handlers.travis.repos = {}
|
49
|
+
end
|
50
|
+
|
57
51
|
context "happy path" do
|
58
52
|
before do
|
59
|
-
|
60
|
-
|
53
|
+
registry.config.handlers.travis.token = "abc123"
|
54
|
+
registry.config.handlers.travis.repos["foo/bar"] = "#baz"
|
61
55
|
allow(request).to receive(:env).and_return(valid_env)
|
62
56
|
allow(params).to receive(:[]).with("payload").and_return(valid_payload)
|
63
57
|
end
|
@@ -71,25 +65,10 @@ describe Lita::Handlers::Travis, lita_handler: true do
|
|
71
65
|
end
|
72
66
|
end
|
73
67
|
|
74
|
-
context "with a missing token" do
|
75
|
-
before do
|
76
|
-
Lita.config.handlers.travis.repos["foo/bar"] = "#baz"
|
77
|
-
allow(request).to receive(:env).and_return(valid_env)
|
78
|
-
allow(params).to receive(:[]).with("payload").and_return(valid_payload)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "logs a warning that the token is not set" do
|
82
|
-
expect(Lita.logger).to receive(:warn) do |warning|
|
83
|
-
expect(warning).to include("token is not set")
|
84
|
-
end
|
85
|
-
subject.receive(request, response)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
68
|
context "with an invalid authorization header" do
|
90
69
|
before do
|
91
|
-
|
92
|
-
|
70
|
+
registry.config.handlers.travis.token = "abc123"
|
71
|
+
registry.config.handlers.travis.repos["foo/bar"] = "#baz"
|
93
72
|
allow(request).to receive(:env).and_return(invalid_env)
|
94
73
|
allow(params).to receive(:[]).with("payload").and_return(valid_payload)
|
95
74
|
end
|
@@ -104,8 +83,8 @@ describe Lita::Handlers::Travis, lita_handler: true do
|
|
104
83
|
|
105
84
|
context "with only config.default_rooms set" do
|
106
85
|
before do
|
107
|
-
|
108
|
-
|
86
|
+
registry.config.handlers.travis.token = "abc123"
|
87
|
+
registry.config.handlers.travis.default_rooms = "#default"
|
109
88
|
allow(request).to receive(:env).and_return(valid_env)
|
110
89
|
allow(params).to receive(:[]).with("payload").and_return(valid_payload)
|
111
90
|
end
|
@@ -121,7 +100,8 @@ describe Lita::Handlers::Travis, lita_handler: true do
|
|
121
100
|
|
122
101
|
context "without setting a value for the repo in config.repos and no default" do
|
123
102
|
before do
|
124
|
-
|
103
|
+
registry.config.handlers.travis.token = "abc123"
|
104
|
+
allow(registry.config.handlers.travis).to receive(:default_rooms).and_return(nil)
|
125
105
|
allow(request).to receive(:env).and_return(valid_env)
|
126
106
|
allow(params).to receive(:[]).with("payload").and_return(valid_payload)
|
127
107
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-travis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Cuadra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.0.0
|
61
|
+
version: 3.0.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.0.0
|
68
|
+
version: 3.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,4 +141,3 @@ summary: A Lita handler for receiving notifications from Travis CI.
|
|
141
141
|
test_files:
|
142
142
|
- spec/lita/handlers/travis_spec.rb
|
143
143
|
- spec/spec_helper.rb
|
144
|
-
has_rdoc:
|