jiralicious 0.3.0 → 0.4.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.
Files changed (43) hide show
  1. data/README.md +3 -0
  2. data/jiralicious.gemspec +0 -2
  3. data/lib/jiralicious.rb +4 -0
  4. data/lib/jiralicious/avatar.rb +101 -0
  5. data/lib/jiralicious/base.rb +53 -15
  6. data/lib/jiralicious/configuration.rb +30 -4
  7. data/lib/jiralicious/custom_field_option.rb +7 -3
  8. data/lib/jiralicious/errors.rb +10 -0
  9. data/lib/jiralicious/field.rb +23 -12
  10. data/lib/jiralicious/issue.rb +69 -11
  11. data/lib/jiralicious/issue/comment.rb +54 -12
  12. data/lib/jiralicious/issue/fields.rb +44 -3
  13. data/lib/jiralicious/issue/transitions.rb +42 -11
  14. data/lib/jiralicious/issue/watchers.rb +19 -2
  15. data/lib/jiralicious/parsers/field_parser.rb +12 -0
  16. data/lib/jiralicious/project.rb +7 -1
  17. data/lib/jiralicious/project/avatar.rb +126 -0
  18. data/lib/jiralicious/search.rb +9 -0
  19. data/lib/jiralicious/search_result.rb +15 -7
  20. data/lib/jiralicious/session.rb +5 -0
  21. data/lib/jiralicious/user.rb +154 -0
  22. data/lib/jiralicious/user/avatar.rb +130 -0
  23. data/lib/jiralicious/version.rb +1 -1
  24. data/spec/avatar_spec.rb +50 -0
  25. data/spec/basic_session_spec.rb +4 -0
  26. data/spec/comment_spec.rb +2 -2
  27. data/spec/fixtures/avatar.json +7 -0
  28. data/spec/fixtures/avatar_custom.json +16 -0
  29. data/spec/fixtures/avatar_list.json +16 -0
  30. data/spec/fixtures/avatar_temp.json +7 -0
  31. data/spec/fixtures/avatar_test.png +0 -0
  32. data/spec/fixtures/user.json +27 -0
  33. data/spec/fixtures/user_array.json +26 -0
  34. data/spec/fixtures/user_picker.json +18 -0
  35. data/spec/issue_spec.rb +10 -9
  36. data/spec/project_avatar_spec.rb +66 -0
  37. data/spec/project_spec.rb +2 -2
  38. data/spec/search_spec.rb +2 -1
  39. data/spec/support/http.rb +24 -0
  40. data/spec/user_avatar_spec.rb +66 -0
  41. data/spec/user_spec.rb +79 -0
  42. data/spec/watchers_spec.rb +2 -2
  43. metadata +30 -18
@@ -7,8 +7,8 @@ describe Jiralicious, "search" do
7
7
  Jiralicious.configure do |config|
8
8
  config.username = "jstewart"
9
9
  config.password = "topsecret"
10
- config.uri = "http://localhost"
11
- config.auth_type = :cookie
10
+ config.uri = "http://jstewart:topsecret@localhost"
11
+ config.auth_type = :basic
12
12
  config.api_version = "latest"
13
13
  end
14
14
 
@@ -7,7 +7,8 @@ describe Jiralicious, "search" do
7
7
  Jiralicious.configure do |config|
8
8
  config.username = "jstewart"
9
9
  config.password = "topsecret"
10
- config.uri = "http://localhost"
10
+ config.uri = "http://jstewart:topsecret@localhost"
11
+ config.auth_type = :basic
11
12
  config.api_version = "latest"
12
13
  end
13
14
  end
@@ -84,4 +84,28 @@ module JsonResponse
84
84
  File.expand_path('jira.yml', File.dirname(__FILE__) + '/../fixtures')
85
85
  end
86
86
 
87
+ def user_json
88
+ File.expand_path('user.json', File.dirname(__FILE__) + '/../fixtures')
89
+ end
90
+
91
+ def user_array_json
92
+ File.expand_path('user_array.json', File.dirname(__FILE__) + '/../fixtures')
93
+ end
94
+
95
+ def user_picker_json
96
+ File.expand_path('user_picker.json', File.dirname(__FILE__) + '/../fixtures')
97
+ end
98
+
99
+ def avatar_list_json
100
+ File.expand_path('avatar_list.json', File.dirname(__FILE__) + '/../fixtures')
101
+ end
102
+
103
+ def avatar_custom_json
104
+ File.expand_path('avatar_custom.json', File.dirname(__FILE__) + '/../fixtures')
105
+ end
106
+
107
+ def avatar_temp_json
108
+ File.expand_path('avatar_temp.json', File.dirname(__FILE__) + '/../fixtures')
109
+ end
110
+
87
111
  end
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Jiralicious, "Project Avatar" do
5
+
6
+ before :each do
7
+ Jiralicious.configure do |config|
8
+ config.username = "jstewart"
9
+ config.password = "topsecret"
10
+ config.uri = "http://jstewart:topsecret@localhost"
11
+ config.auth_type = :basic
12
+ config.api_version = "latest"
13
+ end
14
+
15
+ FakeWeb.register_uri(:put,
16
+ "#{Jiralicious.rest_path}/user/avatar/",
17
+ :status => "204")
18
+ FakeWeb.register_uri(:post,
19
+ "#{Jiralicious.rest_path}/user/avatar/",
20
+ :status => "200")
21
+ FakeWeb.register_uri(:delete,
22
+ "#{Jiralicious.rest_path}/user/avatar/10100?username=fred",
23
+ :status => "200")
24
+ FakeWeb.register_uri(:get,
25
+ "#{Jiralicious.rest_path}/user/avatars?username=fred",
26
+ :status => "200",
27
+ :body => avatar_list_json)
28
+ FakeWeb.register_uri(:post,
29
+ "#{Jiralicious.rest_path}/user/avatar/temporary",
30
+ :status => "200",
31
+ :body => avatar_temp_json)
32
+ end
33
+
34
+ it "obtain user avatar list" do
35
+ avatar = Jiralicious::User::Avatar.avatars('fred')
36
+ avatar.should be_instance_of(Jiralicious::User::Avatar)
37
+ avatar.system.count.should == 2
38
+ avatar.system[0].id.should == '10100'
39
+ avatar.system[1].isSystemAvatar.should == true
40
+ end
41
+
42
+ it "sends new user avatar" do
43
+ file = "#{File.dirname(__FILE__)}/fixtures/avatar_test.png"
44
+ avatar = Jiralicious::User::Avatar.temporary('fred', {:filename => file, :size => 4035})
45
+ avatar.needsCropping.should == true
46
+ end
47
+
48
+ it "crops the current user avatar" do
49
+ response = Jiralicious::User::Avatar.post('fred', {:cropperWidth => 120,
50
+ :cropperOffsetX => 50,
51
+ :cropperOffsety => 50,
52
+ :needsCropping => false})
53
+ response.response.class.should == Net::HTTPOK
54
+ end
55
+
56
+ it "updates current user avatar" do
57
+ response = Jiralicious::User::Avatar.put('fred')
58
+ response.response.class.should == Net::HTTPNoContent
59
+ end
60
+
61
+ it "updates current user avatar" do
62
+ response = Jiralicious::User::Avatar.remove('fred', 10100)
63
+ response.response.class.should == Net::HTTPOK
64
+ end
65
+
66
+ end
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Jiralicious::User, "finding" do
5
+
6
+ before :each do
7
+ Jiralicious.configure do |config|
8
+ config.username = "jstewart"
9
+ config.password = "topsecret"
10
+ config.uri = "http://jstewart:topsecret@localhost"
11
+ config.auth_type = :basic
12
+ config.api_version = "latest"
13
+ end
14
+
15
+ FakeWeb.register_uri(:get,
16
+ "#{Jiralicious.rest_path}/user?username=test_user",
17
+ :status => "200",
18
+ :body => user_json)
19
+ FakeWeb.register_uri(:get,
20
+ "#{Jiralicious.rest_path}/user/search?username=test_user",
21
+ :status => "200",
22
+ :body => user_array_json)
23
+ FakeWeb.register_uri(:get,
24
+ "#{Jiralicious.rest_path}/user/assignable/multiProjectSearch?projectKeys=EX",
25
+ :status => "200",
26
+ :body => user_array_json)
27
+ FakeWeb.register_uri(:get,
28
+ "#{Jiralicious.rest_path}/user/assignable/search?project=EX",
29
+ :status => "200",
30
+ :body => user_array_json)
31
+ FakeWeb.register_uri(:get,
32
+ "#{Jiralicious.rest_path}/user/picker?query=user",
33
+ :status => "200",
34
+ :body => user_picker_json)
35
+ end
36
+
37
+ it "by username" do
38
+ Jiralicious::User.find("test_user").should be_instance_of(Jiralicious::User)
39
+ user = Jiralicious::User.find("test_user")
40
+ end
41
+
42
+ it "uses the user picker to find a list of current users based on the criteria" do
43
+ Jiralicious::User.picker("user").should be_instance_of(Jiralicious::User)
44
+ user = Jiralicious::User.picker("user")
45
+ user.total.should == user.users.length
46
+ user.users.each do |u|
47
+ u.html.should =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
48
+ end
49
+ end
50
+
51
+ it "uses the user search to find a list of matching users" do
52
+ Jiralicious::User.search("test_user").should be_instance_of(Jiralicious::User)
53
+ user = Jiralicious::User.search("test_user")
54
+ user.length.should == 2
55
+ end
56
+
57
+ it "all assignable users for specified project key using multiproject" do
58
+ Jiralicious::User.assignable_multiProjectSearch("EX").should be_instance_of(Jiralicious::User)
59
+ user = Jiralicious::User.assignable_multiProjectSearch("EX")
60
+ user.length.should == 2
61
+ user.each do |k, u|
62
+ u.emailAddress.should =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
63
+ u.active.should == false
64
+ end
65
+ end
66
+
67
+ it "all assignable users for specified project key" do
68
+ Jiralicious::User.assignable_search({:project => "EX"}).should be_instance_of(Jiralicious::User)
69
+ user = Jiralicious::User.assignable_search({:project => "EX"})
70
+ user.length.should == 2
71
+ user.each do |k, u|
72
+ u.emailAddress.should =~ /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
73
+ u.active.should == false
74
+ end
75
+ end
76
+ end
77
+
78
+ ###########################################################################################################
79
+
@@ -7,8 +7,8 @@ describe Jiralicious, "search" do
7
7
  Jiralicious.configure do |config|
8
8
  config.username = "jstewart"
9
9
  config.password = "topsecret"
10
- config.uri = "http://localhost"
11
- config.auth_type = :cookie
10
+ config.uri = "http://jstewart:topsecret@localhost"
11
+ config.auth_type = :basic
12
12
  config.api_version = "latest"
13
13
  end
14
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jiralicious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
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-07-17 00:00:00.000000000 Z
12
+ date: 2013-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: crack
@@ -103,22 +103,6 @@ dependencies:
103
103
  - - ~>
104
104
  - !ruby/object:Gem::Version
105
105
  version: '2.6'
106
- - !ruby/object:Gem::Dependency
107
- name: gemcutter
108
- requirement: !ruby/object:Gem::Requirement
109
- none: false
110
- requirements:
111
- - - ! '>='
112
- - !ruby/object:Gem::Version
113
- version: '0'
114
- type: :development
115
- prerelease: false
116
- version_requirements: !ruby/object:Gem::Requirement
117
- none: false
118
- requirements:
119
- - - ! '>='
120
- - !ruby/object:Gem::Version
121
- version: '0'
122
106
  - !ruby/object:Gem::Dependency
123
107
  name: rake
124
108
  requirement: !ruby/object:Gem::Requirement
@@ -170,6 +154,7 @@ files:
170
154
  - gemfiles/oldest.gemfile
171
155
  - jiralicious.gemspec
172
156
  - lib/jiralicious.rb
157
+ - lib/jiralicious/avatar.rb
173
158
  - lib/jiralicious/base.rb
174
159
  - lib/jiralicious/basic_session.rb
175
160
  - lib/jiralicious/configuration.rb
@@ -184,14 +169,23 @@ files:
184
169
  - lib/jiralicious/issue/watchers.rb
185
170
  - lib/jiralicious/parsers/field_parser.rb
186
171
  - lib/jiralicious/project.rb
172
+ - lib/jiralicious/project/avatar.rb
187
173
  - lib/jiralicious/search.rb
188
174
  - lib/jiralicious/search_result.rb
189
175
  - lib/jiralicious/session.rb
176
+ - lib/jiralicious/user.rb
177
+ - lib/jiralicious/user/avatar.rb
190
178
  - lib/jiralicious/version.rb
179
+ - spec/avatar_spec.rb
191
180
  - spec/basic_session_spec.rb
192
181
  - spec/comment_spec.rb
193
182
  - spec/configuration_spec.rb
194
183
  - spec/field_parser_spec.rb
184
+ - spec/fixtures/avatar.json
185
+ - spec/fixtures/avatar_custom.json
186
+ - spec/fixtures/avatar_list.json
187
+ - spec/fixtures/avatar_temp.json
188
+ - spec/fixtures/avatar_test.png
195
189
  - spec/fixtures/comment.json
196
190
  - spec/fixtures/comment_single.json
197
191
  - spec/fixtures/issue.json
@@ -207,15 +201,21 @@ files:
207
201
  - spec/fixtures/search.json
208
202
  - spec/fixtures/test.json
209
203
  - spec/fixtures/transitions.json
204
+ - spec/fixtures/user.json
205
+ - spec/fixtures/user_array.json
206
+ - spec/fixtures/user_picker.json
210
207
  - spec/fixtures/watchers.json
211
208
  - spec/issue_spec.rb
212
209
  - spec/jiralicious_spec.rb
210
+ - spec/project_avatar_spec.rb
213
211
  - spec/project_spec.rb
214
212
  - spec/search_result_spec.rb
215
213
  - spec/search_spec.rb
216
214
  - spec/spec_helper.rb
217
215
  - spec/support/configuration.rb
218
216
  - spec/support/http.rb
217
+ - spec/user_avatar_spec.rb
218
+ - spec/user_spec.rb
219
219
  - spec/watchers_spec.rb
220
220
  homepage: http://github.com/jstewart/jiralicious
221
221
  licenses:
@@ -243,10 +243,16 @@ signing_key:
243
243
  specification_version: 3
244
244
  summary: A Ruby library for interacting with JIRA's REST API
245
245
  test_files:
246
+ - spec/avatar_spec.rb
246
247
  - spec/basic_session_spec.rb
247
248
  - spec/comment_spec.rb
248
249
  - spec/configuration_spec.rb
249
250
  - spec/field_parser_spec.rb
251
+ - spec/fixtures/avatar.json
252
+ - spec/fixtures/avatar_custom.json
253
+ - spec/fixtures/avatar_list.json
254
+ - spec/fixtures/avatar_temp.json
255
+ - spec/fixtures/avatar_test.png
250
256
  - spec/fixtures/comment.json
251
257
  - spec/fixtures/comment_single.json
252
258
  - spec/fixtures/issue.json
@@ -262,13 +268,19 @@ test_files:
262
268
  - spec/fixtures/search.json
263
269
  - spec/fixtures/test.json
264
270
  - spec/fixtures/transitions.json
271
+ - spec/fixtures/user.json
272
+ - spec/fixtures/user_array.json
273
+ - spec/fixtures/user_picker.json
265
274
  - spec/fixtures/watchers.json
266
275
  - spec/issue_spec.rb
267
276
  - spec/jiralicious_spec.rb
277
+ - spec/project_avatar_spec.rb
268
278
  - spec/project_spec.rb
269
279
  - spec/search_result_spec.rb
270
280
  - spec/search_spec.rb
271
281
  - spec/spec_helper.rb
272
282
  - spec/support/configuration.rb
273
283
  - spec/support/http.rb
284
+ - spec/user_avatar_spec.rb
285
+ - spec/user_spec.rb
274
286
  - spec/watchers_spec.rb