honeybadger-api 1.2.2 → 2.0.0

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: a299d9bcead1750d8857b2e770459ec8189b87bf
4
- data.tar.gz: 6636363a6cad91c0100f5e958861df31fd60be9b
3
+ metadata.gz: be0770d5bb723023949658276813b3cc0fd80939
4
+ data.tar.gz: 0591dabb54293fcd2748e63c3ffebe8b95b44410
5
5
  SHA512:
6
- metadata.gz: 0abdd9771f02020b94316e13c0c4301fbf334950fc84daf0a79c9e51f659b04f7cc1f53d74b3797c178acc67eea11d36ba492f08a0d0dec2006a37af58c75379
7
- data.tar.gz: 9bf9c69c23f435d969ea640026431f13dafe41e12603e7127c953ec47a2ff54fd90735f086af20f97309fa3ef92d19bda576fdf626ab3ba37cb9bdb8b7638eb6
6
+ metadata.gz: d9f620cf0ba581fd5ccb6eb92414cfdaf46d6133dd01160247f84d08efa6540b598662b3d07603f92ec6d1b261883cdbba718873b5666663bf5f14f6d8c230bf
7
+ data.tar.gz: 29903878f77ab1f3f8770a293929d89f57c3cb57993f17ada2df821a3cc9c1d3bbb4cd75ef7afa57f957bf72f3e93e482393a9b6f98a53fb432eb3c9cba3d2a7
data/README.md CHANGED
@@ -71,9 +71,6 @@ paginator.next
71
71
  # Retrieve the current page number
72
72
  paginator.current_page
73
73
 
74
- # Retrieve the total number of pages
75
- paginator.total_page_count
76
-
77
74
  # Return all previously requested pages as a Hash
78
75
  paginator.pages
79
76
  => {
@@ -123,15 +120,13 @@ Honeybadger::Api::Fault.paginate(project_id)
123
120
 
124
121
  ### Notices
125
122
  ```
126
- # Find a notice
127
- Honeybadger::Api::Notice.find(project_id, fault_id, notice_id)
128
-
129
123
  # Find all the notices
130
124
  Honeybadger::Api::Notice.all(project_id, fault_id)
131
125
 
132
126
  # Retrieve a paginator for notices
133
127
  Honeybadger::Api::Notice.paginate(project_id, fault_id)
134
128
  ```
129
+
135
130
  ### Comments
136
131
  ```
137
132
  # Find a comment
@@ -14,7 +14,6 @@ require "honeybadger-api/comment"
14
14
  require "honeybadger-api/project"
15
15
  require "honeybadger-api/fault"
16
16
  require "honeybadger-api/notice"
17
- require "honeybadger-api/environment"
18
17
 
19
18
  module Honeybadger
20
19
  module Api
@@ -1,4 +1,4 @@
1
- require "net/http"
1
+ require "net/https"
2
2
  require "uri"
3
3
  require "json"
4
4
  require "openssl"
@@ -27,6 +27,7 @@ module Honeybadger
27
27
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
28
28
 
29
29
  request = Net::HTTP::Get.new(uri.request_uri)
30
+ request.basic_auth(access_token, nil)
30
31
 
31
32
  response = http.request(request)
32
33
  end
@@ -38,11 +39,11 @@ module Honeybadger
38
39
  end
39
40
 
40
41
  def build_query(opts)
41
- URI.encode_www_form(opts.merge({:auth_token => access_token}))
42
+ URI.encode_www_form(opts)
42
43
  end
43
44
 
44
45
  def host
45
- "https://api.honeybadger.io/v1/"
46
+ "https://app.honeybadger.io/v2/"
46
47
  end
47
48
  end
48
49
  end
@@ -2,7 +2,7 @@ module Honeybadger
2
2
  module Api
3
3
  class Comment
4
4
 
5
- attr_reader :id, :fault_id, :event, :source, :notices_count, :author, :body, :created_at
5
+ attr_reader :id, :fault_id, :event, :source, :notices_count, :author, :body, :email, :created_at
6
6
 
7
7
  # Public: Build a new instance of Comment
8
8
  #
@@ -17,6 +17,7 @@ module Honeybadger
17
17
  @notices_count = opts[:notices_count]
18
18
  @author = opts[:author]
19
19
  @body = opts[:body]
20
+ @email = opts[:email]
20
21
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
21
22
  end
22
23
 
@@ -2,7 +2,8 @@ module Honeybadger
2
2
  module Api
3
3
  class Deploy
4
4
 
5
- attr_reader :id, :project_id, :repository, :revision, :environment, :local_username, :created_at
5
+ attr_reader :url, :repository, :revision, :environment,
6
+ :changelog, :local_username, :created_at
6
7
 
7
8
  # Public: Build a new instance of Deploy
8
9
  #
@@ -10,11 +11,11 @@ module Honeybadger
10
11
  #
11
12
  # Returns a new Deploy
12
13
  def initialize(opts)
13
- @id = opts[:id]
14
- @project_id = opts[:project_id]
14
+ @url = opts[:url]
15
15
  @repository = opts[:repository]
16
16
  @revision = opts[:revision]
17
17
  @environment = opts[:environment]
18
+ @changelog = opts[:changelog]
18
19
  @local_username = opts[:local_username]
19
20
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
20
21
  end
@@ -3,7 +3,8 @@ module Honeybadger
3
3
  class Fault
4
4
 
5
5
  attr_reader :id, :project_id, :klass, :action, :component, :message,
6
- :environment, :notices_count, :comments_count, :last_notice_at, :created_at
6
+ :environment, :notices_count, :comments_count, :last_notice_at, :created_at,
7
+ :url, :assignee, :tags, :deploy
7
8
 
8
9
  # Public: Build a new instance of Fault
9
10
  #
@@ -24,6 +25,12 @@ module Honeybadger
24
25
  @comments_count = opts[:comments_count]
25
26
  @last_notice_at = opts[:last_notice_at].nil? ? nil : DateTime.parse(opts[:last_notice_at])
26
27
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
28
+ @url = opts[:url]
29
+ if opts[:assignee]
30
+ @assignee = User.new(opts[:assignee][:name], opts[:assignee][:email])
31
+ end
32
+ @tags = opts[:tags]
33
+ @deploy = Deploy.new(opts[:deploy]) unless opts[:deploy].nil?
27
34
  end
28
35
 
29
36
  # Public: Whether tha fault has been marked as ignored.
@@ -2,7 +2,8 @@ module Honeybadger
2
2
  module Api
3
3
  class Notice
4
4
 
5
- attr_reader :id, :fault_id, :environment, :message, :request, :created_at
5
+ attr_reader :id, :url, :fault_id, :environment, :environment_name, :cookies, :message,
6
+ :request, :created_at, :web_environment, :backtrace, :deploy
6
7
 
7
8
  # Public: Build a new instance of Notice
8
9
  #
@@ -11,8 +12,14 @@ module Honeybadger
11
12
  # Returns a new Notice
12
13
  def initialize(opts)
13
14
  @id = opts[:id]
15
+ @url = opts[:url]
14
16
  @fault_id = opts[:fault_id]
15
17
  @environment = opts[:environment]
18
+ @environment_name = opts[:environment_name]
19
+ @cookies = opts[:cookies]
20
+ @web_environment = opts[:web_environment]
21
+ @backtrace = opts[:backtrace]
22
+ @deploy = Deploy.new(opts[:deploy])
16
23
  @message = opts[:message]
17
24
  @request = opts[:request]
18
25
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
@@ -30,12 +37,6 @@ module Honeybadger
30
37
  Honeybadger::Api::Request.paginate(path, handler, filters)
31
38
  end
32
39
 
33
- # Public: Find a notice on a fault for a project.
34
- def self.find(project_id, fault_id, notice_id)
35
- path = "projects/#{project_id}/faults/#{fault_id}/notices/#{notice_id}"
36
- Honeybadger::Api::Request.find(path, handler)
37
- end
38
-
39
40
  # Internal: The handler used to build objects from API responses.
40
41
  def self.handler
41
42
  Proc.new { |response| Notice.new(response) }
@@ -2,7 +2,7 @@ module Honeybadger
2
2
  module Api
3
3
  class Paginator
4
4
 
5
- attr_reader :current_page, :total_page_count, :pages
5
+ attr_reader :current_page, :pages, :next_page_link, :prev_page_link
6
6
 
7
7
  def initialize(path, filters, handler)
8
8
  @path = path
@@ -11,11 +11,12 @@ module Honeybadger
11
11
 
12
12
  @pages = {}
13
13
 
14
- @filters.merge!({ :page => 1 }) if !@filters.has_key?(:page)
14
+ @current_page = 1
15
+
15
16
  response = Honeybadger::Api.client.get(@path, @filters)
16
17
 
17
- @current_page = response[:current_page]
18
- @total_page_count = response[:num_pages]
18
+ @next_page_link = response[:links][:next]
19
+ @prev_page_link = response[:links][:prev]
19
20
 
20
21
  @pages[current_page] = response[:results].map do |r|
21
22
  @handler.call(r)
@@ -23,19 +24,24 @@ module Honeybadger
23
24
  end
24
25
 
25
26
  def next?
26
- current_page < total_page_count
27
+ !@next_page_link.nil?
27
28
  end
28
29
 
29
30
  def previous?
30
- current_page > 1
31
+ !@prev_page_link.nil?
31
32
  end
32
33
 
33
34
  def next
34
35
  if next?
35
- response = Honeybadger::Api.client.get(@path, @filters.merge({:page => current_page + 1}))
36
+ encoded_query = URI.parse(@next_page_link).query
37
+ decoded_query = URI.decode_www_form(encoded_query)
38
+ next_page_filters = decoded_query.inject({}){ |h,(k,v)| h[k.to_sym] = v; h }
39
+
40
+ response = Honeybadger::Api.client.get(@path, @filters.merge(next_page_filters))
36
41
 
37
- @current_page = response[:current_page]
38
- @total_page_count = response[:num_pages]
42
+ @current_page = current_page + 1
43
+ @next_page_link = response[:links][:next]
44
+ @prev_page_link = response[:links][:prev]
39
45
 
40
46
  @pages[current_page] = response[:results].map do |r|
41
47
  @handler.call(r)
@@ -49,10 +55,15 @@ module Honeybadger
49
55
 
50
56
  def previous
51
57
  if previous?
52
- response = Honeybadger::Api.client.get(@path, @filters.merge({:page => current_page - 1}))
58
+ encoded_query = URI.parse(@prev_page_link).query
59
+ decoded_query = URI.decode_www_form(encoded_query)
60
+ prev_page_filters = decoded_query.inject({}){ |h,(k,v)| h[k.to_sym] = v; h }
61
+
62
+ response = Honeybadger::Api.client.get(@path, @filters.merge(prev_page_filters))
53
63
 
54
- @current_page = response[:current_page]
55
- @total_page_count = response[:num_pages]
64
+ @current_page = current_page - 1
65
+ @next_page_link = response[:links][:next]
66
+ @prev_page_link = response[:links][:prev]
56
67
 
57
68
  @pages[current_page] = response[:results].map do |r|
58
69
  @handler.call(r)
@@ -3,7 +3,8 @@ module Honeybadger
3
3
  class Project
4
4
 
5
5
  attr_reader :id, :name, :owner, :users, :token, :environments,
6
- :fault_count, :unresolved_fault_count, :last_notice_at, :created_at
6
+ :fault_count, :unresolved_fault_count, :last_notice_at, :created_at,
7
+ :teams, :earliest_notice_at
7
8
 
8
9
  # Public: Build a new instance of Project
9
10
  #
@@ -16,14 +17,14 @@ module Honeybadger
16
17
  @owner = User.new(opts[:owner][:name], opts[:owner][:email])
17
18
  @users = opts[:users].collect { |user| User.new(user[:name], user[:email]) }
18
19
  @token = opts[:token]
19
- @environments = opts[:environments].collect do |env|
20
- Environment.new(env)
21
- end
20
+ @environments = opts[:environments]
21
+ @teams = opts[:teams]
22
22
  @active = opts[:active]
23
23
  @disable_public_links = opts[:disable_public_links]
24
24
  @fault_count = opts[:fault_count]
25
25
  @unresolved_fault_count = opts[:unresolved_fault_count]
26
26
  @last_notice_at = opts[:last_notice_at].nil? ? nil : DateTime.parse(opts[:last_notice_at])
27
+ @earliest_notice_at = opts[:earliest_notice_at].nil? ? nil : DateTime.parse(opts[:earliest_notice_at])
27
28
  @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
28
29
  end
29
30
 
@@ -1,5 +1,5 @@
1
1
  module Honeybadger
2
2
  module Api
3
- VERSION = "1.2.2"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
data/spec/comment_spec.rb CHANGED
@@ -35,6 +35,10 @@ describe Honeybadger::Api::Comment do
35
35
  expect(@comment.body).to eql("This is a comment")
36
36
  end
37
37
 
38
+ it "should have an email address" do
39
+ expect(@comment.email).to eql("test@example.com")
40
+ end
41
+
38
42
  it "should have the date the comment was created" do
39
43
  expect(@comment.created_at).to eql(DateTime.parse("2012-01-01T00:01:00Z"))
40
44
  end
data/spec/deploy_spec.rb CHANGED
@@ -7,12 +7,8 @@ describe Honeybadger::Api::Deploy do
7
7
  @deploy = FactoryGirl.build :deploy
8
8
  end
9
9
 
10
- it "should have a identifier" do
11
- expect(@deploy.id).to eql(1)
12
- end
13
-
14
- it "should have a project identifier" do
15
- expect(@deploy.project_id).to eql(2)
10
+ it "should have a url" do
11
+ expect(@deploy.url).to eql("https://github.com/murraysum/honeybadger-api/compare/1cf2e67...c128731")
16
12
  end
17
13
 
18
14
  it "should have a repository" do
@@ -27,6 +23,10 @@ describe Honeybadger::Api::Deploy do
27
23
  expect(@deploy.environment).to eql("production")
28
24
  end
29
25
 
26
+ it "should have a changelog" do
27
+ expect(@deploy.changelog).to eql(["New release"])
28
+ end
29
+
30
30
  it "should have a local_username" do
31
31
  expect(@deploy.local_username).to eql("deploy")
32
32
  end
@@ -7,6 +7,7 @@ FactoryGirl.define do
7
7
  notices_count 5
8
8
  author "John"
9
9
  body "This is a comment"
10
+ email "test@example.com"
10
11
  created_at "2012-01-01T00:01:00Z"
11
12
 
12
13
  initialize_with do
@@ -1,11 +1,11 @@
1
1
  FactoryGirl.define do
2
2
  factory :deploy, :class => Honeybadger::Api::Deploy do
3
- id 1
4
- project_id 2
3
+ url "https://github.com/murraysum/honeybadger-api/compare/1cf2e67...c128731"
5
4
  repository "honeybadger-api"
6
5
  revision "11111"
7
6
  environment "production"
8
7
  local_username "deploy"
8
+ changelog ["New release"]
9
9
  created_at "2012-01-01T00:01:00Z"
10
10
 
11
11
  initialize_with do
@@ -13,12 +13,20 @@ FactoryGirl.define do
13
13
  comments_count 0
14
14
  last_notice_at "2012-01-01T00:02:00Z"
15
15
  created_at "2012-01-01T00:01:00Z"
16
+ url "https://app.honeybadger.io/projects/2/faults/1"
17
+ assignee nil
18
+ tags ["internal"]
19
+ association :deploy, :factory => :deploy, :strategy => :attributes_for
16
20
 
17
21
  initialize_with do
18
22
  new(attributes)
19
23
  end
20
24
  end
21
25
 
26
+ factory :assigned_fault, :parent => :fault do
27
+ association :assignee, :factory => :user, :strategy => :attributes_for
28
+ end
29
+
22
30
  factory :ignored_fault, :parent => :fault do
23
31
  ignored true
24
32
  end
@@ -1,9 +1,34 @@
1
1
  FactoryGirl.define do
2
2
  factory :notice, :class => Honeybadger::Api::Notice do
3
- id 1
3
+ id "5a24f938-a578-427d-a92b-d2f134d4af67"
4
+ url "https://app.honeybadger.io/projects/1/faults/2/5a24f938-a578-427d-a92b-d2f134d4af67"
4
5
  fault_id 2
5
6
  message "This is a runtime error"
6
- environment "production"
7
+ environment({
8
+ :project_root => "/data/www/apps/myapp/releases/20160701085636",
9
+ :environment_name => "production",
10
+ :hostname => "web1.myapp.com",
11
+ :pid => 22587
12
+ })
13
+ environment_name "production"
14
+ cookies({:cookie => "monster"})
15
+ web_environment({
16
+ :REMOTE_ADDR=>"127.0.0.1",
17
+ :REQUEST_METHOD=>"POST"
18
+ })
19
+ backtrace([
20
+ {
21
+ :number => "21",
22
+ :file => "[PROJECT_ROOT]/lib/multivariate/participation/cookie_participation.rb",
23
+ :method => "[]"
24
+ },
25
+ {
26
+ :number => "21",
27
+ :file => "[PROJECT_ROOT]/lib/multivariate/participation/cookie_participation.rb",
28
+ :method => "get_existing_data"
29
+ }
30
+ ])
31
+ association :deploy, :factory => :deploy, :strategy => :attributes_for
7
32
  request({:action => "runtime error"})
8
33
  created_at "2012-01-01T00:01:00Z"
9
34
 
@@ -12,13 +12,19 @@ FactoryGirl.define do
12
12
  ]
13
13
  token "098sflj2"
14
14
  environments [
15
- FactoryGirl.attributes_for(:environment)
15
+ "development",
16
+ "integration",
17
+ "production"
18
+ ]
19
+ teams [
20
+ { :id => 1, :name => "Engineering" }
16
21
  ]
17
22
  active true
18
23
  disable_public_links false
19
24
  fault_count 14
20
25
  unresolved_fault_count 1
21
26
  last_notice_at "2012-01-01T00:02:00Z"
27
+ earliest_notice_at "2016-04-26T20:38:02.318434Z"
22
28
  created_at "2012-01-01T00:01:00Z"
23
29
 
24
30
  initialize_with do
data/spec/fault_spec.rb CHANGED
@@ -50,6 +50,22 @@ describe Honeybadger::Api::Fault do
50
50
  it "should have a created_at" do
51
51
  expect(@fault.created_at).to eql(DateTime.parse("2012-01-01T00:01:00Z"))
52
52
  end
53
+
54
+ it "should have a url" do
55
+ expect(@fault.url).to eql("https://app.honeybadger.io/projects/2/faults/1")
56
+ end
57
+
58
+ it "should not have an assignee" do
59
+ expect(@fault.assignee).to be_nil
60
+ end
61
+
62
+ it "should have tags" do
63
+ expect(@fault.tags).to eql(["internal"])
64
+ end
65
+
66
+ it "should have a deploy object" do
67
+ expect(@fault.deploy).to_not be_nil
68
+ end
53
69
  end
54
70
 
55
71
  describe "an ignored fault" do
@@ -72,6 +88,20 @@ describe Honeybadger::Api::Fault do
72
88
  end
73
89
  end
74
90
 
91
+ describe "an assigned fault" do
92
+ before :each do
93
+ @fault = FactoryGirl.build :assigned_fault
94
+ end
95
+
96
+ it "should have an assigned name" do
97
+ expect(@fault.assignee.name).to eql("Tom Smith")
98
+ end
99
+
100
+ it "should have an assigned email" do
101
+ expect(@fault.assignee.email).to eql("tom.smith@example.com")
102
+ end
103
+ end
104
+
75
105
  describe "an unresolved and unignored fault" do
76
106
  before :each do
77
107
  @fault = FactoryGirl.build :fault
data/spec/notice_spec.rb CHANGED
@@ -2,13 +2,17 @@ require 'spec_helper'
2
2
 
3
3
  describe Honeybadger::Api::Notice do
4
4
 
5
- describe "initializing a new comment" do
5
+ describe "initializing a new notice" do
6
6
  before :all do
7
7
  @notice = FactoryGirl.build :notice
8
8
  end
9
9
 
10
10
  it "should have a identifier" do
11
- expect(@notice.id).to eql(1)
11
+ expect(@notice.id).to eql("5a24f938-a578-427d-a92b-d2f134d4af67")
12
+ end
13
+
14
+ it "should have a url" do
15
+ expect(@notice.url).to eql("https://app.honeybadger.io/projects/1/faults/2/5a24f938-a578-427d-a92b-d2f134d4af67")
12
16
  end
13
17
 
14
18
  it "should have a fault identifier" do
@@ -20,7 +24,49 @@ describe Honeybadger::Api::Notice do
20
24
  end
21
25
 
22
26
  it "should have an environment" do
23
- expect(@notice.environment).to eql("production")
27
+ environment = {
28
+ :project_root => "/data/www/apps/myapp/releases/20160701085636",
29
+ :environment_name => "production",
30
+ :hostname => "web1.myapp.com",
31
+ :pid => 22587
32
+ }
33
+ expect(@notice.environment).to eql(environment)
34
+ end
35
+
36
+ it "should have an environment_name" do
37
+ expect(@notice.environment_name).to eql("production")
38
+ end
39
+
40
+ it "should have cookies" do
41
+ expect(@notice.cookies).to eql({:cookie => "monster"})
42
+ end
43
+
44
+ it "should have a web environment" do
45
+ web_environment = {
46
+ :REMOTE_ADDR => "127.0.0.1",
47
+ :REQUEST_METHOD => "POST"
48
+ }
49
+ expect(@notice.web_environment).to eql(web_environment)
50
+ end
51
+
52
+ it "should have a backtrace" do
53
+ backtrace = [
54
+ {
55
+ :number => "21",
56
+ :file => "[PROJECT_ROOT]/lib/multivariate/participation/cookie_participation.rb",
57
+ :method => "[]"
58
+ },
59
+ {
60
+ :number => "21",
61
+ :file => "[PROJECT_ROOT]/lib/multivariate/participation/cookie_participation.rb",
62
+ :method => "get_existing_data"
63
+ }
64
+ ]
65
+ expect(@notice.backtrace).to eql(backtrace)
66
+ end
67
+
68
+ it "should have a deploy object" do
69
+ expect(@notice.deploy).to_not be_nil
24
70
  end
25
71
 
26
72
  it "should have a request" do
@@ -62,20 +108,4 @@ describe Honeybadger::Api::Notice do
62
108
  Honeybadger::Api::Notice.paginate(@project_id, @fault_id, @filters)
63
109
  end
64
110
  end
65
-
66
- describe "find" do
67
- before :each do
68
- @project_id = 1
69
- @fault_id = 2
70
- @notice_id = 3
71
- @path = "projects/#{@project_id}/faults/#{@fault_id}/notices/#{@notice_id}"
72
- @handler = Proc.new { |response| Notice.new(response) }
73
- Honeybadger::Api::Notice.expects(:handler).returns(@handler)
74
- end
75
-
76
- it "should find a notice" do
77
- Honeybadger::Api::Request.expects(:find).with(@path, @handler).once
78
- Honeybadger::Api::Notice.find(@project_id, @fault_id, @notice_id)
79
- end
80
- end
81
111
  end
@@ -10,9 +10,10 @@ describe Honeybadger::Api::Paginator do
10
10
  describe "when there is one page" do
11
11
  before :all do
12
12
  opts = {
13
- :current_page => 1,
14
- :num_pages => 1,
15
- :results => []
13
+ :results => [],
14
+ :links => {
15
+ :self => "https://api.honeybadger.io/v2/projects"
16
+ }
16
17
  }
17
18
  @client_stub.expects(:get).returns(opts)
18
19
  Honeybadger::Api.stubs(:client).returns(@client_stub)
@@ -33,9 +34,11 @@ describe Honeybadger::Api::Paginator do
33
34
  describe "when there are two pages and on first page" do
34
35
  before :all do
35
36
  opts = {
36
- :current_page => 1,
37
- :num_pages => 2,
38
- :results => []
37
+ :results => [],
38
+ :links => {
39
+ :self => "https://api.honeybadger.io/v2/projects",
40
+ :next => "https://api.honeybadger.io/v2/projects?page=2"
41
+ }
39
42
  }
40
43
  @client_stub.expects(:get).returns(opts)
41
44
  Honeybadger::Api.stubs(:client).returns(@client_stub)
@@ -56,9 +59,11 @@ describe Honeybadger::Api::Paginator do
56
59
  describe "when there are two pages and on last page" do
57
60
  before :all do
58
61
  opts = {
59
- :current_page => 2,
60
- :num_pages => 2,
61
- :results => []
62
+ :results => [],
63
+ :links => {
64
+ :self => "https://api.honeybadger.io/v2/projects",
65
+ :prev => "https://api.honeybadger.io/v2/projects?page=1"
66
+ }
62
67
  }
63
68
  @client_stub.expects(:get).returns(opts)
64
69
  Honeybadger::Api.stubs(:client).returns(@client_stub)
@@ -79,9 +84,12 @@ describe Honeybadger::Api::Paginator do
79
84
  describe "when there are three pages and on middle page" do
80
85
  before :all do
81
86
  opts = {
82
- :current_page => 2,
83
- :num_pages => 3,
84
- :results => []
87
+ :results => [],
88
+ :links => {
89
+ :self => "https://api.honeybadger.io/v2/projects",
90
+ :prev => "https://api.honeybadger.io/v2/projects?page=1",
91
+ :next => "https://api.honeybadger.io/v2/projects?page=3"
92
+ }
85
93
  }
86
94
  @client_stub.expects(:get).returns(opts)
87
95
  Honeybadger::Api.stubs(:client).returns(@client_stub)
data/spec/project_spec.rb CHANGED
@@ -31,8 +31,19 @@ describe Honeybadger::Api::Project do
31
31
  end
32
32
 
33
33
  it "should have a list of environments" do
34
- expect(@project.environments.length).to eql(1)
35
- expect(@project.environments.first).to be_kind_of(Honeybadger::Api::Environment)
34
+ environments = [
35
+ "development",
36
+ "integration",
37
+ "production"
38
+ ]
39
+ expect(@project.environments).to eql(environments)
40
+ end
41
+
42
+ it "should have a list of teams" do
43
+ teams = [
44
+ { :id => 1, :name => "Engineering" }
45
+ ]
46
+ expect(@project.teams).to eql(teams)
36
47
  end
37
48
 
38
49
  it "should have a fault count" do
@@ -47,6 +58,10 @@ describe Honeybadger::Api::Project do
47
58
  expect(@project.last_notice_at).to eql(DateTime.parse("2012-01-01T00:02:00Z"))
48
59
  end
49
60
 
61
+ it "should have an earliest notice at" do
62
+ expect(@project.earliest_notice_at).to eql(DateTime.parse("2016-04-26T20:38:02.318434Z"))
63
+ end
64
+
50
65
  it "should have a created_at" do
51
66
  expect(@project.created_at).to eql(DateTime.parse("2012-01-01T00:01:00Z"))
52
67
  end
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,6 @@ require 'honeybadger-api'
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.color = true
9
- config.formatter = 'documentation'
10
9
  config.mock_framework = :mocha
11
10
  end
12
11
 
data/spec/version_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Honeybadger::Api::VERSION" do
4
- it "should be version 1.2.2" do
5
- expect(Honeybadger::Api::VERSION).to eql("1.2.2")
4
+ it "should be version 2.0.0" do
5
+ expect(Honeybadger::Api::VERSION).to eql("2.0.0")
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Murray Summers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-05 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -113,7 +113,6 @@ files:
113
113
  - lib/honeybadger-api/comment.rb
114
114
  - lib/honeybadger-api/configuration.rb
115
115
  - lib/honeybadger-api/deploy.rb
116
- - lib/honeybadger-api/environment.rb
117
116
  - lib/honeybadger-api/fault.rb
118
117
  - lib/honeybadger-api/notice.rb
119
118
  - lib/honeybadger-api/paginator.rb
@@ -126,10 +125,8 @@ files:
126
125
  - lib/honeybadger-api/version.rb
127
126
  - spec/comment_spec.rb
128
127
  - spec/deploy_spec.rb
129
- - spec/environment_spec.rb
130
128
  - spec/factories/comment_factory.rb
131
129
  - spec/factories/deploy_factory.rb
132
- - spec/factories/environment_factory.rb
133
130
  - spec/factories/fault_factory.rb
134
131
  - spec/factories/notice_factory.rb
135
132
  - spec/factories/project_factory.rb
@@ -174,10 +171,8 @@ summary: Honeybadger Read API
174
171
  test_files:
175
172
  - spec/comment_spec.rb
176
173
  - spec/deploy_spec.rb
177
- - spec/environment_spec.rb
178
174
  - spec/factories/comment_factory.rb
179
175
  - spec/factories/deploy_factory.rb
180
- - spec/factories/environment_factory.rb
181
176
  - spec/factories/fault_factory.rb
182
177
  - spec/factories/notice_factory.rb
183
178
  - spec/factories/project_factory.rb
@@ -195,3 +190,4 @@ test_files:
195
190
  - spec/team_spec.rb
196
191
  - spec/user_spec.rb
197
192
  - spec/version_spec.rb
193
+ has_rdoc:
@@ -1,27 +0,0 @@
1
- module Honeybadger
2
- module Api
3
- class Environment
4
-
5
- attr_reader :id, :name, :project_id, :updated_at, :created_at
6
-
7
- # Public: Build a new instance of Environment
8
- #
9
- # opts - A Hash of attributes to initialize a Environment
10
- #
11
- # Returns a new Environment
12
- def initialize(opts)
13
- @id = opts[:id]
14
- @name = opts[:name]
15
- @notifications = opts[:notifications]
16
- @project_id = opts[:project_id]
17
- @updated_at = opts[:updated_at].nil? ? nil : DateTime.parse(opts[:updated_at])
18
- @created_at = opts[:created_at].nil? ? nil : DateTime.parse(opts[:created_at])
19
- end
20
-
21
- # Public: Whether notification are raised.
22
- def notifications?
23
- @notifications
24
- end
25
- end
26
- end
27
- end
@@ -1,33 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Honeybadger::Api::Environment do
4
- describe "initializing a new environment" do
5
- before :all do
6
- @environment = FactoryGirl.build :environment
7
- end
8
-
9
- it "should have an identifier" do
10
- expect(@environment.id).to eql(1)
11
- end
12
-
13
- it "should have a name" do
14
- expect(@environment.name).to eql("production")
15
- end
16
-
17
- it "should have a project identifier" do
18
- expect(@environment.project_id).to eql(2)
19
- end
20
-
21
- it "should raise notifications" do
22
- expect(@environment.notifications?).to be_truthy
23
- end
24
-
25
- it "should have the date the environment was updated" do
26
- expect(@environment.updated_at).to eql(DateTime.parse("2012-01-01T00:02:00Z"))
27
- end
28
-
29
- it "should have the date the environment was created" do
30
- expect(@environment.created_at).to eql(DateTime.parse("2012-01-01T00:01:00Z"))
31
- end
32
- end
33
- end
@@ -1,14 +0,0 @@
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