Skip to content

Commit

Permalink
Add spec test to check clearing @search_text variable
Browse files Browse the repository at this point in the history
Add spec test to check the variable for Control -> Explorer screens,
when clearing search text from the Search form by search clear button.
  • Loading branch information
Hilda Stastna committed Apr 10, 2018
1 parent 6f606ad commit f774ff1
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/controllers/miq_policy_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f774ff1

Please sign in to comment.