gitlab-org--gitlab-foss/spec/support/helpers/assets_helpers.rb
Alexis Reigel 29598f6e6d
find assets in test for CI and local test
Due to the change in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14583/diffs we
can't use the same method to access assets in a CI and the local test
environment anymore.
2018-06-06 11:28:13 +02:00

15 lines
524 B
Ruby

module AssetsHelpers
# In a CI environment the assets are not compiled, as there is a CI job
# `compile-assets` that compiles them in the prepare stage for all following
# specs.
# Locally the assets are precompiled dynamically.
#
# Sprockets doesn't provide one method to access an asset for both cases.
def find_asset(asset_name)
if ENV['CI']
Sprockets::Railtie.build_environment(Rails.application, true)[asset_name]
else
Rails.application.assets.find_asset(asset_name)
end
end
end