party_foul 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc917c71e501ebad9f395bc517fe1f617a2f9a6f
4
- data.tar.gz: 8426ffe718e0efdb32632ecff589b9a42d6907b4
3
+ metadata.gz: 8f80dcba58cf47603afe74982f963afc9e5bc188
4
+ data.tar.gz: b44e5e15e8288f829b85835e3c33ea5ca27a6f03
5
5
  SHA512:
6
- metadata.gz: 544e52e45551cf2941b748dcdbd1ad0b3c9adda8a8168344ebcd5541433954ffd32194bc1d4ce3a1b241b3abfa3305dfce25719509adf93fb3d6c5ee9f4964ea
7
- data.tar.gz: bdbc637243df87af0006679025ecab3a55cde18bdb91842b11785c7a2fde29f58ff0a5ff81f98cb1207be6474dac8c628ae89eec7b5e11661117ef33a0204bcd
6
+ metadata.gz: 28bd2e96700f5e2932b85671579830ad9ed28f9fd6c04ab62f16a528ed46ce044a8b485dd8c39c65bfa5c2ffb9140439f6ea7e1d08f95efae4a9ba05bc5e6b09
7
+ data.tar.gz: 5f6527076d22d9c696d7a6c44e0e887bdf40493d9fe5b85fb8b4a62addf63aa097938362dd55f721d22e69837907070a83645155f4d4d9f422eea0d95296bc7a
data/lib/party_foul.rb CHANGED
@@ -80,7 +80,7 @@ module PartyFoul
80
80
  # @param [Block]
81
81
  def self.configure(&block)
82
82
  yield self
83
- self.github ||= Octokit.new oauth_token: oauth_token, api_endpoint: api_endpoint
83
+ self.github ||= Octokit::Client.new access_token: oauth_token, api_endpoint: api_endpoint
84
84
  end
85
85
  end
86
86
 
@@ -36,37 +36,33 @@ class PartyFoul::ExceptionHandler
36
36
 
37
37
  # Hits the GitHub API to find the matching issue using the fingerprint.
38
38
  def find_issue
39
- unless issue = PartyFoul.github.search_issues(PartyFoul.repo_path, fingerprint, 'open').first
40
- issue = PartyFoul.github.search_issues(PartyFoul.repo_path, fingerprint, 'closed').first
41
- end
42
-
43
- issue
39
+ find_first_issue('open') || find_first_issue('closed')
44
40
  end
45
41
 
46
42
  # Will create a new issue and a comment with the proper details. All issues are labeled as 'bug'.
47
43
  def create_issue
48
44
  self.sha = PartyFoul.github.references(PartyFoul.repo_path, "heads/#{PartyFoul.branch}").object.sha
49
45
  issue = PartyFoul.github.create_issue(PartyFoul.repo_path, rendered_issue.title, rendered_issue.body, labels: ['bug'] + rendered_issue.labels)
50
- PartyFoul.github.add_comment(PartyFoul.repo_path, issue['number'], rendered_issue.comment)
46
+ PartyFoul.github.add_comment(PartyFoul.repo_path, issue[:number], rendered_issue.comment)
51
47
  end
52
48
 
53
49
  # Updates the given issue. If the issue is labeled as 'wontfix' nothing is done. If the issue is closed the issue is reopened and labeled as 'regression'.
54
50
  #
55
- # @param [Hashie::Mash]
51
+ # @param [Sawyer::Resource]
56
52
  def update_issue(issue)
57
- unless issue.key?('labels') && issue['labels'].include?('wontfix')
58
- body = rendered_issue.update_body(issue['body'])
53
+ unless issue.key?(:labels) && issue[:labels].include?('wontfix')
54
+ body = rendered_issue.update_body(issue[:body])
59
55
  params = {state: 'open'}
60
56
 
61
- if issue['state'] == 'closed'
62
- params[:labels] = (['bug', 'regression'] + issue['labels']).uniq
57
+ if issue[:state] == 'closed'
58
+ params[:labels] = (['bug', 'regression'] + issue[:labels]).uniq
63
59
  end
64
60
 
65
61
  self.sha = PartyFoul.github.references(PartyFoul.repo_path, "heads/#{PartyFoul.branch}").object.sha
66
- PartyFoul.github.update_issue(PartyFoul.repo_path, issue['number'], issue.title, body, params)
62
+ PartyFoul.github.update_issue(PartyFoul.repo_path, issue[:number], issue.title, body, params)
67
63
 
68
- unless comment_limit_met?(issue['body'])
69
- PartyFoul.github.add_comment(PartyFoul.repo_path, issue['number'], rendered_issue.comment)
64
+ unless comment_limit_met?(issue[:body])
65
+ PartyFoul.github.add_comment(PartyFoul.repo_path, issue[:number], rendered_issue.comment)
70
66
  end
71
67
  end
72
68
  end
@@ -93,4 +89,8 @@ class PartyFoul::ExceptionHandler
93
89
  def comment_limit_met?(body)
94
90
  !!PartyFoul.comment_limit && PartyFoul.comment_limit <= occurrence_count(body)
95
91
  end
92
+
93
+ def find_first_issue(state)
94
+ PartyFoul.github.legacy_search_issues(PartyFoul.repo_path, fingerprint, state).first
95
+ end
96
96
  end
@@ -16,7 +16,7 @@ class PartyFoul::IssueRenderers::Base
16
16
  #
17
17
  # @return [String]
18
18
  def title
19
- raw_title.gsub(/#<(\w+):0x\w+?>/, "#<\\1:0xXXXXXX>")
19
+ raw_title.gsub(/0x(\w+)/, "0xXXXXXX")
20
20
  end
21
21
 
22
22
  # Renders the issue body
@@ -1,4 +1,9 @@
1
1
  class PartyFoul::IssueRenderers::Rack < PartyFoul::IssueRenderers::Base
2
+
3
+ def request
4
+ @request ||= ::Rack::Request.new(env)
5
+ end
6
+
2
7
  def comment_options
3
8
  super.merge(URL: url, Params: params, Session: session, 'IP Address' => ip_address, 'HTTP Headers' => http_headers)
4
9
  end
@@ -7,25 +12,25 @@ class PartyFoul::IssueRenderers::Rack < PartyFoul::IssueRenderers::Base
7
12
  #
8
13
  # @return [Hash]
9
14
  def params
10
- env['QUERY_STRING']
15
+ request.params
11
16
  end
12
17
 
13
18
  # IP address of the client who triggered the exception
14
19
  #
15
20
  # @return [String]
16
21
  def ip_address
17
- env['REMOTE_ADDR']
22
+ request.ip
18
23
  end
19
24
 
20
25
  def url
21
- "[#{env['REQUEST_METHOD']}] #{env['REQUEST_URI']}"
26
+ "[#{request.request_method}] #{env['REQUEST_URI']}"
22
27
  end
23
28
 
24
29
  # The session hash for the client at the time of the exception
25
30
  #
26
31
  # @return [Hash]
27
32
  def session
28
- env['rack.session']
33
+ request.session
29
34
  end
30
35
 
31
36
  # HTTP Headers hash from the request. Headers can be filtered out by
@@ -33,7 +38,12 @@ class PartyFoul::IssueRenderers::Rack < PartyFoul::IssueRenderers::Base
33
38
  #
34
39
  # @return [Hash]
35
40
  def http_headers
36
- { Version: env['HTTP_VERSION'], 'User Agent' => env['HTTP_USER_AGENT'], 'Accept Encoding' => env['HTTP_ACCEPT_ENCODING'], Accept: env['HTTP_ACCEPT'] }
41
+ {
42
+ Version: env['HTTP_VERSION'],
43
+ 'User Agent' => request.user_agent,
44
+ 'Accept Encoding' => env['HTTP_ACCEPT_ENCODING'],
45
+ Accept: env['HTTP_ACCEPT'],
46
+ }
37
47
  end
38
48
 
39
49
  private
@@ -1,3 +1,3 @@
1
1
  module PartyFoul
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -5,11 +5,12 @@ require 'generators/party_foul/install_generator'
5
5
  class PartyFoul::GeneratorTest < Rails::Generators::TestCase
6
6
  destination File.expand_path('../tmp', __FILE__)
7
7
  tests PartyFoul::InstallGenerator
8
+
8
9
  test 'it copies the initializer' do
9
10
  owner = 'test_owner'
10
11
  repo = 'test_repo'
11
12
  octokit = mock('Octokit')
12
- octokit.expects(:create_authorization).with(scopes: ['repo'], note: 'PartyFoul test_owner/test_repo', note_url: 'http://example.com/test_owner/test_repo').returns(Hashie::Mash.new(token: 'test_token'))
13
+ octokit.expects(:create_authorization).with(scopes: ['repo'], note: 'PartyFoul test_owner/test_repo', note_url: 'http://example.com/test_owner/test_repo').returns(sawyer_resource({token: 'test_token'}))
13
14
  Octokit.stubs(:new).with(:login => 'test_login', :password => 'test_password', :api_endpoint => 'http://api.example.com').returns(octokit)
14
15
  $stdin.stubs(:gets).returns('test_login').then.returns('test_password').then.returns(owner).then.returns(repo).then.returns('http://api.example.com').then.returns('http://example.com').then.returns('')
15
16
  run_generator
@@ -20,8 +20,8 @@ describe 'Party Foul Confg' do
20
20
 
21
21
  PartyFoul.blacklisted_exceptions.must_equal ['StandardError']
22
22
  PartyFoul.github.must_be_instance_of Octokit::Client
23
- PartyFoul.github.oauth_token.must_equal 'test_token'
24
- PartyFoul.github.api_endpoint.must_equal 'http://api.example.com'
23
+ PartyFoul.github.access_token.must_equal 'test_token'
24
+ PartyFoul.github.api_endpoint.must_equal 'http://api.example.com/'
25
25
  PartyFoul.owner.must_equal 'test_owner'
26
26
  PartyFoul.repo.must_equal 'test_repo'
27
27
  PartyFoul.repo_path.must_equal 'test_owner/test_repo'
@@ -17,10 +17,10 @@ describe 'Party Foul Exception Handler' do
17
17
  it 'will open a new error on GitHub' do
18
18
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
19
19
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
20
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
21
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([])
22
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug']).returns(Hashie::Mash.new('number' => 1))
23
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(Hashie::Mash.new(object: Hashie::Mash.new(sha: 'abcdefg1234567890')))
20
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
21
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([])
22
+ PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', labels: ['bug']).returns( {number: 1} )
23
+ PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns( sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
24
24
  PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
25
25
  PartyFoul::ExceptionHandler.new(nil, {}).run
26
26
  end
@@ -37,10 +37,10 @@ describe 'Party Foul Exception Handler' do
37
37
  it 'will open a new error on GitHub with the additional labels' do
38
38
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
39
39
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
40
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
41
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([])
42
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'custom', 'label']).returns(Hashie::Mash.new('number' => 1))
43
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(Hashie::Mash.new(object: Hashie::Mash.new(sha: 'abcdefg1234567890')))
40
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
41
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([])
42
+ PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'custom', 'label']).returns( { number: 1 } )
43
+ PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns( sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
44
44
  PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
45
45
  PartyFoul::ExceptionHandler.new(nil, {}).run
46
46
  end
@@ -59,9 +59,9 @@ describe 'Party Foul Exception Handler' do
59
59
  end
60
60
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
61
61
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:comment).returns('Test Comment')
62
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
63
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([])
64
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(Hashie::Mash.new(object: Hashie::Mash.new(sha: 'abcdefg1234567890')))
62
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
63
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([])
64
+ PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns( sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
65
65
  PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
66
66
  end
67
67
  after do
@@ -69,17 +69,17 @@ describe 'Party Foul Exception Handler' do
69
69
  end
70
70
 
71
71
  it 'will open a new error on GitHub with the default labels if no additional labels are returned from the proc' do
72
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug']).returns(Hashie::Mash.new('number' => 1))
72
+ PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug']).returns({ number: 1 })
73
73
  PartyFoul::ExceptionHandler.new(stub(:message => ''), {}).run
74
74
  end
75
75
 
76
76
  it 'will open a new error on GitHub with the additional labels based on the exception message' do
77
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'database_error']).returns(Hashie::Mash.new('number' => 1))
77
+ PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'database_error']).returns({ number: 1 })
78
78
  PartyFoul::ExceptionHandler.new(stub(:message => 'Database'), {}).run
79
79
  end
80
80
 
81
81
  it 'will open a new error on GitHub with the additional labels based on the env' do
82
- PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'beta']).returns(Hashie::Mash.new('number' => 1))
82
+ PartyFoul.github.expects(:create_issue).with('test_owner/test_repo', 'Test Title', 'Test Body', :labels => ['bug', 'beta']).returns({ number: 1 })
83
83
  PartyFoul::ExceptionHandler.new(stub(:message => ''), {:http_host => 'beta.example.com'}).run
84
84
  end
85
85
  end
@@ -93,9 +93,11 @@ describe 'Party Foul Exception Handler' do
93
93
 
94
94
  context 'and open' do
95
95
  before do
96
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([Hashie::Mash.new(title: 'Test Title', body: 'Test Body', state: 'open', number: 1)])
96
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns(
97
+ [sawyer_resource({title: 'Test Title', body: 'Test Body', state: 'open', number: 1})] )
97
98
  PartyFoul.github.expects(:update_issue).with('test_owner/test_repo', 1, 'Test Title', 'New Body', state: 'open')
98
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(Hashie::Mash.new(object: Hashie::Mash.new(sha: 'abcdefg1234567890')))
99
+ PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(
100
+ sawyer_resource({object: {sha: 'abcdefg1234567890'}}) )
99
101
  end
100
102
 
101
103
  it 'will update the issue' do
@@ -115,11 +117,12 @@ describe 'Party Foul Exception Handler' do
115
117
 
116
118
  context 'and closed' do
117
119
  it 'will update the count on the body and re-open the issue' do
118
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
119
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([Hashie::Mash.new(title: 'Test Title', body: 'Test Body', state: 'closed', number: 1, labels: ['staging'])])
120
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
121
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns(
122
+ [sawyer_resource({title: 'Test Title', body: 'Test Body', state: 'closed', number: 1, labels: ['staging']})] )
120
123
  PartyFoul.github.expects(:update_issue).with('test_owner/test_repo', 1, 'Test Title', 'New Body', state: 'open', labels: ['bug', 'regression', 'staging'])
121
124
  PartyFoul.github.expects(:add_comment).with('test_owner/test_repo', 1, 'Test Comment')
122
- PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(Hashie::Mash.new(object: Hashie::Mash.new(sha: 'abcdefg1234567890')))
125
+ PartyFoul.github.expects(:references).with('test_owner/test_repo', 'heads/deploy').returns(sawyer_resource({object: {sha: 'abcdefg1234567890'}}))
123
126
  PartyFoul::ExceptionHandler.new(nil, {}).run
124
127
  end
125
128
  end
@@ -128,8 +131,9 @@ describe 'Party Foul Exception Handler' do
128
131
  context 'when issue is marked as "wontfix"' do
129
132
  it 'does nothing' do
130
133
  PartyFoul::IssueRenderers::Rails.any_instance.stubs(:body).returns('Test Body')
131
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
132
- PartyFoul.github.expects(:search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns([Hashie::Mash.new(title: 'Test Title', body: 'Test Body', state: 'closed', number: 1, labels: ['wontfix'])])
134
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'open').returns([])
135
+ PartyFoul.github.expects(:legacy_search_issues).with('test_owner/test_repo', 'test_fingerprint', 'closed').returns(
136
+ [sawyer_resource({title: 'Test Title', body: 'Test Body', state: 'closed', number: 1, labels: ['wontfix']})] )
133
137
  PartyFoul.github.expects(:create_issue).never
134
138
  PartyFoul.github.expects(:update_issue).never
135
139
  PartyFoul.github.expects(:add_comment).never
@@ -111,6 +111,12 @@ Fingerprint: `abcdefg1234567890`
111
111
  rendered_issue.stubs(:raw_title).returns('Error for #<ClassName:0xabcdefg1234567>')
112
112
  rendered_issue.title.must_equal 'Error for #<ClassName:0xXXXXXX>'
113
113
  end
114
+
115
+ it 'masks the extended object ids in the raw_title' do
116
+ rendered_issue = PartyFoul::IssueRenderers::Base.new(nil, nil)
117
+ rendered_issue.stubs(:raw_title).returns('Error for #<#<ClassName:0x007fbddbdcd340>:0x007fbddf6be0a0>')
118
+ rendered_issue.title.must_equal 'Error for #<#<ClassName:0xXXXXXX>:0xXXXXXX>'
119
+ end
114
120
  end
115
121
 
116
122
  describe '#stack_trace' do
@@ -3,22 +3,76 @@ require 'test_helper'
3
3
  describe 'Rack Issue Renderer' do
4
4
  describe '#params' do
5
5
  before do
6
- @rendered_issue = PartyFoul::IssueRenderers::Rack.new(nil, {'QUERY_STRING' => { 'status' => 'ok' } })
6
+ @issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, ::Rack::MockRequest.env_for("/?status=ok"))
7
7
  end
8
8
 
9
- it 'returns ok' do
10
- @rendered_issue.params['status'].must_equal 'ok'
9
+ it 'returns the value of the query param' do
10
+ @issue_renderer.params['status'].must_equal 'ok'
11
11
  end
12
12
  end
13
-
13
+
14
14
  describe '#raw_title' do
15
15
  before do
16
16
  @exception = Exception.new('message')
17
17
  end
18
18
 
19
19
  it 'constructs the title with the class and instance method' do
20
- @rendered_issue = PartyFoul::IssueRenderers::Rack.new(@exception, {})
21
- @rendered_issue.send(:raw_title).must_equal %{(Exception) "message"}
20
+ @issue_renderer = PartyFoul::IssueRenderers::Rack.new(@exception, {})
21
+ @issue_renderer.send(:raw_title).must_equal %{(Exception) "message"}
22
+ end
23
+ end
24
+
25
+ describe '#request' do
26
+ it 'builds a rack request' do
27
+ issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, {})
28
+ assert issue_renderer.request.is_a?(::Rack::Request)
29
+ end
30
+ end
31
+
32
+ describe '#ip_address' do
33
+ # we are delegating to rack, see
34
+ # https://github.com/rack/rack/blob/master/test/spec_request.rb
35
+
36
+ it 'returns the IP address when REMOTE_ADDR is set' do
37
+ issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'REMOTE_ADDR' => '1.2.3.4' })
38
+ issue_renderer.ip_address.must_equal '1.2.3.4'
22
39
  end
40
+
41
+ it 'return the IP address when HTTP_X_FORWARDED_FOR is set' do
42
+ issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'HTTP_X_FORWARDED_FOR' => '10.0.0.1, 10.0.0.1, 3.4.5.6' })
43
+ issue_renderer.ip_address.must_equal '3.4.5.6'
44
+ end
45
+ end
46
+
47
+ describe '#url' do
48
+ it 'returns the method and uri' do
49
+ issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/something' })
50
+ issue_renderer.url.must_equal '[GET] /something'
51
+ end
52
+ end
53
+
54
+ describe '#session' do
55
+ it 'returns the session' do
56
+ issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil, { 'rack.session' => 'abc:123' })
57
+ issue_renderer.session.must_equal 'abc:123'
58
+ end
59
+ end
60
+
61
+ describe '#http_headers' do
62
+ it 'returns http headers' do
63
+ issue_renderer = PartyFoul::IssueRenderers::Rack.new(nil,
64
+ {
65
+ 'HTTP_VERSION' => 'version',
66
+ 'HTTP_USER_AGENT' => 'user agent',
67
+ 'HTTP_ACCEPT_ENCODING' => 'accept encoding',
68
+ 'HTTP_ACCEPT' => 'accept'
69
+ })
70
+
71
+ issue_renderer.http_headers[:Version].must_equal 'version'
72
+ issue_renderer.http_headers['User Agent'].must_equal 'user agent'
73
+ issue_renderer.http_headers['Accept Encoding'].must_equal 'accept encoding'
74
+ issue_renderer.http_headers[:Accept].must_equal 'accept'
75
+ end
23
76
  end
77
+
24
78
  end
data/test/test_helper.rb CHANGED
@@ -12,7 +12,7 @@ end
12
12
  require 'rack/test'
13
13
  require 'mocha/setup'
14
14
  require 'party_foul'
15
- require 'hashie/mash'
15
+
16
16
 
17
17
  class MiniTest::Spec
18
18
  class << self
@@ -29,3 +29,8 @@ def clean_up_party
29
29
  PartyFoul.send("#{attr}=", nil)
30
30
  end
31
31
  end
32
+
33
+ def sawyer_resource(attrs)
34
+ agent = Sawyer::Agent.new(PartyFoul.api_endpoint)
35
+ Sawyer::Resource.new(agent, attrs)
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: party_foul
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cardarella
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - <
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 2.0.0
20
+ version: 2.3.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - <
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: 2.0.0
27
+ version: 2.3.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: actionpack
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.0.3
199
+ rubygems_version: 2.1.5
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Auto-submit Rails exceptions as new issues on GitHub