This caused our model hooks based on this state to not be called.
---
.../controllers/resources/instances_controller.rb | 2 +-
src/app/models/image.rb | 10 +++++-----
src/app/models/provider_image.rb | 6 +++---
.../20110302120000_add_status_to_provider_image.rb | 4 ++--
src/features/step_definitions/template_steps.rb | 2 +-
src/spec/factories/provider_image.rb | 2 +-
6 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/app/controllers/resources/instances_controller.rb
b/src/app/controllers/resources/instances_controller.rb
index 6eba323..234fe6b 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -35,7 +35,7 @@ class Resources::InstancesController < ApplicationController
@templates = Template.paginate(
:page => params[:page] || 1,
:include => {:images => :provider_images},
- :conditions => "provider_images.status =
'#{ProviderImage::STATE_COMPLETE}'"
+ :conditions => "provider_images.status =
'#{ProviderImage::STATE_COMPLETED}'"
)
end
diff --git a/src/app/models/image.rb b/src/app/models/image.rb
index 3f9653c..2425472 100644
--- a/src/app/models/image.rb
+++ b/src/app/models/image.rb
@@ -65,12 +65,12 @@ class Image < ActiveRecord::Base
STATE_QUEUED = 'queued'
STATE_CREATED = 'created'
STATE_BUILDING = 'building'
- STATE_COMPLETE = 'complete'
+ STATE_COMPLETED = 'completed'
STATE_CANCELED = 'canceled'
STATE_FAILED = 'failed'
ACTIVE_STATES = [ STATE_QUEUED, STATE_CREATED, STATE_BUILDING ]
- INACTIVE_STATES = [STATE_COMPLETE, STATE_FAILED, STATE_CANCELED]
+ INACTIVE_STATES = [STATE_COMPLETED, STATE_FAILED, STATE_CANCELED]
def generate_uuid
self.uuid ||= "image-#{self.template_id}-#{Time.now.to_f.to_s}"
@@ -78,7 +78,7 @@ class Image < ActiveRecord::Base
# TODO: for now when build is finished we call upload automatically for all providers
def after_update
- if self.status_changed? and self.status == STATE_COMPLETE
+ if self.status_changed? and self.status == STATE_COMPLETED
# TODO: use after_commit callback in rails 3 - it's better to have it outside
# update transaction
begin
@@ -150,7 +150,7 @@ class Image < ActiveRecord::Base
image = Image.new(
:name => raw_image.name,
- :status => 'complete',
+ :status => STATE_COMPLETED,
:provider_type_id => account.provider.provider_type_id,
:template_id => template.id
)
@@ -160,7 +160,7 @@ class Image < ActiveRecord::Base
:image_id => image.id,
:provider_id => account.provider.id,
:provider_image_key => image_id,
- :status => 'complete'
+ :status => STATE_COMPLETED
)
rep.save!
diff --git a/src/app/models/provider_image.rb b/src/app/models/provider_image.rb
index 81d7be1..67390dd 100644
--- a/src/app/models/provider_image.rb
+++ b/src/app/models/provider_image.rb
@@ -24,15 +24,15 @@ class ProviderImage < ActiveRecord::Base
validates_uniqueness_of :image_id, :scope => :provider_id
STATE_QUEUED = 'queued'
- STATE_COMPLETE = 'complete'
+ STATE_COMPLETED = 'completed'
STATE_CANCELED = 'canceled'
STATE_FAILED = 'failed'
ACTIVE_STATES = [ STATE_QUEUED ]
- INACTIVE_STATES = [STATE_COMPLETE, STATE_FAILED, STATE_CANCELED]
+ INACTIVE_STATES = [STATE_COMPLETED, STATE_FAILED, STATE_CANCELED]
def after_update
- if self.status_changed? and self.status == STATE_COMPLETE
+ if self.status_changed? and self.status == STATE_COMPLETED
begin
invoke_sync
rescue => e
diff --git a/src/db/migrate/20110302120000_add_status_to_provider_image.rb
b/src/db/migrate/20110302120000_add_status_to_provider_image.rb
index 7a54db1..f5f9c5c 100644
--- a/src/db/migrate/20110302120000_add_status_to_provider_image.rb
+++ b/src/db/migrate/20110302120000_add_status_to_provider_image.rb
@@ -3,7 +3,7 @@ class AddStatusToProviderImage < ActiveRecord::Migration
add_column :provider_images, :status, :string
ProviderImage.all.each do |image|
if image.uploaded
- image.status = "complete"
+ image.status = 'completed'
else
image.status = "queued"
end
@@ -17,7 +17,7 @@ class AddStatusToProviderImage < ActiveRecord::Migration
add_column :provider_images, :uploaded, :boolean
add_column :provider_images, :registered, :boolean
ProviderImage.all.each do |image|
- if image.status == "complete"
+ if image.status == 'completed'
image.uploaded = true
image.registered = true
else
diff --git a/src/features/step_definitions/template_steps.rb
b/src/features/step_definitions/template_steps.rb
index 479d234..3b479f1 100644
--- a/src/features/step_definitions/template_steps.rb
+++ b/src/features/step_definitions/template_steps.rb
@@ -97,7 +97,7 @@ Given /^there is Amazon AWS provider account$/ do
end
Given /^there is Amazon AWS build for this template$/ do
- image = Factory.create(:image, :template => @template, :status =>
Image::STATE_COMPLETE)
+ image = Factory.create(:image, :template => @template, :status =>
Image::STATE_COMPLETED)
Factory.create(:ec2_provider_image, :image => image)
end
diff --git a/src/spec/factories/provider_image.rb b/src/spec/factories/provider_image.rb
index 42053e8..06c5645 100644
--- a/src/spec/factories/provider_image.rb
+++ b/src/spec/factories/provider_image.rb
@@ -2,7 +2,7 @@ Factory.define :provider_image do |ri|
ri.association :image
ri.association :provider
ri.sequence(:provider_image_key) { |n| "provider_image_key#(n)" }
- ri.status "complete"
+ ri.status "completed"
ri.association :icicle
end
--
1.7.4