]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/message_controller_test.rb
Move vagrant provisioning script to a better location.
[rails.git] / test / functional / message_controller_test.rb
index 45d0a267c4825a4b63b0cbc6c4e708baea161d75..66ca8bc7008f3a27ce28a9a06d885ab9e84b9009 100644 (file)
@@ -65,6 +65,44 @@ class MessageControllerTest < ActionController::TestCase
       assert_select "input[type='submit'][value='Send']", :count => 1
     end
 
       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
     # Check that sending a message works
     assert_difference "ActionMailer::Base.deliveries.size", 1 do
       assert_difference "Message.count", 1 do