Add empty recommended messages text.

This commit is contained in:
taitus
2017-08-04 13:27:03 +02:00
parent edbbe6174b
commit 6e2063310f
9 changed files with 94 additions and 12 deletions

View File

@@ -110,7 +110,7 @@ class ProposalsController < ApplicationController
end
def load_featured
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? && @current_order != "recommendations"
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3)
if @featured_proposals.present?
set_featured_proposal_votes(@featured_proposals)

View File

@@ -4,4 +4,12 @@ module DebatesHelper
Debate.all.featured.count > 0
end
end
def empty_recommended_debates_message_text(user)
if user.interests.any?
t('debates.index.recommendations.without_results')
else
t('debates.index.recommendations.without_interests')
end
end
end

View File

@@ -32,4 +32,12 @@ module ProposalsHelper
Proposal::RETIRE_OPTIONS.collect { |option| [ t("proposals.retire_options.#{option}"), option ] }
end
end
def empty_recommended_proposals_message_text(user)
if user.interests.any?
t('proposals.index.recommendations.without_results')
else
t('proposals.index.recommendations.without_interests')
end
end
end

View File

@@ -53,8 +53,12 @@
<div class="show-for-small-only">
<%= link_to t("debates.index.start_debate"), new_debate_path, class: 'button expanded' %>
</div>
<%= render @debates %>
<% if @debates.any? %>
<%= render @debates %>
<% else %>
<%= empty_recommended_debates_message_text(current_user) %>
<% end %>
<%= paginate @debates %>
</div>

View File

@@ -66,7 +66,11 @@
</div>
<div id="proposals-list">
<%= render partial: 'proposals/proposal', collection: @proposals %>
<% if @proposals.any? %>
<%= render partial: 'proposals/proposal', collection: @proposals %>
<% else %>
<%= empty_recommended_proposals_message_text(current_user) %>
<% end %>
<%= paginate @proposals %>
</div>
</div>

View File

@@ -109,6 +109,9 @@ en:
most_commented: most commented
relevance: relevance
recommendations: recommendations
recommendations:
without_results: There are not debates related to your interests
without_interests: Follow proposals so we can give you recommendations
search_form:
button: Search
placeholder: Search debates...
@@ -331,6 +334,9 @@ en:
relevance: relevance
archival_date: Archived
recommendations: recommendations
recommendations:
without_results: There are not proposals related to your interests
without_interests: Follow proposals so we can give you recommendations
retired_proposals: Retired proposals
retired_proposals_link: "Proposals retired by the author"
retired_links:

View File

@@ -109,6 +109,9 @@ es:
most_commented: Más comentados
relevance: Más relevantes
recommendations: Recomendaciones
recommendations:
without_results: No existen debates relacionados con tus intereses
without_interests: Sigue propuestas para que podamos darte recomendaciones
search_form:
button: Buscar
placeholder: Buscar debates...
@@ -330,7 +333,10 @@ es:
most_commented: Más comentadas
relevance: Más relevantes
archival_date: Archivadas
recommendations: Recomendaciones
recommendations: Recomendaciones
recommendations:
without_results: No existen propuestas relacionadas con tus intereses
without_interests: Sigue propuestas para que podamos darte recomendaciones
retired_proposals: Propuestas retiradas
retired_proposals_link: "Propuestas retiradas por sus autores"
retired_links:

View File

@@ -371,6 +371,28 @@ feature 'Debates' do
expect(page).not_to have_selector('a', text: 'recommendations')
end
scenario 'Should display text when there are not recommendeds results', :js do
user = create(:user)
proposal = create(:proposal, tag_list: "Distinct_to_sport")
create(:follow, followable: proposal, user: user)
login_as(user)
visit debates_path
click_link 'recommendations'
expect(page).to have_content "There are not debates related to your interests"
end
scenario 'Should display text when user has not related interests', :js do
user = create(:user)
login_as(user)
visit debates_path
click_link 'recommendations'
expect(page).to have_content "Follow proposals so we can give you recommendations"
end
scenario 'Debates are ordered by recommendations when there is a user logged', :js do
proposal = create(:proposal, tag_list: "Sport" )
user = create(:user)

View File

@@ -632,11 +632,11 @@ feature 'Proposals' do
context 'Recommendations' do
background do
before do
Setting['feature.user.recommendations'] = true
create(:proposal, title: 'Best', cached_votes_up: 10)
create(:proposal, title: 'Medium', cached_votes_up: 5)
create(:proposal, title: 'Worst', cached_votes_up: 1)
create(:proposal, title: 'Best', cached_votes_up: 10, tag_list: "Sport")
create(:proposal, title: 'Medium', cached_votes_up: 5, tag_list: "Sport")
create(:proposal, title: 'Worst', cached_votes_up: 1, tag_list: "Sport")
end
after do
@@ -649,8 +649,32 @@ feature 'Proposals' do
expect(page).not_to have_selector('a', text: 'recommendations')
end
scenario 'Should display text when there are not recommendeds results', :js do
user = create(:user)
proposal = create(:proposal, tag_list: "Distinct_to_sport")
create(:follow, followable: proposal, user: user)
login_as(user)
visit proposals_path
click_link 'recommendations'
expect(page).to have_content "There are not proposals related to your interests"
end
scenario 'Should display text when user has not related interests', :js do
user = create(:user)
login_as(user)
visit proposals_path
click_link 'recommendations'
expect(page).to have_content "Follow proposals so we can give you recommendations"
end
scenario 'Proposals are ordered by recommendations when there is an user logged', :js do
user = create(:user)
proposal = create(:proposal, tag_list: "Sport")
create(:follow, followable: proposal, user: user)
login_as(user)
visit proposals_path
@@ -659,7 +683,7 @@ feature 'Proposals' do
expect(page).to have_selector('a.active', text: 'recommendations')
within '#proposals' do
within '#proposals-list' do
expect('Best').to appear_before('Medium')
expect('Medium').to appear_before('Worst')
end