Commit 7663e2bb authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'fix-dast-deactivation' into 'master'

Fixes the deactivation  of DAST schedule above limit

See merge request gitlab-org/gitlab!70371
parents a50a945f b2596805
...@@ -88,6 +88,8 @@ class Dast::ProfileSchedule < ApplicationRecord ...@@ -88,6 +88,8 @@ class Dast::ProfileSchedule < ApplicationRecord
# The will_save_change_to_active? returns false when the new object is created # 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. # 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 def validate_plan_limit_not_exceeded_while_activating
return if active == false
validate_plan_limit_not_exceeded validate_plan_limit_not_exceeded
end end
end end
...@@ -97,6 +97,13 @@ RSpec.describe Dast::ProfileSchedule, type: :model do ...@@ -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.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") expect(inactive_schedule.errors[:base]).to contain_exactly("Maximum number of #{inactive_schedule.class.limit_name.humanize(capitalize: false)} (1) exceeded")
end 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 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