Merge pull request #938 from consul/blank-codes
[bugfix] no blank redeemable codes
This commit is contained in:
@@ -56,6 +56,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params[:user].delete(:redeemable_code) if params[:user].present? && params[:user][:redeemable_code].blank?
|
||||
params.require(:user).permit(:username, :email, :password,
|
||||
:password_confirmation, :captcha,
|
||||
:captcha_key, :terms_of_service, :locale,
|
||||
|
||||
@@ -24,4 +24,24 @@ feature 'Registration form' do
|
||||
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
|
||||
end
|
||||
|
||||
scenario 'do not save blank redeemable codes' do
|
||||
visit new_user_registration_path(use_redeemable_code: 'true')
|
||||
|
||||
fill_in 'user_username', with: "NewUserWithCode77"
|
||||
fill_in 'user_email', with: "new@madrid.es"
|
||||
fill_in 'user_password', with: "password"
|
||||
fill_in 'user_password_confirmation', with: "password"
|
||||
fill_in 'user_redeemable_code', with: " "
|
||||
fill_in 'user_captcha', with: correct_captcha_text
|
||||
check 'user_terms_of_service'
|
||||
|
||||
click_button 'Register'
|
||||
|
||||
expect(page).to have_content "Thank you for registering"
|
||||
|
||||
new_user = User.last
|
||||
expect(new_user.username).to eq("NewUserWithCode77")
|
||||
expect(new_user.redeemable_code).to be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user