2020-05-04 02:10:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DesignManagementTestHelpers
|
2020-05-28 17:08:22 -04:00
|
|
|
def enable_design_management(enabled = true)
|
2020-05-04 02:10:10 -04:00
|
|
|
stub_lfs_setting(enabled: enabled)
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_designs(*designs)
|
|
|
|
act_on_designs(designs) { ::DesignManagement::Action.deletion }
|
|
|
|
end
|
|
|
|
|
|
|
|
def restore_designs(*designs)
|
|
|
|
act_on_designs(designs) { ::DesignManagement::Action.creation }
|
|
|
|
end
|
|
|
|
|
|
|
|
def modify_designs(*designs)
|
|
|
|
act_on_designs(designs) { ::DesignManagement::Action.modification }
|
|
|
|
end
|
|
|
|
|
|
|
|
def path_for_design(design)
|
|
|
|
path_options = { vueroute: design.filename }
|
|
|
|
Gitlab::Routing.url_helpers.designs_project_issue_path(design.project, design.issue, path_options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def url_for_design(design)
|
|
|
|
path_options = { vueroute: design.filename }
|
|
|
|
Gitlab::Routing.url_helpers.designs_project_issue_url(design.project, design.issue, path_options)
|
|
|
|
end
|
|
|
|
|
|
|
|
def url_for_designs(issue)
|
|
|
|
Gitlab::Routing.url_helpers.designs_project_issue_url(issue.project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def act_on_designs(designs, &block)
|
|
|
|
issue = designs.first.issue
|
2020-08-13 14:10:36 -04:00
|
|
|
version = build(:design_version, :empty, issue: issue).tap { |v| v.save!(validate: false) }
|
2020-05-04 02:10:10 -04:00
|
|
|
designs.each do |d|
|
2020-08-13 14:10:36 -04:00
|
|
|
yield.create!(design: d, version: version)
|
2020-05-04 02:10:10 -04:00
|
|
|
end
|
|
|
|
version
|
|
|
|
end
|
|
|
|
end
|