resources_controller_spec.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:
Ajax
开发平台:
Others
- require File.dirname(__FILE__) + '/../../spec_helper'
- describe Admin::ResourcesController do
- before do
- @request.session = { :user => users(:tobi).id }
- end
- it "test_index" do
- get :index
- assert_response :success
- assert_template 'index'
- assert_template_has 'resources'
- assert_not_nil assigns(:resources)
- end
- it "test_images" do
- get :images
- assert_response :success
- assert_template 'images'
- assert_template_has 'resources'
- assert_not_nil assigns(:resources)
- end
- it "test_destroy_image" do
- res_id = resources(:resource1).id
- assert_not_nil Resource.find(res_id)
- get :destroy, :id => res_id
- assert_response :success
- assert_template 'destroy'
- assert_not_nil assigns(:file)
- post :destroy, :id => res_id
- response.should redirect_to(:action => 'images')
- end
- it "test_destroy_regular_file" do
- res_id = resources(:resource3).id
- assert_not_nil Resource.find(res_id)
- get :destroy, :id => res_id
- assert_response :success
- assert_template 'destroy'
- assert_not_nil assigns(:file)
- post :destroy, :id => res_id
- response.should redirect_to(:action => 'index')
- end
- it "test_upload" do
- # unsure how to test upload constructs :'(
- end
- end