2
0
mirror of https://github.com/moebooru/moebooru synced 2025-08-23 02:17:32 +00:00
moebooru/test/controllers/admin_controller_test.rb

39 lines
1.0 KiB
Ruby
Raw Normal View History

require "test_helper"
class AdminControllerTest < ActionController::TestCase
fixtures :users
2014-08-23 16:19:01 +09:00
def setup_action_mailer
ActionMailer::Base.delivery_method = :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.deliveries = []
end
2014-08-23 16:19:01 +09:00
def test_index
2016-08-16 07:50:23 +09:00
get :index, :session => { :user_id => 1 }
assert_response :success
end
2014-08-23 16:19:01 +09:00
def test_edit_user
2016-08-16 07:50:23 +09:00
get :edit_user, :session => { :user_id => 1 }
assert_response :success
2014-08-23 16:19:01 +09:00
2016-08-16 07:50:23 +09:00
post :edit_user, :params => { :user => { :name => "admin", :level => 10 } }, :session => { :user_id => 1 }
assert_equal(10, User.find(1).level)
end
2014-08-23 16:19:01 +09:00
def test_reset_password
setup_action_mailer
2014-08-23 16:19:01 +09:00
2016-08-16 07:50:23 +09:00
get :reset_password, :params => { :user => { :name => "admin" } }, :session => { :user_id => 1 }
assert_response :success
2014-08-23 16:19:01 +09:00
admin = User.find(1)
old_password_hash = admin.password_hash
2014-08-23 16:19:01 +09:00
2016-08-16 07:50:23 +09:00
post :reset_password, :params => { :user => { :name => "admin" } }, :session => { :user_id => 1 }
admin.reload
assert_not_equal(old_password_hash, admin.password_hash)
end
end