     @valid_attrs %{name: "Test Name", email: "test@test.com", password: "password", username: "username"}
     @update_attrs %{name: "Updated Name", email: "test_update@test.com", password: "updated_password", username: "testusername_updated"}
     @invalid_attrs %{name: nil, email: nil, password_hash: nil, username: nil}
+    @valid_attrs2 %{name: "Test Name", email: "test2@test.com", password: "password", username: "UsErNaMe"}
+    @valid_attrs3 %{name: "Test Name", email: "TeSt@TeSt.com", password: "password", username: "username2"}
 
     def user_fixture(attrs \\ %{}) do
       {:ok, user} =

    defp is_the_same_users(user, user2) do
      is_the_same_users([user], [user2])
    end

    test "list_users/0 returns all users" do
      user = user_fixture()
      admin = Accounts.get_user_by_username("admin")
      is_the_same_users(Accounts.list_users(), [admin, user])

      assert user.email == @update_attrs.email
      assert user.name == @update_attrs.name
      assert user.username == @update_attrs.username
    end

    test "update_user/2 not updates current_user rights if user is not admin" do
      user = user_fixture()
      assert {:ok, user} = Accounts.update_user(user, %{is_staff: true, is_superuser: true}, user)
      assert %User{} = user
      assert user.is_staff == false
      assert user.is_superuser == false
    end

    test "update_user/2 updates current_user rights if user is admin" do
      user = user_fixture()
      admin = Accounts.get_user_by_username("admin")
      assert {:ok, user} = Accounts.update_user(user, %{is_staff: true, is_superuser: true}, admin)
      assert %User{} = user
      assert user.is_staff == true
      assert user.is_superuser == true
    end

    test "update_user/2 with invalid data returns error changeset" do
