ruby 用于检查rails_admin实现中的自定义操作的集成测试

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 用于检查rails_admin实现中的自定义操作的集成测试相关的知识,希望对你有一定的参考价值。

require 'test_helper'

class RailsadminFlowsTest < ActionDispatch::IntegrationTest
  include Warden::Test::Helpers

  test "login as admin" do
    login_as_admin
    get "/admin"
    assert_response :success

  end

  test "magic asset admin functions" do
    login_as_admin

    magic_asset = magic_assets(:magic_assets_001)

    get "/admin/magic_asset/#{magic_asset.id}"
    assert_response :success

    get "/admin/magic_asset/#{magic_asset.id}/edit"
    assert_response :success

    get "/admin/magic_asset/#{magic_asset.id}/refxmanindex"
    assert_response :redirect
    assert_equal 'translation missing: en.restarted_refx_index_job', flash[:success]
  end

  test "event_handler admin functions" do
    login_as_admin
    event_handler = event_handlers(:event_handlers_001)

    get "/admin/event_handler/#{event_handler.id}"
    assert_response :success

    get "/admin/event_handler/#{event_handler.id}/edit"
    assert_response :success

    get "/admin/event_handler/#{event_handler.id}/configurehandler"
    assert_response :success

    post_via_redirect "/admin/event_handler/#{event_handler.id}/configurehandler"
    assert_response :success
  end

  test "work admin functions" do
    login_as_admin
    work = works(:works_001)

    get "/admin/work/#{work.id}"
    assert_response :success

    get "/admin/work/#{work.id}/edit"
    assert_response :success
  end

  private

  def login_as_admin
    Warden.test_mode!

    user = users(:users_001)
    login_as(user, :scope => :user)
  end
end

以上是关于ruby 用于检查rails_admin实现中的自定义操作的集成测试的主要内容,如果未能解决你的问题,请参考以下文章

用于检查应用程序中有多少行代码的 Ruby 脚本

ruby 用于检查Codeship状态的简单Ruby脚本

Pundit gem 错误类覆盖我在 ruby​​ 中的自定义错误类

安装 rails_admin 会导致 SafeYAML 警告

Rails 4 的 Rails_admin 批量分配错误

用于检查网站是不是具有搜索引擎友好 URL 的 Ruby 代码