Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/avo/resources/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def fields # rubocop:disable Metrics
field :email_reset, as: :boolean
field :handle, as: :text
field :public_email, as: :boolean
field :twitter_username, as: :text, as_html: true, format_using: -> { link_to value, "https://twitter.com/#{value}", target: :_blank, rel: :noopener if value.present? }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename to social_link (and follow the same for helpers ...) and remove the forma_using here (swap with validation on model side to be valid link)?

field :unconfirmed_email, as: :text

field :mail_fails, as: :number
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def params_user
end
end

PERMITTED_PROFILE_PARAMS = %i[handle twitter_username unconfirmed_email public_email full_name].freeze
PERMITTED_PROFILE_PARAMS = %i[handle unconfirmed_email public_email full_name].freeze

def verify_password
password = params.expect(user: :password)[:password]
Expand Down
1 change: 0 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def create
location
password
website
twitter_username
full_name
].freeze

Expand Down
8 changes: 0 additions & 8 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
module UsersHelper
def twitter_username(user)
"@#{user.twitter_username}" if user.twitter_username.present?
end

def twitter_url(user)
"https://twitter.com/#{user.twitter_username}"
end

def show_policies_acknowledge_banner?(user)
user.present? && !user.policies_acknowledged?
end
Expand Down
5 changes: 0 additions & 5 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ class User < ApplicationRecord
validates :handle, format: { with: Patterns::HANDLE_PATTERN }, length: { within: 2..40 }, allow_nil: true
validate :unique_with_org_handle

validates :twitter_username, format: {
with: /\A[a-zA-Z0-9_]*\z/,
message: "can only contain letters, numbers, and underscores"
}, allow_nil: true, length: { within: 0..20 }

validates :password,
length: { minimum: 10 },
unpwn: true,
Expand Down
12 changes: 0 additions & 12 deletions app/views/dashboards/_subject.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@
%></p>
</div>
<% end %>

<% if user.twitter_username.present? %>
<div class="flex items-center mb-4 text-b3 lg:text-b2">
<%= icon_tag("x-twitter", color: :primary, class: "w-6 text-orange mr-3") %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the icon here and just use the link in link_to as is in social_link field (if present)

<p class="text-neutral-800 dark:text-white"><%=
link_to(
twitter_username(user),
twitter_url(user)
)
%></p>
</div>
<% end %>
</div>

<hr class="hidden lg:block lg:mb-6 border-neutral-400 dark:border-neutral-600" />
Expand Down
19 changes: 0 additions & 19 deletions app/views/profiles/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@
<%= form.text_field :handle, :class => 'form__input' %>
</div>

<div class="text_field">
<%= form.label :twitter_username, class: 'form__label form__label__icon-container' do %>
<%=
image_tag("/images/x_icon.png", alt: 'X icon', class: 'form__label__icon')
%>

<span class='form__label__text'><%= t('.twitter_username') %></span>
<% end %>

<p class='form__field__instructions'>
<%= t('.optional_twitter_username') %>
</p>

<div class="form__input__addon-container form__input__addon-left">
<span class="form__input__addon">@</span>
<%= form.text_field(:twitter_username, class: 'form__input') %>
</div>
</div>

<% if current_user.unconfirmed_email %>
<div class="push--bottom-s">
<p class='form__field__instructions'>
Expand Down
18 changes: 0 additions & 18 deletions app/views/profiles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@
%>
</p>
<% end %>

<% if @user.twitter_username.present? %>
<%=
image_tag(
"/images/x_icon.png",
alt: "X icon",
class: "profile__header__icon"
)
%>

<%=
link_to(
twitter_username(@user),
twitter_url(@user),
class: "profile__header__attribute t-link--black"
)
%>
<% end %>
<% end %>
</div>

Expand Down
2 changes: 0 additions & 2 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,6 @@ de:
email_awaiting_confirmation:
enter_password:
optional_full_name:
optional_twitter_username:
twitter_username: Benutzername
title: Bearbeite Profil
delete:
delete:
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,6 @@ en:
email_awaiting_confirmation: Please confirm your new email address %{unconfirmed_email}
enter_password: Please enter your account's password
optional_full_name: Optional. Will be displayed publicly
optional_twitter_username: Optional X username. Will be displayed publicly
twitter_username: Username
title: Edit profile
delete:
delete: Delete
Expand Down
3 changes: 0 additions & 3 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,6 @@ es:
%{unconfirmed_email}
enter_password: Por favor introduce tu contraseña
optional_full_name: Opcional. Será mostrado en tu perfil público
optional_twitter_username: Usuario de X opcional. Será mostrado en tu perfil
público
twitter_username: Usuario
title: Editar perfil
delete:
delete: Eliminar
Expand Down
2 changes: 0 additions & 2 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,6 @@ fr:
%{unconfirmed_email}
enter_password: Veuillez entrer le mot de passe de votre compte
optional_full_name:
optional_twitter_username: Nom d'utilisateur X optionnel. Sera affiché publiquement
twitter_username: Pseudonyme
title: Modification de profil
delete:
delete: Supprimer
Expand Down
2 changes: 0 additions & 2 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,6 @@ ja:
email_awaiting_confirmation: 新しいEメールアドレス%{unconfirmed_email}を確認してください。
enter_password: アカウントのパスワードを入力してください。
optional_full_name: 省略可能です。公開されます。
optional_twitter_username: Xのユーザー名。省略可能です。公開されます。
twitter_username: ユーザー名
title: プロフィールを編集
delete:
delete: 削除
Expand Down
2 changes: 0 additions & 2 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,6 @@ nl:
email_awaiting_confirmation:
enter_password:
optional_full_name:
optional_twitter_username:
twitter_username: Gebruikersnaam
title: Wijzig profiel
delete:
delete:
Expand Down
2 changes: 0 additions & 2 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,6 @@ pt-BR:
email_awaiting_confirmation:
enter_password:
optional_full_name:
optional_twitter_username:
twitter_username: Usuário
title: Editar Perfil
delete:
delete:
Expand Down
2 changes: 0 additions & 2 deletions config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,6 @@ zh-CN:
email_awaiting_confirmation: 请确认您新的邮箱地址 %{unconfirmed_email}
enter_password: 请输入您账户的密码
optional_full_name: 将公开显示(可选)
optional_twitter_username: 可选 X 用户名。这将会被公开显示
twitter_username: 用户名
title: 修改个人资料
delete:
delete: 删除
Expand Down
2 changes: 0 additions & 2 deletions config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,6 @@ zh-TW:
email_awaiting_confirmation: 請確認您的新電子郵件地址 %{unconfirmed_email}
enter_password: 輸入密碼
optional_full_name: 選填。將公開顯示
optional_twitter_username: X 帳號(可選)
twitter_username: 帳號
title: 編輯個人檔案
delete:
delete: 刪除
Expand Down
10 changes: 0 additions & 10 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,6 @@ class UserTest < ActiveSupport::TestCase
end
end

context "twitter_username" do
should validate_length_of(:twitter_username).is_at_most(20)
should allow_value("user123_32").for(:twitter_username)
should_not allow_value("@user").for(:twitter_username)
should_not allow_value("user 1").for(:twitter_username)
should_not allow_value("user-1").for(:twitter_username)
should allow_value("01234567890123456789").for(:twitter_username)
should_not allow_value("012345678901234567890").for(:twitter_username)
end

context "password" do
should "be between 10 characters and 72 bytes" do
user = build(:user, password: "%5a&12ed/")
Expand Down
38 changes: 0 additions & 38 deletions test/system/profile_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,44 +107,6 @@ class ProfileTest < ApplicationSystemTestCase
assert page.has_content?("Email Me")
end

test "adding X(formerly Twitter) username" do
sign_in
visit profile_path("nick1")

click_link "Edit Profile"
fill_in "user_twitter_username", with: "nick1"
fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD
click_button "Update"

sign_out
visit profile_path("nick1")

assert page.has_link?("@nick1", href: "https://twitter.com/nick1")
end

test "adding X(formerly Twitter) username without filling in your password" do
twitter_username = "nick1twitter"

sign_in
visit profile_path("nick1")

click_link "Edit Profile"
fill_in "user_twitter_username", with: twitter_username

assert_equal twitter_username, page.find_by_id("user_twitter_username").value

click_button "Update"

# Verify that the newly added Twitter username is still on the form so that the user does not need to re-enter it
assert_equal twitter_username, page.find_by_id("user_twitter_username").value

fill_in "Password", with: PasswordHelpers::SECURE_TEST_PASSWORD
click_button "Update"

assert page.has_content? "Your profile was updated."
assert_equal twitter_username, page.find_by_id("user_twitter_username").value
end

test "deleting profile" do
sign_in
visit profile_path("nick1")
Expand Down
Loading