-
Notifications
You must be signed in to change notification settings - Fork 0
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
187384622/new email model - PR1 - Change Email and Make Sure original tests didn't break #49
Conversation
The backend code looks good for creating the email model and updating the tests and switching everything to use that model. I also like that you are breaking up the task into smaller PRs since this is a big feature that requires a lot of changes to the codebase. I have a couple of things that I would change:
|
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.
Looks good! The code was written concisely and I don't see any major issues except what Razvan mentioned. The testing also seems cohesive and the new lines were properly tested.
Thanks for reducing the PR size. 🙌
@razztech @fp456, I just updated this PR based on the feedback from you and Michael.
Below are screenshots of the current effect. Customers can see the views the same as the original, and new teachers can be created using the new backend (with new email model). |
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.
This is good! A lot here.
One high level comment: I think perhaps teacher#create and teacher#update should only ever update the primary email. Updating of personal emails should probably happen with separate controller actions. This will make the params / other logic a lot easier.
That will simplify the forms, controller actions, and params handling.
db/migrate/20240407190132_adapt_teachers_after_new_email_addresses.rb
Outdated
Show resolved
Hide resolved
end | ||
end | ||
|
||
# TODO: This needs to be re-written. | ||
# If you are logged in and not an admin, this should fail. | ||
def create | ||
# Find by email, but allow updating other info. | ||
@teacher = Teacher.find_by(email: teacher_params[:email]) | ||
teacher_id = EmailAddress.find_by(email: teacher_params[:primary_email])&.teacher_id | ||
@teacher = Teacher.find_by(id: teacher_id) | ||
if @teacher && defined?(current_user.id) && (current_user.id == @teacher.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.
This isn't for this PR, but the creation workflow when signed in seems like it doesn't make sense anymore. We should revisit this...
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.
Marked. We will discuss it during next available meeting.
@cycomachead, I have just finished updating based on the review you provided as of Apr 11, 2:30 PM. The only uncertain part I have is regarding separating the updating of personal email to a different controller: I am not sure what is expected for separating that, as updating personal email was already in the original code under |
Pivotal Tracker Link1
What This PR Does
This pull request is the first in a series intended to facilitate easier code review. It restructures the
teacher
model to enable ateacher
to have multipleemail_addresses
. The primary goals of this feature are:Notably, this PR does not introduce new tests. Its primary objective is to ensure that existing tests continue to pass without issues. Subsequent PRs will include:
Screenshots and Visuals
After running
rails db:migrate
andrails db:seed
, the following changes are observable:email
field for original entries in the database. This is due to the migration of the database schema without corresponding data migration, leaving the new email model without the original email information. A forthcoming PR will address this with a data migration script.Who authored this PR?
How should this PR be tested?
At least make sure every original feature doesn't break.
Specs & Features are basically same as the original tests, with changes only relevant to some keywords changing & the way mocking the data (such as originally we can directly create a teacher with a email, now we need to associate them together)
For this PR, at least make sure it didn't break any existing test.
Are there any complications to deploying this?
rails db:migrate
rails db:seed
Checklist:
michael/12345-add-new-feature
Any branch name will do as long as the story ID is there. You can usegit checkout -b [new-branch-name]
)