jiralicious 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/README.md +32 -4
- data/jiralicious.gemspec +7 -5
- data/lib/jiralicious.rb +10 -3
- data/lib/jiralicious/base.rb +114 -0
- data/lib/jiralicious/configuration.rb +13 -2
- data/lib/jiralicious/cookie_session.rb +5 -5
- data/lib/jiralicious/custom_field_option.rb +27 -0
- data/lib/jiralicious/field.rb +39 -0
- data/lib/jiralicious/issue.rb +111 -26
- data/lib/jiralicious/issue/comment.rb +62 -0
- data/lib/jiralicious/issue/fields.rb +93 -0
- data/lib/jiralicious/issue/transitions.rb +92 -0
- data/lib/jiralicious/issue/watchers.rb +47 -0
- data/lib/jiralicious/parsers/field_parser.rb +2 -2
- data/lib/jiralicious/project.rb +44 -0
- data/lib/jiralicious/search.rb +4 -1
- data/lib/jiralicious/search_result.rb +4 -0
- data/lib/jiralicious/version.rb +1 -1
- data/spec/basic_session_spec.rb +4 -4
- data/spec/comment_spec.rb +64 -0
- data/spec/configuration_spec.rb +9 -0
- data/spec/fixtures/comment.json +30 -0
- data/spec/fixtures/comment_single.json +29 -0
- data/spec/fixtures/issue.json +89 -93
- data/spec/fixtures/issue_2.json +30 -0
- data/spec/fixtures/issue_create.json +5 -0
- data/spec/fixtures/issue_createmeta.json +34 -0
- data/spec/fixtures/issue_editmeta.json +22 -0
- data/spec/fixtures/issue_update.json +164 -0
- data/spec/fixtures/jira.yml +7 -0
- data/spec/fixtures/project.json +87 -0
- data/spec/fixtures/project_issue_list.json +20 -0
- data/spec/fixtures/projects.json +22 -0
- data/spec/fixtures/search.json +9 -9
- data/spec/fixtures/test.json +24 -0
- data/spec/fixtures/transitions.json +61 -61
- data/spec/fixtures/watchers.json +17 -0
- data/spec/issue_spec.rb +255 -21
- data/spec/project_spec.rb +55 -0
- data/spec/search_result_spec.rb +20 -8
- data/spec/search_spec.rb +6 -6
- data/spec/support/http.rb +55 -2
- data/spec/watchers_spec.rb +43 -0
- metadata +154 -100
- data/.rvmrc +0 -1
- data/spec/cookie_session_spec.rb +0 -268
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use 1.9.2@jiralicious --create
|
data/spec/cookie_session_spec.rb
DELETED
@@ -1,268 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe Jiralicious::CookieSession, "when logging in" do
|
5
|
-
context "successfully" do
|
6
|
-
before :each do
|
7
|
-
register_login
|
8
|
-
@session = Jiralicious::CookieSession.new
|
9
|
-
@session.login
|
10
|
-
end
|
11
|
-
|
12
|
-
it "is alive" do
|
13
|
-
@session.should be_alive
|
14
|
-
end
|
15
|
-
|
16
|
-
it "populates the session and login info" do
|
17
|
-
@session.session.should == {
|
18
|
-
"name" => "JSESSIONID",
|
19
|
-
"value" => "12345678901234567890"
|
20
|
-
}
|
21
|
-
@session.login_info.should == {
|
22
|
-
"failedLoginCount" => 10,
|
23
|
-
"loginCount" => 127,
|
24
|
-
"lastFailedLoginTime" => "2011-07-25T06:31:07.556-0500",
|
25
|
-
"previousLoginTime" => "2011-07-25T06:31:07.556-0500"
|
26
|
-
}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "with an invalid login" do
|
31
|
-
before :each do
|
32
|
-
FakeWeb.register_uri(:post,
|
33
|
-
Jiralicious.uri + '/rest/auth/latest/session',
|
34
|
-
:status => ["401", "Not Authorized"])
|
35
|
-
@session = Jiralicious::CookieSession.new
|
36
|
-
end
|
37
|
-
|
38
|
-
it "raises the correct exception" do
|
39
|
-
lambda { @session.login }.
|
40
|
-
should raise_error(Jiralicious::InvalidLogin)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "is not alive" do
|
44
|
-
begin; @session.login; rescue Jiralicious::InvalidLogin; end
|
45
|
-
@session.should_not be_alive
|
46
|
-
end
|
47
|
-
|
48
|
-
it "clears the session and login info" do
|
49
|
-
@session.login_info = "GARBAGE"
|
50
|
-
@session.session = "GARBAGE"
|
51
|
-
begin; @session.login; rescue Jiralicious::InvalidLogin; end
|
52
|
-
@session.login_info.should be_nil
|
53
|
-
@session.session.should be_nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "when CAPTCHA is required" do
|
58
|
-
before :each do
|
59
|
-
FakeWeb.register_uri(:post,
|
60
|
-
Jiralicious.uri + '/rest/auth/latest/session',
|
61
|
-
:status => ["403", "Captcha Required"])
|
62
|
-
@session = Jiralicious::CookieSession.new
|
63
|
-
end
|
64
|
-
|
65
|
-
it "raises an exception" do
|
66
|
-
lambda { @session.login }.
|
67
|
-
should raise_error(Jiralicious::CaptchaRequired)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "clears the session and login info" do
|
71
|
-
@session.login_info = "GARBAGE"
|
72
|
-
@session.session = "GARBAGE"
|
73
|
-
begin; @session.login; rescue Jiralicious::CaptchaRequired; end
|
74
|
-
@session.login_info.should be_nil
|
75
|
-
@session.session.should be_nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "with any other HTTP error" do
|
80
|
-
before :each do
|
81
|
-
FakeWeb.register_uri(:post,
|
82
|
-
Jiralicious.uri + '/rest/auth/latest/session',
|
83
|
-
:body => "Internal Server Error",
|
84
|
-
:status => ["500", "Internal Server Error"])
|
85
|
-
@session = Jiralicious::CookieSession.new
|
86
|
-
end
|
87
|
-
|
88
|
-
it "raises an exception" do
|
89
|
-
lambda { @session.login }.
|
90
|
-
should raise_error(Jiralicious::JiraError)
|
91
|
-
end
|
92
|
-
|
93
|
-
it "clears the session and login info" do
|
94
|
-
@session.login_info = "GARBAGE"
|
95
|
-
@session.session = "GARBAGE"
|
96
|
-
begin; @session.login; rescue Jiralicious::JiraError; end
|
97
|
-
@session.login_info.should be_nil
|
98
|
-
@session.session.should be_nil
|
99
|
-
end
|
100
|
-
|
101
|
-
it "gives the Net::HTTP reason for failure" do
|
102
|
-
begin
|
103
|
-
@session.login
|
104
|
-
rescue Jiralicious::JiraError => e
|
105
|
-
e.message.should == "Internal Server Error"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe Jiralicious::CookieSession, "when logging out" do
|
112
|
-
before :each do
|
113
|
-
register_login
|
114
|
-
@session = Jiralicious::CookieSession.new
|
115
|
-
@session.login
|
116
|
-
@session.should be_alive
|
117
|
-
FakeWeb.register_uri(:delete,
|
118
|
-
Jiralicious.uri + '/rest/auth/latest/session',
|
119
|
-
:status => "204")
|
120
|
-
@session.logout
|
121
|
-
end
|
122
|
-
|
123
|
-
it "is not alive" do
|
124
|
-
@session.should_not be_alive
|
125
|
-
end
|
126
|
-
|
127
|
-
it "clears the session and login info" do
|
128
|
-
@session.session.should be_nil
|
129
|
-
@session.login_info.should be_nil
|
130
|
-
end
|
131
|
-
|
132
|
-
context "when not logged in" do
|
133
|
-
before :each do
|
134
|
-
@session = Jiralicious::CookieSession.new
|
135
|
-
FakeWeb.register_uri(:delete,
|
136
|
-
Jiralicious.uri + '/rest/auth/latest/session',
|
137
|
-
:status => ["401", "Not Authorized"])
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should raise the correct error" do
|
141
|
-
lambda { @session.logout }.should raise_error(Jiralicious::NotLoggedIn)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "with any other HTTP error" do
|
146
|
-
before :each do
|
147
|
-
@session = Jiralicious::CookieSession.new
|
148
|
-
FakeWeb.register_uri(:delete,
|
149
|
-
Jiralicious.uri + '/rest/auth/latest/session',
|
150
|
-
:status => ["500", "Internal Server Error"])
|
151
|
-
end
|
152
|
-
|
153
|
-
it "raises an exception" do
|
154
|
-
lambda { @session.logout }.
|
155
|
-
should raise_error(Jiralicious::JiraError)
|
156
|
-
end
|
157
|
-
|
158
|
-
it "gives the Net::HTTP reason for failure" do
|
159
|
-
begin
|
160
|
-
@session.logout
|
161
|
-
rescue Jiralicious::JiraError => e
|
162
|
-
e.message.should == "Internal Server Error"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe Jiralicious::CookieSession, "performing a request" do
|
169
|
-
include ConfigurationHelper
|
170
|
-
include LoginHelper
|
171
|
-
|
172
|
-
before :each do
|
173
|
-
FakeWeb.register_uri(:get,
|
174
|
-
Jiralicious.uri + '/fake/uri',
|
175
|
-
:status => "200")
|
176
|
-
end
|
177
|
-
|
178
|
-
context "when login is required" do
|
179
|
-
before :each do
|
180
|
-
@session = Jiralicious::CookieSession.new
|
181
|
-
@session.stub!(:require_login?).and_return(true)
|
182
|
-
end
|
183
|
-
|
184
|
-
it "attempts to log in beforehand" do
|
185
|
-
@session.should_receive(:login)
|
186
|
-
@session.request(:get, '/fake/uri')
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
context "when login is not required" do
|
191
|
-
before :each do
|
192
|
-
@session = Jiralicious::CookieSession.new
|
193
|
-
@session.stub!(:require_login?).and_return(false)
|
194
|
-
end
|
195
|
-
|
196
|
-
it "doesn't try to log in before making the request" do
|
197
|
-
@session.should_receive(:login).never
|
198
|
-
@session.request(:get, '/fake/uri')
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
describe "performing a request with a successful response" do
|
204
|
-
before :each do
|
205
|
-
FakeWeb.register_uri(:get,
|
206
|
-
Jiralicious.uri + '/ok',
|
207
|
-
:status => "200")
|
208
|
-
FakeWeb.register_uri(:post,
|
209
|
-
Jiralicious.uri + '/created',
|
210
|
-
:status => "201")
|
211
|
-
FakeWeb.register_uri(:delete,
|
212
|
-
Jiralicious.uri + '/nocontent',
|
213
|
-
:status => "204")
|
214
|
-
|
215
|
-
register_login
|
216
|
-
end
|
217
|
-
|
218
|
-
let(:session) { Jiralicious::CookieSession.new }
|
219
|
-
|
220
|
-
it "returns the response on ok" do
|
221
|
-
session.request(:get, '/ok').class.should == HTTParty::Response
|
222
|
-
end
|
223
|
-
|
224
|
-
it "returns the response on created" do
|
225
|
-
session.request(:post, '/created').class.should == HTTParty::Response
|
226
|
-
end
|
227
|
-
|
228
|
-
it "returns the response on no content" do
|
229
|
-
session.request(:delete, '/nocontent').class.should == HTTParty::Response
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe "performing a request with an unsuccessful response" do
|
234
|
-
before :each do
|
235
|
-
FakeWeb.register_uri(:get,
|
236
|
-
Jiralicious.uri + '/cookie_expired',
|
237
|
-
[
|
238
|
-
{:status => "401", :body => "Cookie Expired"},
|
239
|
-
{:status => "200"}
|
240
|
-
])
|
241
|
-
FakeWeb.register_uri(:get,
|
242
|
-
Jiralicious.uri + '/captcha_needed',
|
243
|
-
:status => "401",
|
244
|
-
"X-Seraph-LoginReason" => "AUTHENTICATION_DENIED")
|
245
|
-
register_login
|
246
|
-
end
|
247
|
-
|
248
|
-
let(:session) { Jiralicious::CookieSession.new }
|
249
|
-
|
250
|
-
it "raises an exception when cookie invalid" do
|
251
|
-
FakeWeb.register_uri(:get,
|
252
|
-
Jiralicious.uri + '/cookie_expired',
|
253
|
-
[
|
254
|
-
{:status => "401", :body => "Cookie Expired"},
|
255
|
-
{:status => "401", :body => "Cookie Expired"}
|
256
|
-
])
|
257
|
-
|
258
|
-
lambda {
|
259
|
-
session.request(:get, '/cookie_expired')
|
260
|
-
}.should raise_error(Jiralicious::CookieExpired)
|
261
|
-
end
|
262
|
-
|
263
|
-
it "raises an exception when the captcha is required" do
|
264
|
-
lambda {
|
265
|
-
session.request(:get, '/captcha_needed')
|
266
|
-
}.should raise_error(Jiralicious::CaptchaRequired)
|
267
|
-
end
|
268
|
-
end
|