|
64 | 64 | expect(last_response.headers['location']).to eq('/features/search') |
65 | 65 | end |
66 | 66 | end |
| 67 | + |
| 68 | + context 'when disable_fully_enable is false' do |
| 69 | + before { Flipper::UI.configuration.disable_fully_enable = false } |
| 70 | + after { Flipper::UI.configuration.disable_fully_enable = nil } |
| 71 | + |
| 72 | + it 'allows enabling the feature' do |
| 73 | + flipper.disable :search |
| 74 | + post 'features/search/boolean', |
| 75 | + { 'action' => 'Enable', 'authenticity_token' => token }, |
| 76 | + 'rack.session' => session |
| 77 | + expect(flipper.enabled?(:search)).to be(true) |
| 78 | + end |
| 79 | + end |
| 80 | + |
| 81 | + context 'when disable_fully_enable is true' do |
| 82 | + before { Flipper::UI.configuration.disable_fully_enable = true } |
| 83 | + after { Flipper::UI.configuration.disable_fully_enable = nil } |
| 84 | + |
| 85 | + context 'with enable' do |
| 86 | + before do |
| 87 | + flipper.disable :search |
| 88 | + post 'features/search/boolean', |
| 89 | + { 'action' => 'Enable', 'authenticity_token' => token }, |
| 90 | + 'rack.session' => session |
| 91 | + end |
| 92 | + |
| 93 | + it 'does not enable the feature' do |
| 94 | + expect(flipper.enabled?(:search)).to be(false) |
| 95 | + end |
| 96 | + |
| 97 | + it 'returns 403 status' do |
| 98 | + expect(last_response.status).to be(403) |
| 99 | + end |
| 100 | + |
| 101 | + it 'renders the default disabled message' do |
| 102 | + expect(last_response.body).to include('Fully enabling features via the UI is disabled.') |
| 103 | + end |
| 104 | + end |
| 105 | + |
| 106 | + context 'with disable' do |
| 107 | + before do |
| 108 | + flipper.enable :search |
| 109 | + post 'features/search/boolean', |
| 110 | + { 'action' => 'Disable', 'authenticity_token' => token }, |
| 111 | + 'rack.session' => session |
| 112 | + end |
| 113 | + |
| 114 | + it 'still allows disabling the feature' do |
| 115 | + expect(flipper.enabled?(:search)).to be(false) |
| 116 | + end |
| 117 | + |
| 118 | + it 'redirects back to feature' do |
| 119 | + expect(last_response.status).to be(302) |
| 120 | + expect(last_response.headers['location']).to eq('/features/search') |
| 121 | + end |
| 122 | + end |
| 123 | + end |
| 124 | + |
| 125 | + context 'when disable_fully_enable is a custom message' do |
| 126 | + before { Flipper::UI.configuration.disable_fully_enable = "Use deploy pipeline instead." } |
| 127 | + after { Flipper::UI.configuration.disable_fully_enable = nil } |
| 128 | + |
| 129 | + it 'renders the custom message on 403' do |
| 130 | + flipper.disable :search |
| 131 | + post 'features/search/boolean', |
| 132 | + { 'action' => 'Enable', 'authenticity_token' => token }, |
| 133 | + 'rack.session' => session |
| 134 | + expect(last_response.status).to be(403) |
| 135 | + expect(last_response.body).to include('Use deploy pipeline instead.') |
| 136 | + end |
| 137 | + end |
67 | 138 | end |
68 | 139 | end |
0 commit comments