Fixes the deactivation of DAST schedule above limit
What does this MR do and why?
Currently, it's not allowing to deactivate the DAST schedule when the plan limit is reached. We want to allow the deactivation of DAST schedules in this case so that users can create another schedule if required.
Related to !68551 (merged) #335816 (closed)
Steps to test
Change the limit to 1 in the local and try to create more than one schedule for different profiles.
- update the limit to 1 using rails console:
PlanLimits.all.map {|p| p.update!(dast_profile_schedules: 1)}
- Create schedules
user = User.first # root user
project = user.projects.first # find project with dast enabled
profile = Dast::Profile.find_by(project: project.id)
dast_profile = ::Dast::Profile.create!(
project: project,
name: 'tadaa1',
description: 'adad',
branch_name: profile.branch_name,
dast_site_profile: profile.dast_site_profile,
dast_scanner_profile: profile.dast_scanner_profile
)
schedule = Dast::ProfileSchedule.create!(user_id: user.id, cron: "0 0 8 */3 *", next_run_at: Time.now.in_time_zone('Melbourne'), dast_profile_id: dast_profile1.id, project_id: project.id, starts_at: Time.zone.now, timezone: 'ETC/UTC', active: true)
schedule.update!(active: false)
schedule update should not give the error.
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.