5

我有一个 Rails 控制器,它发送具有不同 Content-Type 的文件

Exel-File 示例,控制器设置 Content-Type ="application/excel"

这是 RSpec 测试:

describe "GET getfile" do
  it "Excel File" do
    controller.stub(:render)
    controller.should_receive(:send_file)
    get :getfile, :name => 'test+xls'
    controller.response.header.should == '???'
  end
end

测试的答案是:

1) ExportController GET getfile Excel File
   Failure/Error: controller.response.header.should == ''
     expected: ""
          got: {"Content-Type"=>"text/html; charset=utf-8"} (using ==)
     Diff:
     @@ -1,2 +1,2 @@
     -""
     +"Content-Type" => "text/html; charset=utf-8"
4

1 回答 1

0

If you're willing (or already using) the thoughtbot shoulda gem, paperclip hooks into it

https://github.com/thoughtbot/paperclip/blob/master/shoulda_macros/paperclip.rb

and has an s3 upload method.

于 2014-02-19T14:21:09.753 回答