sends a copy of the direct message to the sender

This commit is contained in:
rgarcia
2016-06-14 18:55:28 +02:00
parent fd67294075
commit ce6072d17b
9 changed files with 86 additions and 15 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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