I am using activeadmin on my Rails project and I would like to know how to make test on it. I looked over on internet but there is no documentation about it. I have a settings resource, and I disabled the possibility to create a new one or to delete it.
I would like to know how to test these routes doesn’t exists or another way to be sure it can’t be accessible. In my actual though I was trying to assert this page to be a 404 but the test seems to throw this error (which is what I tried to test !!!): ActionController::UrlGenerationError: No route matches {:action=>"new", :controller=>"admin/settings"}
I precise I DON’T USE RSPEC but MINITEST from Rails.
Thanks for your help !
My activeadmin file:
ActiveAdmin.register Setting do
actions :all, except: [:new, :destroy]
…
end
My tests:
require 'test_helper'
class Admin::SettingsControllerTest < ActionController::TestCase
include Devise::TestHelpers
setup :initialize_settings
test 'should throw 404 if trying to access new action' do
get :new
assert_response 404
end
def initialize_settings
sign_in users(:one)
end
end
My project:
- Rails 4.2
- Ruby 2.2.0
- Minitest (NOT RSPEC)
Aucun commentaire:
Enregistrer un commentaire