0

Rails 仍然是新手,但我有一个问题,我正在更新两个模型enabled_rewardchild并且enabled_rewards_controller它正在注销作为current_user.

任何人都可以提供一些帮助吗?我不知道 cookie 是否发生了某些事情,或者 cookie是否在通话remember_token中被删除。update_attribute我没有任何涉及child视图的内容,所以我排除了这一点。

提前致谢

下面是enabled_rewards_controller更新方法:

def update
  @enabled_reward = EnabledReward.find(params[:id])

  if @enabled_reward.update_attributes(params[:enabled_reward])
    if @enabled_reward.redeemed
      @enabled_reward.child.update_attribute(:points,
        @enabled_reward.child.points - @enabled_reward.points)

      redirect_to @enabled_reward.child
    end
  end
end

这是 rspec 测试:

before do
  sign_in child
  visit child_path(child)
end

describe "redeeming reward" do
  before { click_button "Redeem" }

  it "should still have the child signed in" do
    should_not have_link('Sign in') # fails
  end
end

错误信息:

 Failure/Error: should_not have_link('Sign in')
   expected link "Sign in" not to return anything
 # ./spec/requests/child_pages_spec.rb:284:in `block (4 levels) 
   in <top (required)>'
4

0 回答 0