Rangers, Cruz agree to two-year contract