2019-07-25 01:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-17 11:47:05 -04:00
|
|
|
module WikiHelpers
|
|
|
|
extend self
|
|
|
|
|
2020-09-11 14:08:42 -04:00
|
|
|
def stub_group_wikis(enabled)
|
|
|
|
stub_licensed_features(group_wikis: enabled)
|
|
|
|
end
|
|
|
|
|
2020-02-26 13:09:24 -05:00
|
|
|
def wait_for_svg_to_be_loaded(example = nil)
|
|
|
|
# Ensure the SVG is loaded first before clicking the button
|
|
|
|
find('.svg-content .js-lazy-loaded') if example.nil? || example.metadata.key?(:js)
|
|
|
|
end
|
|
|
|
|
2020-09-29 05:09:49 -04:00
|
|
|
def upload_file_to_wiki(wiki, user, file_name)
|
|
|
|
params = {
|
2018-10-17 11:47:05 -04:00
|
|
|
file_name: file_name,
|
|
|
|
file_content: File.read(expand_fixture_path(file_name))
|
|
|
|
}
|
|
|
|
|
2020-05-13 14:08:47 -04:00
|
|
|
::Wikis::CreateAttachmentService.new(
|
2020-09-29 05:09:49 -04:00
|
|
|
container: wiki.container,
|
2020-05-13 14:08:47 -04:00
|
|
|
current_user: user,
|
2020-09-29 05:09:49 -04:00
|
|
|
params: params
|
|
|
|
).execute.dig(:result, :file_path)
|
2018-10-17 11:47:05 -04:00
|
|
|
end
|
|
|
|
end
|