diff options
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/identities_controller_test.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/identities_controller_test.rb b/test/functional/identities_controller_test.rb new file mode 100644 index 0000000..fcdeaa2 --- /dev/null +++ b/test/functional/identities_controller_test.rb @@ -0,0 +1,42 @@ +require 'test_helper' + +class IdentitiesControllerTest < ActionController::TestCase + + test "admin can list active and blocked ids" do + login :is_admin? => true + get :index + assert_response :success + assert ids = assigns(:identities) + end + + test "non-admin can't list usernames" do + login + get :index + assert_access_denied + end + + test "requires login" do + get :index + assert_login_required + end + + test "admin can unblock username" do + # an identity without user_id and destination is a blocked handle + identity = FactoryGirl.create :identity + login :is_admin? => true + delete :destroy, id: identity.id + assert_response :redirect + assert_nil Identity.find(identity.id) + end + + test "admin cannot remove main identity" do + user = FactoryGirl.create :user + identity = FactoryGirl.create :identity, + Identity.attributes_from_user(user) + login :is_admin? => true + delete :destroy, id: identity.id + assert_response :redirect + assert_equal identity, Identity.find(identity.id) + end + +end |