Permalink
Browse files

show quota in relation to usage [Finishes #54137635]

  • Loading branch information...
1 parent f937c3c commit 62f82a0f3b62a22ca16fc78c9bddf344a9854be5 @zrob zrob committed Mar 6, 2014
@@ -7,7 +7,7 @@ def show
if logged_in?
instance = ServiceInstance.find(params[:id])
if can_manage_instance?(instance)
- render text: "#{ServiceInstanceUsageQuery.new(instance).execute} MB used."
+ render text: "#{ServiceInstanceUsageQuery.new(instance).execute} MB of #{QuotaEnforcer::QUOTA_IN_MB} MB used."
else
render text: 'Not Authorized'
end
@@ -2,9 +2,9 @@
require Rails.root.join('app/models/service_instance')
module QuotaEnforcer
- class << self
- QUOTA_IN_MB = Settings.services[0].plans[0].max_storage_mb.to_i rescue nil
+ QUOTA_IN_MB = Settings.services[0].plans[0].max_storage_mb.to_i rescue nil
+ class << self
def enforce!
raise 'You must specify a service and a plan' if QUOTA_IN_MB == nil
@@ -46,9 +46,12 @@
end
it 'displays the usage information for the given instance' do
+ quota = Settings.services[0].plans[0].max_storage_mb.to_i
+
get :show, id: 'abc-123'
+
expect(response.status).to eql(200)
- expect(response.body).to match(/10\.3 MB used/)
+ expect(response.body).to match(/10\.3 MB of #{quota} MB used./)
expect(query).to have_received(:execute).once
end

0 comments on commit 62f82a0

Please sign in to comment.