Hello, there is such a code in the controller:
before_action :set_question, only: [:show, :edit, :update, :destroy, :upvote,:downvote] def show end def update if @question.update(question_params) flash[:success] = "Question was successufly updated" redirect_to question_path(@question) else render 'edit' end end # DELETE /questions/1 # DELETE /questions/1.json def destroy @question.destroy flash[:success] = "Question was successfully destroyed." redirect_to questions_url end def set_question @question = Question.where(id: params[:id]).first unless @question render status: 404 end end And such a test
def self.it_renders_404_page_when_question_is_not_found(*actions) actions.each do |a| it "#{a} renders 404 page when questions is not found" do verb = if a == :update "PATCH" elsif a == :destroy "DELETE" else "GET" end process a, verb, {id: 0} expect(response).to have_http_status(404) end end end it_renders_404_page_when_question_is_not_found :show, :edit, :update, :destroy On the show method, everything is fine, but on update and destroy there is such an error:
Failure/Error: render status: 404 ActionView::MissingTemplate: Missing template questions/destroy, application/destroy with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :slim, :jbuilder]}. Searched in: * "/home/max/Desktop/stack/app/views" * "/home/max/.rvm/gems/ruby-2.2.2/gems/twitter-bootstrap-rails-3.2.2/app/views" * "/home/max/.rvm/gems/ruby-2.2.2/gems/devise-3.5.5/app/views"