From f774ff15499b2a9a55ae2e501ecf09190a21ed9c Mon Sep 17 00:00:00 2001 From: Hilda Stastna Date: Tue, 10 Apr 2018 17:55:51 +0200 Subject: [PATCH] Add spec test to check clearing @search_text variable Add spec test to check the variable for Control -> Explorer screens, when clearing search text from the Search form by search clear button. --- .../controllers/miq_policy_controller_spec.rb | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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