def test_create
assert_difference 'IssueStatus.count' do
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_status => {
:name => 'New status'
}
}
+ )
end
assert_redirected_to :action => 'index'
status = IssueStatus.order('id DESC').first
end
def test_create_with_failure
- post :create, :params => {
+ post(
+ :create,
+ :params => {
:issue_status => {
:name => ''
}
}
+ )
assert_response :success
assert_select_error /name cannot be blank/i
end
def test_edit
- get :edit, :params => {
- :id => '3'
- }
+ get(:edit, :params => {:id => '3'})
assert_response :success
assert_select 'input[name=?][value=?]', 'issue_status[name]', 'Resolved'
end
def test_update
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => '3',
:issue_status => {
:name => 'Renamed status'
}
}
+ )
assert_redirected_to :action => 'index'
status = IssueStatus.find(3)
assert_equal 'Renamed status', status.name
end
def test_update_with_failure
- put :update, :params => {
+ put(
+ :update,
+ :params => {
:id => '3',
:issue_status => {
:name => ''
}
}
+ )
assert_response :success
assert_select_error /name cannot be blank/i
end
def test_destroy
Issue.where(:status_id => 1).delete_all
Tracker.where(:default_status_id => 1).delete_all
-
assert_difference 'IssueStatus.count', -1 do
- delete :destroy, :params => {
- :id => '1'
- }
+ delete(:destroy, :params => {:id => '1'})
end
assert_redirected_to :action => 'index'
assert_nil IssueStatus.find_by_id(1)
def test_destroy_should_block_if_status_is_used_by_issues
assert Issue.where(:status_id => 1).any?
Tracker.where(:default_status_id => 1).delete_all
-
assert_no_difference 'IssueStatus.count' do
- delete :destroy, :params => {
- :id => '1'
- }
+ delete(:destroy, :params => {:id => '1'})
end
assert_redirected_to :action => 'index'
assert_not_nil IssueStatus.find_by_id(1)
def test_destroy_should_block_if_status_is_used_as_tracker_default_status
Issue.where(:status_id => 1).delete_all
assert Tracker.where(:default_status_id => 1).any?
-
assert_no_difference 'IssueStatus.count' do
- delete :destroy, :params => {
- :id => '1'
- }
+ delete(:destroy, :params => {:id => '1'})
end
assert_redirected_to :action => 'index'
assert_not_nil IssueStatus.find_by_id(1)