test/unit/cleaner_test.rb in foreman-tasks-6.0.3 vs test/unit/cleaner_test.rb in foreman-tasks-7.0.0

- old
+ new

@@ -131,36 +131,34 @@ end describe 'default behaviour' do it 'searches for the actions that have the cleanup_after defined' do ForemanTasks::Cleaner.stubs(:cleanup_settings => {}) - _(ForemanTasks::Cleaner.actions_with_default_cleanup[ActionWithCleanup]).must_equal '15d' + actions = ForemanTasks::Cleaner.actions_with_default_cleanup + example = actions.find { |rule| rule.klass == ActionWithCleanup } + _(example.after).must_equal '15d' end it 'searches for the actions that have the cleanup_after defined' do ForemanTasks::Cleaner.stubs(:cleanup_settings => { :actions => [{ :name => ActionWithCleanup.name, :after => '5d' }] }) - _(ForemanTasks::Cleaner.actions_with_default_cleanup[ActionWithCleanup]).must_equal '5d' + actions = ForemanTasks::Cleaner.actions_with_default_cleanup + example = actions.find { |rule| rule.klass == ActionWithCleanup } + _(example.after).must_equal '5d' end - it 'deprecates the usage of :after' do - Foreman::Deprecation.expects(:deprecation_warning) - ForemanTasks::Cleaner.any_instance.expects(:delete) - ForemanTasks::Cleaner.stubs(:cleanup_settings => - { :after => '1d' }) - ForemanTasks::Cleaner.stubs(:actions_with_default_cleanup).returns({}) - ForemanTasks::Cleaner.run({}) - end - it 'generates filters from rules properly' do - actions_with_default = { 'action1' => nil, 'action2' => nil } + actions_with_default = ForemanTasks::CompositeActionRule.new( + ForemanTasks::ActionRule.new('action1', nil), + ForemanTasks::ActionRule.new('action2', nil) + ) rules = [{ :after => nil }, { :after => '10d', :filter => 'label = something', :states => %w[stopped paused] }, { :after => '15d', :filter => 'label = something_else', :override_actions => true, :states => 'all' }] ForemanTasks::Cleaner.stubs(:cleanup_settings).returns(:rules => rules) r1, r2 = ForemanTasks::Cleaner.actions_by_rules actions_with_default - _(r1[:filter]).must_equal '(label !^ (action1, action2)) AND (label = something)' + _(r1[:filter]).must_equal '(NOT ((label ^ (action1, action2)))) AND (label = something)' _(r1[:states]).must_equal %w[stopped paused] _(r2[:filter]).must_equal '(label = something_else)' _(r2[:states]).must_equal [] end end