Don't show the project dropdown when logging time on an issue.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10183 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-08-09 17:12:24 +00:00
parent f1650b8ff4
commit e06bf0c464
2 changed files with 27 additions and 13 deletions

View File

@ -3,7 +3,7 @@
<div class="box tabular">
<% if @time_entry.new_record? %>
<% if params[:project_id] %>
<% if params[:project_id] || @time_entry.issue %>
<%= f.hidden_field :project_id %>
<% else %>
<p><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).all, :selected => @time_entry.project), :required => true %></p>

View File

@ -36,24 +36,22 @@ class TimelogControllerTest < ActionController::TestCase
@response = ActionController::TestResponse.new
end
def test_get_new
def test_new_with_project_id
@request.session[:user_id] = 3
get :new, :project_id => 1
assert_response :success
assert_template 'new'
# Default activity selected
assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
:content => 'Development'
assert_select 'input[name=project_id][value=1]'
assert_select 'select[name=?]', 'time_entry[project_id]', 0
assert_select 'input[name=?][value=1][type=hidden]', 'time_entry[project_id]'
end
def test_get_new_should_only_show_active_time_entry_activities
def test_new_with_issue_id
@request.session[:user_id] = 3
get :new, :project_id => 1
get :new, :issue_id => 2
assert_response :success
assert_template 'new'
assert_no_tag 'select', :attributes => {:name => 'time_entry[project_id]'}
assert_no_tag 'option', :content => 'Inactive Activity'
assert_select 'select[name=?]', 'time_entry[project_id]', 0
assert_select 'input[name=?][value=1][type=hidden]', 'time_entry[project_id]'
end
def test_new_without_project
@ -61,8 +59,8 @@ class TimelogControllerTest < ActionController::TestCase
get :new
assert_response :success
assert_template 'new'
assert_tag 'select', :attributes => {:name => 'time_entry[project_id]'}
assert_select 'input[name=project_id]', 0
assert_select 'select[name=?]', 'time_entry[project_id]'
assert_select 'input[name=?]', 'time_entry[project_id]', 0
end
def test_new_without_project_should_prefill_the_form
@ -73,7 +71,7 @@ class TimelogControllerTest < ActionController::TestCase
assert_select 'select[name=?]', 'time_entry[project_id]' do
assert_select 'option[value=1][selected=selected]'
end
assert_select 'input[name=project_id]', 0
assert_select 'input[name=?]', 'time_entry[project_id]', 0
end
def test_new_without_project_should_deny_without_permission
@ -84,6 +82,22 @@ class TimelogControllerTest < ActionController::TestCase
assert_response 403
end
def test_new_should_select_default_activity
@request.session[:user_id] = 3
get :new, :project_id => 1
assert_response :success
assert_select 'select[name=?]', 'time_entry[activity_id]' do
assert_select 'option[selected=selected]', :text => 'Development'
end
end
def test_new_should_only_show_active_time_entry_activities
@request.session[:user_id] = 3
get :new, :project_id => 1
assert_response :success
assert_no_tag 'option', :content => 'Inactive Activity'
end
def test_get_edit_existing_time
@request.session[:user_id] = 2
get :edit, :id => 2, :project_id => nil