tim 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +17 -0
- data/README.rdoc +231 -8
- data/app/controllers/tim/application_controller.rb +6 -3
- data/app/controllers/tim/base_images_controller.rb +10 -18
- data/app/controllers/tim/image_versions_controller.rb +10 -9
- data/app/controllers/tim/provider_images_controller.rb +13 -10
- data/app/controllers/tim/target_images_controller.rb +9 -7
- data/app/controllers/tim/templates_controller.rb +7 -7
- data/app/exceptions/tim/exceptions.rb +6 -0
- data/app/filters/tim/resource_link_filter.rb +56 -0
- data/app/models/tim/base_image.rb +7 -3
- data/app/models/tim/image_version.rb +4 -2
- data/app/models/tim/provider_image.rb +42 -6
- data/app/models/tim/target_image.rb +48 -9
- data/app/models/tim/template.rb +18 -3
- data/app/patches/rails/active_record/autosave_association.rb +29 -0
- data/app/validators/template_validator.rb +9 -5
- data/app/views/tim/base_images/_base_image.xml.haml +1 -0
- data/app/views/tim/target_images/_target_image.xml.haml +1 -0
- data/db/migrate/20121115151914_add_import_to_tim_base_images.rb +5 -0
- data/db/migrate/20121210131423_add_build_method_to_target_image.rb +5 -0
- data/db/migrate/20121216131814_rename_provider_account_id_attribute.rb +13 -0
- data/db/migrate/20121216134538_add_factory_base_image_id_to_image_versions.rb +5 -0
- data/lib/image_factory/model/base_image.rb +6 -0
- data/lib/tim/engine.rb +12 -0
- data/lib/tim/version.rb +1 -1
- data/spec/controllers/base_images_controller_spec.rb +24 -8
- data/spec/controllers/image_versions_controller_spec.rb +20 -7
- data/spec/controllers/provider_images_controller_spec.rb +19 -6
- data/spec/controllers/target_images_controller_spec.rb +22 -8
- data/spec/factories/tim/base_image.rb +5 -1
- data/spec/factories/tim/image_factory/target_image.rb +1 -0
- data/spec/factories/tim/image_version.rb +4 -0
- data/spec/factories/tim/provider_image.rb +4 -1
- data/spec/factories/tim/target_image.rb +6 -2
- data/spec/filters/resource_link_filter_spec.rb +158 -0
- data/spec/models/base_image_spec.rb +5 -5
- data/spec/models/dummy/pool_family_spec.rb +1 -1
- data/spec/models/dummy/provider_account_spec.rb +3 -1
- data/spec/models/dummy/provider_type_spec.rb +2 -1
- data/spec/models/dummy/user_spec.rb +1 -1
- data/spec/models/image_version_spec.rb +4 -3
- data/spec/models/provider_image_spec.rb +28 -5
- data/spec/models/target_image_spec.rb +74 -4
- data/spec/models/template_spec.rb +11 -2
- data/spec/validators/template_validator_spec.rb +10 -0
- data/spec/views/base_images_spec.rb +2 -1
- data/spec/views/provider_images_spec.rb +1 -0
- data/test/dummy/app/decorators/tim/controllers/base_images_controller_decorator.rb +13 -0
- data/test/dummy/config/database.yml +0 -3
- data/test/dummy/config/initializers/tim.rb +1 -1
- data/test/dummy/config/routes.rb +6 -1
- data/test/dummy/db/migrate/20121216133232_add_provider_account_id_to_provider_images.rb +5 -0
- data/test/dummy/db/schema.rb +28 -24
- data/tim.gemspec +32 -0
- metadata +46 -60
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -982
- data/test/dummy/log/test.log +0 -8629
- data/test/dummy/tmp/cache/assets/C7A/BB0/sprockets%2F13445f7a19078dd2df39517062aa6711 +0 -0
- data/test/dummy/tmp/cache/assets/C8C/CC0/sprockets%2F95d79f3b3096348427f3e4e38b5202e3 +0 -0
- data/test/dummy/tmp/cache/assets/CB0/2B0/sprockets%2F79106b90879c02a115d7f6f1c8390ac4 +0 -0
- data/test/dummy/tmp/cache/assets/CE0/690/sprockets%2F04c628c2a636286bfa92a4966b82b92a +0 -0
- data/test/dummy/tmp/cache/assets/D03/040/sprockets%2Fd9e94204d4b307145f12efc109b16c1f +0 -0
- data/test/dummy/tmp/cache/assets/D06/DC0/sprockets%2Fcd282851b6e4c463409ba3ece67e0510 +0 -0
- data/test/dummy/tmp/cache/assets/D23/5F0/sprockets%2F2a521f3183c6bbcd71bd26a5490b201e +0 -0
- data/test/dummy/tmp/cache/assets/D64/3A0/sprockets%2F56ac1aed10c39b12a88cb1b30f668f58 +0 -0
- data/test/dummy/tmp/cache/assets/D69/BD0/sprockets%2F0aaf75cf34556b33a9fec534fe4d0415 +0 -0
- data/test/dummy/tmp/cache/assets/D87/D80/sprockets%2Fefa3c8b210e87358c7add88cd6f49597 +0 -0
- data/test/dummy/tmp/cache/assets/D89/200/sprockets%2Ff9b4e953c874ed6a87de6490d055d9db +0 -0
- data/test/dummy/tmp/cache/assets/DF4/430/sprockets%2F403bb1de60cae4325cebd7e6c389b8ad +0 -0
- data/test/dummy/tmp/cache/assets/E00/500/sprockets%2Faaddc5b6f2cb6b98930cc54cf4c64a95 +0 -0
- data/test/dummy/tmp/cache/assets/EB3/CE0/sprockets%2Fd75a89c9fffacd99bce7eed96844eafc +0 -0
@@ -4,12 +4,16 @@ class TemplateValidator < ActiveModel::Validator
|
|
4
4
|
@@template_rng = File.join(Tim::Engine.root, "config/schemas", "tdl.rng")
|
5
5
|
|
6
6
|
def validate(record)
|
7
|
-
|
8
|
-
|
7
|
+
begin
|
8
|
+
rng = Nokogiri::XML::RelaxNG(File.read(@@template_rng))
|
9
|
+
xml = Nokogiri::XML(record.xml) { |config| config.strict }
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
rng.validate(xml).each do |error|
|
12
|
+
record.errors.add :xml, error.message
|
13
|
+
end
|
14
|
+
rescue Nokogiri::XML::SyntaxError => e
|
15
|
+
record.errors.add :xml, "Syntax error on line #{e.line} at column #{e.column}: #{e.message}"
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
end
|
@@ -4,6 +4,7 @@
|
|
4
4
|
%description= base_image.description
|
5
5
|
- if base_image.template
|
6
6
|
= render :partial => 'tim/templates/template_minimal', :locals => {:template => base_image.template}
|
7
|
+
%import= base_image.import
|
7
8
|
%image_versions
|
8
9
|
- base_image.image_versions.each do |image_version|
|
9
10
|
= render :partial => 'tim/image_versions/image_version_minimal', :locals => {:image_version => image_version}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
!!! XML
|
2
2
|
%target_image{:id => target_image.id, :href => target_image_url(target_image.id) }
|
3
3
|
%target= target_image.target
|
4
|
+
%build_method= target_image.build_method
|
4
5
|
%status= target_image.status
|
5
6
|
%status_detail= target_image.status_detail
|
6
7
|
%progress= target_image.progress
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class RenameProviderAccountIdAttribute < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
change_table :tim_provider_images do |t|
|
4
|
+
t.rename :provider_account_id, :factory_provider_account_id
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
change_table :tim_provider_images do |t|
|
10
|
+
t.rename :factory_provider_account_id, :provider_account_id
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/tim/engine.rb
CHANGED
@@ -5,5 +5,17 @@ module Tim
|
|
5
5
|
g.test_framework :rspec, :view_specs => false
|
6
6
|
g.template_engine :haml
|
7
7
|
end
|
8
|
+
|
9
|
+
# Load Host Decorator Classes
|
10
|
+
config.to_prepare do |c|
|
11
|
+
# Load everything under patches, exceptions and decorators dir
|
12
|
+
[
|
13
|
+
Dir[Rails.root.join('app', 'decorators', '**', '*_decorator.rb')],
|
14
|
+
Dir[Tim::Engine.root.join('app', 'patches', '**', '*.rb')],
|
15
|
+
Dir[Tim::Engine.root.join('app', 'exceptions', '**', '*.rb')]
|
16
|
+
].flatten.each do |f|
|
17
|
+
Rails.application.config.cache_classes ? require(f) : load(f)
|
18
|
+
end
|
19
|
+
end
|
8
20
|
end
|
9
21
|
end
|
data/lib/tim/version.rb
CHANGED
@@ -14,7 +14,10 @@ module Tim
|
|
14
14
|
|
15
15
|
context "Success" do
|
16
16
|
it "should return a new base image as xml" do
|
17
|
-
|
17
|
+
template = FactoryGirl.build(:template)
|
18
|
+
post :create, { :base_image => { :name => "Name",
|
19
|
+
:description => "Description",
|
20
|
+
:template_attributes => {:xml => template.xml }}}
|
18
21
|
response.code.should == "201"
|
19
22
|
|
20
23
|
body = Hash.from_xml(response.body)
|
@@ -30,11 +33,24 @@ module Tim
|
|
30
33
|
|
31
34
|
body = Hash.from_xml(response.body)
|
32
35
|
body.keys.should == ["base_image"]
|
33
|
-
body["base_image"].keys.should =~ ["template", "id", "href", "name", "description", "image_versions"]
|
36
|
+
body["base_image"].keys.should =~ ["template", "id", "href", "name", "description", "image_versions", "import"]
|
34
37
|
body["base_image"]["template"].keys.should =~ ["id", "href"]
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
41
|
+
it "should return a new base image with an existing template" do
|
42
|
+
template = FactoryGirl.create(:template)
|
43
|
+
post :create, { :base_image => { :name => "Name",
|
44
|
+
:description => "Description",
|
45
|
+
:template => {:id => template.id}}}
|
46
|
+
response.code.should == "201"
|
47
|
+
|
48
|
+
body = Hash.from_xml(response.body)
|
49
|
+
body.keys.should == ["base_image"]
|
50
|
+
body["base_image"].keys.should =~ ["template", "id", "href", "name", "description", "image_versions", "import"]
|
51
|
+
body["base_image"]["template"].keys.should =~ ["id", "href"]
|
52
|
+
end
|
53
|
+
|
38
54
|
context "failure" do
|
39
55
|
it "should return a unprocessable entity error when the client sends invalid content" do
|
40
56
|
post :create, { :invalid_image => FactoryGirl.build(:base_image).attributes }
|
@@ -46,14 +62,14 @@ module Tim
|
|
46
62
|
describe "Show Base Image" do
|
47
63
|
context "Success" do
|
48
64
|
it "should return an existing base image as XML" do
|
49
|
-
base_image = FactoryGirl.create(:base_image)
|
65
|
+
base_image = FactoryGirl.create(:base_image, :import => true)
|
50
66
|
get :show, :id => base_image.id
|
51
67
|
|
52
68
|
response.code.should == "200"
|
53
69
|
|
54
70
|
body = Hash.from_xml(response.body)
|
55
71
|
body.keys.should == ["base_image"]
|
56
|
-
body["base_image"].keys.should =~ ["id", "href", "name", "description", "image_versions"]
|
72
|
+
body["base_image"].keys.should =~ ["id", "href", "name", "description", "image_versions", "import"]
|
57
73
|
end
|
58
74
|
|
59
75
|
it "should return an existing base image as XML with template" do
|
@@ -64,7 +80,7 @@ module Tim
|
|
64
80
|
|
65
81
|
body = Hash.from_xml(response.body)
|
66
82
|
body.keys.should == ["base_image"]
|
67
|
-
body["base_image"].keys.should =~ ["template", "id", "href", "name", "description", "image_versions"]
|
83
|
+
body["base_image"].keys.should =~ ["template", "id", "href", "name", "description", "image_versions", "import"]
|
68
84
|
body["base_image"]["template"].keys.should =~ ["id", "href"]
|
69
85
|
end
|
70
86
|
|
@@ -80,7 +96,7 @@ module Tim
|
|
80
96
|
|
81
97
|
body = Hash.from_xml(response.body)
|
82
98
|
body.keys.should == ["base_image"]
|
83
|
-
body["base_image"].keys.should =~ ["image_versions", "template", "id", "href", "name", "description"]
|
99
|
+
body["base_image"].keys.should =~ ["image_versions", "template", "id", "href", "name", "description", "import"]
|
84
100
|
body["base_image"]["image_versions"]["image_version"].size.should == 2
|
85
101
|
end
|
86
102
|
end
|
@@ -97,7 +113,7 @@ module Tim
|
|
97
113
|
context "Success" do
|
98
114
|
it "should return a list of existing base images as XML" do
|
99
115
|
3.times do
|
100
|
-
FactoryGirl.create(:
|
116
|
+
FactoryGirl.create(:base_image_with_template)
|
101
117
|
end
|
102
118
|
|
103
119
|
get :index
|
@@ -113,7 +129,7 @@ module Tim
|
|
113
129
|
describe "List Delete Image" do
|
114
130
|
context "Success" do
|
115
131
|
it "should return a no content code when deleting an image" do
|
116
|
-
base_image = FactoryGirl.create(:
|
132
|
+
base_image = FactoryGirl.create(:base_image_with_template)
|
117
133
|
delete :destroy, :id => base_image.id
|
118
134
|
response.code.should == "204"
|
119
135
|
end
|
@@ -15,7 +15,8 @@ module Tim
|
|
15
15
|
|
16
16
|
context "Success" do
|
17
17
|
it "should return a new image version as xml" do
|
18
|
-
|
18
|
+
image_version = FactoryGirl.build(:image_version_with_full_tree)
|
19
|
+
post :create, { :image_version => image_version.attributes }
|
19
20
|
response.code.should == "201"
|
20
21
|
|
21
22
|
body = Hash.from_xml(response.body)
|
@@ -23,7 +24,19 @@ module Tim
|
|
23
24
|
end
|
24
25
|
|
25
26
|
it "should return a new image version with base image as xml" do
|
26
|
-
|
27
|
+
image_version = FactoryGirl.build(:image_version_with_full_tree)
|
28
|
+
post :create, { :image_version => image_version.attributes }
|
29
|
+
response.code.should == "201"
|
30
|
+
|
31
|
+
body = Hash.from_xml(response.body)
|
32
|
+
body.keys.should == ["image_version"]
|
33
|
+
body["image_version"].keys.should =~ ["base_image", "id", "href", "target_images"]
|
34
|
+
body["image_version"]["base_image"].keys.should =~ ["id", "href"]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return a new image version with existing base image" do
|
38
|
+
base_image = FactoryGirl.create(:base_image_with_template)
|
39
|
+
post :create, { :image_version => {:base_image => {:id => base_image.id}}}
|
27
40
|
response.code.should == "201"
|
28
41
|
|
29
42
|
body = Hash.from_xml(response.body)
|
@@ -44,7 +57,7 @@ module Tim
|
|
44
57
|
describe "Show Image Version" do
|
45
58
|
context "Success" do
|
46
59
|
it "should return an existing image version as XML" do
|
47
|
-
image_version = FactoryGirl.create(:
|
60
|
+
image_version = FactoryGirl.create(:image_version_with_full_tree)
|
48
61
|
get :show, :id => image_version.id
|
49
62
|
|
50
63
|
response.code.should == "200"
|
@@ -79,7 +92,7 @@ module Tim
|
|
79
92
|
context "Success" do
|
80
93
|
it "should return a list of existing base images as XML" do
|
81
94
|
3.times do
|
82
|
-
FactoryGirl.create(:
|
95
|
+
FactoryGirl.create(:image_version_with_full_tree)
|
83
96
|
end
|
84
97
|
|
85
98
|
get :index
|
@@ -96,7 +109,7 @@ module Tim
|
|
96
109
|
describe "Delete Image Version" do
|
97
110
|
context "Success" do
|
98
111
|
it "should return a no content code when deleting an image version" do
|
99
|
-
image_version = FactoryGirl.create(:
|
112
|
+
image_version = FactoryGirl.create(:image_version_with_full_tree)
|
100
113
|
delete :destroy, :id => image_version.id
|
101
114
|
response.code.should == "204"
|
102
115
|
|
@@ -117,7 +130,7 @@ module Tim
|
|
117
130
|
context "Success" do
|
118
131
|
it "should return an updated image version as xml" do
|
119
132
|
image_version = FactoryGirl.create(:image_version_with_full_tree)
|
120
|
-
image_version.base_image = FactoryGirl.create(:
|
133
|
+
image_version.base_image = FactoryGirl.create(:base_image_with_template)
|
121
134
|
put :update, :id => image_version.id, :image_version => image_version.attributes
|
122
135
|
response.code.should == "200"
|
123
136
|
|
@@ -130,7 +143,7 @@ module Tim
|
|
130
143
|
|
131
144
|
context "failure" do
|
132
145
|
it "should return a unprocessable entity error when the client sends invalid content" do
|
133
|
-
image_version = FactoryGirl.create(:
|
146
|
+
image_version = FactoryGirl.create(:image_version_with_full_tree)
|
134
147
|
post :update, :id => image_version.id, :invalid_image => image_version.attributes
|
135
148
|
response.code.should == "422"
|
136
149
|
end
|
@@ -10,6 +10,7 @@ module Tim
|
|
10
10
|
TargetImage.any_instance.stub(:template).and_return(FactoryGirl.build(:template))
|
11
11
|
ProviderImage.any_instance.stub(:create_factory_provider_image).and_return(true)
|
12
12
|
TargetImage.any_instance.stub(:create_factory_target_image).and_return(true)
|
13
|
+
TargetImage.any_instance.stub(:imported?).and_return(false)
|
13
14
|
@status_detail = mock(:status)
|
14
15
|
@status_detail.stub(:activity).and_return("Building")
|
15
16
|
ImageFactory::TargetImage.stub(:create).and_return(FactoryGirl.build(:image_factory_target_image, :status_detail => @status_detail))
|
@@ -33,11 +34,23 @@ module Tim
|
|
33
34
|
"snapshot", "status_detail", "progress", "href", "id","target_image", "status"]
|
34
35
|
body["provider_image"]["target_image"]["id"].should == provider_image.target_image .id.to_s
|
35
36
|
end
|
37
|
+
|
38
|
+
it "should return a new provider image awith existing target image" do
|
39
|
+
target_image = FactoryGirl.create(:target_image_with_full_tree)
|
40
|
+
post :create, { :provider_image => { :target_image => { :id => target_image.id }}}
|
41
|
+
response.code.should == "201"
|
42
|
+
|
43
|
+
body = Hash.from_xml(response.body)
|
44
|
+
body.keys.should == ["provider_image"]
|
45
|
+
body["provider_image"].keys.should =~ ["external_image_id", "provider",
|
46
|
+
"snapshot", "status_detail", "progress", "href", "id","target_image", "status"]
|
47
|
+
body["provider_image"]["target_image"]["id"].should == target_image .id.to_s
|
48
|
+
end
|
36
49
|
end
|
37
50
|
|
38
51
|
context "failure" do
|
39
52
|
it "should return a unprocessable entity error when the client sends invalid content" do
|
40
|
-
post :create, { :invalid_image => FactoryGirl.build(:
|
53
|
+
post :create, { :invalid_image => FactoryGirl.build(:provider_image_with_full_tree).attributes }
|
41
54
|
response.code.should == "422"
|
42
55
|
end
|
43
56
|
end
|
@@ -71,7 +84,7 @@ module Tim
|
|
71
84
|
context "Success" do
|
72
85
|
it "should return a list of existing provider images as XML" do
|
73
86
|
3.times do
|
74
|
-
FactoryGirl.create(:
|
87
|
+
FactoryGirl.create(:provider_image_with_full_tree)
|
75
88
|
end
|
76
89
|
|
77
90
|
get :index
|
@@ -87,7 +100,7 @@ module Tim
|
|
87
100
|
describe "Delete Provider Image" do
|
88
101
|
context "Success" do
|
89
102
|
it "should return a no content code when deleting a provider image" do
|
90
|
-
provider_image = FactoryGirl.create(:
|
103
|
+
provider_image = FactoryGirl.create(:provider_image_with_full_tree)
|
91
104
|
delete :destroy, :id => provider_image.id
|
92
105
|
response.code.should == "204"
|
93
106
|
|
@@ -108,7 +121,7 @@ module Tim
|
|
108
121
|
context "Success" do
|
109
122
|
it "should return an updated provider image as xml" do
|
110
123
|
provider_image = FactoryGirl.create(:provider_image_with_full_tree)
|
111
|
-
provider_image.target_image = FactoryGirl.create(:
|
124
|
+
provider_image.target_image = FactoryGirl.create(:target_image_with_full_tree )
|
112
125
|
put :update, :id => provider_image.id, :provider_image => provider_image.attributes
|
113
126
|
response.code.should == "200"
|
114
127
|
|
@@ -121,13 +134,13 @@ module Tim
|
|
121
134
|
|
122
135
|
context "failure" do
|
123
136
|
it "should return a unprocessable entity error when the client sends invalid content" do
|
124
|
-
provider_image = FactoryGirl.create(:
|
137
|
+
provider_image = FactoryGirl.create(:provider_image_with_full_tree)
|
125
138
|
post :update, :id => provider_image.id, :invalid_image => provider_image.attributes
|
126
139
|
response.code.should == "422"
|
127
140
|
end
|
128
141
|
|
129
142
|
it "should return a not found code when updating a Provider image that does not exist" do
|
130
|
-
delete :update, :id => -1, :provider_image => FactoryGirl.create(:
|
143
|
+
delete :update, :id => -1, :provider_image => FactoryGirl.create(:provider_image_with_full_tree).attributes
|
131
144
|
response.code.should == "404"
|
132
145
|
end
|
133
146
|
end
|
@@ -9,6 +9,7 @@ module Tim
|
|
9
9
|
send_and_accept_xml
|
10
10
|
TargetImage.any_instance.stub(:template).and_return(FactoryGirl.build(:template))
|
11
11
|
TargetImage.any_instance.stub(:create_factory_target_image).and_return(true)
|
12
|
+
TargetImage.any_instance.stub(:imported?).and_return(false)
|
12
13
|
@status_detail = mock(:status)
|
13
14
|
@status_detail.stub(:activity).and_return("Building")
|
14
15
|
TargetImagesController.any_instance.stub(:template_exists?).and_return false
|
@@ -28,14 +29,27 @@ module Tim
|
|
28
29
|
|
29
30
|
body = Hash.from_xml(response.body)
|
30
31
|
body.keys.should == ["target_image"]
|
31
|
-
body["target_image"].keys.should =~ ["target", "status", "status_detail", "progress", "href", "id",
|
32
|
+
body["target_image"].keys.should =~ ["target", "status", "status_detail", "progress", "href", "id",
|
33
|
+
"provider_images", "image_version", "build_method"]
|
32
34
|
body["target_image"]["image_version"]["id"].should == target_image.image_version.id.to_s
|
33
35
|
end
|
36
|
+
|
37
|
+
it "should create a new target image for imported images" do
|
38
|
+
image_version = FactoryGirl.create(:image_version_import)
|
39
|
+
post :create, { :target_image => {:image_version => {:id => image_version.id}, :target => "mock"}}
|
40
|
+
response.code.should == "201"
|
41
|
+
|
42
|
+
body = Hash.from_xml(response.body)
|
43
|
+
body.keys.should == ["target_image"]
|
44
|
+
body["target_image"].keys.should =~ ["target", "status", "status_detail", "progress", "href", "id",
|
45
|
+
"provider_images", "image_version", "build_method"]
|
46
|
+
body["target_image"]["image_version"]["id"].should == image_version.id.to_s
|
47
|
+
end
|
34
48
|
end
|
35
49
|
|
36
50
|
context "failure" do
|
37
51
|
it "should return a unprocessable entity error when the client sends invalid content" do
|
38
|
-
post :create, { :invalid_image => FactoryGirl.build(:
|
52
|
+
post :create, { :invalid_image => FactoryGirl.build(:target_image_with_full_tree).attributes }
|
39
53
|
response.code.should == "422"
|
40
54
|
end
|
41
55
|
end
|
@@ -52,7 +66,7 @@ module Tim
|
|
52
66
|
body = Hash.from_xml(response.body)
|
53
67
|
body.keys.should == ["target_image"]
|
54
68
|
body["target_image"].keys.should =~ ["id", "href", "image_version",
|
55
|
-
"provider_images", "target", "status", "status_detail", "progress"]
|
69
|
+
"provider_images", "target", "status", "status_detail", "progress", "build_method"]
|
56
70
|
end
|
57
71
|
end
|
58
72
|
|
@@ -68,7 +82,7 @@ module Tim
|
|
68
82
|
context "Success" do
|
69
83
|
it "should return a list of existing target images as XML" do
|
70
84
|
3.times do
|
71
|
-
FactoryGirl.create(:
|
85
|
+
FactoryGirl.create(:target_image_with_full_tree)
|
72
86
|
end
|
73
87
|
|
74
88
|
get :index
|
@@ -84,7 +98,7 @@ module Tim
|
|
84
98
|
describe "Delete Target Image" do
|
85
99
|
context "Success" do
|
86
100
|
it "should return a no content code when deleting a target image" do
|
87
|
-
target_image = FactoryGirl.create(:
|
101
|
+
target_image = FactoryGirl.create(:target_image_with_full_tree)
|
88
102
|
delete :destroy, :id => target_image.id
|
89
103
|
response.code.should == "204"
|
90
104
|
|
@@ -105,7 +119,7 @@ module Tim
|
|
105
119
|
context "Success" do
|
106
120
|
it "should return an updated target image as xml" do
|
107
121
|
target_image = FactoryGirl.create(:target_image_with_full_tree)
|
108
|
-
target_image.image_version = FactoryGirl.create(:
|
122
|
+
target_image.image_version = FactoryGirl.create(:image_version_with_full_tree)
|
109
123
|
put :update, :id => target_image.id, :target_image => target_image.attributes
|
110
124
|
response.code.should == "200"
|
111
125
|
|
@@ -118,13 +132,13 @@ module Tim
|
|
118
132
|
|
119
133
|
context "failure" do
|
120
134
|
it "should return a unprocessable entity error when the client sends invalid content" do
|
121
|
-
target_image = FactoryGirl.create(:
|
135
|
+
target_image = FactoryGirl.create(:target_image_with_full_tree)
|
122
136
|
put :update, :id => target_image.id, :invalid_image => target_image.attributes
|
123
137
|
response.code.should == "422"
|
124
138
|
end
|
125
139
|
|
126
140
|
it "should return a not found code when updating a target image that does not exist" do
|
127
|
-
delete :update, :id => -1, :target_image => FactoryGirl.build(:
|
141
|
+
delete :update, :id => -1, :target_image => FactoryGirl.build(:target_image_with_full_tree).attributes
|
128
142
|
response.code.should == "404"
|
129
143
|
end
|
130
144
|
end
|