module ThoughtBot::Shoulda::Controller::HTML::ClassMethods

def make_destroy_html_tests(res)

def make_destroy_html_tests(res)
  context "on DELETE to #{controller_name_from_class}#destroy" do
    setup do
      @record = get_existing_record(res)
      parent_params = make_parent_params(res, @record)
      delete :destroy, parent_params.merge({ res.identifier => @record.to_param })
    end
    if res.denied.actions.include?(:destroy)
      should_redirect_to res.denied.redirect
      should_set_the_flash_to res.denied.flash

      should "not destroy record" do
        assert_nothing_raised { assert @record.reload }
      end
    else
      should_set_the_flash_to res.destroy.flash
      if res.destroy.redirect.is_a? Symbol
        should_respond_with res.destroy.redirect
      else
        should_redirect_to res.destroy.redirect
      end
      should "destroy record" do
        assert_raises(::ActiveRecord::RecordNotFound, "@#{res.object} was not destroyed.") do
          @record.reload
        end
      end
    end
  end
end