|
- <%= link_to user_url(@direct_message.sender_id), style: "font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; background: #f7f5f2; border-radius: 6px; color: #3d3d66!important; font-weight: bold; margin: 0px; padding: 10px 15px; text-align: center; text-decoration: none; min-width: 200px; display: inline-block;", target: "_blank" do %>
+ <%= link_to user_url(@direct_message.sender), style: "font-family: 'Open Sans','Helvetica Neue',arial,sans-serif; background: #f7f5f2; border-radius: 6px; color: #3d3d66!important; font-weight: bold; margin: 0px; padding: 10px 15px; text-align: center; text-decoration: none; min-width: 200px; display: inline-block;", target: "_blank" do %>
<%= image_tag('icon_mailer_reply.png', style: "border: 0; display: inline-block; width: 100%; max-width: 12px; vertical-align: sub;", alt: "") %>
<%= t('mailers.direct_message.reply',
sender: @direct_message.sender.name) %>
diff --git a/app/views/mailer/direct_message_for_sender.html.erb b/app/views/mailer/direct_message_for_sender.html.erb
new file mode 100644
index 000000000..219337705
--- /dev/null
+++ b/app/views/mailer/direct_message_for_sender.html.erb
@@ -0,0 +1,11 @@
+ |
+ <%= @direct_message.receiver.name %>
+
+
+ <%= @direct_message.title %>
+
+
+
+ <%= @direct_message.body %>
+
+ |
diff --git a/config/locales/mailers.en.yml b/config/locales/mailers.en.yml
index 66c1c75ea..ec6e7f45c 100755
--- a/config/locales/mailers.en.yml
+++ b/config/locales/mailers.en.yml
@@ -37,5 +37,8 @@ en:
title: You received the following notifications
share: Share
comment: Comment proposal
- direct_message:
- reply: Reply to %{sender}
\ No newline at end of file
+ direct_message_for_receiver:
+ subject: "You have received a new private message"
+ reply: Reply to %{sender}
+ direct_message_for_sender:
+ subject: "You have send a new private message"
\ No newline at end of file
diff --git a/config/locales/mailers.es.yml b/config/locales/mailers.es.yml
index 36343267d..4defbd1ed 100644
--- a/config/locales/mailers.es.yml
+++ b/config/locales/mailers.es.yml
@@ -37,5 +37,8 @@ es:
title: Has recibido las siguientes notificaciones
share: Compartir
comment: Comentar propuesta
- direct_message:
- reply: Responder a %{sender}
\ No newline at end of file
+ direct_message_for_receiver:
+ subject: "Has recibido un nuevo mensaje privado"
+ reply: Responder a %{sender}
+ direct_message_for_sender:
+ subject: "Has enviado un nuevo mensaje privado"
\ No newline at end of file
diff --git a/spec/features/direct_messages_spec.rb b/spec/features/direct_messages_spec.rb
index 142be8cbb..2ee1f4365 100644
--- a/spec/features/direct_messages_spec.rb
+++ b/spec/features/direct_messages_spec.rb
@@ -61,11 +61,4 @@ feature 'Direct messages' do
expect(page).to have_content error_message
end
- context "Limits" do
-
- pending "Cannot send more than one notification within established interval"
- pending "use timecop to make sure notifications can be sent after time interval"
-
- end
-
end
\ No newline at end of file
diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb
index 5894d40ed..237444f85 100644
--- a/spec/features/emails_spec.rb
+++ b/spec/features/emails_spec.rb
@@ -148,6 +148,41 @@ feature 'Emails' do
expect(email).to have_body_text(spending_proposal.feasible_explanation)
end
+ context "Direct Message" do
+
+ scenario "Receiver email" do
+ sender = create(:user, :level_two)
+ receiver = create(:user, :level_two)
+
+ direct_message = create_direct_message(sender, receiver)
+
+ email = unread_emails_for(receiver.email).first
+
+ expect(email).to have_subject("You have received a new private message")
+ expect(email).to have_body_text(direct_message.title)
+ expect(email).to have_body_text(direct_message.body)
+ expect(email).to have_body_text(direct_message.sender.name)
+ expect(email).to have_body_text(/#{user_path(direct_message.sender_id)}/)
+ end
+
+ scenario "Sender email" do
+ sender = create(:user, :level_two)
+ receiver = create(:user, :level_two)
+
+ direct_message = create_direct_message(sender, receiver)
+
+ email = unread_emails_for(sender.email).first
+
+ expect(email).to have_subject("You have send a new private message")
+ expect(email).to have_body_text(direct_message.title)
+ expect(email).to have_body_text(direct_message.body)
+ expect(email).to have_body_text(direct_message.receiver.name)
+ end
+
+ pending "In the copy sent to the sender, display the receiver's name"
+
+ end
+
context "Proposal notifications" do
scenario "Proposal notification" do
diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb
index 39faf03f5..8eba8b13d 100644
--- a/spec/support/common_actions.rb
+++ b/spec/support/common_actions.rb
@@ -214,4 +214,20 @@ module CommonActions
Notification.last
end
+ def create_direct_message(sender, receiver)
+ login_as(sender)
+ visit user_path(receiver)
+
+ click_link "Send private message"
+
+ expect(page).to have_content "Send private message to #{receiver.name}"
+
+ fill_in 'direct_message_title', with: "Hey #{receiver.name}!"
+ fill_in 'direct_message_body', with: "How are you doing? This is #{sender.name}"
+ click_button "Send message"
+
+ expect(page).to have_content "You message has been sent successfully."
+ DirectMessage.last
+ end
+
end