1
鉴于这种确认方法:绷工作,但不是在规格:Rails的3 + Rspec的
if (@bucket.confirmation_code == @code)
puts "OLAAA"
@bucket.toggle!(:confirmation)
@bucket.save
flash[:success] = "Successfully confirmed bucket."
redirect_to bucket_url(@bucket)
else
flash[:fail] = "Error confirming bucket."
redirect_to bucket_url(@bucket)
end
我有一个规范的测试,如果按下该键则确认属性,但即使在控制器,似乎一切正在工作(confirmation == true
),测试失败(confirmation == false
而不是true
)。
测试是:
it "should have a confirmation URL" do
@attr3 = {:email => "[email protected]", :confirmation_code => "ola123"}
post :create, :bucket => @attr3
@bucket = Bucket.last
post :confirm, :id => @bucket.id, :code => "ola123"
@bucket.save
@bucket.confirmation.should == true
end