我有一个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
Run Code Online (Sandbox Code Playgroud)
测试的答案是:
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"
Run Code Online (Sandbox Code Playgroud) 我有一个关联的应用程序,并将页面分页.
主对象"cat_list"的索引页面显示了指向"data_lists"关联的链接.索引页面也有"will_paginate"的分页
此索引页面显示包含Edit,Destroy和New链接的data_lists列表.并且cat_lists索引页面的后向链接现在为"/ cat_lists"
实现这些功能的最佳做法是什么,Back Link现在来自哪个页面?