0
我想设置一个RESTful API的重定向链接数据库。我在黄瓜里设置了很多测试,其中一个是用户在/ links /:id上执行GET操作。这应该是将用户重定向到链接。它在浏览器中工作,但我在黄瓜中设置此测试时遇到了一些麻烦。红宝石轨道︰黄瓜瓦特/水豚去applicationController on redirect_to
Given /^The link id part of the URL matches an existing entry in the links table$/ do
FactoryGirl.create(:users)
FactoryGirl.create(:links, :OWNER_USERID => Users.first.id)
Users.count.should==1
Links.count.should==1
end
When /^you use GET on link$/ do
visit link_path(Links.first.id)
end
指定的link_path送我去这个节目的方法:
def show
redir=Links.find_by_id(params[:id])
redirect_to redir.target, :status=>307
end
的问题是在这一点黄瓜失败,当部分抱怨我没有对应用程序/索引的模板。由于某种原因,它不会重定向我,而是会转到我自己站点的root_path。任何人都知道如何检查这种重定向是否真的有效?