|
154 | 154 | expect(assigns(:flash_array)).to be_nil
|
155 | 155 | end
|
156 | 156 |
|
| 157 | + it "forces Event to check to be present for eval_method - Event threshold" do |
| 158 | + @miq_alert = FactoryBot.create( |
| 159 | + :miq_alert, |
| 160 | + :db => "Host", |
| 161 | + :options => {:notifications => {:email => {:to => ["[email protected]"]}}}, |
| 162 | + :expression => {:eval_method => 'event_threshold', :mode => "internal", :options => {:event_types => []}}, |
| 163 | + :severity => 'info' |
| 164 | + ) |
| 165 | + |
| 166 | + edit = { |
| 167 | + :new => { |
| 168 | + :expression => {:eval_method => 'event_threshold', :mode => "internal", :options => {:event_types => []}}, |
| 169 | + } |
| 170 | + } |
| 171 | + controller.instance_variable_set(:@edit, edit) |
| 172 | + controller.send(:alert_valid_record?, @miq_alert) |
| 173 | + expect(assigns(:flash_array).first[:message]).to(match("Event to Check is required")) |
| 174 | + end |
| 175 | + |
| 176 | + it "does not force Event to check to be present for eval_method - Event threshold" do |
| 177 | + @miq_alert = FactoryBot.create( |
| 178 | + :miq_alert, |
| 179 | + :db => "Host", |
| 180 | + :options => {:notifications => {:email => {:to => ["[email protected]"]}}}, |
| 181 | + :expression => {:eval_method => 'event_threshold', :mode => "internal", :options => {:event_types => ["PowerOnVM_Task_Complete"]}}, |
| 182 | + :severity => 'info' |
| 183 | + ) |
| 184 | + |
| 185 | + edit = { |
| 186 | + :new => { |
| 187 | + :expression => {:eval_method => 'event_threshold', :mode => "internal", :options => {:event_types => ["PowerOnVM_Task_Complete"]}}, |
| 188 | + } |
| 189 | + } |
| 190 | + controller.instance_variable_set(:@edit, edit) |
| 191 | + controller.send(:alert_valid_record?, @miq_alert) |
| 192 | + expect(assigns(:flash_array)).to(be_nil) |
| 193 | + end |
| 194 | + |
157 | 195 | context 'not choosing Send an E-mail option while adding new Alert' do
|
158 | 196 | let(:alert) do
|
159 | 197 | FactoryBot.create(:miq_alert,
|
|
0 commit comments