To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / test / functional / issue_statuses_controller_test.rb @ 441:cbce1fd3b1b7

History | View | Annotate | Download (2.5 KB)

1
require File.expand_path('../../test_helper', __FILE__)
2
require 'issue_statuses_controller'
3

    
4
# Re-raise errors caught by the controller.
5
class IssueStatusesController; def rescue_action(e) raise e end; end
6

    
7

    
8
class IssueStatusesControllerTest < ActionController::TestCase
9
  fixtures :issue_statuses, :issues
10
  
11
  def setup
12
    @controller = IssueStatusesController.new
13
    @request    = ActionController::TestRequest.new
14
    @response   = ActionController::TestResponse.new
15
    User.current = nil
16
    @request.session[:user_id] = 1 # admin
17
  end
18
  
19
  def test_index
20
    get :index
21
    assert_response :success
22
    assert_template 'index'
23
  end
24
  
25
  def test_new
26
    get :new
27
    assert_response :success
28
    assert_template 'new'
29
  end
30
  
31
  def test_create
32
    assert_difference 'IssueStatus.count' do
33
      post :create, :issue_status => {:name => 'New status'}
34
    end
35
    assert_redirected_to :action => 'index'
36
    status = IssueStatus.find(:first, :order => 'id DESC')
37
    assert_equal 'New status', status.name
38
  end
39
  
40
  def test_edit
41
    get :edit, :id => '3'
42
    assert_response :success
43
    assert_template 'edit'
44
  end
45
  
46
  def test_update
47
    post :update, :id => '3', :issue_status => {:name => 'Renamed status'}
48
    assert_redirected_to :action => 'index'
49
    status = IssueStatus.find(3)
50
    assert_equal 'Renamed status', status.name
51
  end
52
  
53
  def test_destroy
54
    Issue.delete_all("status_id = 1")
55
    
56
    assert_difference 'IssueStatus.count', -1 do
57
      post :destroy, :id => '1'
58
    end
59
    assert_redirected_to :action => 'index'
60
    assert_nil IssueStatus.find_by_id(1)
61
  end
62
  
63
  def test_destroy_should_block_if_status_in_use
64
    assert_not_nil Issue.find_by_status_id(1)
65
    
66
    assert_no_difference 'IssueStatus.count' do
67
      post :destroy, :id => '1'
68
    end
69
    assert_redirected_to :action => 'index'
70
    assert_not_nil IssueStatus.find_by_id(1)
71
  end
72

    
73
  context "on POST to :update_issue_done_ratio" do
74
    context "with Setting.issue_done_ratio using the issue_field" do
75
      setup do
76
        Setting.issue_done_ratio = 'issue_field'
77
        post :update_issue_done_ratio
78
      end
79

    
80
      should_set_the_flash_to /not updated/
81
      should_redirect_to('the index') { '/issue_statuses' }
82
    end
83

    
84
    context "with Setting.issue_done_ratio using the issue_status" do
85
      setup do
86
        Setting.issue_done_ratio = 'issue_status'
87
        post :update_issue_done_ratio
88
      end
89

    
90
      should_set_the_flash_to /Issue done ratios updated/
91
      should_redirect_to('the index') { '/issue_statuses' }
92
    end
93
  end
94
  
95
end