1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

fix testing assets with rails 5

This commit is contained in:
Sylvain 2020-04-01 12:51:46 +02:00
parent 705bedc25c
commit 0b81f957ef
2 changed files with 14 additions and 3 deletions

View File

@ -94,6 +94,17 @@ module ApplicationHelper
res
end
##
# check if the provided asset file is available
# @see https://github.com/rails/sprockets-rails/issues/298
#
def asset_available?(logical_path)
if Rails.configuration.assets.compile
Rails.application.precompiled_assets.include? logical_path
else
Rails.application.assets_manifest.assets[logical_path].present?
end
end
private

View File

@ -143,7 +143,7 @@
<script type="text/javascript">MessageFormat.locale.ach=function(n){return n===0||n===1?"one":"other"};</script>
<% end %>
<!-- if required locale does not exist, use the default "en" -->
<% if Rails.application.assets_manifest.find("moment/locale/#{Rails.application.secrets.moment_locale}.js").first %>
<% if asset_available?("moment/locale/#{Rails.application.secrets.moment_locale}.js") %>
<script type="text/javascript" src="<%= asset_path "moment/locale/#{Rails.application.secrets.moment_locale}.js" %>"></script>
<%
elsif Rails.application.secrets.moment_locale != 'en'
@ -151,7 +151,7 @@
end
%>
<!-- if required locale does not exist, use the default "en-US" -->
<% if Rails.application.assets_manifest.find("summernote/lang/summernote-#{Rails.application.secrets.summernote_locale}.js").first %>
<% if asset_available?("summernote/lang/summernote-#{Rails.application.secrets.summernote_locale}.js") %>
<script type="text/javascript" src="<%= asset_path "summernote/lang/summernote-#{Rails.application.secrets.summernote_locale}.js" %>"></script>
<%
elsif Rails.application.secrets.summernote_locale != 'en-US'
@ -159,7 +159,7 @@
end
%>
<!-- if required locale does not exist, use the default "en" -->
<% if Rails.application.assets_manifest.find("fullcalendar/dist/lang/#{Rails.application.secrets.fullcalendar_locale}.js").first %>
<% if asset_available?("fullcalendar/dist/lang/#{Rails.application.secrets.fullcalendar_locale}.js") %>
<script type="text/javascript" src="<%= asset_path "fullcalendar/dist/lang/#{Rails.application.secrets.fullcalendar_locale}.js" %>"></script>
<%
elsif Rails.application.secrets.fullcalendar_locale != 'en'