Commit b2596805 authored by atiwari71's avatar atiwari71

Fixes the deactivation of DAST schedule above limit

     DAST schedule should be deactivated above limit
parent ab79e34a
......@@ -88,6 +88,8 @@ class Dast::ProfileSchedule < ApplicationRecord
# The will_save_change_to_active? returns false when the new object is created
# with the same value as the db defaults. That's why we need to this indirect to call validate_plan_limit_not_exceeded.
def validate_plan_limit_not_exceeded_while_activating
return if active == false
validate_plan_limit_not_exceeded
end
end
......@@ -97,6 +97,13 @@ RSpec.describe Dast::ProfileSchedule, type: :model do
expect { inactive_schedule.save! }.to raise_error(ActiveRecord::RecordInvalid).and not_change { described_class.count }
expect(inactive_schedule.errors[:base]).to contain_exactly("Maximum number of #{inactive_schedule.class.limit_name.humanize(capitalize: false)} (1) exceeded")
end
it 'allows the schedule to be deactivated', :aggregate_failures do
active_schedule = subject.dup
expect { active_schedule.save! }.to change { described_class.count }
expect(active_schedule.update(active: false)).to be true
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment