foreman_docker 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_docker/image_step.js +17 -16
  3. data/app/assets/stylesheets/foreman_docker/autocomplete.css.scss +2 -2
  4. data/app/controllers/api/v2/containers_controller.rb +23 -15
  5. data/app/controllers/containers/steps_controller.rb +3 -3
  6. data/app/controllers/containers_controller.rb +17 -19
  7. data/app/helpers/container_steps_helper.rb +5 -1
  8. data/app/helpers/containers_helper.rb +5 -7
  9. data/app/models/concerns/fog_extensions/fogdocker/server.rb +1 -1
  10. data/app/models/docker_registry.rb +16 -4
  11. data/app/models/foreman_docker/docker.rb +2 -1
  12. data/app/models/service/containers.rb +1 -1
  13. data/app/overrides/remove_docker_from_compute_profiles.rb +14 -0
  14. data/app/overrides/rename_virtual_machines_containers.rb +10 -0
  15. data/app/services/foreman_docker/container_remover.rb +20 -0
  16. data/app/views/containers/index.html.erb +4 -7
  17. data/app/views/containers/show.html.erb +2 -2
  18. data/app/views/containers/steps/_image_hub_tab.html.erb +41 -40
  19. data/app/views/foreman_docker/common_parameters/_dns_entry.html.erb +2 -2
  20. data/app/views/foreman_docker/common_parameters/_environment_variable.html.erb +2 -2
  21. data/app/views/foreman_docker/common_parameters/_exposed_port.html.erb +1 -1
  22. data/app/views/registries/index.html.erb +7 -7
  23. data/config/routes.rb +1 -1
  24. data/db/migrate/20141209182008_remove_docker_tables.rb +8 -2
  25. data/lib/foreman_docker/engine.rb +1 -0
  26. data/lib/foreman_docker/version.rb +1 -1
  27. data/locale/Makefile +58 -4
  28. data/locale/de/LC_MESSAGES/foreman_docker.mo +0 -0
  29. data/locale/de/foreman_docker.edit.po +631 -0
  30. data/locale/de/foreman_docker.po +110 -78
  31. data/locale/de/foreman_docker.po.time_stamp +0 -0
  32. data/locale/es/LC_MESSAGES/foreman_docker.mo +0 -0
  33. data/locale/es/foreman_docker.edit.po +631 -0
  34. data/locale/es/foreman_docker.po +110 -78
  35. data/locale/es/foreman_docker.po.time_stamp +0 -0
  36. data/locale/foreman_docker.pot +414 -219
  37. data/locale/fr/LC_MESSAGES/foreman_docker.mo +0 -0
  38. data/locale/fr/foreman_docker.edit.po +632 -0
  39. data/locale/fr/foreman_docker.po +111 -84
  40. data/locale/fr/foreman_docker.po.time_stamp +0 -0
  41. data/locale/it/LC_MESSAGES/foreman_docker.mo +0 -0
  42. data/locale/it/foreman_docker.edit.po +630 -0
  43. data/locale/it/foreman_docker.po +110 -82
  44. data/locale/it/foreman_docker.po.time_stamp +0 -0
  45. data/locale/ja/LC_MESSAGES/foreman_docker.mo +0 -0
  46. data/locale/ja/foreman_docker.edit.po +634 -0
  47. data/locale/ja/foreman_docker.po +109 -64
  48. data/locale/ja/foreman_docker.po.time_stamp +0 -0
  49. data/locale/ko/LC_MESSAGES/foreman_docker.mo +0 -0
  50. data/locale/ko/foreman_docker.edit.po +629 -0
  51. data/locale/ko/foreman_docker.po +108 -65
  52. data/locale/ko/foreman_docker.po.time_stamp +0 -0
  53. data/locale/pt_BR/LC_MESSAGES/foreman_docker.mo +0 -0
  54. data/locale/pt_BR/foreman_docker.edit.po +631 -0
  55. data/locale/pt_BR/foreman_docker.po +109 -74
  56. data/locale/pt_BR/foreman_docker.po.time_stamp +0 -0
  57. data/locale/ru/LC_MESSAGES/foreman_docker.mo +0 -0
  58. data/locale/ru/foreman_docker.edit.po +630 -0
  59. data/locale/ru/foreman_docker.po +110 -72
  60. data/locale/ru/foreman_docker.po.time_stamp +0 -0
  61. data/locale/zanata.xml +3 -3
  62. data/locale/zh_CN/LC_MESSAGES/foreman_docker.mo +0 -0
  63. data/locale/zh_CN/foreman_docker.edit.po +628 -0
  64. data/locale/zh_CN/foreman_docker.po +108 -64
  65. data/locale/zh_CN/foreman_docker.po.time_stamp +0 -0
  66. data/locale/zh_TW/LC_MESSAGES/foreman_docker.mo +0 -0
  67. data/locale/zh_TW/foreman_docker.edit.po +628 -0
  68. data/locale/zh_TW/foreman_docker.po +108 -65
  69. data/locale/zh_TW/foreman_docker.po.time_stamp +0 -0
  70. data/test/factories/docker_registry.rb +4 -0
  71. data/test/functionals/api/v2/containers_controller_test.rb +18 -4
  72. data/test/functionals/api/v2/registries_controller_test.rb +2 -0
  73. data/test/functionals/containers_controller_test.rb +56 -8
  74. data/test/integration/container_steps_test.rb +1 -1
  75. data/test/integration/container_test.rb +1 -1
  76. data/test/units/container_remover_test.rb +31 -0
  77. data/test/units/container_test.rb +6 -0
  78. data/test/units/containers_service_test.rb +2 -0
  79. data/test/units/docker_registry_test.rb +20 -3
  80. data/test/units/foreman_docker/docker_test.rb +10 -0
  81. metadata +57 -6
@@ -3,7 +3,6 @@ msgid ""
3
3
  msgstr ""
4
4
  "Project-Id-Version: version 0.0.1\n"
5
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2015-04-22 12:12-0400\n"
7
6
  "PO-Revision-Date: 2015-04-27 05:20+0000\n"
8
7
  "Last-Translator: tchuang <tchuang@redhat.com>\n"
9
8
  "Language-Team: Chinese (Taiwan)\n"
@@ -14,20 +13,28 @@ msgstr ""
14
13
  "Plural-Forms: nplurals=1; plural=0\n"
15
14
  "X-Generator: Zanata 3.6.0\n"
16
15
 
17
- msgid "\"#{resource.name}\""
18
- msgstr "\"#{resource.name}\""
19
-
20
16
  msgid "%{container} commit was successful"
21
- msgstr "%{container} 交付成功"
17
+ msgstr ""
22
18
 
23
- # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
24
- msgid "%{cores} Cores and %{memory} memory"
25
- msgstr "%{cores} 核心 , %{memory} 記憶體"
19
+ msgid "%{cores} cores and %{memory} memory"
20
+ msgstr ""
26
21
 
27
22
  # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
28
23
  msgid "%{vm} is now %{vm_state}"
29
24
  msgstr "%{vm} 目前狀態為 %{vm_state}"
30
25
 
26
+ msgid "Action"
27
+ msgstr ""
28
+
29
+ msgid "Actions"
30
+ msgstr ""
31
+
32
+ msgid "Add DNS"
33
+ msgstr ""
34
+
35
+ msgid "Add Exposed Port"
36
+ msgstr ""
37
+
31
38
  msgid "Add environment variable"
32
39
  msgstr "新增環境變數"
33
40
 
@@ -64,6 +71,9 @@ msgstr "上一步"
64
71
  msgid "Basic options"
65
72
  msgstr "基本選項"
66
73
 
74
+ msgid "CPU set"
75
+ msgstr ""
76
+
67
77
  msgid "CPU sets"
68
78
  msgstr "CPU 集"
69
79
 
@@ -99,21 +109,39 @@ msgstr "運算選項"
99
109
  msgid "Compute resource"
100
110
  msgstr "運算資源"
101
111
 
112
+ msgid "Configuration"
113
+ msgstr ""
114
+
102
115
  msgid "Container %s is being deleted."
103
116
  msgstr "Container %s 正被刪除中。"
104
117
 
105
118
  msgid "Containers"
106
119
  msgstr "Container"
107
120
 
121
+ msgid "Content View"
122
+ msgstr ""
123
+
108
124
  # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
109
125
  msgid "Cores"
110
126
  msgstr "核心"
111
127
 
128
+ msgid "Could not start container"
129
+ msgstr ""
130
+
112
131
  msgid "Create a container"
113
132
  msgstr "建立 container"
114
133
 
115
- msgid "Create container in a compute resource"
116
- msgstr "在運算資源中建立 container"
134
+ msgid "Create a docker registry"
135
+ msgstr ""
136
+
137
+ msgid "Create container on a compute resource"
138
+ msgstr ""
139
+
140
+ msgid "DNS"
141
+ msgstr ""
142
+
143
+ msgid "DNS e.g. 8.8.8.8"
144
+ msgstr ""
117
145
 
118
146
  # translation auto-copied from project Satellite6 Foreman Discovery, version 6.1, document foreman_discovery
119
147
  msgid "Delete %s?"
@@ -122,16 +150,16 @@ msgstr "刪除 %s?"
122
150
  msgid "Delete a container"
123
151
  msgstr "刪除 container"
124
152
 
125
- msgid "Delete container in a compute resource"
126
- msgstr "刪除運算資源中的 container"
153
+ msgid "Delete a docker registry"
154
+ msgstr ""
155
+
156
+ msgid "Delete container on a compute resource"
157
+ msgstr ""
127
158
 
128
159
  # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
129
160
  msgid "Deploy on"
130
161
  msgstr "建置於"
131
162
 
132
- msgid "Describing of the registry"
133
- msgstr "登錄檔詳述"
134
-
135
163
  # translation auto-copied from project Satellite6 Hammer CLI Foreman, version 6.1, document hammer-cli-foreman
136
164
  msgid "Description"
137
165
  msgstr "描述"
@@ -139,6 +167,9 @@ msgstr "描述"
139
167
  msgid "Description of the commit"
140
168
  msgstr "交付詳述"
141
169
 
170
+ msgid "Description of the registry"
171
+ msgstr ""
172
+
142
173
  msgid "Docker hub"
143
174
  msgstr "Docker hub"
144
175
 
@@ -154,6 +185,9 @@ msgstr "此映像檔是否支援使用者資料輸入?"
154
185
  msgid "Edit Registry"
155
186
  msgstr "編輯登錄檔"
156
187
 
188
+ msgid "Environment"
189
+ msgstr ""
190
+
157
191
  msgid "Environment Variables"
158
192
  msgstr "環境變數"
159
193
 
@@ -170,6 +204,9 @@ msgstr "連上運算資源時發生了錯誤:<strong> %s </strong>"
170
204
  msgid "Error creating communicating with Docker. Check the Foreman logs: %s"
171
205
  msgstr "與 Docker 建立通訊時發生了錯誤。請檢查 Foreman 的日誌:%s"
172
206
 
207
+ msgid "Exposed Ports"
208
+ msgstr ""
209
+
173
210
  msgid "Exposed ports"
174
211
  msgstr "公開的連接埠"
175
212
 
@@ -179,16 +216,19 @@ msgstr "外部登錄檔"
179
216
  msgid "Failed to commit %{container}: %{e}"
180
217
  msgstr "%{container} 交付失敗:%{e}"
181
218
 
182
- msgid "Find your favorite container, e.g: centos"
183
- msgstr "尋找您偏好使用的 container,例如 centos"
219
+ msgid "Find your favorite container, e.g. centos"
220
+ msgstr ""
184
221
 
185
- msgid "Foreman user <foremaner@theforeman.org>"
186
- msgstr "Foreman 使用者 <foremaner@theforeman.org>"
222
+ msgid "Foreman user <foremaner@example.org>"
223
+ msgstr ""
187
224
 
188
225
  # translation auto-copied from project Satellite6 Foreman Discovery, version 6.1, document foreman_discovery
189
226
  msgid "IP Address"
190
227
  msgstr "IP 位址"
191
228
 
229
+ msgid "If selected, the container will start after it is created"
230
+ msgstr ""
231
+
192
232
  # translation auto-copied from project Satellite6 Hammer CLI Foreman, version 6.1, document hammer-cli-foreman
193
233
  msgid "Image"
194
234
  msgstr "映像檔"
@@ -199,22 +239,14 @@ msgstr "映像檔軟體庫"
199
239
  msgid "Image Tag"
200
240
  msgstr "映像檔標籤"
201
241
 
202
- msgid ""
203
- "Image to use to create the container.\\n "
204
- " Format should be repository:tag, e.g: centos:7"
205
- msgstr ""
206
- "使用來建立 container 的映像檔。\\n 格式應該是 "
207
- "repository:tag,例如:centos:7"
208
-
209
- # translation auto-copied from project Red Hat Satellite User Guide, version 6.0, document chap-Introduction_to_Red_Hat_Satellite
210
- msgid "Katello"
211
- msgstr "Katello"
212
-
213
242
  msgid "List all containers"
214
243
  msgstr "列出所有 container"
215
244
 
216
- msgid "List all containers in a compute resource"
217
- msgstr "列出運算資源中的所有 container"
245
+ msgid "List all containers on a compute resource"
246
+ msgstr ""
247
+
248
+ msgid "List all docker registries"
249
+ msgstr ""
218
250
 
219
251
  # translation auto-copied from project Satellite6 Hammer CLI Foreman, version 6.1, document hammer-cli-foreman
220
252
  msgid "Locations"
@@ -236,8 +268,11 @@ msgstr "記憶體"
236
268
  msgid "Name"
237
269
  msgstr "名稱"
238
270
 
239
- msgid "Name, e.g: PING_HOST"
240
- msgstr "名稱,例如 PING_HOST"
271
+ msgid "Name of the repository to use to create the container. e.g. centos"
272
+ msgstr ""
273
+
274
+ msgid "Name, e.g. PING_HOST"
275
+ msgstr ""
241
276
 
242
277
  msgid "New Registry"
243
278
  msgstr "新增登錄檔"
@@ -245,6 +280,9 @@ msgstr "新增登錄檔"
245
280
  msgid "New container"
246
281
  msgstr "新增 container"
247
282
 
283
+ msgid "New registry"
284
+ msgstr ""
285
+
248
286
  # translation auto-copied from project subscription-manager, version 1.10.10, document keys
249
287
  msgid "Next"
250
288
  msgstr "下一步"
@@ -271,10 +309,12 @@ msgstr "用來進行認證的密碼 - 用於 SSH 完成步驟。"
271
309
  msgid "Password used for authentication to the registry"
272
310
  msgstr "用來認證登錄檔的密碼"
273
311
 
274
- msgid ""
275
- "Please turn on your container to see processes running, logs, and more."
312
+ msgid "Please turn on your container to see processes running, logs, and more."
276
313
  msgstr "請開啟您的 container 以查看執行中的程序、日誌等等。"
277
314
 
315
+ msgid "Port number e.g. 22"
316
+ msgstr ""
317
+
278
318
  # translation auto-copied from project Satellite6 Hammer CLI Foreman, version 6.1, document hammer-cli-foreman
279
319
  msgid "Power"
280
320
  msgstr "電源"
@@ -283,6 +323,9 @@ msgstr "電源"
283
323
  msgid "Power ON this machine"
284
324
  msgstr "開啟這部機器的電源"
285
325
 
326
+ msgid "Preliminary"
327
+ msgstr ""
328
+
286
329
  # translation auto-copied from project gnome-system-monitor, version 3.8.2.1, document gnome-system-monitor
287
330
  msgid "Processes"
288
331
  msgstr "程序"
@@ -297,18 +340,8 @@ msgstr "登錄檔"
297
340
  msgid "Registry"
298
341
  msgstr "登錄檔"
299
342
 
300
- msgid "Registry name"
301
- msgstr "登錄檔名稱"
302
-
303
- msgid ""
304
- "Registry this container will have to use\\n "
305
- " to get the image"
343
+ msgid "Registry this container will have to use to get the image"
306
344
  msgstr ""
307
- "這個 container 取得映像檔所必須\\n "
308
- " 使用的登錄檔"
309
-
310
- msgid "Registry url"
311
- msgstr "登錄檔網址"
312
345
 
313
346
  msgid "Repo"
314
347
  msgstr "軟體庫"
@@ -319,8 +352,11 @@ msgstr "資源選擇"
319
352
  msgid "Run power operation on a container"
320
353
  msgstr "在一個 container 上執行電源作業"
321
354
 
322
- msgid "Run power operation on a container in a compute resource"
323
- msgstr "在運算資源中的 container 上執行電源作業"
355
+ msgid "Run power operation on a container on a compute resource"
356
+ msgstr ""
357
+
358
+ msgid "Run?"
359
+ msgstr ""
324
360
 
325
361
  # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
326
362
  msgid "Running on"
@@ -339,14 +375,17 @@ msgstr "Shell"
339
375
  msgid "Show a container"
340
376
  msgstr "顯示 container"
341
377
 
342
- msgid "Show container in a compute resource"
343
- msgstr "顯示運算資源中的 container"
378
+ msgid "Show a docker registry"
379
+ msgstr ""
344
380
 
345
381
  msgid "Show container logs"
346
382
  msgstr "顯示 container 的日誌"
347
383
 
348
- msgid "Show logs from a container in a compute resource"
349
- msgstr "顯示運算資源中的 container 日誌"
384
+ msgid "Show container on a compute resource"
385
+ msgstr ""
386
+
387
+ msgid "Show logs from a container on a compute resource"
388
+ msgstr ""
350
389
 
351
390
  # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
352
391
  msgid "Start"
@@ -368,13 +407,17 @@ msgstr "TTY"
368
407
  msgid "Tag"
369
408
  msgstr "標籤"
370
409
 
410
+ msgid "Tag to use to create the container. e.g. latest"
411
+ msgstr ""
412
+
371
413
  # translation auto-copied from project Satellite6 Foreman, version 6.1, document foreman
372
414
  msgid "Test Connection"
373
415
  msgstr "測試連線"
374
416
 
375
- msgid ""
376
- "The user that is used to ssh into the instance, normally docker-user, "
377
- "ubuntu, root etc"
417
+ msgid "The capsule this container will have to use to get the image. Relevant for images retrieved from katello registry."
418
+ msgstr ""
419
+
420
+ msgid "The user that is used to ssh into the instance, normally docker-user, ubuntu, root etc"
378
421
  msgstr "使用來 ssh 入 instance 的使用者,一般會是 docker-user、ubuntu、root 等等"
379
422
 
380
423
  # translation auto-copied from project Satellite6 Hammer CLI Foreman, version 6.1, document hammer-cli-foreman
@@ -385,21 +428,23 @@ msgstr "網址"
385
428
  msgid "UUID"
386
429
  msgstr "UUID"
387
430
 
431
+ msgid "Unable to log in to this Docker Registry - %s"
432
+ msgstr ""
433
+
388
434
  msgid "Unknown method: available power operations are %s"
389
435
  msgstr "不明的 method:有效的電源作業包含了 %s"
390
436
 
437
+ msgid "Update a docker registry"
438
+ msgstr ""
439
+
391
440
  msgid "Uptime"
392
441
  msgstr "上線時間"
393
442
 
394
- # translation auto-copied from project Satellite6 Hammer CLI Foreman, version 6.1, document hammer-cli-foreman
395
- msgid "Url"
396
- msgstr "網址"
397
-
398
443
  msgid "Username used to access the registry"
399
444
  msgstr "用來存取登錄檔的使用者名稱"
400
445
 
401
- msgid "Value, e.g: theforeman.org"
402
- msgstr "值,例如 theforeman.org"
446
+ msgid "Value, e.g. example.org"
447
+ msgstr ""
403
448
 
404
449
  msgid "Where do you want to deploy your container?:"
405
450
  msgstr "您希望在哪建置您的 container?"
@@ -411,9 +456,7 @@ msgstr "錯誤的屬性:%s"
411
456
  msgid "Yes"
412
457
  msgstr "是"
413
458
 
414
- msgid ""
415
- "You need a Docker compute resource in order to create containers. Please %s "
416
- "and try again."
459
+ msgid "You need a Docker compute resource in order to create containers. Please %s and try again."
417
460
  msgstr "您需要一個 Docker 運算資源以建立 container。請 %s 並重新嘗試。"
418
461
 
419
462
  msgid "Your container is stopped."
@@ -6,6 +6,10 @@ FactoryGirl.define do
6
6
  sequence(:password) { |n| "password#{n}" }
7
7
  end
8
8
 
9
+ after(:build) do |registry|
10
+ registry.stubs(:attempt_login)
11
+ end
12
+
9
13
  trait :with_location do
10
14
  locations { [FactoryGirl.build(:location)] }
11
15
  end
@@ -40,10 +40,24 @@ module Api
40
40
  assert_equal ActiveSupport::JSON.decode(response.body)['name'], 'foo'
41
41
  end
42
42
 
43
- test 'delete removes a container in foreman and in Docker host' do
44
- delete :destroy, :id => @container.id
45
- assert_response :success
46
- assert_equal ActiveSupport::JSON.decode(response.body)['name'], 'foo'
43
+ context 'deletion' do
44
+ setup do
45
+ Container.any_instance.stubs(:uuid).returns('randomuuid')
46
+ end
47
+
48
+ test 'delete removes a container in foreman and in Docker host' do
49
+ delete :destroy, :id => @container.id
50
+ assert_response :success
51
+ assert_equal ActiveSupport::JSON.decode(response.body)['name'], 'foo'
52
+ end
53
+
54
+ test 'if deletion on Docker host fails, Foreman deletion fails' do
55
+ ComputeResource.any_instance.expects(:destroy_vm).
56
+ with('randomuuid').
57
+ raises(::Foreman::Exception.new('Problem removing container'))
58
+ delete :destroy, :id => @container.id
59
+ assert_response :precondition_failed
60
+ end
47
61
  end
48
62
 
49
63
  test 'power call turns on/off container in Docker host' do
@@ -24,6 +24,7 @@ module Api
24
24
 
25
25
  test 'creates a new registry with valid params' do
26
26
  docker_attrs = FactoryGirl.attributes_for(:docker_registry)
27
+ DockerRegistry.any_instance.stubs(:attempt_login)
27
28
  post :create, :registry => docker_attrs
28
29
  assert_response :success
29
30
  end
@@ -41,6 +42,7 @@ module Api
41
42
  end
42
43
 
43
44
  test 'update a docker registry' do
45
+ DockerRegistry.any_instance.stubs(:attempt_login)
44
46
  put :update, :id => @registry.id, :registry => { :name => 'hello_world' }
45
47
  assert_response :success
46
48
  assert DockerRegistry.exists?(:name => 'hello_world')
@@ -15,14 +15,62 @@ class ContainersControllerTest < ActionController::TestCase
15
15
  assert_template 'index'
16
16
  end
17
17
 
18
- test 'deleting a container in compute resource redirects to containers index' do
19
- Fog.mock!
20
- container_resource = FactoryGirl.create(:docker_cr)
21
- container = container_resource.vms.first
22
- container.class.any_instance.expects(:destroy).returns(true)
23
- delete :destroy, { :compute_resource_id => container_resource,
24
- :id => container.id }, set_session_user
25
- assert_redirected_to containers_path
18
+ context 'delete container' do
19
+ setup do
20
+ Fog.mock!
21
+ @container_resource = FactoryGirl.create(:docker_cr)
22
+ @container = @container_resource.vms.first
23
+ end
24
+
25
+ teardown { Fog.unmock! }
26
+
27
+ test 'deleting an unmanaged container redirects to containers index' do
28
+ ComputeResource.any_instance.expects(:destroy_vm).with(@container.id)
29
+ delete :destroy, { :compute_resource_id => @container_resource,
30
+ :id => @container.id }, set_session_user
31
+ assert_redirected_to containers_path
32
+ assert_equal "Container #{@container.id} is being deleted.",
33
+ flash[:notice]
34
+ end
35
+
36
+ test 'failed deletion of unmanaged container in Docker' do
37
+ ComputeResource.any_instance.stubs(:destroy_vm).
38
+ raises(::Foreman::Exception.new('Could not destroy Docker container'))
39
+ @request.env['HTTP_REFERER'] = "http://test.host/#{containers_path}"
40
+ delete :destroy, { :compute_resource_id => @container_resource,
41
+ :id => @container.id }, set_session_user
42
+ assert @container.present?
43
+ assert_redirected_to :back
44
+ assert_equal 'Your container could not be deleted in Docker',
45
+ flash[:error]
46
+ end
47
+
48
+ test 'deleting a managed container deletes container in Docker' do
49
+ managed_container = FactoryGirl.create(
50
+ :container,
51
+ :compute_resource => @container_resource)
52
+ ComputeResource.any_instance.expects(:destroy_vm).
53
+ with('randomuuid')
54
+ Container.any_instance.expects(:uuid).returns('randomuuid').at_least_once
55
+ Container.any_instance.expects(:destroy)
56
+ delete :destroy, { :id => managed_container.id }, set_session_user
57
+ assert_redirected_to containers_path
58
+ assert_equal "Container #{managed_container.uuid} is being deleted.",
59
+ flash[:notice]
60
+ end
61
+
62
+ test 'failed deletion of managed container keeps container in Foreman' do
63
+ ComputeResource.any_instance.stubs(:destroy_vm).
64
+ raises(::Foreman::Exception.new('Could not destroy Docker container'))
65
+ managed_container = FactoryGirl.create(
66
+ :container,
67
+ :compute_resource => @container_resource)
68
+ delete :destroy, { :id => managed_container.id }, set_session_user
69
+ assert managed_container.present? # Foreman container would not be deleted
70
+ assert_redirected_to containers_path
71
+ assert_equal 'Your container could not be deleted in Docker',
72
+ flash[:error]
73
+ end
26
74
  end
27
75
 
28
76
  test 'committing a managed container' do