|
513 | 513 | end |
514 | 514 | end |
515 | 515 |
|
| 516 | + describe 'default stack state change warning' do |
| 517 | + let(:stack_config_file) { File.join(Paths::FIXTURES, 'config/stacks.yml') } |
| 518 | + let(:default_stack_name) { 'default-stack-name' } |
| 519 | + |
| 520 | + before do |
| 521 | + VCAP::CloudController::Stack.dataset.destroy |
| 522 | + VCAP::CloudController::Stack.configure(stack_config_file) |
| 523 | + set_current_user_as_admin |
| 524 | + end |
| 525 | + |
| 526 | + context 'when changing state on the default stack' do |
| 527 | + let!(:default_stack) { VCAP::CloudController::Stack.make(name: default_stack_name) } |
| 528 | + |
| 529 | + it 'returns a warning header with the stack name' do |
| 530 | + patch :update, params: { guid: default_stack.guid, state: 'DEPRECATED' }, as: :json |
| 531 | + |
| 532 | + expect(response).to have_http_status(:ok) |
| 533 | + expect(response).to have_warning_message("Changing state on the default stack '#{default_stack_name}' may affect new application deployments.") |
| 534 | + end |
| 535 | + end |
| 536 | + |
| 537 | + context 'when changing state on a non-default stack' do |
| 538 | + let!(:default_stack) { VCAP::CloudController::Stack.make(name: default_stack_name) } |
| 539 | + let!(:other_stack) { VCAP::CloudController::Stack.make(name: 'other-stack') } |
| 540 | + |
| 541 | + it 'does not return a warning header' do |
| 542 | + patch :update, params: { guid: other_stack.guid, state: 'DEPRECATED' }, as: :json |
| 543 | + |
| 544 | + expect(response).to have_http_status(:ok) |
| 545 | + expect(response.headers['X-Cf-Warnings']).to be_nil |
| 546 | + end |
| 547 | + end |
| 548 | + |
| 549 | + context 'when updating metadata on the default stack without changing state' do |
| 550 | + let!(:default_stack) { VCAP::CloudController::Stack.make(name: default_stack_name) } |
| 551 | + |
| 552 | + it 'does not return a warning header' do |
| 553 | + patch :update, params: { guid: default_stack.guid, metadata: { labels: { foo: 'bar' } } }, as: :json |
| 554 | + |
| 555 | + expect(response).to have_http_status(:ok) |
| 556 | + expect(response.headers['X-Cf-Warnings']).to be_nil |
| 557 | + end |
| 558 | + end |
| 559 | + end |
| 560 | + |
516 | 561 | describe 'authorization' do |
517 | 562 | it_behaves_like 'permissions endpoint' do |
518 | 563 | let(:roles_to_http_responses) do |
|
0 commit comments