Permalink
Browse files

Less noise.

Don't announce:
* updated tasks
* column changes
* card moves
* ready-to-move checkmarks
  • Loading branch information...
1 parent 68a65fe commit 3cfbc72d32d3fe77775d622c664dd743315ef660 @spraints committed Mar 1, 2012
Showing with 51 additions and 10 deletions.
  1. +20 −6 lib/campfire_notifier.rb
  2. +31 −4 spec/lib/campfire_notifier_spec.rb
View
@@ -18,22 +18,36 @@ def message_for(params)
'[kanbanery] ' +
case resource[:type]
when 'Task'
- "Task #{resource[:id]} \"#{resource[:title]}\" updated. #{resource[:global_in_context_url]}"
+ if new? resource
+ "Task #{resource[:id]} \"#{resource[:title]}\" added. #{resource[:global_in_context_url]}"
+ else
+ return false
+ end
when 'Comment'
"Comment added to task #{resource[:task_id]}: \"#{resource[:body]}\" #{url_for resource[:task_id]}"
- when 'LoggedTaskEvent'
- "#{resource[:name].humanize}. #{url_for resource[:task_id]}"
when 'Blocking'
"Task #{resource[:task_id]} is blocked! \"#{resource[:blocking_message]}\" #{url_for resource[:task_id]}"
- when 'Column'
- "Column \"#{resource[:name]}\" modified."
- when 'GitCommit'
+ when 'Subtask'
+ change =
+ if new? resource
+ "added"
+ elsif resource[:completed] == 'true'
+ "completed"
+ else
+ "updated"
+ end
+ "Subtask \"#{resource[:body]}\" #{change}. #{url_for resource[:task_id]}"
+ when 'GitCommit', 'Column', 'LoggedTaskEvent'
return false
else
"#{resource[:type].humanize}. #{url_for resource[:task_id]}"
end
end
+ def new? resource
+ resource[:created_at] == resource[:updated_at]
+ end
+
def url_for task_id
task_id && "https://kanbanery.com/tasks/#{task_id}/in-context"
end
@@ -13,18 +13,45 @@
let(:params) { { :resource => resource.with_indifferent_access }.with_indifferent_access }
context 'Task' do
- let(:resource) { { "type"=>"Task", "id"=>"12345", "global_in_context_url"=>"https://kanbanery.com/tasks/12345/in-context", "title"=>"Title of the task", "created_at"=>"2011-11-23T22:16:53+00:00", "updated_at"=>"2011-11-30T14:31:34+00:00", "description"=>"Description of task", "task_type_id"=>"44444", "column_id"=>"55555", "creator_id"=>"8765", "owner_id"=>"8765", "position"=>"2", "priority"=>"0", "ready_to_pull"=>"true", "moved_at"=>"2011-11-30T14:11:08+00:00", "blocked"=>"false" } }
- it { should == '[kanbanery] Task 12345 "Title of the task" updated. https://kanbanery.com/tasks/12345/in-context' }
+ let(:resource) { { "type"=>"Task", "id"=>"12345", "global_in_context_url"=>"https://kanbanery.com/tasks/12345/in-context", "title"=>"Title of the task", "created_at"=>created_at, "updated_at"=>updated_at, "description"=>"Description of task", "task_type_id"=>"44444", "column_id"=>"55555", "creator_id"=>"8765", "owner_id"=>"8765", "position"=>"2", "priority"=>"0", "ready_to_pull"=>"true", "moved_at"=>"2011-11-30T14:11:08+00:00", "blocked"=>"false" } }
+ let(:created_at) { '2012-02-29T01:23:45+00:00' }
+ let(:updated_at) { '2012-02-29T21:23:45+00:00' }
+ context 'new' do
+ let(:updated_at) { created_at }
+ it { should == '[kanbanery] Task 12345 "Title of the task" added. https://kanbanery.com/tasks/12345/in-context' }
+ end
+ context 'updated' do
+ it { should == false }
+ end
end
context 'Comment' do
let(:resource) { { "type"=>"Comment", "task_id"=>"12345", "body"=>"This is a comment body.", "id"=>"23456", "created_at"=>"2011-11-30T14:34:35+00:00", "updated_at"=>"2011-11-30T14:34:35+00:00", "author_id"=>"8765" } }
it { should == '[kanbanery] Comment added to task 12345: "This is a comment body." https://kanbanery.com/tasks/12345/in-context' }
end
+ context 'Subtask' do
+ let(:resource) { { "id" => "45678", "created_at" => created_at, "updated_at" => updated_at, "body" => "subtask title", "creator_id" => "8888", "completed" => completed, "task_id" => "12345", "type" => "Subtask" } }
+ let(:created_at) { '2012-02-29T01:23:45+00:00' }
+ let(:updated_at) { '2012-02-29T21:23:45+00:00' }
+ let(:completed) { "false" }
+ context 'new' do
+ let(:updated_at) { created_at }
+ it { should == '[kanbanery] Subtask "subtask title" added. https://kanbanery.com/tasks/12345/in-context' }
+ end
+ context 'not completed' do
+ let(:completed) { 'false' }
+ it { should == '[kanbanery] Subtask "subtask title" updated. https://kanbanery.com/tasks/12345/in-context' }
+ end
+ context 'completed' do
+ let(:completed) { 'true' }
+ it { should == '[kanbanery] Subtask "subtask title" completed. https://kanbanery.com/tasks/12345/in-context' }
+ end
+ end
+
context 'LoggedTaskEvent' do
let(:resource) { { "type"=>"LoggedTaskEvent", "name"=>"task_ready_to_pull", "task_id"=>"12345", "custom_attributes"=>"[\"task_type_name\", \"Feature\"]", "id"=>"deadbeef123456789abcdef0", "user_id"=>"8765", "created_at"=>"2011-11-30T14:31:34+00:00", "project_id"=>"7777", "column_id"=>"55555" } }
- it { should == '[kanbanery] Task ready to pull. https://kanbanery.com/tasks/12345/in-context' }
+ it { should == false }
end
context 'Blocking' do
@@ -34,7 +61,7 @@
context 'Column' do
let(:resource) { { "id"=>"55555", "created_at"=>"2011-11-29T19:16:03+00:00", "updated_at"=>"2011-12-05T13:19:48+00:00", "project_id"=>"8765", "name"=>"My Column", "fixed"=>"false", "position"=>"3", "type"=>"Column" } }
- it { should == '[kanbanery] Column "My Column" modified.' }
+ it { should == false }
end
context 'Gitcommit' do

0 comments on commit 3cfbc72

Please sign in to comment.