Heat oil in a pan and gently fry the onion for 3 mins. Stir in the apple and cook for 2-3 mins until both have softened. Stir in tomatoes, passata and beans. Bring to the boil, then simmer gently for 10 mins. Stir in the pesto and pasta, mixing well until the pasta is heated through. Serve in bowls with crusty bread.