-
Notifications
You must be signed in to change notification settings - Fork 56
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
Issue 95: Interactors #108
Conversation
e6f5e8b
to
7758e2a
Compare
@@ -222,8 +222,8 @@ def knight | |||
end | |||
|
|||
volunteer = Volunteer.find(params[:volunteer_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.
I left this find here in case we wanted to apply the pattern here and act on both a Volunteer and Assignment.
If not, I'll pull this down into Knight.
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.
So I think the difference between these is that this one makes the volunteer a "super admin" whereas the one in assignments_controller
makes the volunteer a "region admin".
As far as authorization goes, there's basically 3 roles a user can be: super admin, region admin, or regular volunteer:
- Volunteers are assigned to a region, and can only do certain things in that region.
- Region admins can do everything a regular volunteer can do but can do more things than regular volunteers in the regions they are assigned to.
- Super admins can do everything regular volunteers can do and everything region admins can do (for all regions), plus some other stuff.
What would you think of renaming this interactor to something like ToggleSuperAdmin
? Then we could create a separate interactor for AssignmentsController#knight
named something like ToggleRegionAdmin
?
I think it's still fine to have it take an ActiveRecord object (Volunteer
) instead of an id
though.
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'm down with that!
spec/interactors/knight_spec.rb
Outdated
) | ||
end | ||
|
||
it 'sets the admin flad' do |
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.
Small typo ;)
spec/interactors/knight_spec.rb
Outdated
require 'rails_helper' | ||
|
||
RSpec.describe Knight do | ||
describe '::call' do |
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.
What does the "::" in "::call" indicate? Yeah, yeah, I know that I technically wrote this, haha.
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.
That it's a class method, opposed to an instance method which would be #call
.
Based on the notation in the docs: https://ruby-doc.org/core-2.2.0/Array.html
Feedback on style and naming for this project is welcome so I stay consistent with this app. |
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.
LGTM 👍
Overview
This is intended to address Issue #95
Details