-
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
Add tests for passwords#edit when redirect_whitelist is set #1247
Add tests for passwords#edit when redirect_whitelist is set #1247
Conversation
put :edit, | ||
params: { email: '[email protected]' } | ||
get_reset_token | ||
get :edit, params: { reset_password_token: @mail_reset_token} |
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 was wrong lol, I am glad that I did 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.
You could replace these parts by get_reset_token
, they look the same:
describe 'case-sensitive email' do
before do
post :create,
params: { email: @resource.email,
redirect_url: @redirect_url }
@mail = ActionMailer::Base.deliveries.last
@resource.reload
@data = JSON.parse(response.body)
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
end
describe 'Alternate user class' do
before do
@resource = create(:mang_user, :confirmed)
@redirect_url = 'http://ng-token-auth.dev'
post :create, params: { email: @resource.email,
redirect_url: @redirect_url }
@mail = ActionMailer::Base.deliveries.last
@resource.reload
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
end
describe 'alternate user type' do
before do
@resource = create(:user, :confirmed)
@config_name = 'altUser'
post :create, params: { email: @resource.email,
redirect_url: @redirect_url,
config_name: @config_name }
@mail = ActionMailer::Base.deliveries.last
@resource.reload
@mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1])
@mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1])
@mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1]
end
@@ -66,10 +66,9 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase | |||
describe 'for edit' do | |||
before do | |||
@auth_headers = @resource.create_new_auth_token |
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.
You could also delete this:
@auth_headers = @resource.create_new_auth_token |
because it appears in another before block which is above:
describe 'not redirect_url should return 401' do
before do
@auth_headers = @resource.create_new_auth_token
@new_password = Faker::Internet.password
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.
In general, everything looks good.
Some tests failed. I have released PR #1249 to fix it. |
867ddea
to
4f6d9c5
Compare
4f6d9c5
to
9ba635c
Compare
Missing tests from #1228