]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/reports_controller_test.rb
Use options_for_select to set the selected items in the search form
[rails.git] / test / controllers / reports_controller_test.rb
index 9c39350f95dfce9b1cf223678dc01b7e91a941a9..d9bc190d8b1d9a5495177c2dd5f1cfa318ad6f09 100644 (file)
@@ -20,17 +20,19 @@ class ReportsControllerTest < ActionController::TestCase
     assert_response :success
     assert_difference "Issue.count", 1 do
       details = "Details of a report"
+      category = "other"
       post :create,
            :params => {
              :report => {
                :details => details,
+               :category => category,
                :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
              }
            }
     end
     assert_equal 1, Issue.count
     assert_response :redirect
-    assert_redirected_to root_path
+    assert_redirected_to user_path(target_user.display_name)
   end
 
   def test_new_report_with_incomplete_details
@@ -47,40 +49,30 @@ class ReportsControllerTest < ActionController::TestCase
     assert_response :success
     assert_difference "Issue.count", 1 do
       details = "Details of a report"
+      category = "other"
       post :create,
            :params => {
              :report => {
                :details => details,
+               :category => category,
                :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
              }
            }
     end
     assert_equal 1, Issue.count
     assert_response :redirect
-    assert_redirected_to root_path
+    assert_redirected_to user_path(target_user.display_name)
 
     get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
     assert_response :success
 
-    # Report without report_type
-    assert_no_difference "Issue.count" do
-      details = "Details of another report under the same issue"
-      post :create,
-           :params => {
-             :report => {
-               :details => details,
-               :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
-             }
-           }
-    end
-    assert_response :redirect
-    assert_equal 1, Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count
-
     # Report without details
     assert_no_difference "Issue.count" do
+      category = "other"
       post :create,
            :params => {
              :report => {
+               :category => category,
                :issue => { :reportable_id => 1, :reportable_type => "User" }
              }
            }
@@ -103,27 +95,31 @@ class ReportsControllerTest < ActionController::TestCase
     assert_response :success
     assert_difference "Issue.count", 1 do
       details = "Details of a report"
+      category = "other"
       post :create,
            :params => {
              :report => {
                :details => details,
+               :category => category,
                :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
              }
            }
     end
     assert_equal 1, Issue.count
     assert_response :redirect
-    assert_redirected_to root_path
+    assert_redirected_to user_path(target_user.display_name)
 
     # Create a report for an existing Issue
     get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
     assert_response :success
     assert_no_difference "Issue.count" do
       details = "Details of another report under the same issue"
+      category = "other"
       post :create,
            :params => {
              :report => {
                :details => details,
+               :category => category,
                :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
              }
            }