Skip to content

Commit 0d37cbe

Browse files
authored
Ensure specs that create models in threads are rolled back with truncation (#4146)
* Also prefix shared_examples and other RSpec methods so they don't error when using `--bisect`
1 parent 0545c0c commit 0d37cbe

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

spec/support/shared_examples/access/access_levels.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
shared_examples 'full access' do
1+
RSpec.shared_examples 'full access' do
22
it { is_expected.to allow_op_on_object :create, object }
33
it { is_expected.to allow_op_on_object :read, object }
44
it { is_expected.to allow_op_on_object :read_for_update, object }
@@ -7,7 +7,7 @@
77
it { is_expected.to allow_op_on_object :index, object.class }
88
end
99

10-
shared_examples 'read only access' do
10+
RSpec.shared_examples 'read only access' do
1111
it { is_expected.not_to allow_op_on_object :create, object }
1212
it { is_expected.to allow_op_on_object :read, object }
1313
it { is_expected.not_to allow_op_on_object :read_for_update, object }
@@ -17,7 +17,7 @@
1717
it { is_expected.to allow_op_on_object :index, object.class }
1818
end
1919

20-
shared_examples 'no access' do
20+
RSpec.shared_examples 'no access' do
2121
it { is_expected.not_to allow_op_on_object :create, object }
2222
it { is_expected.not_to allow_op_on_object :read, object }
2323
it { is_expected.not_to allow_op_on_object :read_for_update, object }
@@ -29,22 +29,22 @@
2929
# override the default behavior of always allowing access to :index
3030
end
3131

32-
shared_examples 'admin full access' do
32+
RSpec.shared_examples 'admin full access' do
3333
include_context 'admin setup'
3434
it_behaves_like 'full access'
3535
end
3636

37-
shared_examples 'admin read only access' do
37+
RSpec.shared_examples 'admin read only access' do
3838
include_context 'admin read only setup'
3939
it_behaves_like 'read only access'
4040
end
4141

42-
shared_examples 'global auditor access' do
42+
RSpec.shared_examples 'global auditor access' do
4343
include_context 'global auditor setup'
4444
it_behaves_like 'read only access'
4545
end
4646

47-
shared_context 'admin setup' do
47+
RSpec.shared_context 'admin setup' do
4848
before do
4949
token = { 'scope' => [VCAP::CloudController::Roles::CLOUD_CONTROLLER_ADMIN_SCOPE] }
5050
VCAP::CloudController::SecurityContext.set(user, token)
@@ -53,7 +53,7 @@
5353
after { VCAP::CloudController::SecurityContext.clear }
5454
end
5555

56-
shared_context 'global auditor setup' do
56+
RSpec.shared_context 'global auditor setup' do
5757
before do
5858
token = { 'scope' => [VCAP::CloudController::Roles::CLOUD_CONTROLLER_GLOBAL_AUDITOR] }
5959
VCAP::CloudController::SecurityContext.set(user, token)
@@ -62,7 +62,7 @@
6262
after { VCAP::CloudController::SecurityContext.clear }
6363
end
6464

65-
shared_context 'admin read only setup' do
65+
RSpec.shared_context 'admin read only setup' do
6666
before do
6767
token = { 'scope' => [VCAP::CloudController::Roles::CLOUD_CONTROLLER_ADMIN_READ_ONLY_SCOPE] }
6868
VCAP::CloudController::SecurityContext.set(user, token)

spec/support/shared_examples/controllers/permissions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
shared_context 'permissions' do
1+
RSpec.shared_context 'permissions' do
22
before do
33
@org_a = VCAP::CloudController::Organization.make
44
@org_a_manager = VCAP::CloudController::User.make
@@ -44,7 +44,7 @@
4444
end
4545
end
4646

47-
shared_examples 'permission enumeration' do |perm_name, opts|
47+
RSpec.shared_examples 'permission enumeration' do |perm_name, opts|
4848
name = opts[:name]
4949
path = opts[:path]
5050
expected = opts[:enumerate]

spec/support/shared_examples/controllers/resource_pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
shared_context 'resource pool' do
1+
RSpec.shared_context 'resource pool' do
22
before(:all) do
33
@max_file_size = 1098 # this is arbitrary
44
num_dirs = 3

spec/support/shared_examples/models/encrypted_attribute.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'cloud_controller/encryptor'
22

33
module VCAP::CloudController
4-
shared_examples 'a model with an encrypted attribute' do
4+
RSpec.shared_examples 'a model with an encrypted attribute' do
55
before do
66
allow(Encryptor).to receive(:database_encryption_keys).
77
and_return({ Encryptor.current_encryption_key_label.to_sym => 'correct-key' })

spec/support/shared_examples/models/stager_interface.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module VCAP::CloudController
2-
shared_examples 'a stager' do
2+
RSpec.shared_examples 'a stager' do
33
it 'defines #stage' do
44
expect(subject).to respond_to(:stage)
55
end

spec/unit/middleware/service_broker_rate_limiter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module CloudFoundry
44
module Middleware
5-
RSpec.describe ServiceBrokerRateLimiter do
5+
RSpec.describe ServiceBrokerRateLimiter, isolation: :truncation do
66
let(:app) { double(:app) }
77
let(:logger) { double }
88
let(:instance) { VCAP::CloudController::Service.make(instances_retrievable: true) }

0 commit comments

Comments
 (0)