在我的测试之前,我这样做:回报率:过滤器返回false并不停止动作形式运行
delete :destroy, :id => p.id
assert_equal "You do not have permission to delete this Object.", flash[:error]
Object.find_by_id(p.id).should_not be_nil #line 48 (reffed by console output below)
和我的前过滤器,有一个看跌期权,所以我知道结果是假的,并没有按” t请根据此页面返回
before_filter lambda { |controller|
result = controller.is_object_on_same_account_as_current_account_for_id?(
controller_name.classify.constantize,
controller.params[:id])
puts result
return if result
}, :only => [:destroy]
:http://citizen428.net/archives/846,通过过滤器限制的行动只有当过滤器返回执行。
,这里是控制台输出:
Started
false
F
Finished in 0.865708 seconds.
1) Failure:
test: .... ...
blah blah, issue is on line 48
shoulda (2.11.3) lib/shoulda/context.rb:382:in `...']:
expected: not nil
got: nil
所以......这到底是怎么回事呢?我完全无能为力。
相关代码:
破坏方法:
def destroy
@content.destroy
不是,那我只运行一个测试。
点出这是错误的代码,并提供更多的细节* *。 –
我做了,第48行。 – DerNalia