honeybadger-api 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +189 -0
- data/Rakefile +1 -0
- data/honeybadger-api.gemspec +26 -0
- data/lib/honeybadger-api.rb +41 -0
- data/lib/honeybadger-api/client.rb +48 -0
- data/lib/honeybadger-api/comment.rb +47 -0
- data/lib/honeybadger-api/configuration.rb +12 -0
- data/lib/honeybadger-api/deploy.rb +46 -0
- data/lib/honeybadger-api/environment.rb +27 -0
- data/lib/honeybadger-api/fault.rb +63 -0
- data/lib/honeybadger-api/notice.rb +45 -0
- data/lib/honeybadger-api/paginator.rb +72 -0
- data/lib/honeybadger-api/project.rb +71 -0
- data/lib/honeybadger-api/request.rb +44 -0
- data/lib/honeybadger-api/team.rb +42 -0
- data/lib/honeybadger-api/team_invitation.rb +61 -0
- data/lib/honeybadger-api/team_member.rb +58 -0
- data/lib/honeybadger-api/user.rb +19 -0
- data/lib/honeybadger-api/version.rb +5 -0
- data/spec/comment_spec.rb +89 -0
- data/spec/deploy_spec.rb +82 -0
- data/spec/environment_spec.rb +31 -0
- data/spec/factories/comment_factory.rb +16 -0
- data/spec/factories/deploy_factory.rb +15 -0
- data/spec/factories/environment_factory.rb +14 -0
- data/spec/factories/fault_factory.rb +29 -0
- data/spec/factories/notice_factory.rb +14 -0
- data/spec/factories/project_factory.rb +44 -0
- data/spec/factories/team_factory.rb +16 -0
- data/spec/factories/team_invitation_factory.rb +27 -0
- data/spec/factories/team_member_factory.rb +17 -0
- data/spec/factories/user_factory.rb +10 -0
- data/spec/fault_spec.rb +132 -0
- data/spec/notice_spec.rb +81 -0
- data/spec/paginator_spec.rb +106 -0
- data/spec/project_spec.rb +151 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/team_invitation_spec.rb +98 -0
- data/spec/team_member_spec.rb +112 -0
- data/spec/team_spec.rb +68 -0
- data/spec/user_spec.rb +17 -0
- data/spec/version_spec.rb +7 -0
- metadata +195 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module Honeybadger
|
2
|
+
module Api
|
3
|
+
class User
|
4
|
+
|
5
|
+
attr_reader :name, :email
|
6
|
+
|
7
|
+
# Public: Build a new instance of User
|
8
|
+
#
|
9
|
+
# name - the name of the user
|
10
|
+
# email - the email address of the user
|
11
|
+
#
|
12
|
+
# Returns a new User
|
13
|
+
def initialize(name, email)
|
14
|
+
@name = name
|
15
|
+
@email = email
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Api::Comment do
|
4
|
+
|
5
|
+
describe "initializing a new comment" do
|
6
|
+
before :all do
|
7
|
+
@comment = FactoryGirl.build :comment
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a identifier" do
|
11
|
+
@comment.id.should == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a fault identifier" do
|
15
|
+
@comment.fault_id.should == 2
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have an event" do
|
19
|
+
@comment.event.should == "an event"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a source" do
|
23
|
+
@comment.source.should == "app"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a notice count" do
|
27
|
+
@comment.notices_count.should == 5
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have an author" do
|
31
|
+
@comment.author.should == "John"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have a body" do
|
35
|
+
@comment.body.should == "This is a comment"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should have the date the comment was created" do
|
39
|
+
@comment.created_at.should == DateTime.parse("2012-01-01T00:01:00Z")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "all" do
|
44
|
+
before :each do
|
45
|
+
@project_id = 1
|
46
|
+
@fault_id = 2
|
47
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}/comments"
|
48
|
+
@handler = Proc.new { |response| Comment.new(response) }
|
49
|
+
Honeybadger::Api::Comment.expects(:handler).returns(@handler)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should find all of the comments" do
|
53
|
+
Honeybadger::Api::Request.expects(:all).with(@path, @handler).once
|
54
|
+
Honeybadger::Api::Comment.all(@project_id, @fault_id)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "paginate" do
|
59
|
+
before :each do
|
60
|
+
@project_id = 1
|
61
|
+
@fault_id = 2
|
62
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}/comments"
|
63
|
+
@handler = Proc.new { |response| Comment.new(response) }
|
64
|
+
@filters = { some_filter: 'value' }
|
65
|
+
Honeybadger::Api::Comment.expects(:handler).returns(@handler)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should paginate all of the comments" do
|
69
|
+
Honeybadger::Api::Request.expects(:paginate).with(@path, @handler, @filters).once
|
70
|
+
Honeybadger::Api::Comment.paginate(@project_id, @fault_id, @filters)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "find" do
|
75
|
+
before :each do
|
76
|
+
@project_id = 1
|
77
|
+
@fault_id = 2
|
78
|
+
@comment_id = 3
|
79
|
+
@path = "projects/#{@project_id}/faults/#{@fault_id}/comments/#{@comment_id}"
|
80
|
+
@handler = Proc.new { |response| Comment.new(response) }
|
81
|
+
Honeybadger::Api::Comment.expects(:handler).returns(@handler)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should find a comment" do
|
85
|
+
Honeybadger::Api::Request.expects(:find).with(@path, @handler).once
|
86
|
+
Honeybadger::Api::Comment.find(@project_id, @fault_id, @comment_id)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/deploy_spec.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Honeybadger::Api::Deploy do
|
4
|
+
|
5
|
+
describe "initializing a new deploy" do
|
6
|
+
before :all do
|
7
|
+
@deploy = FactoryGirl.build :deploy
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have a identifier" do
|
11
|
+
@deploy.id.should == 1
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a project identifier" do
|
15
|
+
@deploy.project_id.should == 2
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a repository" do
|
19
|
+
@deploy.repository.should == "honeybadger-api"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a revision" do
|
23
|
+
@deploy.revision.should == "11111"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a environment" do
|
27
|
+
@deploy.environment.should == "production"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should have a local_username" do
|
31
|
+
@deploy.local_username.should == "deploy"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have the date the deploy was made" do
|
35
|
+
@deploy.created_at.should == DateTime.parse("2012-01-01T00:01:00Z")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "all" do
|
40
|
+
before :each do
|
41
|
+
@project_id = 1
|
42
|
+
@path = "projects/#{@project_id}/deploys"
|
43
|
+
@handler = Proc.new { |response| Deploy.new(response) }
|
44
|
+
Honeybadger::Api::Deploy.expects(:handler).returns(@handler)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should find all of the deploys" do
|
48
|
+
Honeybadger::Api::Request.expects(:all).with(@path, @handler).once
|
49
|
+
Honeybadger::Api::Deploy.all(@project_id)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "paginate" do
|
54
|
+
before :each do
|
55
|
+
@project_id = 1
|
56
|
+
@path = "projects/#{@project_id}/deploys"
|
57
|
+
@handler = Proc.new { |response| Deploy.new(response) }
|
58
|
+
@filters = { some_filter: 'value' }
|
59
|
+
Honeybadger::Api::Deploy.expects(:handler).returns(@handler)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should paginate all of the deploys" do
|
63
|
+
Honeybadger::Api::Request.expects(:paginate).with(@path, @handler, @filters).once
|
64
|
+
Honeybadger::Api::Deploy.paginate(@project_id, @filters)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "find" do
|
69
|
+
before :each do
|
70
|
+
@project_id = 1
|
71
|
+
@deploy_id = 2
|
72
|
+
@path = "projects/#{@project_id}/deploys/#{@deploy_id}"
|
73
|
+
@handler = Proc.new { |response| Deploy.new(response) }
|
74
|
+
Honeybadger::Api::Deploy.expects(:handler).returns(@handler)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should find a deploy" do
|
78
|
+
Honeybadger::Api::Request.expects(:find).with(@path, @handler).once
|
79
|
+
Honeybadger::Api::Deploy.find(@project_id, @deploy_id)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
describe Honeybadger::Api::Environment do
|
2
|
+
describe "initializing a new environment" do
|
3
|
+
before :all do
|
4
|
+
@environment = FactoryGirl.build :environment
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should have an identifier" do
|
8
|
+
@environment.id.should == 1
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should have a name" do
|
12
|
+
@environment.name.should == "production"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have a project identifier" do
|
16
|
+
@environment.project_id.should == 2
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should raise notifications" do
|
20
|
+
@environment.notifications?.should eql(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have the date the environment was updated" do
|
24
|
+
@environment.updated_at.should == DateTime.parse("2012-01-01T00:02:00Z")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have the date the environment was created" do
|
28
|
+
@environment.created_at.should == DateTime.parse("2012-01-01T00:01:00Z")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :comment, :class => Honeybadger::Api::Comment do
|
3
|
+
id 1
|
4
|
+
fault_id 2
|
5
|
+
event "an event"
|
6
|
+
source "app"
|
7
|
+
notices_count 5
|
8
|
+
author "John"
|
9
|
+
body "This is a comment"
|
10
|
+
created_at "2012-01-01T00:01:00Z"
|
11
|
+
|
12
|
+
initialize_with do
|
13
|
+
new(attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :deploy, :class => Honeybadger::Api::Deploy do
|
3
|
+
id 1
|
4
|
+
project_id 2
|
5
|
+
repository "honeybadger-api"
|
6
|
+
revision "11111"
|
7
|
+
environment "production"
|
8
|
+
local_username "deploy"
|
9
|
+
created_at "2012-01-01T00:01:00Z"
|
10
|
+
|
11
|
+
initialize_with do
|
12
|
+
new(attributes)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :environment, :class => Honeybadger::Api::Environment do
|
3
|
+
id 1
|
4
|
+
name "production"
|
5
|
+
project_id 2
|
6
|
+
notifications true
|
7
|
+
updated_at "2012-01-01T00:02:00Z"
|
8
|
+
created_at "2012-01-01T00:01:00Z"
|
9
|
+
end
|
10
|
+
|
11
|
+
initialize_with do
|
12
|
+
new(attributes)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :fault, :class => Honeybadger::Api::Fault do
|
3
|
+
id 1
|
4
|
+
project_id 2
|
5
|
+
klass "RuntimeError"
|
6
|
+
action "runtime_error"
|
7
|
+
component "pages"
|
8
|
+
message "This is a runtime error"
|
9
|
+
environment "production"
|
10
|
+
ignored false
|
11
|
+
resolved false
|
12
|
+
notices_count 7
|
13
|
+
comments_count 0
|
14
|
+
last_notice_at "2012-01-01T00:02:00Z"
|
15
|
+
created_at "2012-01-01T00:01:00Z"
|
16
|
+
|
17
|
+
initialize_with do
|
18
|
+
new(attributes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
factory :ignored_fault, :parent => :fault do
|
23
|
+
ignored true
|
24
|
+
end
|
25
|
+
|
26
|
+
factory :resolved_fault, :parent => :fault do
|
27
|
+
resolved true
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :notice, :class => Honeybadger::Api::Notice do
|
3
|
+
id 1
|
4
|
+
fault_id 2
|
5
|
+
message "This is a runtime error"
|
6
|
+
environment "production"
|
7
|
+
request({:action => "runtime error"})
|
8
|
+
created_at "2012-01-01T00:01:00Z"
|
9
|
+
|
10
|
+
initialize_with do
|
11
|
+
new(attributes)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :project, :class => Honeybadger::Api::Project do
|
3
|
+
id 1
|
4
|
+
name "Rails"
|
5
|
+
association :owner, :factory => :user, :strategy => :attributes_for
|
6
|
+
# users
|
7
|
+
users [
|
8
|
+
{
|
9
|
+
:email => "user@example.com",
|
10
|
+
:name => "user"
|
11
|
+
}
|
12
|
+
]
|
13
|
+
token "098sflj2"
|
14
|
+
environments [
|
15
|
+
FactoryGirl.attributes_for(:environment)
|
16
|
+
]
|
17
|
+
active true
|
18
|
+
disable_public_links false
|
19
|
+
fault_count 14
|
20
|
+
unresolved_fault_count 1
|
21
|
+
last_notice_at "2012-01-01T00:02:00Z"
|
22
|
+
created_at "2012-01-01T00:01:00Z"
|
23
|
+
|
24
|
+
initialize_with do
|
25
|
+
new(attributes)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
factory :active_project, :parent => :project do
|
30
|
+
active true
|
31
|
+
end
|
32
|
+
|
33
|
+
factory :inactive_project, :parent => :project do
|
34
|
+
active false
|
35
|
+
end
|
36
|
+
|
37
|
+
factory :public_project, :parent => :project do
|
38
|
+
disable_public_links false
|
39
|
+
end
|
40
|
+
|
41
|
+
factory :private_project, :parent => :project do
|
42
|
+
disable_public_links true
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :team, :class => Honeybadger::Api::Team do
|
3
|
+
id 1
|
4
|
+
name "team"
|
5
|
+
association :owner, :factory => :user, :strategy => :attributes_for
|
6
|
+
|
7
|
+
members([])
|
8
|
+
projects([])
|
9
|
+
created_at "2012-01-01T00:01:00Z"
|
10
|
+
|
11
|
+
initialize_with do
|
12
|
+
new(attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :team_invitation, :class => Honeybadger::Api::TeamInvitation do
|
3
|
+
id 1
|
4
|
+
token "e62394d2"
|
5
|
+
email "invitation@example.com"
|
6
|
+
created_by({
|
7
|
+
:email => "invitation.created@example.com",
|
8
|
+
:name => "John Created"
|
9
|
+
})
|
10
|
+
accepted_by({
|
11
|
+
:email => "invitation.accepted@example.com",
|
12
|
+
:name => "John Accepted"
|
13
|
+
})
|
14
|
+
admin false
|
15
|
+
accepted_at "2012-01-01T00:02:00Z"
|
16
|
+
created_at "2012-01-01T00:01:00Z"
|
17
|
+
message "Come join in"
|
18
|
+
|
19
|
+
initialize_with do
|
20
|
+
new(attributes)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
factory :admin_team_invitation, :parent => :team_invitation do
|
25
|
+
admin true
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :normal_team_member, :class => Honeybadger::Api::TeamMember do
|
3
|
+
id 1
|
4
|
+
name "John Smith"
|
5
|
+
email "john.smith@example.com"
|
6
|
+
admin false
|
7
|
+
created_at "2012-01-01T00:01:00Z"
|
8
|
+
|
9
|
+
initialize_with do
|
10
|
+
new(attributes)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
factory :admin_team_member, :parent => :normal_team_member do
|
15
|
+
admin true
|
16
|
+
end
|
17
|
+
end
|