blacklist_controller_test.rb

来自「用ruby on rails写的一个博客程序,还不错..ruby on rail」· RB 代码 · 共 64 行

RB
64
字号
require File.dirname(__FILE__) + '/../../test_helper'require 'admin/blacklist_controller'# Re-raise errors caught by the controller.class Admin::BlacklistController; def rescue_action(e) raise e end; endclass Admin::BlacklistControllerTest < Test::Unit::TestCase  fixtures :blacklist_patterns, :users  def setup    @controller = Admin::BlacklistController.new    @request    = ActionController::TestRequest.new    @response   = ActionController::TestResponse.new    @request.session = { :user => users(:tobi) }  end  def test_index    get :index    assert_template 'list'  end  def test_list    get :list    assert_template 'list'    assert_template_has 'blacklist_patterns'  end  def test_create    num_blacklist_patterns = BlacklistPattern.count    post :new, 'blacklist_pattern' => { }    assert_response :redirect, :action => 'list'    assert_equal num_blacklist_patterns + 1, BlacklistPattern.count  end  def test_edit    get :edit, 'id' => 1    assert_template 'edit'    assert_template_has('blacklist_pattern')    assert_valid assigns(:blacklist_pattern)  end  def test_update    post :edit, 'id' => 1    assert_response :redirect, :action => 'list'  end  def test_destroy    assert_not_nil BlacklistPattern.find(1)    get :destroy, 'id' => 1    assert_response :success    post :destroy, 'id' => 1    assert_response :redirect, :action => 'list'    assert_raise(ActiveRecord::RecordNotFound) {      blacklist_pattern = BlacklistPattern.find(1)    }  endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?