show link to sign in for no connect users
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -1,27 +1,65 @@
|
||||
<span>
|
||||
<%= t('comments.comment.votes', count: comment.total_votes) %>
|
||||
</span>
|
||||
|
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: 'yes'),
|
||||
method: "post", remote: true do %>
|
||||
<i class="icon-angle-up"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="icon-angle-up"></i>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
</span>
|
||||
<div class="votes">
|
||||
<% if user_signed_in? %>
|
||||
<%= t('comments.comment.votes', count: comment.total_votes) %>
|
||||
|
|
||||
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: 'no'),
|
||||
method: "post", remote: true do %>
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: 'yes'),
|
||||
method: "post", remote: true do %>
|
||||
<i class="icon-angle-up"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="icon-angle-up"></i>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
</span>
|
||||
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: 'no'),
|
||||
method: "post", remote: true do %>
|
||||
<i class="icon-angle-down"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="icon-angle-down"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="icon-angle-down"></i>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
|
||||
<% elsif !user_signed_in? %>
|
||||
|
||||
<div class="logged" >
|
||||
<%= t('comments.comment.votes', count: comment.total_votes) %>
|
||||
|
|
||||
|
||||
<span class="in_favor">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: 'yes'),
|
||||
method: "post", remote: true do %>
|
||||
<i class="icon-angle-up"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="icon-angle-up"></i>
|
||||
<% end %>
|
||||
<%= comment.total_likes %>
|
||||
</span>
|
||||
<span class="against">
|
||||
<% if can?(:vote, comment) %>
|
||||
<%= link_to vote_comment_path(comment, value: 'no'),
|
||||
method: "post", remote: true do %>
|
||||
<i class="icon-angle-down"></i>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<i class="icon-angle-down"></i>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="not-logged" style='display:none'>
|
||||
<%= 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 %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= comment.total_dislikes %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user