adds link to send message from my activity
This commit is contained in:
@@ -3,6 +3,7 @@ class UsersController < ApplicationController
|
|||||||
|
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
helper_method :authorized_for_filter?
|
helper_method :authorized_for_filter?
|
||||||
|
helper_method :author?
|
||||||
helper_method :author_or_admin?
|
helper_method :author_or_admin?
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -65,8 +66,12 @@ class UsersController < ApplicationController
|
|||||||
@user.public_activity || authorized_current_user?
|
@user.public_activity || authorized_current_user?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def author?
|
||||||
|
@author ||= current_user && (current_user == @user)
|
||||||
|
end
|
||||||
|
|
||||||
def author_or_admin?
|
def author_or_admin?
|
||||||
@author_or_admin ||= current_user && (current_user == @user || current_user.administrator?)
|
@author_or_admin ||= current_user && (author? || current_user.administrator?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def authorized_current_user?
|
def authorized_current_user?
|
||||||
|
|||||||
@@ -7,17 +7,24 @@
|
|||||||
<%= proposal.summary %>
|
<%= proposal.summary %>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<% if author? %>
|
||||||
|
<td class="text-center">
|
||||||
|
<%= link_to t("users.proposals.send_message"), new_proposal_notification_path(proposal_id: proposal.id) %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if author_or_admin? %>
|
<% if author_or_admin? %>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<% if proposal.retired? %>
|
<% if proposal.retired? %>
|
||||||
<span class="label alert"><%= t('users.show.retired') %></span>
|
<span class="label alert"><%= t('users.proposals.retired') %></span>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to t('users.show.retire'),
|
<%= link_to t('users.proposals.retire'),
|
||||||
retire_form_proposal_path(proposal),
|
retire_form_proposal_path(proposal),
|
||||||
class: 'delete' %>
|
class: 'delete' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -510,8 +510,10 @@ en:
|
|||||||
other: "%{count} Spending proposals"
|
other: "%{count} Spending proposals"
|
||||||
no_activity: User has no public activity
|
no_activity: User has no public activity
|
||||||
private_activity: This user decided to keep the activity list private
|
private_activity: This user decided to keep the activity list private
|
||||||
retire: Retire
|
proposals:
|
||||||
retired: Retired
|
send_message: "Send message"
|
||||||
|
retire: "Retire"
|
||||||
|
retired: "Retired"
|
||||||
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}.
|
||||||
|
|||||||
@@ -510,8 +510,10 @@ es:
|
|||||||
other: "%{count} Propuestas de inversión"
|
other: "%{count} Propuestas de inversión"
|
||||||
no_activity: Usuario sin actividad pública
|
no_activity: Usuario sin actividad pública
|
||||||
private_activity: Este usuario ha decidido mantener en privado su lista de actividades
|
private_activity: Este usuario ha decidido mantener en privado su lista de actividades
|
||||||
retire: Retirar
|
proposals:
|
||||||
retired: Retirada
|
send_message: "Enviar mensaje"
|
||||||
|
retire: "Retirar"
|
||||||
|
retired: "Retirada"
|
||||||
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}.
|
||||||
|
|||||||
@@ -6,9 +6,17 @@ feature 'Proposal Notifications' do
|
|||||||
noelia = create(:user)
|
noelia = create(:user)
|
||||||
vega = create(:user)
|
vega = create(:user)
|
||||||
|
|
||||||
proposal = create(:proposal)
|
author = create(:user)
|
||||||
#use correct path from my activity
|
proposal = create(:proposal, author: author)
|
||||||
visit new_proposal_notification_path(proposal_id: proposal.id)
|
|
||||||
|
login_as(author)
|
||||||
|
visit root_path
|
||||||
|
|
||||||
|
click_link "My activity"
|
||||||
|
|
||||||
|
within("#proposal_#{proposal.id}") do
|
||||||
|
click_link "Send message"
|
||||||
|
end
|
||||||
|
|
||||||
fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal"
|
fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal"
|
||||||
fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!"
|
fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!"
|
||||||
@@ -19,6 +27,30 @@ feature 'Proposal Notifications' do
|
|||||||
expect(page).to have_content "Please share it with others so we can make it happen!"
|
expect(page).to have_content "Please share it with others so we can make it happen!"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "Permissions" do
|
||||||
|
|
||||||
|
scenario "Link to send the message" do
|
||||||
|
user = create(:user)
|
||||||
|
author = create(:user)
|
||||||
|
proposal = create(:proposal, author: author)
|
||||||
|
|
||||||
|
login_as(author)
|
||||||
|
visit user_path(author)
|
||||||
|
|
||||||
|
within("#proposal_#{proposal.id}") do
|
||||||
|
expect(page).to have_link "Send message"
|
||||||
|
end
|
||||||
|
|
||||||
|
login_as(user)
|
||||||
|
visit user_path(author)
|
||||||
|
|
||||||
|
within("#proposal_#{proposal.id}") do
|
||||||
|
expect(page).to_not have_link "Send message"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Error messages" do
|
scenario "Error messages" do
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user