-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adding in unlocks controller and specs. This should resolve #927. #971
Conversation
Thanks so much @brycesenz ! Any reason some of the tests are commented out? Otherwise looks pretty good to me, especially for a first cut. |
@zachfeldman - oh, haha, probably just human error. Like I said, I'm awful with Minitest - I couldn't figure out the command to test just one spec in isolation (as opposed to the whole file), so I took to commenting things out once they worked. Please let me know the rest of your thoughts once you've had a chance to review. Also, as should be clear from the code, I added an API endpoint to let a user trigger an unlock email to be sent to his/her account (a |
No problem, mind uncommenting that so we can run Travis against it? Yeah that sounds like a good thing to have! Thanks for pointing it out. |
All checks have passed. Going to approve this - if one more person does, I will merge. |
Nice work there, I feel you about Minitest, however, you did great testing! But I don't like some copy/pasted code from Can you in some way refactor the first part of the create method to a concern or to the |
@MaicolBen - Haha, yeah, I ripped a lot of stuff from the PasswordsController actually. The two are very similar! That provider change has actually not made its way into the PasswordsController yet I see - good reason to abstract it! Is that the only part of the create action that you were talking about refactoring? It seems like a fair bit of the library could use some refactoring (no offense; that's the nature of open source sometimes), but I don't want to have the scope of this PR bleed too far. |
Ok, submitted a refactor with a new module. Some parts of the code still aren't really clear to me - for example, this block appears in the def resource_class(m=nil)
if m
mapping = Devise.mappings[m]
else
mapping = Devise.mappings[resource_name] || Devise.mappings.values.first
end
mapping.to
end |
You didn't give me time to tell you to not do it if it were too much effort! But you did great work! I will review it. I'm thinking in cleaning it more in the future. |
Agreed. The code climate score for this project is really embarrassing x_x |
@lynndylanhurley - But the test coverage is solid! I mean for real - I would not have had the confidence to change anything if I didn't have a test suite to run against to make sure I didn't break anything. Y'all have done an awesome job keeping the test suite in order! |
|
||
@resource = resource_class.where(q, @email).first | ||
@email = get_case_insensitive_field_from_resource_params(:email) | ||
@resource = find_resource(:email, @email) |
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.
Shouldn't be :uid
instead?
@resource = lockable_users(:unlocked_user) | ||
end | ||
|
||
describe 'not email should return 401' 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.
Is this message correct? I would put request unlock without email
@MaicolBen - Both of those points are valid. I have incorporated those changes into the PR. |
Looks good to me! Love the |
This should resolve the core issue of #927. However, it has these known shortcomings (and perhaps more that I haven't identified):