I'm using Rails 4.2.5, I've written a controller test for the destroy action, an I'm using ajax call to destroy and using destroy.js.erb file. Please help me to solve the following issue to pass the test when it calls js format, I'm pasting error below.
def destroy
@status = @song.destroy
respond_to do |format|
format.js
end
end
SongsControllerTest#test_should_destroy_song:
ActionController::UnknownFormat: ActionController::UnknownFormat
app/controllers/songs_controller.rb:36:in `destroy'
songs_controller_test.rb
test "should destroy song" do
assert_difference('Song.count', -1) do
delete :destroy, id: @song
end
get :destroy, format: 'js'
end
destroy.js.erb
var element = document.getElementById("<%="song#{@song.id}" %>");
<%if @status%>
element.parentNode.parentNode.remove();
<%end%>