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