sends a copy of the direct message to the sender
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user