Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adds Flowdock notification support #232

Merged
merged 1 commit into from

2 participants

@jeremyw

No description provided.

lib/app/public/integrity.css
@@ -140,6 +140,7 @@ a {
margin-top: 1em;
margin-bottom: 0; }
#content form fieldset p.normal {
+ clear: both;
@p Collaborator
p added a note

This needs to be changed in https://github.com/integrity/integrity/blob/master/lib/app/views/integrity.sass and then integrity.css should be generated from integrity.sass.

Also, what does this change do?

@jeremyw
jeremyw added a note

Ah, didn't notice the sass source.

This fixes a float issue when there's a long label. It was reproducible with the "From address (used for Gravatar)" label, where the following "Notify on success" paragraph was floating.

@p Collaborator
p added a note

Could you send a separate PR for it?

@jeremyw
jeremyw added a note

It's in a separate commit now. Is that all right?

@p Collaborator
p added a note

Almost. You need to create a new branch off master, cherry pick the stylesheet commit into it and create a pull request for that branch. Then hard reset this branch to the first commit and force push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@p
Collaborator
p commented

Otherwise looks good, thanks!

@jeremyw

Amended the commit to update the sass file. Thanks!

@p p merged commit ea23b90 into integrity:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2013
  1. @jeremyw
This page is out of date. Refresh to see the latest.
View
1  doc/integrity.txt
@@ -206,6 +206,7 @@ Integrity supports a number of notification mechanisms:
* AMQP
* http://campfirenow.com[Campfire]
+* https://www.flowdock.com[Flowdock]
* Co-op
* Email
* HTTP
View
2  init.rb
@@ -15,6 +15,8 @@
# require "integrity/notifier/ses"
# = Campfire
# require "integrity/notifier/campfire"
+# = Flowdock
+# require "integrity/notifier/flowdock"
# = TCP
# require "integrity/notifier/tcp"
# = HTTP
View
11 lib/integrity/notifier/flowdock.haml
@@ -0,0 +1,11 @@
+%p.normal
+ %label{ :for => "flowdock_notifier_token" } API Token
+ %input.text#flowdock_notifier_token{ :name => "notifiers[Flowdock][token]", :value => config["token"], :type => "text" }
+
+%p.normal
+ %label{ :for => "flowdock_notifier_from_address" } From address (used for Gravatar)
+ %input.text#flowdock_from_address{ :name => "notifiers[Flowdock][from_address]", :value => config["from_address"], :type => "email", :placeholder => 'integrity@yourdomain.com' }
+
+%p.normal
+ %label{ :for => "flowdock_notifier_announce_success" } Notify on success?
+ %input#flowdock_notifier_announce_success{ :name => "notifiers[Flowdock][announce_success]", :type => "checkbox", :checked => config['announce_success'], :value => "1" }
View
49 lib/integrity/notifier/flowdock.rb
@@ -0,0 +1,49 @@
+require 'uri'
+require 'net/http'
+require 'net/https'
+
+module Integrity
+ class Notifier
+ class Flowdock < Notifier::Base
+ attr_reader :config
+
+ def self.to_haml
+ @haml ||= File.read(File.dirname(__FILE__) + "/flowdock.haml")
+ end
+
+ def deliver!
+ token = config["token"]
+
+ headers = {
+ "Accept" => "application/json",
+ "Content-Type" => "application/json; charset=utf-8",
+ "User-Agent" => "Integrity Flowdock Notifier",
+ }
+
+ uri = URI.parse("https://api.flowdock.com/v1/messages/team_inbox/#{token}")
+
+ https = Net::HTTP.new(uri.host, uri.port)
+ https.use_ssl = true
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
+
+ post = Net::HTTP::Post.new(uri.path, headers)
+ post.body = {
+ "source" => "Integrity",
+ "subject" => short_message,
+ "content" => "<pre>#{full_message}</pre>",
+ "from_address" => config["from_address"],
+ "link" => build_url,
+ "tags" => ["integrity", build.failed? ? "failure" : "success"]
+ }.to_json
+
+ response = https.request(post)
+ end
+
+ def announce_build?
+ build.failed? || config["announce_success"]
+ end
+ end
+
+ register Flowdock
+ end
+end
View
64 test/acceptance/flowdock_notification_test.rb
@@ -0,0 +1,64 @@
+require "helper/acceptance"
+
+class FlowdockNotificationTest < Test::Unit::AcceptanceTestCase
+ story <<-EOS
+ As an administrator,
+ I want to setup the Flowdock notifiers on my projects
+ So that I get alerts with every build
+ EOS
+
+ setup do
+ load "integrity/notifier/flowdock.rb"
+
+ @token = "fc7795d580b6adacaa90f1ds24030s14a31a6522sed"
+ @repo = git_repo(:my_test_project)
+ Project.gen(:my_test_project, :uri => @repo.uri)
+
+ @api_url = "https://api.flowdock.com/v1/messages/team_inbox/#{@token}"
+ end
+
+ teardown do
+ WebMock.reset!
+ Notifier.available.replace({})
+ end
+
+ def commit(successful)
+ successful ? @repo.add_successful_commit : @repo.add_failing_commit
+ @repo.short_head
+ end
+
+ def build
+ login_as "admin", "test"
+ visit "/my-test-project"
+ click_link "Edit"
+
+ check "enabled_notifiers_flowdock"
+ fill_in "API Token", :with => @token
+ check "Notify on success?"
+ click_button "Update"
+ click_button "Manual Build"
+ end
+
+ scenario "Notifying a successful build" do
+ head = commit(true)
+
+ stub_request(:post, @api_url).to_return(
+ :status => 200,
+ :body => {}.to_json)
+
+ build
+
+ assert_requested :post, @api_url
+ end
+
+ scenario "Notifying a failed build" do
+ head = commit(false)
+ stub_request(:post, @api_url).to_return(
+ :status => 200,
+ :body => {}.to_json)
+
+ build
+
+ assert_requested :post, @api_url
+ end
+end
Something went wrong with that request. Please try again.