0

I upgraded my Rails Application from 4.2 -> 5.0.0.1.

Other TESTS works fine (e.g. Model, Helper, Feature), but havinf trouble with my Controller Test.

I have read about Keyword arguments in controller & integration tests in Rails 5. So I changed the code structure as given below...

ActionView::Template::Error: nil is not a valid asset source

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

But I got new error with ActionView.

Is there anyone encountered and fixed the same issue, please help!

Thank you!

aldrien.h
  • 3,437
  • 2
  • 30
  • 52

1 Answers1

0

You may want to add some logtrace, probably it hints you where it went wrong.

May it be that the main_logo-fixture doesn't have an image? Since Rails 5 image_tag raises this error when given an nil-value, see also: Rails, "nil is not a valid asset source" for a particular image_tag (Carrierwave)

Besides that, typically the new scaffolded code would look as follows:

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
Community
  • 1
  • 1
murb
  • 1,736
  • 21
  • 31