From: Jean-Philippe Lang Date: Thu, 9 Aug 2012 17:12:24 +0000 (+0000) Subject: Don't show the project dropdown when logging time on an issue. X-Git-Tag: 2.1.0~149 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e06bf0c464184a457fa15efde1b7ddf8aede3f67;p=redmine.git 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 --- diff --git a/app/views/timelog/_form.html.erb b/app/views/timelog/_form.html.erb index 8b1ed3a0a..7ecdd446d 100644 --- a/app/views/timelog/_form.html.erb +++ b/app/views/timelog/_form.html.erb @@ -3,7 +3,7 @@
<% if @time_entry.new_record? %> - <% if params[:project_id] %> + <% if params[:project_id] || @time_entry.issue %> <%= f.hidden_field :project_id %> <% else %>

<%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).all, :selected => @time_entry.project), :required => true %>

diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 3e159c39d..c83d4d17f 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -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