vendredi 10 juillet 2020

How do I fix ActionController::MissingExactTemplate: EventsController#index is missing a template for request formats: text/html

I am fixing some tests and the first line of the following test gives me this error ActionController::MissingExactTemplate: EventsController#index is missing a template for request formats: text/html.

test "#index should respond to the correct format" do
    get :index, params: {id: @event.id, format: :html} #<-- this line causes problems
    assert_response :success 

    get :index, params: {id: @event.id, format: :json}
    assert_response :success 
end

I believe the error refers to the following method in the controllers.

    def index
       @events = Event.upcoming.recent
       respond_to do |format|
         format.html # index.html.erb
         format.json { render json: @events }
       end
    end

I am starting to consider that the line is useless but I am still unsure.

Aucun commentaire:

Enregistrer un commentaire