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.anonymous-votes", votes).show();
|
||||||
$("div.organizations-votes", votes).show();
|
$("div.organizations-votes", votes).show();
|
||||||
$("div.not-logged", votes).show();
|
$("div.not-logged", votes).show();
|
||||||
|
$("div.logged", votes).hide();
|
||||||
, ->
|
, ->
|
||||||
$("div.anonymous-votes", votes).hide();
|
$("div.anonymous-votes", votes).hide();
|
||||||
$("div.organizations-votes", votes).hide();
|
$("div.organizations-votes", votes).hide();
|
||||||
$("div.not-logged", votes).hide();
|
$("div.not-logged", votes).hide();
|
||||||
|
$("div.logged", votes).show();
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
App.Votes.hoverize votes for votes in $("div.votes")
|
App.Votes.hoverize votes for votes in $("div.votes")
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<span>
|
<div class="votes">
|
||||||
|
<% if user_signed_in? %>
|
||||||
<%= t('comments.comment.votes', count: comment.total_votes) %>
|
<%= t('comments.comment.votes', count: comment.total_votes) %>
|
||||||
</span>
|
|
||||||
|
|
|
|
||||||
|
|
||||||
<span class="in_favor">
|
<span class="in_favor">
|
||||||
<% if can?(:vote, comment) %>
|
<% if can?(:vote, comment) %>
|
||||||
<%= link_to vote_comment_path(comment, value: 'yes'),
|
<%= link_to vote_comment_path(comment, value: 'yes'),
|
||||||
@@ -25,3 +26,40 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= comment.total_dislikes %>
|
<%= comment.total_dislikes %>
|
||||||
</span>
|
</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 %>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -442,6 +442,7 @@ en:
|
|||||||
votes:
|
votes:
|
||||||
agree: I agree
|
agree: I agree
|
||||||
anonymous: Too many anonymous votes to admit vote %{verify_account}.
|
anonymous: Too many anonymous votes to admit vote %{verify_account}.
|
||||||
|
comment_unauthenticated: You must %{signin} or %{signup} to vote.
|
||||||
disagree: I disagree
|
disagree: I disagree
|
||||||
organizations: Organisations are not permitted to vote
|
organizations: Organisations are not permitted to vote
|
||||||
signin: Sign in
|
signin: Sign in
|
||||||
|
|||||||
@@ -443,6 +443,7 @@ es:
|
|||||||
votes:
|
votes:
|
||||||
agree: Estoy de acuerdo
|
agree: Estoy de acuerdo
|
||||||
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
|
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
|
||||||
|
comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar.
|
||||||
disagree: No estoy de acuerdo
|
disagree: No estoy de acuerdo
|
||||||
organizations: Las organizaciones no pueden votar
|
organizations: Las organizaciones no pueden votar
|
||||||
signin: iniciar sesión
|
signin: iniciar sesión
|
||||||
|
|||||||
@@ -299,6 +299,28 @@ feature 'Votes' do
|
|||||||
end
|
end
|
||||||
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
|
scenario 'Anonymous user trying to vote debates', :js do
|
||||||
user = create(:user)
|
user = create(:user)
|
||||||
debate = create(:debate)
|
debate = create(:debate)
|
||||||
|
|||||||
@@ -153,6 +153,12 @@ module CommonActions
|
|||||||
expect(page).to have_selector('.in-favor a', visible: false)
|
expect(page).to have_selector('.in-favor a', visible: false)
|
||||||
end
|
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
|
def expect_message_to_many_anonymous_votes
|
||||||
expect(page).to have_content 'Too many anonymous votes to admit vote'
|
expect(page).to have_content 'Too many anonymous votes to admit vote'
|
||||||
expect(page).to have_selector('.in-favor a', visible: false)
|
expect(page).to have_selector('.in-favor a', visible: false)
|
||||||
|
|||||||
Reference in New Issue
Block a user