2017-05-09 299 views
1

我想运行一些水豚/ Poltergeist RSPEC集成测试。Paperclip ActionController :: RoutingError:没有路由匹配[GET]

在我的测试中,我创建了一个图像,并用Paperclip“上传”它。

型号:Platform::ContentImage

has_attached_file :attachment, { 
    styles: lambda { |a| a.instance.styles_by_image_type}, 
    processors: [:thumbnail, :paperclip_optimizer], 
    paperclip_optimizer: { 
     nice: 19, 
     jpegoptim: { allow_lossy: true, strip: :all, max_quality: 75 }, 
     jpegrecompress: {allow_lossy: true, quality: 3}, 
     jpegtran: {progressive: true}, 
     optipng: { level: 2 }, 
     pngout: false 
    }, 
    path: "#{'public/' if Rails.env.test?}content_image/:id/:style/:basename.:extension", 
    convert_options: { :all => '-auto-orient +profile "exif"' }, 
    s3_headers: { 'Cache-Control' => 'max-age=31536000'} 
    } 

在我application.rb测试环境

config.paperclip_defaults = { 
     url: "/public/:class/:id/:style/:basename.:extension" 
     } 

我的错误返回

ActionController::RoutingError: 
     No route matches [GET] "/system/platform/content_images/attachments/000/000/001/thumb/blue_night_swatch.jpg" 

我想显示图像,但我做不到似乎正确地配置了URL。由于我覆盖了Platform::ContentImage模型中的默认值,因此它成功创建了目录public/content_image,但是在测试期间,我似乎无法“解调”类名。我可以在Platform::ContentImage定义中指定URL,但仅限于测试环境?

+0

这是否对你的工作,当你在开发试试? – Jeremie

+0

@Jeremie是的,它确实有用,但不是在测试过程中 – reid

回答

-1

把表格上此消息,并看到它为什么不节省:

<% if @portifolio.errors.any? %> 
<div id="error_explanation"> 
<h2><%= pluralize(@portifolio.errors.count, "error") %> 
prohibited this portifolio from being saved:</h2> 
<ul> 
<% @portifolio.errors.full_messages.each do |message| %> 
    <li><%= message %></li> 
<% end %> 
</ul> 
</div> 
<% end %> 
相关问题