X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/41e45bad51c90dd4e131068ba1cfc1dd1184155f..25b93471c1861b77190f15dac17b526619710858:/test/functional/message_controller_test.rb diff --git a/test/functional/message_controller_test.rb b/test/functional/message_controller_test.rb index 77fdfbeb9..66ca8bc70 100644 --- a/test/functional/message_controller_test.rb +++ b/test/functional/message_controller_test.rb @@ -65,6 +65,44 @@ class MessageControllerTest < ActionController::TestCase assert_select "input[type='submit'][value='Send']", :count => 1 end + # Check that the subject is preserved over errors + assert_difference "ActionMailer::Base.deliveries.size", 0 do + assert_difference "Message.count", 0 do + post :new, + :display_name => users(:public_user).display_name, + :message => { :title => "Test Message", :body => "" } + end + end + assert_response :success + assert_template "new" + assert_select "title", "OpenStreetMap | Send message" + assert_select "form[action='#{new_message_path(:display_name => users(:public_user).display_name)}']", :count => 1 do + assert_select "input#message_title", :count => 1 do + assert_select "[value=Test Message]" + end + assert_select "textarea#message_body", :text => "", :count => 1 + assert_select "input[type='submit'][value='Send']", :count => 1 + end + + # Check that the body text is preserved over errors + assert_difference "ActionMailer::Base.deliveries.size", 0 do + assert_difference "Message.count", 0 do + post :new, + :display_name => users(:public_user).display_name, + :message => { :title => "", :body => "Test message body" } + end + end + assert_response :success + assert_template "new" + assert_select "title", "OpenStreetMap | Send message" + assert_select "form[action='#{new_message_path(:display_name => users(:public_user).display_name)}']", :count => 1 do + assert_select "input#message_title", :count => 1 do + assert_select "[value=]" + end + assert_select "textarea#message_body", :text => "Test message body", :count => 1 + assert_select "input[type='submit'][value='Send']", :count => 1 + end + # Check that sending a message works assert_difference "ActionMailer::Base.deliveries.size", 1 do assert_difference "Message.count", 1 do @@ -93,7 +131,7 @@ class MessageControllerTest < ActionController::TestCase get :new, :display_name => "non_existent_user" assert_response :not_found assert_template "user/no_such_user" - assert_select "h2", "The user non_existent_user does not exist" + assert_select "h1", "The user non_existent_user does not exist" end ##