jira_client 1.0.2 → 1.0.3

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.
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "simplecov"
24
+ spec.add_development_dependency "webmock"
23
25
 
24
26
  spec.add_runtime_dependency "rest-client"
25
27
  spec.add_runtime_dependency "json"
@@ -81,10 +81,10 @@ module JiraClient
81
81
  end
82
82
 
83
83
  # Returns a RestClient resource
84
- def resource
84
+ def resource(url=nil)
85
85
  raise JiraClient::Error::ConfigurationError, "No configuration found. Please run JiraClient.configure" if JiraClient.configuration.nil?
86
86
  @resource ||= begin
87
- url = JiraClient.configuration.full_url
87
+ url = url || JiraClient.configuration.full_url
88
88
  options = {
89
89
  :headers => {:content_type => :json, :accept => :json}
90
90
  }
@@ -13,6 +13,12 @@ module JiraClient
13
13
  object_from_response(JiraClient::User, :get, "/user", :username => username)
14
14
  end
15
15
 
16
+ def current_user
17
+ request = resource(JiraClient.configuration.base_url)
18
+ response = request["/rest/gadget/1.0/currentUser"].get
19
+ JiraClient::User.from_response snake_case!(JSON.parse(response, :symbolize_names => true))
20
+ end
21
+
16
22
  end
17
23
  end
18
- end
24
+ end
@@ -22,4 +22,4 @@ module JiraClient
22
22
 
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -1,6 +1,6 @@
1
1
  module JiraClient
2
2
  class User < JiraClient::Base
3
- attr_reader :display_name, :email_address, :name
3
+ attr_reader :display_name, :email_address, :name, :username
4
4
 
5
5
  def active?
6
6
  @attrs[:active] == true
@@ -11,4 +11,4 @@ module JiraClient
11
11
  end
12
12
 
13
13
  end
14
- end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module JiraClient
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -0,0 +1,5 @@
1
+ {
2
+ "username": "username",
3
+ "fullName": "Full Name",
4
+ "email": "full.username@example.com"
5
+ }
@@ -53,4 +53,24 @@ describe JiraClient::API::Users do
53
53
  end
54
54
  end
55
55
 
56
- end
56
+ describe "#current_user" do
57
+
58
+ before do
59
+ stub_request(:get, JiraClient.configuration.base_url + "/rest/gadget/1.0/currentUser").to_return(:status => 200, :body => fixture("user.json"))
60
+ @user = JiraClient.current_user
61
+ end
62
+
63
+ it "requests the correct resource" do
64
+ expect(a_request(:get, JiraClient.configuration.base_url + "/rest/gadget/1.0/currentUser")).to have_been_made
65
+ end
66
+
67
+ it "returns a user object" do
68
+ @user.should be_a_kind_of JiraClient::User
69
+ end
70
+
71
+ it "has the correct username" do
72
+ @user.username.should == "username"
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,11 @@
1
+ describe JiraClient::Comment do
2
+
3
+ describe "#to_s" do
4
+ let(:comment) { JiraClient::Comment.from_response({:body => "Comment"})}
5
+
6
+ it "prints the comment body" do
7
+ comment.to_s.should == "Comment"
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,10 @@
1
+ describe JiraClient::Issue do
2
+ describe "#to_s" do
3
+ let(:issue) { JiraClient::Issue.from_response({:key => "key", :summary => "summary"})}
4
+
5
+ it "prints the issue key and summary" do
6
+ issue.to_s.should include "key"
7
+ issue.to_s.should include "summary"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ describe JiraClient::Project do
2
+ describe "#to_s" do
3
+ let(:project) { JiraClient::Project.from_response({:name => "Project"}) }
4
+
5
+ it "prints the project name" do
6
+ project.to_s.should == "Project"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ describe JiraClient::ServerInfo do
2
+
3
+ describe "#to_s" do
4
+ let(:server_info) { JiraClient::ServerInfo.from_response({:base_url => "url", :version => "version"})}
5
+
6
+ it "prints the base url and version" do
7
+ server_info.to_s.should include "url"
8
+ server_info.to_s.should include "version"
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,9 @@
1
+ describe JiraClient::Status do
2
+ describe "#to_s" do
3
+ let(:status) { JiraClient::Status.from_response({ :name => "Status" })}
4
+
5
+ it "prints the status' name" do
6
+ status.to_s.should == "Status"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ describe JiraClient::User do
2
+ describe "#to_s" do
3
+ let(:user) { JiraClient::User.from_response({:display_name => "Name"})}
4
+
5
+ it "prints the user's display name" do
6
+ user.to_s.should == "Name"
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-16 00:00:00.000000000 Z
12
+ date: 2013-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -43,6 +43,38 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: simplecov
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
46
78
  - !ruby/object:Gem::Dependency
47
79
  name: rest-client
48
80
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +188,7 @@ files:
156
188
  - spec/fixtures/server_info.json
157
189
  - spec/fixtures/status.json
158
190
  - spec/fixtures/statuses.json
191
+ - spec/fixtures/user.json
159
192
  - spec/fixtures/user_doesnt_exist.json
160
193
  - spec/fixtures/users.json
161
194
  - spec/fixtures/worklog.json
@@ -166,7 +199,13 @@ files:
166
199
  - spec/jira_client/api/statuses_spec.rb
167
200
  - spec/jira_client/api/users_spec.rb
168
201
  - spec/jira_client/api/worklogs_spec.rb
202
+ - spec/jira_client/comment_spec.rb
169
203
  - spec/jira_client/configuration_spec.rb
204
+ - spec/jira_client/issue_spec.rb
205
+ - spec/jira_client/project_spec.rb
206
+ - spec/jira_client/server_info_spec.rb
207
+ - spec/jira_client/status_spec.rb
208
+ - spec/jira_client/user_spec.rb
170
209
  - spec/jira_client_spec.rb
171
210
  - spec/spec_helper.rb
172
211
  homepage: https://github.com/mrwillihog/jira_client
@@ -219,6 +258,7 @@ test_files:
219
258
  - spec/fixtures/server_info.json
220
259
  - spec/fixtures/status.json
221
260
  - spec/fixtures/statuses.json
261
+ - spec/fixtures/user.json
222
262
  - spec/fixtures/user_doesnt_exist.json
223
263
  - spec/fixtures/users.json
224
264
  - spec/fixtures/worklog.json
@@ -229,7 +269,13 @@ test_files:
229
269
  - spec/jira_client/api/statuses_spec.rb
230
270
  - spec/jira_client/api/users_spec.rb
231
271
  - spec/jira_client/api/worklogs_spec.rb
272
+ - spec/jira_client/comment_spec.rb
232
273
  - spec/jira_client/configuration_spec.rb
274
+ - spec/jira_client/issue_spec.rb
275
+ - spec/jira_client/project_spec.rb
276
+ - spec/jira_client/server_info_spec.rb
277
+ - spec/jira_client/status_spec.rb
278
+ - spec/jira_client/user_spec.rb
233
279
  - spec/jira_client_spec.rb
234
280
  - spec/spec_helper.rb
235
281
  has_rdoc: