Skip to content

Commit

Permalink
test: add test for risk category management through enumerations
Browse files Browse the repository at this point in the history
  • Loading branch information
xel1045 committed Feb 23, 2024
1 parent d6eb768 commit edd5ede
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/functional/enumerations_controller_test.rb
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

0 comments on commit edd5ede

Please sign in to comment.