Merge pull request #938 from consul/blank-codes

[bugfix] no blank redeemable codes
This commit is contained in:
Raimond Garcia
2016-02-26 18:06:41 +01:00
2 changed files with 21 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
private private
def sign_up_params 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, params.require(:user).permit(:username, :email, :password,
:password_confirmation, :captcha, :password_confirmation, :captcha,
:captcha_key, :terms_of_service, :locale, :captcha_key, :terms_of_service, :locale,

View File

@@ -24,4 +24,24 @@ feature 'Registration form' do
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available") expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
end 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 end