Я сейчас занимаюсь обновлением проекта Ruby on Rails 3 до Ruby on Rails 4.0. Некоторые из моих тестов, связанных с контроллерами, терпят неудачу, потому что определенные c файлы не могут быть найдены при рендеринге шаблонов во время тестов:
ActionView::Template::Error: No such file or directory
Все эти ошибки имеют то же самое общее, что они пытаются загрузить файлы из tmp/cache
в приложении Rails. Это нормально работало под Rails 3. Требуется ли что-то конкретное c для компиляции ресурсов под Rails 4 в тестах?
# config/application.rb
# Enable the asset pipeline
config.assets.enabled = true
Вышеуказанное не перезаписывается в нашей тестовой среде, поэтому я предполагаю, что это остается ? И мы также использовали звездочки в Rails 3.
- Рельсы: 4.0
- Звездочки: 3.6
Возможно, я упустил что-то очевидное, просто могу 't find it ...
Ошибка вывода
test_0001_should show a form to upload attachments and display existing ones(AttachmentsControllerTest::#new):
ActionView::Template::Error: No such file or directory @ rb_sysopen - /root/my_app/tmp/cache/assets/test/sprockets/v3.0/m7/m7YIr0duEvKhRldOP5LjpABJF7kd9H6aT5dCMyGnOl8.cache.47262198725000.3291.4516
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:278:in `initialize'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:278:in `open'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/path_utils.rb:278:in `atomic_write'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cache/file_store.rb:107:in `set'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cache.rb:212:in `set'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cache.rb:86:in `fetch'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:56:in `file_digest'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/unloaded_asset.rb:104:in `dependency_history_key'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:304:in `fetch_asset_from_dependency_cache'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/loader.rb:44:in `load'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `yield'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/cached_environment.rb:47:in `load'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:66:in `find_asset'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/environment.rb:30:in `find_asset'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-3.7.2/lib/sprockets/base.rb:92:in `[]'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:123:in `asset_digest_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:76:in `compute_asset_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_url_helper.rb:132:in `asset_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:91:in `asset_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_url_helper.rb:234:in `javascript_path'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_tag_helper.rb:58:in `block in javascript_include_tag'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_tag_helper.rb:56:in `map'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/asset_tag_helper.rb:56:in `javascript_include_tag'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:148:in `javascript_include_tag'
/root/my_app/app/views/layouts/attachments.html.erb:2:in `block in _app_views_layouts_attachments_html_erb___457563631613762413_47262336759680'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/haml-4.0.7/lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:38:in `capture'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/haml-4.0.7/lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/helpers/capture_helper.rb:152:in `content_for'
/root/my_app/app/views/layouts/attachments.html.erb:1:in `_app_views_layouts_attachments_html_erb___457563631613762413_47262336759680'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/template.rb:143:in `block in render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `block in instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/template.rb:141:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/template_renderer.rb:17:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/renderer.rb:42:in `render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_view/renderer/renderer.rb:23:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:127:in `_render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/streaming.rb:219:in `_render_template'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:120:in `render_to_body'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:97:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rendering.rb:16:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/core_ext/benchmark.rb:12:in `ms'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.13/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:40:in `render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/base.rb:189:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rendering.rb:10:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/callbacks.rb:453:in `_run__64868443609262235__process_action__callbacks'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/callbacks.rb:80:in `run_callbacks'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/callbacks.rb:17:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/rescue.rb:29:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `block in instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/notifications.rb:159:in `instrument'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.0.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/base.rb:136:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/abstract_controller/rendering.rb:44:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:572:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:64:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/active_model_serializers-0.9.5/lib/action_controller/serialization_test_case.rb:25:in `process'
/root/my_app/vendor/bundle/ruby/2.2.0/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:472:in `get'
/root/my_app/test/functional/attachments_controller_test.rb:78:in `block (2 levels) in <class:AttachmentsControllerTest>'
EDIT Это файл, вызывающий ошибку: app/views/layouts/attachments.html.erb
<%= content_for :head do %>
<%= javascript_include_tag 'attachments' %>
<% end %>
<%= render template: "layouts/standard_bootstrap" %>
Это следующий шаблон:
<!DOCTYPE html>
%html{lang: "en"}
%head
%script
= javascript_include_tag "/javascripts/jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"
= javascript_include_tag "/javascripts/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js"
= stylesheet_link_tag "/javascripts/jquery-ui-1.9.2.custom/css/flick/jquery-ui-1.9.2.custom.min.css"
= stylesheet_link_tag 'standard'
= stylesheet_link_tag '/stylesheets/bootstrap/css/bootstrap.min.css'
= stylesheet_link_tag '/stylesheets/bootstrap/css/bootstrap-datepicker.standalone.min.css'
= javascript_include_tag "standard_bootstrap_third_party.js"
= yield :head
%body
#content
= yield
Может быть, он не находит один из файлов в шаблоне? Все указанные файлы находятся в папке /public/javascripts
.