samson_hipchat 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +1 -6
- data/samson_hipchat.gemspec +0 -7
- data/test/models/hipchat_notification_renderer_test.rb +0 -42
- data/test/models/hipchat_notification_test.rb +0 -47
- data/test/models/hooks_test.rb +0 -32
- data/test/test_helper.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a86107258ced4799407193a488346748f14a859
|
4
|
+
data.tar.gz: 1723ee5b9fb3f9f9b3ad337584c8fd72cc45553a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef6c68e55855cac9300ab12a7ba3ceb9b3a15c00596ce8f3085884ece2f3bae0de432d81d65165e3b721d6cd1f809e57657351e09531001b2d4a9bbfc331b72c
|
7
|
+
data.tar.gz: 0d679d408bd5691d5b7e637f00b80e1e896361f16b9e2b55b01330787304f6c803d7c8e9bac0dad158de4215afdc3fe611315d35557dae830430761deb278f4c
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samson_hipchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vinh Nguyen
|
@@ -39,11 +39,6 @@ files:
|
|
39
39
|
- config/initializers/hipchat.rb
|
40
40
|
- db/migrate/20150519105221_create_hipchat_rooms.rb
|
41
41
|
- lib/samson_hipchat/samson_plugin.rb
|
42
|
-
- samson_hipchat.gemspec
|
43
|
-
- test/models/hipchat_notification_renderer_test.rb
|
44
|
-
- test/models/hipchat_notification_test.rb
|
45
|
-
- test/models/hooks_test.rb
|
46
|
-
- test/test_helper.rb
|
47
42
|
homepage:
|
48
43
|
licenses: []
|
49
44
|
metadata: {}
|
data/samson_hipchat.gemspec
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
describe HipchatNotificationRenderer do
|
4
|
-
describe "starting" do
|
5
|
-
it "renders a nicely formatted notification" do
|
6
|
-
changeset = stub("changeset")
|
7
|
-
deploy = stub("deploy", short_reference: "xyz", changeset: changeset)
|
8
|
-
|
9
|
-
author1 = "author1"
|
10
|
-
author2 = "author2"
|
11
|
-
changeset.stubs(:author_names).returns([author1, author2])
|
12
|
-
|
13
|
-
commit1 = stub("commit1", url: "#", author_name: "author1", summary: "Introduce bug")
|
14
|
-
commit2 = stub("commit2", url: "#", author_name: "author2", summary: "Fix bug")
|
15
|
-
changeset.stubs(:commits).returns([commit1, commit2])
|
16
|
-
|
17
|
-
file1 = stub("file1", status: "added", filename: "foo.rb")
|
18
|
-
file2 = stub("file2", status: "modified", filename: "bar.rb")
|
19
|
-
changeset.stubs(:files).returns([file1, file2])
|
20
|
-
|
21
|
-
subject = "Deploy starting"
|
22
|
-
|
23
|
-
result = HipchatNotificationRenderer.render(deploy, subject)
|
24
|
-
|
25
|
-
result.must_equal <<-RESULT.strip_heredoc.chomp
|
26
|
-
Deploy starting
|
27
|
-
2 commits by author1 and author2.
|
28
|
-
<br>
|
29
|
-
<strong>Files changed:</strong>
|
30
|
-
<ul>
|
31
|
-
<li>A foo.rb</li>
|
32
|
-
<li>M bar.rb</li>
|
33
|
-
</ul>
|
34
|
-
<strong>Commits:</strong>
|
35
|
-
<ol>
|
36
|
-
<li><a href='#'>(author1)</a>: Introduce bug</li>
|
37
|
-
<li><a href='#'>(author2)</a>: Fix bug</li>
|
38
|
-
<ol>
|
39
|
-
RESULT
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
describe HipchatNotification do
|
4
|
-
let(:project) { stub(name: "Glitter") }
|
5
|
-
let(:user) { stub(name: "John Wu", email: "wu@rocks.com") }
|
6
|
-
let(:stage) { stub(name: "staging", hipchat_rooms: [stub(name: "x123yx", token: "token123")], project: project) }
|
7
|
-
let(:hipchat_message) { stub(content: "hello world!", style: {color: :red}, subject: "subject") }
|
8
|
-
let(:previous_deploy) { stub(summary: "hello world!", user: user, stage: stage) }
|
9
|
-
let(:deploy) { stub(summary: "hello world!", user: user, stage: stage, changeset: "changeset") }
|
10
|
-
let(:notification) { HipchatNotification.new(deploy) }
|
11
|
-
let(:endpoint) { "https://api.hipchat.com/v2/room/x123yx/notification?auth_token=token123" }
|
12
|
-
|
13
|
-
before do
|
14
|
-
HipchatNotificationRenderer.stubs(:render).returns("foo")
|
15
|
-
HipchatNotification::Message.any_instance.stubs(:content).returns("message to send")
|
16
|
-
HipchatNotification::Message.any_instance.stubs(:from).returns("Deployer")
|
17
|
-
HipchatNotification::Message.any_instance.stubs(:style).returns({color: :red})
|
18
|
-
end
|
19
|
-
|
20
|
-
it "notifies hipchat channels configured for the stage" do
|
21
|
-
delivery = stub_request(:post, endpoint)
|
22
|
-
notification.deliver
|
23
|
-
|
24
|
-
assert_requested delivery
|
25
|
-
end
|
26
|
-
|
27
|
-
it "renders a nicely formatted notification" do
|
28
|
-
stub_request(:post, endpoint)
|
29
|
-
HipchatNotificationRenderer.stubs(:render).returns("bar")
|
30
|
-
notification.deliver
|
31
|
-
|
32
|
-
content, format, from, color = nil
|
33
|
-
assert_requested :post, endpoint do |request|
|
34
|
-
body = JSON.parse(request.body)
|
35
|
-
puts body["message"]
|
36
|
-
content = body.fetch("message")
|
37
|
-
format = body.fetch("message_format")
|
38
|
-
from = body.fetch("from")
|
39
|
-
color = body.fetch("color")
|
40
|
-
content.must_equal "message to send"
|
41
|
-
format.must_equal "html"
|
42
|
-
from.must_equal "Deployer"
|
43
|
-
color.must_equal "red"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
data/test/models/hooks_test.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
|
3
|
-
describe "hipchat hooks" do
|
4
|
-
let(:deploy) { deploys(:succeeded_test) }
|
5
|
-
let(:stage) { deploy.stage }
|
6
|
-
|
7
|
-
describe :before_deploy do
|
8
|
-
it "sends notification on before hook" do
|
9
|
-
stage.stubs(:send_hipchat_notifications?).returns(true)
|
10
|
-
HipchatNotification.any_instance.expects(:deliver)
|
11
|
-
Samson::Hooks.fire(:before_deploy, deploy, nil)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "does not send notifications when disabled" do
|
15
|
-
HipchatNotification.any_instance.expects(:deliver).never
|
16
|
-
Samson::Hooks.fire(:before_deploy, deploy, nil)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe :after_deploy do
|
21
|
-
it "sends notification on after hook" do
|
22
|
-
stage.stubs(:send_hipchat_notifications?).returns(true)
|
23
|
-
HipchatNotification.any_instance.expects(:deliver)
|
24
|
-
Samson::Hooks.fire(:after_deploy, deploy, nil)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "does not send notifications when disabled" do
|
28
|
-
HipchatNotification.any_instance.expects(:deliver).never
|
29
|
-
Samson::Hooks.fire(:after_deploy, deploy, nil)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require_relative '../../../test/test_helper'
|