-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Convert controller specs to requests #90
Conversation
2ba1580
to
1062a7c
Compare
1062a7c
to
76f809c
Compare
2b2aafb
to
ab31c3f
Compare
@SamuelMartini I've opened solidusio/solidus#3873 to track what we need to do in core to remove the hack we did to test system specs without forgery protection. |
ab31c3f
to
4a9ff09
Compare
@SamuelMartini forgery protection is now false on the dummy app in core! |
4a9ff09
to
ff86ed1
Compare
99de74d
to
8263594
Compare
@SamuelMartini can you please rebase now that specs are green on master? Also, I'd love to take advantage of this PR to get rid of the |
Usually, the authentication in solidus applications is provided by `solidus_auth_devise`[1]. The solidus controllers in fact expect the devise `current_spree_user` or custom `spree_current_user` methods to be implemented and called inside the proxy `try_spree_current-user`[2] When testing controllers through requests specs, examples should have no dependency and knowledge of `solidus_auth_devise`. However, solidus controllers need one of the above methods to fetch the current user. This commit adds an helper method to the tested controllers to behave like an extension implementing `spree_current_user`. [1]: https://github.com/solidusio/solidus_auth_devise [2]: https://github.com/solidusio/solidus/blob/fa7aa92d1b1c174d1a2489a0e20a3f99201820b8/core/lib/spree/core/controller_helpers/auth.rb#L71
This commit also remove an example[1] as a similar test is already done in the same context[2]. [1]: https://github.com/nebulab/solidus_starter_frontend/blob/v0.1.0/spec/controllers/spree/orders_controller_spec.rb#L45 [2]: https://github.com/nebulab/solidus_starter_frontend/blob/v0.1.0/spec/controllers/spree/orders_controller_spec.rb#L61
This commit remove two examples: - This test[1] as it is not possible to test without simulating an user login during a checkout. However, this is tested in this system spec[2] which is a more proper place for this kind of spec. - This test[3] as it is testing the case the user does not respond to a method defined in solidus_core[4]. This method is part of the users methods[5] which is a rails concern that must be included in any user defined class. [1]: https://github.com/nebulab/solidus_starter_frontend/blob/v0.1.0/spec/controllers/spree/checkout_controller_spec.rb#L59 [2]: https://github.com/nebulab/solidus_starter_frontend/blob/v0.1.0/spec/system/checkout_spec.rb#L162 [3]: https://github.com/nebulab/solidus_starter_frontend/blob/v0.1.0/spec/controllers/spree/checkout_controller_spec.rb#L127 [4]: https://github.com/solidusio/solidus/blob/v2.11.7/core/app/models/spree/order.rb#L787 [5]: https://github.com/solidusio/solidus/blob/v2.11.7/core/app/models/concerns/spree/user_methods.rb
8263594
to
d2bbee2
Compare
d2bbee2
to
103618f
Compare
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 @SamuelMartini for never give up on this huge task!
Description
Ref #18
In converting the controller in request specs I have tried to not stubbing any method. The purpose of this PR is to port every test that was written in the controller and for this reason, it was not possible to avoid stubs in every example.
CheckoutController
andOrderController
are the more sensitive tests.CheckoutController
has manybefore_action
filters that make it cumbersome to ensure the example was testing the right filter (when the expectation is the same). Those tests probably make sense in a Controller test where you can stub messages to be received but in a request spec we are only interested in the response so we may want to revisit those tests. Also, It would be really cool to refactor the controller andmake it lean.