]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/reports_controller_test.rb
Show issues based on all the users roles
[rails.git] / test / controllers / reports_controller_test.rb
index 8dc10238ecfad5a28730fe48be915a3dc5d949c6..d061e284a18db56a3276c6a3ac6cc88a61f19d33 100644 (file)
@@ -13,7 +13,7 @@ class ReportsControllerTest < ActionController::TestCase
 
     session[:user] = create(:user).id
 
-    assert_equal Issue.count, 0
+    assert_equal 0, Issue.count
 
     # Create an Issue and a report
     get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
@@ -28,7 +28,7 @@ class ReportsControllerTest < ActionController::TestCase
              }
            }
     end
-    assert_equal Issue.count, 1
+    assert_equal 1, Issue.count
     assert_response :redirect
     assert_redirected_to root_path
   end
@@ -40,7 +40,7 @@ class ReportsControllerTest < ActionController::TestCase
     # Login
     session[:user] = create(:user).id
 
-    assert_equal Issue.count, 0
+    assert_equal 0, Issue.count
 
     # Create an Issue and a report
     get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
@@ -55,27 +55,13 @@ class ReportsControllerTest < ActionController::TestCase
              }
            }
     end
-    assert_equal Issue.count, 1
+    assert_equal 1, Issue.count
     assert_response :redirect
     assert_redirected_to root_path
 
     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 Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count, 1
-
     # Report without details
     assert_no_difference "Issue.count" do
       post :create,
@@ -86,7 +72,7 @@ class ReportsControllerTest < ActionController::TestCase
            }
     end
     assert_response :redirect
-    assert_equal Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count, 1
+    assert_equal 1, Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count
   end
 
   def test_new_report_with_complete_details
@@ -96,7 +82,7 @@ class ReportsControllerTest < ActionController::TestCase
     # Login
     session[:user] = create(:user).id
 
-    assert_equal Issue.count, 0
+    assert_equal 0, Issue.count
 
     # Create an Issue and a report
     get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
@@ -111,7 +97,7 @@ class ReportsControllerTest < ActionController::TestCase
              }
            }
     end
-    assert_equal Issue.count, 1
+    assert_equal 1, Issue.count
     assert_response :redirect
     assert_redirected_to root_path
 
@@ -130,6 +116,6 @@ class ReportsControllerTest < ActionController::TestCase
     end
     assert_response :redirect
     report_count = Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count
-    assert_equal report_count, 2
+    assert_equal 2, report_count
   end
 end