@@ -3,7 +3,7 | |||||
3 |
|
3 | |||
4 | <div class="box tabular"> |
|
4 | <div class="box tabular"> | |
5 | <% if @time_entry.new_record? %> |
|
5 | <% if @time_entry.new_record? %> | |
6 | <% if params[:project_id] %> |
|
6 | <% if params[:project_id] || @time_entry.issue %> | |
7 | <%= f.hidden_field :project_id %> |
|
7 | <%= f.hidden_field :project_id %> | |
8 | <% else %> |
|
8 | <% else %> | |
9 | <p><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).all, :selected => @time_entry.project), :required => true %></p> |
|
9 | <p><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).all, :selected => @time_entry.project), :required => true %></p> |
@@ -36,24 +36,22 class TimelogControllerTest < ActionController::TestCase | |||||
36 | @response = ActionController::TestResponse.new |
|
36 | @response = ActionController::TestResponse.new | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def test_get_new |
|
39 | def test_new_with_project_id | |
40 | @request.session[:user_id] = 3 |
|
40 | @request.session[:user_id] = 3 | |
41 | get :new, :project_id => 1 |
|
41 | get :new, :project_id => 1 | |
42 | assert_response :success |
|
42 | assert_response :success | |
43 | assert_template 'new' |
|
43 | assert_template 'new' | |
44 | # Default activity selected |
|
44 | assert_select 'select[name=?]', 'time_entry[project_id]', 0 | |
45 | assert_tag :tag => 'option', :attributes => { :selected => 'selected' }, |
|
45 | assert_select 'input[name=?][value=1][type=hidden]', 'time_entry[project_id]' | |
46 | :content => 'Development' |
|
|||
47 | assert_select 'input[name=project_id][value=1]' |
|
|||
48 | end |
|
46 | end | |
49 |
|
47 | |||
50 | def test_get_new_should_only_show_active_time_entry_activities |
|
48 | def test_new_with_issue_id | |
51 | @request.session[:user_id] = 3 |
|
49 | @request.session[:user_id] = 3 | |
52 |
get :new, : |
|
50 | get :new, :issue_id => 2 | |
53 | assert_response :success |
|
51 | assert_response :success | |
54 | assert_template 'new' |
|
52 | assert_template 'new' | |
55 |
assert_ |
|
53 | assert_select 'select[name=?]', 'time_entry[project_id]', 0 | |
56 | assert_no_tag 'option', :content => 'Inactive Activity' |
|
54 | assert_select 'input[name=?][value=1][type=hidden]', 'time_entry[project_id]' | |
57 | end |
|
55 | end | |
58 |
|
56 | |||
59 | def test_new_without_project |
|
57 | def test_new_without_project | |
@@ -61,8 +59,8 class TimelogControllerTest < ActionController::TestCase | |||||
61 | get :new |
|
59 | get :new | |
62 | assert_response :success |
|
60 | assert_response :success | |
63 | assert_template 'new' |
|
61 | assert_template 'new' | |
64 |
assert_t |
|
62 | assert_select 'select[name=?]', 'time_entry[project_id]' | |
65 | assert_select 'input[name=project_id]', 0 |
|
63 | assert_select 'input[name=?]', 'time_entry[project_id]', 0 | |
66 | end |
|
64 | end | |
67 |
|
65 | |||
68 | def test_new_without_project_should_prefill_the_form |
|
66 | def test_new_without_project_should_prefill_the_form | |
@@ -73,7 +71,7 class TimelogControllerTest < ActionController::TestCase | |||||
73 | assert_select 'select[name=?]', 'time_entry[project_id]' do |
|
71 | assert_select 'select[name=?]', 'time_entry[project_id]' do | |
74 | assert_select 'option[value=1][selected=selected]' |
|
72 | assert_select 'option[value=1][selected=selected]' | |
75 | end |
|
73 | end | |
76 | assert_select 'input[name=project_id]', 0 |
|
74 | assert_select 'input[name=?]', 'time_entry[project_id]', 0 | |
77 | end |
|
75 | end | |
78 |
|
76 | |||
79 | def test_new_without_project_should_deny_without_permission |
|
77 | def test_new_without_project_should_deny_without_permission | |
@@ -84,6 +82,22 class TimelogControllerTest < ActionController::TestCase | |||||
84 | assert_response 403 |
|
82 | assert_response 403 | |
85 | end |
|
83 | end | |
86 |
|
84 | |||
|
85 | def test_new_should_select_default_activity | |||
|
86 | @request.session[:user_id] = 3 | |||
|
87 | get :new, :project_id => 1 | |||
|
88 | assert_response :success | |||
|
89 | assert_select 'select[name=?]', 'time_entry[activity_id]' do | |||
|
90 | assert_select 'option[selected=selected]', :text => 'Development' | |||
|
91 | end | |||
|
92 | end | |||
|
93 | ||||
|
94 | def test_new_should_only_show_active_time_entry_activities | |||
|
95 | @request.session[:user_id] = 3 | |||
|
96 | get :new, :project_id => 1 | |||
|
97 | assert_response :success | |||
|
98 | assert_no_tag 'option', :content => 'Inactive Activity' | |||
|
99 | end | |||
|
100 | ||||
87 | def test_get_edit_existing_time |
|
101 | def test_get_edit_existing_time | |
88 | @request.session[:user_id] = 2 |
|
102 | @request.session[:user_id] = 2 | |
89 | get :edit, :id => 2, :project_id => nil |
|
103 | get :edit, :id => 2, :project_id => nil |
General Comments 0
You need to be logged in to leave comments.
Login now