ci_in_a_can 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ci_in_a_can/app.rb +14 -56
- data/lib/ci_in_a_can/version.rb +1 -1
- data/lib/ci_in_a_can/view_models/login_form.rb +24 -0
- data/lib/ci_in_a_can/view_models/repo_form.rb +25 -0
- data/lib/ci_in_a_can/view_models/view_model.rb +1 -1
- data/lib/ci_in_a_can/web.rb +78 -0
- data/spec/ci_in_a_can/web_spec.rb +426 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec408de18d9c47e09339a8c2ed0bc8453a42a039
|
4
|
+
data.tar.gz: cb23d747865712a372931f1a558fee78f618bf95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8475a583069b024c3460c151fdbc30b0f404072936784378a9be2076eb19a25b6acfbf03601b551497914adc154085c00afbbf2744140113beaf5304c31d2d4d
|
7
|
+
data.tar.gz: fe8538c757f0d30cb4da661c083e06285a031d0a5a9563c891c63f0060d7dc582797fe85fcc800f921676b7190b9f24bb2c0d6e90f5c28950aa8f9090fdebe7f
|
data/lib/ci_in_a_can/app.rb
CHANGED
@@ -15,93 +15,51 @@ module CiInACan
|
|
15
15
|
end
|
16
16
|
|
17
17
|
get '/login' do
|
18
|
-
CiInACan::
|
19
|
-
<<EOF
|
20
|
-
<form action="/login" method="post">
|
21
|
-
Passphrase
|
22
|
-
<input type="password" name="passphrase">
|
23
|
-
<button type="submit">Submit</button>
|
24
|
-
</form>
|
25
|
-
EOF
|
26
|
-
)
|
18
|
+
CiInACan::Web.new.login_page
|
27
19
|
end
|
28
20
|
|
29
21
|
post '/login' do
|
30
|
-
|
22
|
+
web = CiInACan::Web.new(params: params, session: session)
|
23
|
+
web.submit_a_passphrase
|
31
24
|
redirect '/'
|
32
25
|
end
|
33
26
|
|
34
27
|
get '/test_result/:id.json' do
|
35
|
-
CiInACan::
|
28
|
+
CiInACan::Web.new(params: params).show_the_test_result_in_json
|
36
29
|
end
|
37
30
|
|
38
31
|
post %r{/repo/(.+)} do
|
39
32
|
|
40
|
-
|
33
|
+
web = CiInACan::Web.new(params: params, session: session)
|
34
|
+
unless web.logged_in?
|
41
35
|
redirect '/login'
|
42
36
|
return
|
43
37
|
end
|
44
|
-
|
45
|
-
|
46
|
-
commands = params[:commands].gsub("\r\n", "\n").split("\n")
|
47
|
-
commands = commands.map { |x| x.strip }.select { |x| x != '' }
|
48
|
-
repo = CiInACan::Repo.find params[:id]
|
49
|
-
repo = CiInACan::Repo.create(id: params[:id]) unless repo
|
50
|
-
repo.build_commands = commands
|
51
|
-
repo.save
|
52
|
-
redirect "/repo/#{params[:id]}"
|
38
|
+
repo = web.update_repo_details
|
39
|
+
redirect "/repo/#{repo.id}"
|
53
40
|
end
|
54
41
|
|
55
42
|
get %r{/repo/(.+)} do
|
43
|
+
web = CiInACan::Web.new(params: params, session: session)
|
56
44
|
|
57
|
-
unless
|
45
|
+
unless web.logged_in?
|
58
46
|
redirect '/login'
|
59
47
|
return
|
60
48
|
end
|
61
49
|
|
62
|
-
|
63
|
-
repo = CiInACan::Repo.find(params[:id])
|
64
|
-
url = repo ? repo.url : nil
|
65
|
-
commands = repo ? repo.build_commands.join("\n") : ''
|
66
|
-
CiInACan::WebContent.full_page_of(
|
67
|
-
<<EOF
|
68
|
-
<form action="/repo/#{params[:id]}" method="post">
|
69
|
-
<div>#{url}</div>
|
70
|
-
<textarea name="commands">
|
71
|
-
#{commands}
|
72
|
-
</textarea>
|
73
|
-
<input type="submit">Submit</input>
|
74
|
-
</form>
|
75
|
-
EOF
|
76
|
-
)
|
50
|
+
web.show_the_repo_edit_form
|
77
51
|
end
|
78
52
|
|
79
53
|
get '/test_result/:id' do
|
80
|
-
|
81
|
-
CiInACan::WebContent.full_page_of test_result.to_html
|
54
|
+
CiInACan::Web.new(params: params).show_the_test_result
|
82
55
|
end
|
83
56
|
|
84
57
|
get '/' do
|
85
|
-
|
86
|
-
::CiInACan::ViewModels::AListOfRuns.new(runs).to_html
|
58
|
+
CiInACan::Web.new.show_a_list_of_the_runs
|
87
59
|
end
|
88
60
|
|
89
61
|
post %r{/push/(.+)} do
|
90
|
-
|
91
|
-
api_key = capture.pop
|
92
|
-
id = capture.join('/')
|
93
|
-
|
94
|
-
repo = CiInACan::Repo.find id
|
95
|
-
raise 'Could not find this repo' unless repo
|
96
|
-
raise 'Invalid API Key' unless repo.api_key == api_key
|
97
|
-
|
98
|
-
write_a_file_with params
|
99
|
-
end
|
100
|
-
|
101
|
-
def write_a_file_with params
|
102
|
-
data = params.to_json
|
103
|
-
File.open("#{self.class.jobs_location}/#{UUID.new.generate}.json", 'w') { |f| f.write data }
|
104
|
-
data
|
62
|
+
CiInACan::Web.new(params: params).start_a_new_build
|
105
63
|
end
|
106
64
|
|
107
65
|
end
|
data/lib/ci_in_a_can/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module CiInACan
|
2
|
+
|
3
|
+
module ViewModels
|
4
|
+
|
5
|
+
class LoginForm < ViewModel
|
6
|
+
|
7
|
+
def to_html
|
8
|
+
CiInACan::WebContent.full_page_of(
|
9
|
+
<<EOF
|
10
|
+
<form action="/login" method="post">
|
11
|
+
Passphrase
|
12
|
+
<input type="password" name="passphrase">
|
13
|
+
<button type="submit">Submit</button>
|
14
|
+
</form>
|
15
|
+
EOF
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CiInACan
|
2
|
+
|
3
|
+
module ViewModels
|
4
|
+
|
5
|
+
class RepoForm < ViewModel
|
6
|
+
|
7
|
+
def to_html
|
8
|
+
CiInACan::WebContent.full_page_of(
|
9
|
+
<<EOF
|
10
|
+
<form action="/repo/#{id}" method="post">
|
11
|
+
<div>#{url}</div>
|
12
|
+
<textarea name="commands">
|
13
|
+
#{build_commands.join("\n")}
|
14
|
+
</textarea>
|
15
|
+
<input type="submit">Submit</input>
|
16
|
+
</form>
|
17
|
+
EOF
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module CiInACan
|
2
|
+
|
3
|
+
class Web
|
4
|
+
|
5
|
+
params_constructor
|
6
|
+
|
7
|
+
attr_accessor :params, :session
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :jobs_location
|
11
|
+
end
|
12
|
+
|
13
|
+
def login_page
|
14
|
+
CiInACan::ViewModels::LoginForm.new.to_html
|
15
|
+
end
|
16
|
+
|
17
|
+
def submit_a_passphrase
|
18
|
+
session[:passphrase] = params[:passphrase]
|
19
|
+
end
|
20
|
+
|
21
|
+
def show_the_test_result_in_json
|
22
|
+
CiInACan::TestResult.find(params[:id]).to_json
|
23
|
+
end
|
24
|
+
|
25
|
+
def logged_in?
|
26
|
+
return false if session[:passphrase].to_s == ''
|
27
|
+
session[:passphrase] == ENV['PASSPHRASE']
|
28
|
+
end
|
29
|
+
|
30
|
+
def show_the_repo_edit_form
|
31
|
+
id = params[:captures].first
|
32
|
+
repo = CiInACan::Repo.find(id) || CiInACan::Repo.new(id: id)
|
33
|
+
CiInACan::ViewModels::RepoForm.new(repo).to_html
|
34
|
+
end
|
35
|
+
|
36
|
+
def start_a_new_build
|
37
|
+
assert_that_the_new_build_is_valid
|
38
|
+
|
39
|
+
write_a_file_with params
|
40
|
+
params.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
def show_a_list_of_the_runs
|
44
|
+
CiInACan::ViewModels::AListOfRuns.new(CiInACan::Run.all.to_a).to_html
|
45
|
+
end
|
46
|
+
|
47
|
+
def show_the_test_result
|
48
|
+
test_result = CiInACan::TestResult.find(params[:id])
|
49
|
+
CiInACan::WebContent.full_page_of test_result.to_html
|
50
|
+
end
|
51
|
+
|
52
|
+
def update_repo_details
|
53
|
+
CiInACan::Repo.create(id: params[:captures].first,
|
54
|
+
build_commands: params[:commands].gsub("\r\n", "\n")
|
55
|
+
.split("\n")
|
56
|
+
.map { |x| x.strip }
|
57
|
+
.select { |x| x != '' } )
|
58
|
+
end
|
59
|
+
|
60
|
+
def write_a_file_with params
|
61
|
+
data = params.to_json
|
62
|
+
file = "#{self.class.jobs_location}/#{UUID.new.generate}.json"
|
63
|
+
CiInACan::FileSystem.create_file file, data
|
64
|
+
end
|
65
|
+
|
66
|
+
def assert_that_the_new_build_is_valid
|
67
|
+
capture = params[:captures].first.split('/')
|
68
|
+
api_key = capture.pop
|
69
|
+
id = capture.join('/')
|
70
|
+
|
71
|
+
repo = CiInACan::Repo.find id
|
72
|
+
raise 'Could not find this repo' unless repo
|
73
|
+
raise 'Invalid API Key' unless repo.api_key == api_key
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,426 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe CiInACan::Web do
|
4
|
+
|
5
|
+
let(:params) { {} }
|
6
|
+
let(:session) { {} }
|
7
|
+
|
8
|
+
let(:web) do
|
9
|
+
CiInACan::Web.new(params: params,
|
10
|
+
session: session)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "login page" do
|
14
|
+
|
15
|
+
it "should return the login form html" do
|
16
|
+
|
17
|
+
html = Object.new
|
18
|
+
login_form = Object.new
|
19
|
+
|
20
|
+
login_form.stubs(:to_html).returns html
|
21
|
+
CiInACan::ViewModels::LoginForm.stubs(:new).returns login_form
|
22
|
+
|
23
|
+
web.login_page.must_be_same_as html
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "submit a passphrase" do
|
30
|
+
|
31
|
+
it "should set the passphrase in session" do
|
32
|
+
|
33
|
+
passphrase = Object.new
|
34
|
+
params[:passphrase] = passphrase
|
35
|
+
|
36
|
+
web.submit_a_passphrase
|
37
|
+
|
38
|
+
session[:passphrase].must_be_same_as passphrase
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "showing the test result in html" do
|
45
|
+
|
46
|
+
it "should return the html results" do
|
47
|
+
|
48
|
+
params[:id] = Object.new
|
49
|
+
test_result = Object.new
|
50
|
+
web_content = Object.new
|
51
|
+
html = Object.new
|
52
|
+
|
53
|
+
test_result.stubs(:to_html).returns html
|
54
|
+
|
55
|
+
CiInACan::TestResult.stubs(:find)
|
56
|
+
.with(params[:id])
|
57
|
+
.returns test_result
|
58
|
+
|
59
|
+
CiInACan::WebContent.stubs(:full_page_of)
|
60
|
+
.with(html)
|
61
|
+
.returns web_content
|
62
|
+
|
63
|
+
result = web.show_the_test_result
|
64
|
+
|
65
|
+
result.must_be_same_as web_content
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "showing the test result in json" do
|
72
|
+
|
73
|
+
it "should return the json results" do
|
74
|
+
|
75
|
+
params[:id] = Object.new
|
76
|
+
test_result = Object.new
|
77
|
+
json = Object.new
|
78
|
+
|
79
|
+
test_result.stubs(:to_json).returns json
|
80
|
+
|
81
|
+
CiInACan::TestResult.stubs(:find)
|
82
|
+
.with(params[:id])
|
83
|
+
.returns test_result
|
84
|
+
|
85
|
+
result = web.show_the_test_result_in_json
|
86
|
+
|
87
|
+
result.must_be_same_as json
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "determining if the user is logged in" do
|
94
|
+
|
95
|
+
it "should return true if the passphrase in session and ENV match" do
|
96
|
+
|
97
|
+
passphrase = Object.new
|
98
|
+
|
99
|
+
ENV.stubs(:[]).with('PASSPHRASE').returns passphrase
|
100
|
+
session[:passphrase] = passphrase
|
101
|
+
|
102
|
+
web.logged_in?.must_equal true
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should return false if the passphrases do not match" do
|
107
|
+
|
108
|
+
ENV.stubs(:[]).with('PASSPHRASE').returns Object.new
|
109
|
+
session[:passphrase] = Object.new
|
110
|
+
|
111
|
+
web.logged_in?.must_equal false
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should return false if the passphrases are nil" do
|
116
|
+
|
117
|
+
ENV.stubs(:[]).with('PASSPHRASE').returns nil
|
118
|
+
session[:passphrase] = nil
|
119
|
+
|
120
|
+
web.logged_in?.must_equal false
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should return false if the passphrases are empty strings" do
|
125
|
+
|
126
|
+
ENV.stubs(:[]).with('PASSPHRASE').returns ""
|
127
|
+
session[:passphrase] = ""
|
128
|
+
|
129
|
+
web.logged_in?.must_equal false
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "showing the repo edit form" do
|
136
|
+
|
137
|
+
describe "when the id matches an existing repo" do
|
138
|
+
|
139
|
+
it "should return the html for the repo form" do
|
140
|
+
|
141
|
+
id = Object.new
|
142
|
+
params[:captures] = [id]
|
143
|
+
repo = Object.new
|
144
|
+
repo_form = Object.new
|
145
|
+
html = Object.new
|
146
|
+
|
147
|
+
repo_form.stubs(:to_html).returns html
|
148
|
+
|
149
|
+
CiInACan::Repo.stubs(:find).with(id).returns repo
|
150
|
+
CiInACan::ViewModels::RepoForm.stubs(:new).with(repo).returns repo_form
|
151
|
+
|
152
|
+
web.show_the_repo_edit_form.must_be_same_as html
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "when the id has never been used" do
|
159
|
+
|
160
|
+
it "should return the html for a new repo form" do
|
161
|
+
|
162
|
+
id = Object.new
|
163
|
+
params[:captures] = [id]
|
164
|
+
repo = Object.new
|
165
|
+
repo_form = Object.new
|
166
|
+
html = Object.new
|
167
|
+
|
168
|
+
repo_form.stubs(:to_html).returns html
|
169
|
+
|
170
|
+
CiInACan::Repo.stubs(:find).with(id).returns nil
|
171
|
+
CiInACan::Repo.stubs(:new).with(id: id).returns repo
|
172
|
+
CiInACan::ViewModels::RepoForm.stubs(:new).with(repo).returns repo_form
|
173
|
+
|
174
|
+
web.show_the_repo_edit_form.must_be_same_as html
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
[:captures, :commands, :expected_id, :expected_commands].to_objects {[
|
183
|
+
[['one/two'], "\na\r\nb\nc\r\nd\n\n", 'one/two', ['a', 'b', 'c', 'd']],
|
184
|
+
[['two/three'], "w\nx\ny\r\nz", 'two/three', ['w', 'x', 'y', 'z']]
|
185
|
+
]}.each do |test|
|
186
|
+
|
187
|
+
describe "updating the repo details" do
|
188
|
+
|
189
|
+
before do
|
190
|
+
clear_all_persisted_data
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "a repo that has never been saved before" do
|
194
|
+
|
195
|
+
before do
|
196
|
+
params[:captures] = test.captures
|
197
|
+
params[:commands] = test.commands
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should create a repo" do
|
201
|
+
web.update_repo_details
|
202
|
+
CiInACan::Repo.all.count.must_equal 1
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should set the id" do
|
206
|
+
web.update_repo_details
|
207
|
+
CiInACan::Repo.all.first.id.must_equal test.expected_id
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should set the build commands" do
|
211
|
+
web.update_repo_details
|
212
|
+
CiInACan::Repo.all.first.build_commands.must_equal test.expected_commands
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
describe "a repo that been saved before" do
|
218
|
+
|
219
|
+
before do
|
220
|
+
CiInACan::Repo.create(id: test.expected_id)
|
221
|
+
params[:captures] = test.captures
|
222
|
+
params[:commands] = test.commands
|
223
|
+
end
|
224
|
+
|
225
|
+
it "should create a repo" do
|
226
|
+
web.update_repo_details
|
227
|
+
CiInACan::Repo.all.count.must_equal 1
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should set the build commands" do
|
231
|
+
web.update_repo_details
|
232
|
+
CiInACan::Repo.all.first.build_commands.must_equal test.expected_commands
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should return the repo" do
|
236
|
+
result = web.update_repo_details
|
237
|
+
result.is_a? CiInACan::Repo
|
238
|
+
result.id.must_equal test.expected_id
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
describe "showing a list of the runs" do
|
248
|
+
|
249
|
+
it "should return the html for all of the runs" do
|
250
|
+
|
251
|
+
runs = Object.new
|
252
|
+
array_of_runs = Object.new
|
253
|
+
html = Object.new
|
254
|
+
list_of_runs = Object.new
|
255
|
+
|
256
|
+
|
257
|
+
CiInACan::Run.stubs(:all).returns runs
|
258
|
+
runs.stubs(:to_a).returns array_of_runs
|
259
|
+
CiInACan::ViewModels::AListOfRuns.stubs(:new)
|
260
|
+
.with(array_of_runs)
|
261
|
+
.returns list_of_runs
|
262
|
+
list_of_runs.stubs(:to_html).returns html
|
263
|
+
|
264
|
+
result = web.show_a_list_of_the_runs
|
265
|
+
|
266
|
+
result.must_be_same_as html
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
271
|
+
|
272
|
+
describe "starting a new build" do
|
273
|
+
|
274
|
+
[:url, :repo, :api_key, :jobs_location, :uuid].to_objects {[
|
275
|
+
['account/name/api_key', 'account/name', 'api_key', 'the job', 'the uuid'],
|
276
|
+
['one/two/three', 'one/two', 'three', 'A', 'B']
|
277
|
+
]}.each do |test|
|
278
|
+
|
279
|
+
describe "when the api key is valid" do
|
280
|
+
|
281
|
+
let(:repo) do
|
282
|
+
r = Object.new
|
283
|
+
r.stubs(:api_key).returns test.api_key
|
284
|
+
r
|
285
|
+
end
|
286
|
+
|
287
|
+
let(:json) { Object.new }
|
288
|
+
|
289
|
+
before do
|
290
|
+
params[:captures] = [test.url]
|
291
|
+
|
292
|
+
params.stubs(:to_json).returns json
|
293
|
+
|
294
|
+
CiInACan::Repo.stubs(:find)
|
295
|
+
.with(test.repo)
|
296
|
+
.returns repo
|
297
|
+
|
298
|
+
CiInACan::Web.stubs(:jobs_location).returns test.jobs_location
|
299
|
+
|
300
|
+
CiInACan::FileSystem.stubs(:create_file)
|
301
|
+
|
302
|
+
uuid = Object.new
|
303
|
+
uuid.stubs(:generate).returns test.uuid
|
304
|
+
UUID.stubs(:new).returns uuid
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should not fail when we call it" do
|
308
|
+
web.start_a_new_build
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should write a file" do
|
312
|
+
CiInACan::FileSystem.expects(:create_file)
|
313
|
+
.with("#{test.jobs_location}/#{test.uuid}.json", json)
|
314
|
+
web.start_a_new_build
|
315
|
+
end
|
316
|
+
|
317
|
+
it "should return the json back" do
|
318
|
+
web.start_a_new_build.must_be_same_as json
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
end
|
324
|
+
|
325
|
+
[:url, :repo, :api_key, :jobs_location, :uuid].to_objects {[
|
326
|
+
['account/name/api_key', 'account/name', 'api_key', 'the job', 'the uuid'],
|
327
|
+
]}.each do |test|
|
328
|
+
|
329
|
+
describe "when the repo does not exist" do
|
330
|
+
|
331
|
+
let(:repo) do
|
332
|
+
r = Object.new
|
333
|
+
r.stubs(:api_key).returns test.api_key
|
334
|
+
r
|
335
|
+
end
|
336
|
+
|
337
|
+
before do
|
338
|
+
params[:captures] = [test.url]
|
339
|
+
|
340
|
+
CiInACan::Repo.stubs(:find)
|
341
|
+
.with(test.repo)
|
342
|
+
.returns nil
|
343
|
+
|
344
|
+
CiInACan::FileSystem.stubs(:create_file)
|
345
|
+
|
346
|
+
uuid = Object.new
|
347
|
+
uuid.stubs(:generate).returns test.uuid
|
348
|
+
UUID.stubs(:new).returns uuid
|
349
|
+
end
|
350
|
+
|
351
|
+
it "should throw an error" do
|
352
|
+
error_hit = false
|
353
|
+
begin
|
354
|
+
web.start_a_new_build
|
355
|
+
rescue
|
356
|
+
error_hit = true
|
357
|
+
end
|
358
|
+
|
359
|
+
error_hit.must_equal true
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should not write any files" do
|
363
|
+
called = false
|
364
|
+
# having some issue with never?
|
365
|
+
CiInACan::FileSystem.stubs(:create_file).with { |a, b| [a, b].inspect; called = true; true }
|
366
|
+
-> { web.start_a_new_build }.call_safely
|
367
|
+
called.must_equal false
|
368
|
+
end
|
369
|
+
|
370
|
+
end
|
371
|
+
|
372
|
+
end
|
373
|
+
|
374
|
+
[:url, :repo, :api_key, :jobs_location, :uuid, :the_other_api_key].to_objects {[
|
375
|
+
['account/name/api_key', 'account/name', 'api_key', 'the job', 'the uuid', 'sdf'],
|
376
|
+
['account/name/api_key', 'account/name', 'api_key', 'the job', 'the uuid', 'abc'],
|
377
|
+
]}.each do |test|
|
378
|
+
|
379
|
+
describe "when the repo api key does not match the request" do
|
380
|
+
|
381
|
+
let(:repo) do
|
382
|
+
r = Object.new
|
383
|
+
r.stubs(:api_key).returns test.the_other_api_key
|
384
|
+
r
|
385
|
+
end
|
386
|
+
|
387
|
+
before do
|
388
|
+
params[:captures] = [test.url]
|
389
|
+
|
390
|
+
CiInACan::Repo.stubs(:find)
|
391
|
+
.with(test.repo)
|
392
|
+
.returns repo
|
393
|
+
|
394
|
+
CiInACan::FileSystem.stubs(:create_file)
|
395
|
+
|
396
|
+
uuid = Object.new
|
397
|
+
uuid.stubs(:generate).returns test.uuid
|
398
|
+
UUID.stubs(:new).returns uuid
|
399
|
+
end
|
400
|
+
|
401
|
+
it "should throw an error" do
|
402
|
+
error_hit = false
|
403
|
+
begin
|
404
|
+
web.start_a_new_build
|
405
|
+
rescue
|
406
|
+
error_hit = true
|
407
|
+
end
|
408
|
+
|
409
|
+
error_hit.must_equal true
|
410
|
+
end
|
411
|
+
|
412
|
+
it "should not write any files" do
|
413
|
+
called = false
|
414
|
+
# having some issue with never?
|
415
|
+
CiInACan::FileSystem.stubs(:create_file).with { |a, b| [a, b].inspect; called = true; true }
|
416
|
+
-> { web.start_a_new_build }.call_safely
|
417
|
+
called.must_equal false
|
418
|
+
end
|
419
|
+
|
420
|
+
end
|
421
|
+
|
422
|
+
end
|
423
|
+
|
424
|
+
end
|
425
|
+
|
426
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_in_a_can
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -248,10 +248,13 @@ files:
|
|
248
248
|
- lib/ci_in_a_can/test_runner.rb
|
249
249
|
- lib/ci_in_a_can/version.rb
|
250
250
|
- lib/ci_in_a_can/view_models/a_list_of_runs.rb
|
251
|
+
- lib/ci_in_a_can/view_models/login_form.rb
|
252
|
+
- lib/ci_in_a_can/view_models/repo_form.rb
|
251
253
|
- lib/ci_in_a_can/view_models/run_view_model.rb
|
252
254
|
- lib/ci_in_a_can/view_models/test_result_view_model.rb
|
253
255
|
- lib/ci_in_a_can/view_models/view_model.rb
|
254
256
|
- lib/ci_in_a_can/watcher.rb
|
257
|
+
- lib/ci_in_a_can/web.rb
|
255
258
|
- lib/ci_in_a_can/web_content.rb
|
256
259
|
- sample.json
|
257
260
|
- spec/ci_in_a_can/bash_result_spec.rb
|
@@ -270,6 +273,7 @@ files:
|
|
270
273
|
- spec/ci_in_a_can/test_runner_spec.rb
|
271
274
|
- spec/ci_in_a_can/view_models/view_model_spec.rb
|
272
275
|
- spec/ci_in_a_can/watcher_spec.rb
|
276
|
+
- spec/ci_in_a_can/web_spec.rb
|
273
277
|
- spec/spec_helper.rb
|
274
278
|
- spec/temp/.gitkeep
|
275
279
|
homepage: ''
|
@@ -313,5 +317,6 @@ test_files:
|
|
313
317
|
- spec/ci_in_a_can/test_runner_spec.rb
|
314
318
|
- spec/ci_in_a_can/view_models/view_model_spec.rb
|
315
319
|
- spec/ci_in_a_can/watcher_spec.rb
|
320
|
+
- spec/ci_in_a_can/web_spec.rb
|
316
321
|
- spec/spec_helper.rb
|
317
322
|
- spec/temp/.gitkeep
|