diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 968fa6e66..d185aa7f1 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -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
diff --git a/app/views/users/_interests.html.erb b/app/views/users/_interests.html.erb
new file mode 100644
index 000000000..41dd53bdf
--- /dev/null
+++ b/app/views/users/_interests.html.erb
@@ -0,0 +1,24 @@
+
+
<%= interests_title_text(user) %>
+
+ <% if user.interests.any? %>
+
+ <% user.interests.in_groups_of(10, false) do |interests_group| %>
+
+
+ <% interests_group.each do |interest| %>
+ - <%= interest %>
+ <% end %>
+
+
+ <% end %>
+
+ <% else %>
+
+
+ <%= empty_interests_message_text(user) %>
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index 989e90aac..328c06a5e 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -46,20 +46,7 @@
<%= t('users.show.private_activity') %>
<% end %>
- <% if valid_interests_access? %>
-
-
<%= t('account.show.public_interests_title_list') %>
- <% @user.interests.in_groups_of(10, false) do |interests_group| %>
-
-
- <% interests_group.each do |interest| %>
- - <%= interest %>
- <% end %>
-
-
- <% end %>
-
- <% end %>
+ <%= render 'interests', user: @user if valid_interests_access? %>
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 229bfb3bc..aea5c65c8 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -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
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index 00332dd73..3f21ed55f 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -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
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb
index a5a8c99be..bd2aefa17 100644
--- a/spec/features/users_spec.rb
+++ b/spec/features/users_spec.rb
@@ -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