-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e677588
commit e54ec78
Showing
6 changed files
with
160 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,4 @@ end | |
gem 'hobo_fields' | ||
gem 'delayed_job_active_record' | ||
gem 'daemons' | ||
|
||
gem 'jira-ruby', '0.1.17', require: 'jira' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'jira' | ||
|
||
module JIRA | ||
class ClientWrapper < JIRA::Client | ||
def initialize(settings) | ||
client_options = { | ||
signature_method: 'RSA-SHA1', | ||
consumer_key: settings.consumer_key, | ||
site: settings.site, | ||
context_path: "", | ||
use_ssl: true | ||
} | ||
|
||
super(client_options) | ||
|
||
@request_client.set_access_token(settings.access_token, settings.access_key) | ||
|
||
consumer.http.set_debug_output($stderr) | ||
end | ||
|
||
def find_issue(key) | ||
self.Issue.find(key) | ||
rescue JIRA::HTTPError => ex | ||
puts ex.response | ||
puts '****' | ||
if ex.message == 'Not Found' | ||
nil | ||
else | ||
raise | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
|
||
describe 'JIRA::ClientWrapper' do | ||
|
||
it 'can be created' do | ||
settings = { | ||
site: 'https://www.jira.com', | ||
consumer_key: 'fake_key', | ||
access_token: 'fake_access_token', | ||
access_key: 'fake_access_key' | ||
} | ||
client = JIRA::ClientWrapper.new(OpenStruct.new(settings)) | ||
expect(client).to_not be_nil | ||
end | ||
|
||
context 'issues' do | ||
|
||
before do | ||
settings = { | ||
site: 'https://www.jira.com', | ||
consumer_key: 'fake_key', | ||
access_token: 'fake_access_token', | ||
access_key: 'fake_access_key' | ||
} | ||
@client = JIRA::ClientWrapper.new(OpenStruct.new(settings)) | ||
end | ||
|
||
it 'can find an issue' do | ||
stub_request(:get, /.*/).to_return(status: 200, body: 'tbd') | ||
|
||
expect(@client.find_issue('ISSUE-1234')).to_not be_nil | ||
end | ||
|
||
it 'returns nil if the issue does not exist' do | ||
stub_request(:get, /.*/).to_return(status: 404, body: 'Not Found') | ||
|
||
expect(@client.find_issue('ISSUE-1234')).to be_nil | ||
end | ||
end | ||
|
||
end |