]> source.dussan.org Git - redmine.git/commitdiff
More function tests for MessagesController.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 10 Mar 2012 13:21:34 +0000 (13:21 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 10 Mar 2012 13:21:34 +0000 (13:21 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9168 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/messages_controller_test.rb

index 70df6f0b5338b706155cf47215082606eeb1fc4b..1b892cb7ad5d794d23a8a8abf649fa619c035287 100644 (file)
@@ -141,15 +141,45 @@ class MessagesControllerTest < ActionController::TestCase
 
   def test_destroy_topic
     @request.session[:user_id] = 2
-    post :destroy, :board_id => 1, :id => 1
+    assert_difference 'Message.count', -3 do
+      post :destroy, :board_id => 1, :id => 1
+    end
     assert_redirected_to '/projects/ecookbook/boards/1'
     assert_nil Message.find_by_id(1)
   end
 
+  def test_destroy_reply
+    @request.session[:user_id] = 2
+    assert_difference 'Message.count', -1 do
+      post :destroy, :board_id => 1, :id => 2
+    end
+    assert_redirected_to '/boards/1/topics/1?r=2'
+    assert_nil Message.find_by_id(2)
+  end
+
   def test_quote
     @request.session[:user_id] = 2
     xhr :get, :quote, :board_id => 1, :id => 3
     assert_response :success
     assert_select_rjs :show, 'reply'
   end
+
+  def test_preview_new
+    @request.session[:user_id] = 2
+    post :preview,
+      :board_id => 1,
+      :message => {:subject => "", :content => "Previewed text"}
+    assert_response :success
+    assert_template 'common/_preview'
+  end
+
+  def test_preview_edit
+    @request.session[:user_id] = 2
+    post :preview,
+      :id => 4,
+      :board_id => 1,
+      :message => {:subject => "", :content => "Previewed text"}
+    assert_response :success
+    assert_template 'common/_preview'
+  end
 end