diff --git a/spec/controllers/miq_policy_controller_spec.rb b/spec/controllers/miq_policy_controller_spec.rb index d35890dd4323..81fcf28a863d 100644 --- a/spec/controllers/miq_policy_controller_spec.rb +++ b/spec/controllers/miq_policy_controller_spec.rb @@ -262,6 +262,29 @@ end end + describe '#set_search_text' do + before do + controller.instance_variable_set(:@sb, sandbox) + end + + context 'clearing search text' do + let(:search) { "some_text" } + let(:sandbox) { {:active_tree => tree, :pol_search_text => {tree => search}} } + let(:tree) { :any_tree } + + before do + allow(controller).to receive(:params).and_return(:action => 'adv_search_text_clear') + controller.instance_variable_set(:@search_text, search) + end + + it 'clears search text from the Search form' do + controller.send(:set_search_text) + expect(controller.instance_variable_get(:@sb)[:pol_search_text][tree]).to be(nil) + expect(controller.instance_variable_get(:@search_text)).to be(nil) + end + end + end + describe 'x_button' do before do ApplicationController.handle_exceptions = true