-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(transactional): use proxy on descriptor.value #150
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Please fix the issue I mentioned and then I'll go ahead and merge it.
If you feel like it, you could have a go at writing tests for the decorator that it correctly preserves metadata (If not, I'll add them later)
I investigated a little further, and it's a little puzzling as to why the original method didn't work since it already copies over the necessary metadata. I have to assume that swagger must add some property to the method outside of metadata as that is already being copied over correctly. This is quite strange as I looked over the ApiResponse code and I could only see metadata being defined. Nevertheless, I've already confirmed the code is working in a project, so the changes seem necessary. I've added two tests, one to check that the metadata is being passed over correctly, which passes with the previous code, and one to check that properties are accessible through the proxy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the fix and the tests.
However, mixing actual transaction tests with metadata checking tests is not very transparent, so I'd like to ask you to put the decorator tests into a separate file transactional.decorator.spec.ts
(together with the mock decorators).
Apart from that, everything looks fine to me.
How do I handle checking if adding metadata breaks the transaction decorator? I added it to the original tests to verify that adding other decorators doesn't break the transactions. Should I add some simple transaction test to the new spec file or just check the metadata and assume adding new decorators doesn't affect @transactional? |
Personally, I would add a simple transaction test (using the mock adapter) for a method that accepts multiple parameters and asserts that it received them unchanged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks alright to me :)
Fixes #149 by using a Proxy object to avoid overiding descriptor.value inside the decorator.