Writing functional tests
Test cases that target our controller actions are referred to as functional tests. Web requests are received, and the desired response is generally a rendered view.
The Rails guide indicates that some ideal functional test types would be as follows:
Whether a web request succeeded
Whether the user was redirected to the correct page
Whether the user was authenticated
Whether the proper template was rendered as a response
Whether the correct message shows in a view
As we'll be using test cases that derive from ActionController::TestCase
(http://api.rubyonrails.org/classes/ActionController/TestCase.html), each functional test case should only test a single controller method.
Here is an example of a functional test for our ArticlesController
:
require File.dirname(__FILE__) + '/../test_helper' class ArticlesControllerTest < ActionController::TestCase fixtures :projects, :roles, :users plugin_fixtures :kb_articles, :enabled_modules def setup User.current = User.find...