session[:user] = create(:user).id
- assert_equal 0, Issue.count
-
# Create an Issue and a report
get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
assert_response :success
}
}
end
- assert_equal 1, Issue.count
assert_response :redirect
- assert_redirected_to user_path(target_user.display_name)
+ assert_redirected_to user_path(target_user)
end
def test_new_report_with_incomplete_details
# Login
session[:user] = create(:user).id
- assert_equal 0, Issue.count
-
# Create an Issue and a report
get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
assert_response :success
}
}
end
- assert_equal 1, Issue.count
assert_response :redirect
- assert_redirected_to user_path(target_user.display_name)
+ assert_redirected_to user_path(target_user)
+
+ issue = Issue.last
+
+ assert_equal 1, issue.reports.count
get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
assert_response :success
}
end
assert_response :redirect
- assert_equal 1, Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count
+
+ assert_equal 1, issue.reports.count
end
def test_new_report_with_complete_details
# Login
session[:user] = create(:user).id
- assert_equal 0, Issue.count
-
# Create an Issue and a report
get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
assert_response :success
}
}
end
- assert_equal 1, Issue.count
assert_response :redirect
- assert_redirected_to user_path(target_user.display_name)
+ assert_redirected_to user_path(target_user)
+
+ issue = Issue.last
+
+ assert_equal 1, issue.reports.count
# Create a report for an existing Issue
get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
}
end
assert_response :redirect
- report_count = Issue.find_by(:reportable_id => target_user.id, :reportable_type => "User").reports.count
- assert_equal 2, report_count
+
+ assert_equal 2, issue.reports.count
end
end