diff --git a/app/assets/javascripts/votes.js.coffee b/app/assets/javascripts/votes.js.coffee
index 09f2a7db0..43469909d 100644
--- a/app/assets/javascripts/votes.js.coffee
+++ b/app/assets/javascripts/votes.js.coffee
@@ -5,10 +5,12 @@ App.Votes =
$("div.anonymous-votes", votes).show();
$("div.organizations-votes", votes).show();
$("div.not-logged", votes).show();
+ $("div.logged", votes).hide();
, ->
$("div.anonymous-votes", votes).hide();
$("div.organizations-votes", votes).hide();
$("div.not-logged", votes).hide();
+ $("div.logged", votes).show();
initialize: ->
App.Votes.hoverize votes for votes in $("div.votes")
diff --git a/app/views/comments/_votes.html.erb b/app/views/comments/_votes.html.erb
index 21ee52884..06e6c04c6 100644
--- a/app/views/comments/_votes.html.erb
+++ b/app/views/comments/_votes.html.erb
@@ -1,27 +1,65 @@
-
- <%= t('comments.comment.votes', count: comment.total_votes) %>
-
- |
-
- <% if can?(:vote, comment) %>
- <%= link_to vote_comment_path(comment, value: 'yes'),
- method: "post", remote: true do %>
-
- <% end %>
- <% else %>
-
- <% end %>
- <%= comment.total_likes %>
-
+
+ <% if user_signed_in? %>
+ <%= t('comments.comment.votes', count: comment.total_votes) %>
+ |
-
- <% if can?(:vote, comment) %>
- <%= link_to vote_comment_path(comment, value: 'no'),
- method: "post", remote: true do %>
+
+ <% if can?(:vote, comment) %>
+ <%= link_to vote_comment_path(comment, value: 'yes'),
+ method: "post", remote: true do %>
+
+ <% end %>
+ <% else %>
+
+ <% end %>
+ <%= comment.total_likes %>
+
+
+
+ <% if can?(:vote, comment) %>
+ <%= link_to vote_comment_path(comment, value: 'no'),
+ method: "post", remote: true do %>
+
+ <% end %>
+ <% else %>
- <% end %>
- <% else %>
-
+ <% end %>
+ <%= comment.total_dislikes %>
+
+
+ <% elsif !user_signed_in? %>
+
+
+ <%= t('comments.comment.votes', count: comment.total_votes) %>
+ |
+
+
+ <% if can?(:vote, comment) %>
+ <%= link_to vote_comment_path(comment, value: 'yes'),
+ method: "post", remote: true do %>
+
+ <% end %>
+ <% else %>
+
+ <% end %>
+ <%= comment.total_likes %>
+
+
+ <% if can?(:vote, comment) %>
+ <%= link_to vote_comment_path(comment, value: 'no'),
+ method: "post", remote: true do %>
+
+ <% end %>
+ <% else %>
+
+ <% end %>
+ <%= comment.total_dislikes %>
+
+
+
+ <%= t("votes.comment_unauthenticated",
+ signin: link_to(t("votes.signin"), new_user_session_path),
+ signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
+
<% end %>
- <%= comment.total_dislikes %>
-
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 583fcf496..57e75c8f2 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -442,6 +442,7 @@ en:
votes:
agree: I agree
anonymous: Too many anonymous votes to admit vote %{verify_account}.
+ comment_unauthenticated: You must %{signin} or %{signup} to vote.
disagree: I disagree
organizations: Organisations are not permitted to vote
signin: Sign in
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 9dfb2147f..531c5c6e6 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -443,6 +443,7 @@ es:
votes:
agree: Estoy de acuerdo
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
+ comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar.
disagree: No estoy de acuerdo
organizations: Las organizaciones no pueden votar
signin: iniciar sesión
diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb
index c040bb678..3ccf6bcdb 100644
--- a/spec/features/votes_spec.rb
+++ b/spec/features/votes_spec.rb
@@ -299,6 +299,28 @@ feature 'Votes' do
end
end
+ scenario 'Not logged user trying to vote comments in debates', :js do
+ debate = create(:debate)
+ comment = create(:comment, commentable: debate)
+
+ visit comment_path(debate)
+ within("#comment_#{comment.id}") do
+ find("div.votes").hover
+ expect_message_you_need_to_sign_in_to_vote_comments
+ end
+ end
+
+ scenario 'Not logged user trying to vote comments in proposals', :js do
+ proposal = create(:proposal)
+ comment = create(:comment, commentable: proposal)
+
+ visit comment_path(comment)
+ within("#comment_#{comment.id}_reply") do
+ find("div.votes").hover
+ expect_message_you_need_to_sign_in_to_vote_comments
+ end
+ end
+
scenario 'Anonymous user trying to vote debates', :js do
user = create(:user)
debate = create(:debate)
diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb
index f9331d328..652e6c582 100644
--- a/spec/support/common_actions.rb
+++ b/spec/support/common_actions.rb
@@ -153,6 +153,12 @@ module CommonActions
expect(page).to have_selector('.in-favor a', visible: false)
end
+ def expect_message_you_need_to_sign_in_to_vote_comments
+ expect(page).to have_content 'You must Sign in or Sign up to vote'
+ expect(page).to have_selector('.logged', visible: false)
+ expect(page).to have_selector('.not-logged', visible: true)
+ end
+
def expect_message_to_many_anonymous_votes
expect(page).to have_content 'Too many anonymous votes to admit vote'
expect(page).to have_selector('.in-favor a', visible: false)