Coding as part of an interview should not involve fixing bugs/tickets in their current code. This doesn't demonstrate your coding skills as much as it uses your time to get around to things they are avoiding. Remember that if you do fix bugs as part of your interview - don't commit and leave the changes in the code when you leave. Always remove your work if you feel you are being used.
Actually on the contrary, the practice of asking an interviewee to spend time working on the project, reviewing the code or writing some code to show they are capable, has become more widely accepted in the industry. This is because of a few reasons, first and foremost the number of applicants who over-sell themselves and are not able to handle the technicality side of the job. Other reasons are to measure your coding skill, the way you write your code and your attention to detail.
While these are important and can help you get the job if you don't want to be taken advantage of, there are some things you can do.
- You could say you have another interview a few hours later in the day, or make up some other believable excuse as to why you cannot spend a whole day at the interview. After the primary interview this is acceptable to mention only if you are asked to stay and demonstrate your coding abilities.
- You may choose to do the coding and as this is part of your interview you may have some kind of code review with another developer. You have all rights to delete the code you have written after and not check it in. Once you've shown it to the interviewer, etc. this is a valid reason so to ensure you have not been freely coding all day. Until you work for the company it is technically not their legal property. This only works as long as they are using a code check in system where removing your changes won't affect anyone else.
I have always spent a few hours working after interviews both in my developer jobs and when I was taken on to be a chef for the day. While you may not wish to have an interview for the full day it often increases your chances of getting the job. You have to assess it on a case-by-case basis. Some may seem sketchy and sometimes you can tell.
However I have had one interview where they did use me for the day, but they made the mistake of discussing someone else they were going to hire and that they wanted to "let [me] finish the work before telling me so that they don't need someone else to take it over and finish it off" in a room nearby while I was coding still. At that point you can bet I was annoyed. But being a professional I finished the last few bits - cutting corners and what not before demoing the changes to them. When the demo was complete they said thanks and that I can leave. At this point I turned around and said "sure, let me just delete MY code and I'll be on my way, wouldn't want you guys thinking this interview was free labour".
Best of luck to you.