-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for risk category management through enumerations
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require File.expand_path('../../test_helper', __FILE__) | ||
|
||
class EnumerationsControllerTest < ActionController::TestCase | ||
fixtures :enumerations, :issues, :users | ||
|
||
def setup | ||
@controller = EnumerationsController.new | ||
|
||
# Configure the logged user | ||
@request.session[:user_id] = 1 | ||
end | ||
|
||
def test_index | ||
get :index | ||
assert_response :success | ||
assert_match 'Risk categories', @response.body | ||
end | ||
|
||
def test_new | ||
get(:new, :params => {:type => 'RiskCategory'}) | ||
assert_response :success | ||
|
||
assert_select 'input[name=?][value=?]', 'enumeration[type]', 'RiskCategory' | ||
assert_select 'input[name=?]', 'enumeration[name]' | ||
end | ||
|
||
def test_create | ||
assert_difference 'RiskCategory.count' do | ||
post( | ||
:create, | ||
:params => { | ||
:enumeration => { | ||
:type => 'RiskCategory', | ||
:name => 'Low' | ||
} | ||
} | ||
) | ||
end | ||
assert_redirected_to '/enumerations' | ||
e = RiskCategory.find_by_name('Low') | ||
assert_not_nil e | ||
end | ||
end |