diff --git a/app/actions/organization_quotas_update.rb b/app/actions/organization_quotas_update.rb index 0070fd942d8..229b57b642a 100644 --- a/app/actions/organization_quotas_update.rb +++ b/app/actions/organization_quotas_update.rb @@ -109,14 +109,15 @@ def self.orgs_with_unlimited_processes(quota) def self.unlimited_processes_exist_error!(orgs) named_orgs = orgs.take(MAX_ORGS_TO_LIST_ON_FAILURE).map(&:name).join("', '") - message = if orgs.size == 1 - "Org '#{named_orgs}' assigned this quota contains" - elsif orgs.size > MAX_ORGS_TO_LIST_ON_FAILURE - "Orgs '#{named_orgs}' and #{orgs.drop(MAX_ORGS_TO_LIST_ON_FAILURE).size}" \ - ' other orgs assigned this quota contain' - else - "Orgs '#{named_orgs}' assigned this quota contain" - end + ' apps running with an unlimited log rate limit.' + message = 'This quota is applied to ' + + if orgs.size == 1 + "org '#{named_orgs}' which contains" + elsif orgs.size > MAX_ORGS_TO_LIST_ON_FAILURE + "orgs '#{named_orgs}' and #{orgs.drop(MAX_ORGS_TO_LIST_ON_FAILURE).size}" \ + ' other orgs which contain' + else + "orgs '#{named_orgs}' which contain" + end + ' apps running with an unlimited log rate limit.' raise Error.new("Current usage exceeds new quota values. #{message}") end diff --git a/app/actions/space_quota_update.rb b/app/actions/space_quota_update.rb index ce7295a48a3..1b5ff6808d1 100644 --- a/app/actions/space_quota_update.rb +++ b/app/actions/space_quota_update.rb @@ -102,14 +102,15 @@ def self.spaces_with_unlimited_processes(quota) def self.unlimited_processes_exist_error!(spaces) named_spaces = spaces.take(MAX_SPACES_TO_LIST_ON_FAILURE).map(&:name).join("', '") - message = if spaces.size == 1 - "Space '#{named_spaces}' assigned this quota contains" - elsif spaces.size > MAX_SPACES_TO_LIST_ON_FAILURE - "Spaces '#{named_spaces}' and #{spaces.drop(MAX_SPACES_TO_LIST_ON_FAILURE).size}" \ - ' other spaces assigned this quota contain' - else - "Spaces '#{named_spaces}' assigned this quota contain" - end + ' apps running with an unlimited log rate limit.' + message = 'This quota is applied to ' + + if spaces.size == 1 + "space '#{named_spaces}' which contains" + elsif spaces.size > MAX_SPACES_TO_LIST_ON_FAILURE + "spaces '#{named_spaces}' and #{spaces.drop(MAX_SPACES_TO_LIST_ON_FAILURE).size}" \ + ' other spaces which contain' + else + "spaces '#{named_spaces}' which contain" + end + ' apps running with an unlimited log rate limit.' raise Error.new("Current usage exceeds new quota values. #{message}") end diff --git a/spec/request/organization_quotas_spec.rb b/spec/request/organization_quotas_spec.rb index a7727ee64c4..f77714ae301 100644 --- a/spec/request/organization_quotas_spec.rb +++ b/spec/request/organization_quotas_spec.rb @@ -473,7 +473,7 @@ module VCAP::CloudController expect(last_response).to have_status_code(422) expect(last_response).to include_error_message( 'Current usage exceeds new quota values. ' \ - "Org '#{org.name}' assigned this quota contains apps running with an unlimited log rate limit.") + "This quota is applied to org '#{org.name}' which contains apps running with an unlimited log rate limit.") end end end diff --git a/spec/request/space_quotas_spec.rb b/spec/request/space_quotas_spec.rb index 8670f2333f9..c7eab4b8b6e 100644 --- a/spec/request/space_quotas_spec.rb +++ b/spec/request/space_quotas_spec.rb @@ -269,7 +269,7 @@ module VCAP::CloudController expect(last_response).to have_status_code(422) expect(last_response).to include_error_message( - "Current usage exceeds new quota values. Space '#{space.name}' assigned this quota contains apps running with an unlimited log rate limit.") + "Current usage exceeds new quota values. This quota is applied to space '#{space.name}' which contains apps running with an unlimited log rate limit.") end end end diff --git a/spec/unit/actions/organization_quotas_update_spec.rb b/spec/unit/actions/organization_quotas_update_spec.rb index eafffeffc96..f1d1a891bc4 100644 --- a/spec/unit/actions/organization_quotas_update_spec.rb +++ b/spec/unit/actions/organization_quotas_update_spec.rb @@ -121,8 +121,8 @@ def create_orgs_with_unlimited_log_rate_process(count) it 'errors with a message telling the user the affected org' do expect do OrganizationQuotasUpdate.update(org_quota, message) - end.to raise_error(OrganizationQuotasUpdate::Error, "Current usage exceeds new quota values. Org 'org-name-1' " \ - 'assigned this quota contains apps running with an unlimited log rate limit.') + end.to raise_error(OrganizationQuotasUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to org ' \ + "'org-name-1' which contains apps running with an unlimited log rate limit.") end end context 'and they are in two orgs' do @@ -132,8 +132,8 @@ def create_orgs_with_unlimited_log_rate_process(count) it 'errors with a message telling the user the affected orgs' do expect do OrganizationQuotasUpdate.update(org_quota, message) - end.to raise_error(OrganizationQuotasUpdate::Error, "Current usage exceeds new quota values. Orgs 'org-name-1', 'org-name-2' " \ - 'assigned this quota contain apps running with an unlimited log rate limit.') + end.to raise_error(OrganizationQuotasUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to orgs ' \ + "'org-name-1', 'org-name-2' which contain apps running with an unlimited log rate limit.") end end @@ -144,8 +144,8 @@ def create_orgs_with_unlimited_log_rate_process(count) it 'errors with a message telling the user some of the affected orgs and a total count' do expect do OrganizationQuotasUpdate.update(org_quota, message) - end.to raise_error(OrganizationQuotasUpdate::Error, "Current usage exceeds new quota values. Orgs 'org-name-1', 'org-name-2' and 3 other orgs " \ - 'assigned this quota contain apps running with an unlimited log rate limit.') + end.to raise_error(OrganizationQuotasUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to orgs ' \ + "'org-name-1', 'org-name-2' and 3 other orgs which contain apps running with an unlimited log rate limit.") end end @@ -159,8 +159,8 @@ def create_orgs_with_unlimited_log_rate_process(count) it 'only names the org once in the error message' do expect do OrganizationQuotasUpdate.update(org_quota, message) - end.to raise_error(OrganizationQuotasUpdate::Error, "Current usage exceeds new quota values. Org 'org-name' assigned this quota contains apps " \ - 'running with an unlimited log rate limit.') + end.to raise_error(OrganizationQuotasUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to org ' \ + "'org-name' which contains apps running with an unlimited log rate limit.") end end end diff --git a/spec/unit/actions/space_quota_update_spec.rb b/spec/unit/actions/space_quota_update_spec.rb index 12f4dc3b768..2a8c85344b4 100644 --- a/spec/unit/actions/space_quota_update_spec.rb +++ b/spec/unit/actions/space_quota_update_spec.rb @@ -109,8 +109,8 @@ def create_spaces_with_unlimited_log_rate_process(count) it 'errors with a message telling the user the affected space' do expect do SpaceQuotaUpdate.update(space_quota, message) - end.to raise_error(SpaceQuotaUpdate::Error, "Current usage exceeds new quota values. Space 'space-name-1' " \ - 'assigned this quota contains apps running with an unlimited log rate limit.') + end.to raise_error(SpaceQuotaUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to space ' \ + "'space-name-1' which contains apps running with an unlimited log rate limit.") end end @@ -121,8 +121,8 @@ def create_spaces_with_unlimited_log_rate_process(count) it 'errors with a message telling the user the affected spaces' do expect do SpaceQuotaUpdate.update(space_quota, message) - end.to raise_error(SpaceQuotaUpdate::Error, "Current usage exceeds new quota values. Spaces 'space-name-1', 'space-name-2' " \ - 'assigned this quota contain apps running with an unlimited log rate limit.') + end.to raise_error(SpaceQuotaUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to spaces ' \ + "'space-name-1', 'space-name-2' which contain apps running with an unlimited log rate limit.") end end @@ -133,8 +133,8 @@ def create_spaces_with_unlimited_log_rate_process(count) it 'errors with a message telling the user some of the affected spaces and a total count' do expect do SpaceQuotaUpdate.update(space_quota, message) - end.to raise_error(SpaceQuotaUpdate::Error, "Current usage exceeds new quota values. Spaces 'space-name-1', 'space-name-2' and 3 other spaces " \ - 'assigned this quota contain apps running with an unlimited log rate limit.') + end.to raise_error(SpaceQuotaUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to spaces ' \ + "'space-name-1', 'space-name-2' and 3 other spaces which contain apps running with an unlimited log rate limit.") end end @@ -148,8 +148,8 @@ def create_spaces_with_unlimited_log_rate_process(count) it 'only names the space once in the error message' do expect do SpaceQuotaUpdate.update(space_quota, message) - end.to raise_error(SpaceQuotaUpdate::Error, "Current usage exceeds new quota values. Space 'space-name' assigned this quota contains apps " \ - 'running with an unlimited log rate limit.') + end.to raise_error(SpaceQuotaUpdate::Error, 'Current usage exceeds new quota values. This quota is applied to space ' \ + "'space-name' which contains apps running with an unlimited log rate limit.") end end end