gpt4 book ai didi

ruby-on-rails - 预期响应为 < :redirect> but was <200>

转载 作者:行者123 更新时间:2023-12-02 02:22:09 25 4
gpt4 key购买 nike

我的 rspec 测试遇到了问题,在查看了之前的问题后我无法解决它。测试失败并出现上述错误,但代码在实践中有效,有人知道如何解决这个问题吗?

R规范:

describe "authentication of edit/update pages" do

before(:each) do
@user = Factory(:user)
end

describe "for non-signed in users" do
it "should deny access to 'edit'" do
get :edit, :id => @user
response.should redirect_to(signin_path)
end

it "should deny access to 'update'" do
put :update, :id => @user, :user => {}
response.should redirect_to(signin_path)
end
end
end

session 助手:

def deny_access
redirect_to signin_path, :notice => "Please sign in to access this page."
end

用户 Controller

class UsersController < ApplicationController
before_filter :authenticate, :only => [:edit, :update]
private
def authenticate
deny_access unless signed_in?
end
end

最佳答案

我猜你应该稍微修改一下你的代码:

def deny_access
redirect_to signin_path, :notice => "Please sign in to access this page." and return
end

关于ruby-on-rails - 预期响应为 < :redirect> but was <200>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7632905/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com