2016-11-09 36 views
0

我從4.2 - > 5.0.0.1升級了我的Rails應用程序。Rails 5 Minitest ActionView :: Template :: Error:nil不是有效的資產來源

其他試驗工作正常(如型號,助手,功能),但havinf麻煩我控制器測試

我在控制器&集成測試瞭解關鍵字參數在滑軌5.所以我改變了代碼結構如下...

::的ActionView ::模板錯誤:無不是有效的資產來源

setup do 
    @logo = plogos(:main_logo) 
end 

test "should get edit" do 
    puts @logo.id // just to check...working fine 
    get :edit, params: {id: @logo.id} 
    assert_response :success 
end 

但我得到了新的錯誤與的ActionView

有沒有人遇到和修復相同的問題,請大家幫忙!

謝謝!

回答

0

你可能想添加一些logtrace,可能會提示你出錯的地方。

可能是main_logo-fixture沒有圖像嗎?由於Rails的5 image_tag給予nil - 值時,提出了這個錯誤,也看到:Rails, "nil is not a valid asset source" for a particular image_tag (Carrierwave)

除此之外,通常是新搭建的代碼將如下所示:

require 'test_helper' 
class LogosControllerTest < ActionDispatch::IntegrationTest 
    setup do 
    @logo = plogos(:main_logo) 
    end 
    #... 
    test "should get edit" do 
    get edit_logo_url(@logo) 
    assert_response :success 
    end 
    #... 
end 
相關問題