Merge pull request #1769 from rockandror/empty-user-interests

Add empty interests list message.
This commit is contained in:
BertoCQ
2017-07-26 18:31:14 +02:00
committed by GitHub
6 changed files with 79 additions and 17 deletions

View File

@@ -41,4 +41,20 @@ module UsersHelper
current_user && current_user.administrator?
end
def interests_title_text(user)
if current_user == user
t('account.show.public_interests_my_title_list')
else
t('account.show.public_interests_user_title_list')
end
end
def empty_interests_message_text(user)
if current_user == user
t('account.show.public_interests_my_empty_list')
else
t('account.show.public_interests_user_empty_list')
end
end
end

View File

@@ -0,0 +1,24 @@
<div id="public_interests" class="public-interests">
<h4><%= interests_title_text(user) %></h4>
<% if user.interests.any? %>
<% user.interests.in_groups_of(10, false) do |interests_group| %>
<div class="small-4 column end">
<ul class="no-bullet">
<% interests_group.each do |interest| %>
<li> <small><%= interest %></small> </li>
<% end %>
</ul>
</div>
<% end %>
<% else %>
<div class="callout primary">
<%= empty_interests_message_text(user) %>
</div>
<% end %>
</div>

View File

@@ -46,20 +46,7 @@
<p><%= t('users.show.private_activity') %></p>
<% end %>
<% if valid_interests_access? %>
<div id="public_interests" class="public-interests">
<h4><%= t('account.show.public_interests_title_list') %></h4>
<% @user.interests.in_groups_of(10, false) do |interests_group| %>
<div class="small-4 column end">
<ul class="no-bullet">
<% interests_group.each do |interest| %>
<li> <small><%= interest %></small> </li>
<% end %>
</ul>
</div>
<% end %>
</div>
<% end %>
<%= render 'interests', user: @user if valid_interests_access? %>
</div>
</div>

View File

@@ -14,7 +14,10 @@ en:
phone_number_label: Phone number
public_activity_label: Keep my list of activities public
public_interests_label: Keep my interests public
public_interests_title_list: List of interests
public_interests_my_title_list: List of interests (Tags of elements you follow)
public_interests_user_title_list: List of interests (Tags of elements this user follows)
public_interests_my_empty_list: You do not follow any elements yet.
public_interests_user_empty_list: This user does not follow any elements yet.
save_changes_submit: Save changes
subscription_to_website_newsletter_label: Receive by email website relevant information
email_on_direct_message_label: Receive emails about direct messages

View File

@@ -14,7 +14,10 @@ es:
phone_number_label: Teléfono
public_activity_label: Mostrar públicamente mi lista de actividades
public_interests_label: Mostrar públicamente mis intereses
public_interests_title_list: Lista de intereses
public_interests_my_title_list: Lista de intereses (Etiquetas de los elementos que sigues)
public_interests_user_title_list: Lista de intereses (Etiquetas de los elementos seguidos este usuario)
public_interests_my_empty_list: Aún no sigues ningún elemento.
public_interests_user_empty_list: Este usuario no sigue ningún elemento todavía.
save_changes_submit: Guardar cambios
subscription_to_website_newsletter_label: Recibir emails con información interesante sobre la web
email_on_direct_message_label: Recibir emails con mensajes privados

View File

@@ -213,7 +213,7 @@ feature 'Users' do
end
feature 'Public interest' do
feature 'Public interests' do
background do
@user = create(:user)
end
@@ -310,6 +310,35 @@ feature 'Users' do
expect(page).to have_css('#public_interests')
end
scenario 'Should display generic interests title' do
@user.update(public_interests: true)
visit user_path(@user)
expect(page).to have_content("List of interests (Tags of elements this user follows)")
end
scenario 'Should display custom interests title when user is visiting own user page' do
@user.update(public_interests: true)
login_as(@user)
visit user_path(@user)
expect(page).to have_content("List of interests (Tags of elements you follow)")
end
scenario 'Should display generic empty interests list message when visited user has not interests defined' do
@user.update(public_interests: true)
visit user_path(@user)
expect(page).to have_content("This user does not follow any elements yet.")
end
scenario 'Should display custom empty interests list message when user has not interests defined and user is visiting own user page' do
@user.update(public_interests: true)
login_as(@user)
visit user_path(@user)
expect(page).to have_content("You do not follow any elements yet.")
end
end
feature 'Special comments' do