-
Notifications
You must be signed in to change notification settings - Fork 147
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
Controller Tests #970
base: master
Are you sure you want to change the base?
Controller Tests #970
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.
first: once again many thanks for the great work!
i just skimmed the changes and didn't look into detail for now. most of comments apply multiple times, but i didn't mark every single occurrence
the rubucop checks for it are not enforced, since we have a lot of existing code, but it would be great to stick to the Ruby Style Guide for string literals
i know that's it's a hard to split this PR, when all parts would require the Gemfile
changes, but it would make the review process easier if the PR would be smaller. maybe start with a single controller test?
@@ -64,7 +64,7 @@ def ordergroup | |||
# cancel personal memberships direct from the myProfile-page | |||
def cancel_membership | |||
if params[:membership_id] | |||
membership = @current_user.memberships.find!(params[:membership_id]) | |||
membership = @current_user.memberships.find(params[:membership_id]) |
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.
why is it ok to remove the !
here and keep it in line 69?
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.
i think a find!
method does not exists?
NoMethodError:
undefined method `find!' for #<ActiveRecord::Associations::CollectionProxy []>
Did you mean? find
find_by!
returns a ActiveRecord::RecordNotFound
instead of nil
compared to find_by
I added another test to check that find
also returns a ActiveRecord::RecordNotFound
Exception
before do | ||
order_article | ||
end |
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.
i'd suggest to add a second order at line 15 instead. IMHO there should be no need for a dedicated order_article
factory.
login user | ||
routes.draw { get "deny_access" => "dummy_auth#call_deny_access" } | ||
get :call_deny_access, params: { foodcoop: FoodsoftConfig[:default_scope] } | ||
expect(response).to redirect_to(root_url) |
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.
when do you use _path
and when _url
?
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.
in that specific case the the controller redirects to root_url ... in general not sure, is there a convention?
ad0a138
to
e34bf55
Compare
thanks for your feedback! We'll look into your comments and I'll change the scope of the PR to fit just the Gemfile and one ControllerSpec at first. |
433f74d
to
78936c3
Compare
e5870b5
to
d7591d4
Compare
Co-authored-by: viehlieb <[email protected]> Co-authored-by: Tobias Kneuker <[email protected]>
Co-authored-by: viehlieb <[email protected]> Co-authored-by: Tobias Kneuker <[email protected]> seperate expects refactor login user calls add more articles to test sorting with fix: fix test for rails upgrade
d7591d4
to
d3d7acc
Compare
Keeping this atm to track upcoming smaller PR's
We found that the
articles_controller
sync method throws a DoubleRenderError, should we open a new Issue/PR for that?see spec/controllers/articles_controller_spec.rb:179
Edit: split into seperate PR's