Permalink
Browse files

Update the app version when memory changes

[finishes #43524631]

Change-Id: I3b9fbd1ff376a3467a146e071e8110ab7b26db1e
  • Loading branch information...
1 parent 5c07b49 commit c8b9bdcc620ac14e7e629c0b3511b052ceb48277 Nate Clark committed Feb 1, 2013
Showing with 25 additions and 20 deletions.
  1. +1 −1 config/cloud_controller.yml
  2. +1 −1 lib/cloud_controller/models/app.rb
  3. +23 −18 spec/models/app_spec.rb
@@ -70,7 +70,7 @@ quota_definitions:
paid:
non_basic_services_allowed: true
total_services: 500
- memory_limit: 204800 # 20 GB
+ memory_limit: 204800 # 200 GB
default_quota_definition: free
@@ -92,7 +92,7 @@ def before_save
# We might start populating this with the vcap request guid of an api
# request.
- if column_changed?(:state) && started?
+ if (column_changed?(:state) || column_changed?(:memory)) && started?
self.version = SecureRandom.uuid if !column_changed?(:version)
end
@@ -338,18 +338,9 @@ module VCAP::CloudController
app.version.should_not be_nil
end
- it "should not update the version when changing :memory" do
- orig_version = app.version
- app.memory = 1024
- app.save
- app.version.should == orig_version
- end
-
it "should update the version when changing :state" do
- orig_version = app.version
app.state = "STARTED"
- app.save
- app.version.should_not == orig_version
+ expect { app.save }.to change(app, :version)
end
it "should not update the version if the caller set it" do
@@ -359,16 +350,30 @@ module VCAP::CloudController
app.version.should == "my-version"
end
- it "should not update the version on update of :memory" do
- orig_version = app.version
- app.update(:memory => 999)
- app.version.should == orig_version
+ it "should update the version on update of :state" do
+ expect { app.update(:state => "STARTED") }.to change(app, :version)
end
- it "should update the version on update of :state" do
- orig_version = app.version
- app.update(:state => "STARTED")
- app.version.should_not == orig_version
+ context "for a started app" do
+ before { app.update(:state => "STARTED") }
+
+ it "should update the version when changing :memory" do
+ app.memory = 1024
+ expect { app.save }.to change(app, :version)
+ end
+
+ it "should update the version on update of :memory" do
+ expect { app.update(:memory => 999) }.to change(app, :version)
+ end
+
+ it "should not update the version when changing :instances" do
+ app.instances = 8
+ expect { app.save }.to_not change(app, :version)
+ end
+
+ it "should not update the version on update of :instances" do
+ expect { app.update(:instances => 8) }.to_not change(app, :version)
+ end
end
end

0 comments on commit c8b9bdc

Please sign in to comment.