samson_hipchat 0.0.2 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a86107258ced4799407193a488346748f14a859
4
- data.tar.gz: 1723ee5b9fb3f9f9b3ad337584c8fd72cc45553a
3
+ metadata.gz: 45bb274aa095f6b2a5b740c8d619bcb867a0465f
4
+ data.tar.gz: 2329e861b24b294ebc01b5c044aa815aa13fcae3
5
5
  SHA512:
6
- metadata.gz: ef6c68e55855cac9300ab12a7ba3ceb9b3a15c00596ce8f3085884ece2f3bae0de432d81d65165e3b721d6cd1f809e57657351e09531001b2d4a9bbfc331b72c
7
- data.tar.gz: 0d679d408bd5691d5b7e637f00b80e1e896361f16b9e2b55b01330787304f6c803d7c8e9bac0dad158de4215afdc3fe611315d35557dae830430761deb278f4c
6
+ metadata.gz: 273cab850c46492f71dedaa06c118da187ddc5b79facccf97bea99bb655e448cddab5fd2ebcde118a80af024dba5f3dc28ca7fe1f391b29ef0ff12fc095fbf3a
7
+ data.tar.gz: 5c2a5b8b30bbdba6cd87aa1c77ad2adb2285b0c8c077f9f132051298e76e004c03cc4ac2ad07c11731e75ec19f586d3075d87793a042c2c6b08d4a8a743e9eaf
@@ -4,12 +4,18 @@ There are no new commits since last time.
4
4
  <% else %>
5
5
  <%= pluralize changeset.commits.count, "commit" %> by <%= changeset.author_names.to_sentence %>.
6
6
  <br>
7
+
8
+ <%= deploy.message %>
9
+
10
+ <% if false %>
7
11
  <strong>Files changed:</strong>
8
12
  <ul>
9
13
  <% changeset.files.each do |file| %>
10
14
  <li><%= file.status[0].upcase %> <%= file.filename %></li>
11
15
  <% end %>
12
16
  </ul>
17
+ <% end %>
18
+
13
19
  <strong>Commits:</strong>
14
20
  <ol>
15
21
  <% changeset.commits.each do |commit| %>
@@ -0,0 +1,7 @@
1
+ Gem::Specification.new "samson_hipchat", "0.0.4" do |s|
2
+ s.summary = "Samson hipchat integration"
3
+ s.authors = ["Vinh Nguyen"]
4
+ s.email = "vinh@listia.com"
5
+ s.add_runtime_dependency "hipchat", "~> 1.5"
6
+ s.files = `git ls-files`.split("\n")
7
+ end
@@ -0,0 +1,42 @@
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
@@ -0,0 +1,47 @@
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
@@ -0,0 +1,32 @@
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
@@ -0,0 +1 @@
1
+ require_relative '../../../test/test_helper'
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.2
4
+ version: 0.0.4
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-05-27 00:00:00.000000000 Z
11
+ date: 2015-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hipchat
@@ -39,6 +39,11 @@ 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
42
47
  homepage:
43
48
  licenses: []
44
49
  metadata: {}