samson_hipchat 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/decorators/stage_decorator.rb +4 -2
- data/app/views/samson_hipchat/notification.text.erb +1 -2
- metadata +3 -8
- 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: 5dde8617b79688e447d24772d04c4636257074a7
|
4
|
+
data.tar.gz: 54c8e367ee9a185ee3a195af3aff827558a8a097
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d4b4f361f3a33e2273a116fd5be3b458d03208a1ce1ce250801295bc69f07cb27523ec433da1ab019dda773e4ebcf53093818f6659b20d80ce8f0d04b0820cb
|
7
|
+
data.tar.gz: 487fa2af69ba5a66e2bb79913a4a16f58164bb4aa4fcfb396a9823c7d64161254267039538e779a09ea8c8575bfa8841494df7db6c82fe5d46dd17570c103170
|
@@ -22,12 +22,14 @@ Stage.class_eval do
|
|
22
22
|
def update_room_id
|
23
23
|
if room_for(room_name)
|
24
24
|
self.hipchat_rooms.first.room_id = room_for(room_name)['id']
|
25
|
+
else
|
26
|
+
self.hipchat_rooms.first.room_id = nil
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
def room_exists?
|
29
31
|
if room_name
|
30
|
-
errors.add(:hipchat_rooms_name, "was not found. Create the room first.") unless room_for(room_name)
|
32
|
+
errors.add(:hipchat_rooms_name, "was not found. Create the room first. If this is a notification token, you can ignore this message") unless room_for(room_name)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -42,7 +44,7 @@ Stage.class_eval do
|
|
42
44
|
Rails.cache.fetch(hipchat_rooms_cache_key, expires_in: 5.minutes) do
|
43
45
|
begin
|
44
46
|
hipchat[name].get_room
|
45
|
-
rescue HipChat::UnknownRoom
|
47
|
+
rescue HipChat::UnknownRoom, HipChat::UnknownResponseCode
|
46
48
|
nil
|
47
49
|
end
|
48
50
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
<%= subject %>
|
2
|
+
<p> <%= deploy.message %> </p>
|
2
3
|
<% if changeset.commits.count == 0 %>
|
3
4
|
There are no new commits since last time.
|
4
5
|
<% else %>
|
5
6
|
<%= pluralize changeset.commits.count, "commit" %> by <%= changeset.author_names.to_sentence %>.
|
6
7
|
<br>
|
7
8
|
|
8
|
-
<%= deploy.message %>
|
9
|
-
|
10
9
|
<% if false %>
|
11
10
|
<strong>Files changed:</strong>
|
12
11
|
<ul>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vinh Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hipchat
|
@@ -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: {}
|
@@ -63,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
58
|
version: '0'
|
64
59
|
requirements: []
|
65
60
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.4.
|
61
|
+
rubygems_version: 2.4.6
|
67
62
|
signing_key:
|
68
63
|
specification_version: 4
|
69
64
|
summary: Samson hipchat integration
|
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'
|