Remove redeemable code

I don't think this feature it was ever used. It was introduced in commit
49dec6061 as part of a feature that was removed in commits 1cd47da9d and
c45a0bd8ac.
This commit is contained in:
Javi Martín
2025-03-13 02:45:01 +01:00
parent 6089a9249f
commit 5ba6e7b692
8 changed files with 9 additions and 39 deletions

View File

@@ -6,9 +6,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
invisible_captcha only: [:create], honeypot: :address, scope: :user
def new
super do |user|
user.use_redeemable_code = true if params[:use_redeemable_code].present?
end
super
end
def create
@@ -64,18 +62,13 @@ class Users::RegistrationsController < Devise::RegistrationsController
private
def sign_up_params
if params[:user].present? && params[:user][:redeemable_code].blank?
params[:user].delete(:redeemable_code)
end
params.require(:user).permit(allowed_params)
end
def allowed_params
[
:username, :email, :password,
:password_confirmation, :terms_of_service, :locale,
:redeemable_code
:password_confirmation, :terms_of_service, :locale
]
end

View File

@@ -89,7 +89,7 @@ class User < ApplicationRecord
accepts_nested_attributes_for :organization, update_only: true
attr_accessor :skip_password_validation, :use_redeemable_code, :login
attr_accessor :skip_password_validation, :login
scope :administrators, -> { joins(:administrator) }
scope :moderators, -> { joins(:moderator) }

View File

@@ -15,7 +15,6 @@
<div class="row">
<div class="small-12 column">
<%= f.hidden_field :use_redeemable_code %>
<%= f.hidden_field :locale, value: I18n.locale %>
<%= f.text_field :username, autofocus: true, maxlength: User.username_max_length,
@@ -30,10 +29,6 @@
<%= f.password_field :password_confirmation, autocomplete: "off",
label: t("devise_views.users.registrations.new.password_confirmation_label") %>
<% if resource.use_redeemable_code %>
<%= f.text_field :redeemable_code %>
<% end %>
<%= f.check_box :terms_of_service,
label: t("devise_views.users.registrations.new.terms",
terms: new_window_link_to(t("devise_views.users.registrations.new.terms_link"),

View File

@@ -296,7 +296,6 @@ en:
public_interests: "Keep the elements I follow public"
recommended_debates: "Recommend debates to me"
recommended_proposals: "Recommend proposals to me"
redeemable_code: "Verification code received via email"
direct_message:
title: "Title"
body: "Message"

View File

@@ -296,7 +296,6 @@ es:
public_interests: "Mostrar públicamente los elementos que sigo"
recommended_debates: "Mostrar recomendaciones en el listado de debates"
recommended_proposals: "Mostrar recomendaciones en el listado de propuestas"
redeemable_code: "Código de verificación por carta (opcional)"
direct_message:
title: "Título"
body: "Mensaje"

View File

@@ -0,0 +1,5 @@
class RemoveUsersRedeemableCode < ActiveRecord::Migration[7.0]
def change
remove_column :users, :redeemable_code, :string
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2025_02_22_222739) do
ActiveRecord::Schema[7.0].define(version: 2025_03_13_014205) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
enable_extension "plpgsql"
@@ -1611,7 +1611,6 @@ ActiveRecord::Schema[7.0].define(version: 2025_02_22_222739) do
t.string "locale"
t.string "oauth_email"
t.integer "geozone_id"
t.string "redeemable_code"
t.string "gender", limit: 10
t.datetime "date_of_birth", precision: nil
t.boolean "email_digest", default: true

View File

@@ -38,26 +38,6 @@ describe "Registration form" do
expect(page).to have_content "can't be blank"
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@consul.dev"
fill_in "user_password", with: "password"
fill_in "user_password_confirmation", with: "password"
fill_in "user_redeemable_code", with: " "
check "user_terms_of_service"
click_button "Register"
expect(page).to have_title "Confirm your email address"
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
scenario "Create with invisible_captcha honeypot field", :no_js do
visit new_user_registration_path