El jueves, 23 de marzo de 2017 2:21:22 (CET) CCH escribió:
> Hi Sergion
> 
> Test Failed at:
> Minitest::UnexpectedError: NoMethodError: undefined method `level' for
> nil:NilClass
>     app/models/fas4gst4sql.rb:11:in `authorized_for_delete?'
>     test/controllers/fas4gst4sqls_controller_test.rb:43:in `block (2
> levels) in <class:Fas4gst4sqlsControllerTest>'
>     test/controllers/fas4gst4sqls_controller_test.rb:42:in `block in
> <class:Fas4gst4sqlsControllerTest>'
> app/models/fas4gst4sql.rb:11:in `authorized_for_delete?'
> test/controllers/fas4gst4sqls_controller_test.rb:43:in `block (2 levels) in
> <class:Fas4gst4sqlsControllerTest>'
> test/controllers/fas4gst4sqls_controller_test.rb:42:in `block in
> <class:Fas4gst4sqlsControllerTest>'
> 
> 
> 
> *class Fas4gst4sql < ApplicationRecord*belongs_to :priority
> belongs_to :rootcause
> validates :feature, presence:true, uniqueness:true
> 
> # active_scaffold security feature
> def authorized_for_delete?
> 
> *     if current_user.level > 0*    false
>   else
>        true
>   end
> 
> end
> 
> 
> class Fas4gst4sqlsControllerTest < ActionDispatch::IntegrationTest
>   setup do
>     @fas4gst4sql = fas4gst4sqls(:one)
>   end
> 
> 
> test "should destroy fas4gst4sql" do
>   assert_difference('Fas4gst4sql.count', -1) do
>     delete fas4gst4sql_url(@fas4gst4sql)
>   end
> 
> 
> How can I make the test pass ?

I guess you have to add something to integration test setup about login with 
any user. Also, people usually adds some before_action checking user is logged 
in for controllers which require login, in that case authorized_for_delete? 
wouldn't be called.

How to do it depends how you manage authentication, custom code or some gems 
such as devise

That's beyond 

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.

Reply via email to