assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1
assert_select "textarea#message_body", :count => 1
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1
assert_select "textarea#message_body", :count => 1
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
get :new,
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
get :new,
- :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" }
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "Test message body" } }
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do
assert_select "[value='Test Message']"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do
assert_select "[value='Test Message']"
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
post :new,
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
post :new,
- :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "" }
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "" } }
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do
assert_select "[value='Test Message']"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do
assert_select "[value='Test Message']"
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
post :new,
assert_difference "ActionMailer::Base.deliveries.size", 0 do
assert_difference "Message.count", 0 do
post :new,
- :display_name => recipient_user.display_name,
- :message => { :title => "", :body => "Test message body" }
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "", :body => "Test message body" } }
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do
assert_select "[value='']"
assert_select "form[action='#{new_message_path(:display_name => recipient_user.display_name)}']", :count => 1 do
assert_select "input#message_title", :count => 1 do
assert_select "[value='']"
assert_difference "ActionMailer::Base.deliveries.size", 1 do
assert_difference "Message.count", 1 do
post :new,
assert_difference "ActionMailer::Base.deliveries.size", 1 do
assert_difference "Message.count", 1 do
post :new,
- :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" }
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "Test message body" } }
assert_equal "markdown", m.body_format
# Asking to send a message with a bogus user name should fail
assert_equal "markdown", m.body_format
# Asking to send a message with a bogus user name should fail
assert_response :not_found
assert_template "user/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
assert_response :not_found
assert_template "user/no_such_user"
assert_select "h1", "The user non_existent_user does not exist"
- :display_name => recipient_user.display_name,
- :message => { :title => "Test Message", :body => "Test message body" }
+ :params => { :display_name => recipient_user.display_name,
+ :message => { :title => "Test Message", :body => "Test message body" } }
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
# Check that the message reply page requires us to login
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
# Check that the message reply page requires us to login
assert_redirected_to login_path(:referer => reply_message_path(:message_id => unread_message.id))
# Login as the wrong user
session[:user] = other_user.id
# Check that we can't reply to somebody else's message
assert_redirected_to login_path(:referer => reply_message_path(:message_id => unread_message.id))
# Login as the wrong user
session[:user] = other_user.id
# Check that we can't reply to somebody else's message
assert_redirected_to login_path(:referer => reply_message_path(:message_id => unread_message.id))
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to reply to was not sent to that user. Please login as the correct user in order to reply.", flash[:notice]
assert_redirected_to login_path(:referer => reply_message_path(:message_id => unread_message.id))
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to reply to was not sent to that user. Please login as the correct user in order to reply.", flash[:notice]
assert_select "form[action='#{new_message_path(:display_name => user.display_name)}']", :count => 1 do
assert_select "input#message_title[value='Re: #{unread_message.title}']", :count => 1
assert_select "textarea#message_body", :count => 1
assert_select "form[action='#{new_message_path(:display_name => user.display_name)}']", :count => 1 do
assert_select "input#message_title[value='Re: #{unread_message.title}']", :count => 1
assert_select "textarea#message_body", :count => 1
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
# Check that the read message page requires us to login
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
# Check that the read message page requires us to login
assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
# Login as the wrong user
session[:user] = other_user.id
# Check that we can't read the message
assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
# Login as the wrong user
session[:user] = other_user.id
# Check that we can't read the message
assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to read was not sent by or to that user. Please login as the correct user in order to read it.", flash[:notice]
assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to read was not sent by or to that user. Please login as the correct user in order to read it.", flash[:notice]
- # Check that the message recipient_user can read the message
- get :read, :message_id => unread_message.id
+ # Check that the message recipient can read the message
+ get :read, :params => { :message_id => unread_message.id }
other_user = create(:user)
read_message = create(:message, :read, :recipient => user)
# Check that the inbox page requires us to login
other_user = create(:user)
read_message = create(:message, :read, :recipient => user)
# Check that the inbox page requires us to login
assert_redirected_to login_path(:referer => inbox_path(:display_name => user.display_name))
# Login
session[:user] = user.id
# Check that we can view our inbox when logged in
assert_redirected_to login_path(:referer => inbox_path(:display_name => user.display_name))
# Login
session[:user] = user.id
# Check that we can view our inbox when logged in
create(:message, :sender => user)
# Check that the outbox page requires us to login
create(:message, :sender => user)
# Check that the outbox page requires us to login
assert_redirected_to login_path(:referer => outbox_path(:display_name => user.display_name))
# Login
session[:user] = user.id
# Check that we can view our outbox when logged in
assert_redirected_to login_path(:referer => outbox_path(:display_name => user.display_name))
# Login
session[:user] = user.id
# Check that we can view our outbox when logged in
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
# Check that the marking a message requires us to login
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
# Check that the marking a message requires us to login
assert_response :forbidden
# Login as a user with no messages
session[:user] = other_user.id
# Check that marking a message we didn't send or receive fails
assert_response :forbidden
# Login as a user with no messages
session[:user] = other_user.id
# Check that marking a message we didn't send or receive fails
assert_redirected_to inbox_path(:display_name => recipient_user.display_name)
assert_equal true, Message.find(unread_message.id).message_read
# Check that the marking a message unread works
assert_redirected_to inbox_path(:display_name => recipient_user.display_name)
assert_equal true, Message.find(unread_message.id).message_read
# Check that the marking a message unread works
assert_redirected_to inbox_path(:display_name => recipient_user.display_name)
assert_equal false, Message.find(unread_message.id).message_read
# Check that the marking a message read via XHR works
assert_redirected_to inbox_path(:display_name => recipient_user.display_name)
assert_equal false, Message.find(unread_message.id).message_read
# Check that the marking a message read via XHR works
- xhr :post, :mark, :message_id => unread_message.id, :mark => "read"
+ post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "read" }
assert_response :success
assert_template "mark"
assert_equal true, Message.find(unread_message.id).message_read
# Check that the marking a message unread via XHR works
assert_response :success
assert_template "mark"
assert_equal true, Message.find(unread_message.id).message_read
# Check that the marking a message unread via XHR works
- xhr :post, :mark, :message_id => unread_message.id, :mark => "unread"
+ post :mark, :xhr => true, :params => { :message_id => unread_message.id, :mark => "unread" }
sent_message = create(:message, :unread, :recipient => second_user, :sender => user)
# Check that the deleting a message requires us to login
sent_message = create(:message, :unread, :recipient => second_user, :sender => user)
# Check that the deleting a message requires us to login
assert_response :forbidden
# Login as a user with no messages
session[:user] = other_user.id
# Check that deleting a message we didn't send or receive fails
assert_response :forbidden
# Login as a user with no messages
session[:user] = other_user.id
# Check that deleting a message we didn't send or receive fails
assert_redirected_to inbox_path(:display_name => user.display_name)
assert_equal "Message deleted", flash[:notice]
m = Message.find(read_message.id)
assert_redirected_to inbox_path(:display_name => user.display_name)
assert_equal "Message deleted", flash[:notice]
m = Message.find(read_message.id)
assert_equal false, m.to_user_visible
# Check that the deleting a sent message works
assert_equal false, m.to_user_visible
# Check that the deleting a sent message works
- post :delete, :message_id => sent_message.id, :referer => outbox_path(:display_name => user.display_name)
+ post :delete, :params => { :message_id => sent_message.id, :referer => outbox_path(:display_name => user.display_name) }
assert_redirected_to outbox_path(:display_name => user.display_name)
assert_equal "Message deleted", flash[:notice]
m = Message.find(sent_message.id)
assert_redirected_to outbox_path(:display_name => user.display_name)
assert_equal "Message deleted", flash[:notice]
m = Message.find(sent_message.id)