git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5297 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/1.2.0
<h2><%= l(:label_spent_time) %></h2> | <h2><%= l(:label_spent_time) %></h2> | ||||
<% form_remote_tag(:url => {}, :html => {:method => :get, :id => 'query_form'}, :method => :get, :update => 'content') do %> | |||||
<% form_tag({:controller => 'time_entry_reports', :action => 'report', :project_id => @project, :issue_id => @issue}, :method => :get, :id => 'query_form') do %> | |||||
<% @criterias.each do |criteria| %> | <% @criterias.each do |criteria| %> | ||||
<%= hidden_field_tag 'criterias[]', criteria, :id => nil %> | <%= hidden_field_tag 'criterias[]', criteria, :id => nil %> | ||||
<% end %> | <% end %> | ||||
:onchange => "this.form.onsubmit();" %> | :onchange => "this.form.onsubmit();" %> | ||||
<%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l_or_humanize(@available_criterias[k][:label]), k]}), | <%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l_or_humanize(@available_criterias[k][:label]), k]}), | ||||
:onchange => "this.form.onsubmit();", | |||||
:onchange => "this.form.submit();", | |||||
:style => 'width: 200px', | :style => 'width: 200px', | ||||
:id => nil, | :id => nil, | ||||
:disabled => (@criterias.length >= 3)) %> | :disabled => (@criterias.length >= 3)) %> | ||||
<%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @columns}, | |||||
:method => :get, | |||||
:update => 'content' | |||||
}, :class => 'icon icon-reload' %></p> | |||||
<%= link_to l(:button_clear), {:project_id => @project, :issue_id => @issue, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @columns}, :class => 'icon icon-reload' %></p> | |||||
<% end %> | <% end %> | ||||
<% unless @criterias.empty? %> | <% unless @criterias.empty? %> |
<p> | <p> | ||||
<%= radio_button_tag 'period_type', '1', !@free_period %> | <%= radio_button_tag 'period_type', '1', !@free_period %> | ||||
<%= select_tag 'period', options_for_period_select(params[:period]), | <%= select_tag 'period', options_for_period_select(params[:period]), | ||||
:onchange => 'this.form.onsubmit();', | |||||
:onchange => 'this.form.submit();', | |||||
:onfocus => '$("period_type_1").checked = true;' %> | :onfocus => '$("period_type_1").checked = true;' %> | ||||
</p> | </p> | ||||
<p> | <p> | ||||
</div> | </div> | ||||
</fieldset> | </fieldset> | ||||
<p class="buttons"> | <p class="buttons"> | ||||
<%= link_to_remote l(:button_apply), | |||||
{ :url => { }, | |||||
:update => "content", | |||||
:with => "Form.serialize('query_form')", | |||||
:method => :get | |||||
}, :class => 'icon icon-checked' %> | |||||
<%= link_to_function l(:button_apply), '$("query_form").submit()', :class => 'icon icon-checked' %> | |||||
<%= link_to l(:button_clear), {:controller => controller_name, :action => action_name, :project_id => @project, :issue_id => @issue}, :class => 'icon icon-reload' %> | |||||
</p> | </p> | ||||
<div class="tabs"> | <div class="tabs"> |
<h2><%= l(:label_spent_time) %></h2> | <h2><%= l(:label_spent_time) %></h2> | ||||
<% form_remote_tag( :url => {}, :html => {:method => :get, :id => 'query_form'}, :method => :get, :update => 'content' ) do %> | |||||
<%# TOOD: remove the project_id and issue_id hidden fields, that information is | |||||
already in the URI %> | |||||
<%= hidden_field_tag('project_id', params[:project_id]) if @project %> | |||||
<%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %> | |||||
<% form_tag({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}, :method => :get, :id => 'query_form') do %> | |||||
<%= render :partial => 'date_range' %> | <%= render :partial => 'date_range' %> | ||||
<% end %> | <% end %> | ||||
map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' | ||||
map.connect 'help/:ctrl/:page', :controller => 'help' | map.connect 'help/:ctrl/:page', :controller => 'help' | ||||
map.connect 'projects/:project_id/time_entries/report', :controller => 'time_entry_reports', :action => 'report' | |||||
map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report| | map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report| | ||||
time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report' | |||||
time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report.:format' | |||||
time_report.connect 'projects/:project_id/time_entries/report' | |||||
time_report.connect 'projects/:project_id/time_entries/report.:format' | |||||
time_report.connect 'time_entries/report' | time_report.connect 'time_entries/report' | ||||
time_report.connect 'time_entries/report.:format' | time_report.connect 'time_entries/report.:format' | ||||
time_report.connect 'projects/:project_id/time_entries/report.:format' | |||||
end | end | ||||
# TODO: wasteful since this is also nested under issues, projects, and projects/issues | |||||
map.resources :time_entries, :controller => 'timelog' | map.resources :time_entries, :controller => 'timelog' | ||||
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} |
class TimeEntryReportsControllerTest < ActionController::TestCase | class TimeEntryReportsControllerTest < ActionController::TestCase | ||||
fixtures :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values | fixtures :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values | ||||
def test_report_no_criteria | |||||
get :report, :project_id => 1 | |||||
def test_report_at_project_level | |||||
get :report, :project_id => 'ecookbook' | |||||
assert_response :success | assert_response :success | ||||
assert_template 'report' | assert_template 'report' | ||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/time_entries/report", :id => 'query_form'} | |||||
end | end | ||||
def test_report_all_projects | def test_report_all_projects | ||||
get :report | get :report | ||||
assert_response :success | assert_response :success | ||||
assert_template 'report' | assert_template 'report' | ||||
assert_tag :form, | |||||
:attributes => {:action => "/time_entries/report", :id => 'query_form'} | |||||
end | end | ||||
def test_report_all_projects_denied | def test_report_all_projects_denied | ||||
assert_template 'report' | assert_template 'report' | ||||
assert_not_nil assigns(:total_hours) | assert_not_nil assigns(:total_hours) | ||||
assert_equal "154.25", "%.2f" % assigns(:total_hours) | assert_equal "154.25", "%.2f" % assigns(:total_hours) | ||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/issues/1/time_entries/report", :id => 'query_form'} | |||||
end | end | ||||
def test_report_custom_field_criteria | def test_report_custom_field_criteria |
assert_template 'index' | assert_template 'index' | ||||
assert_not_nil assigns(:total_hours) | assert_not_nil assigns(:total_hours) | ||||
assert_equal "162.90", "%.2f" % assigns(:total_hours) | assert_equal "162.90", "%.2f" % assigns(:total_hours) | ||||
assert_tag :form, | |||||
:attributes => {:action => "/time_entries", :id => 'query_form'} | |||||
end | end | ||||
def test_index_at_project_level | def test_index_at_project_level | ||||
get :index, :project_id => 1 | |||||
get :index, :project_id => 'ecookbook' | |||||
assert_response :success | assert_response :success | ||||
assert_template 'index' | assert_template 'index' | ||||
assert_not_nil assigns(:entries) | assert_not_nil assigns(:entries) | ||||
# display all time by default | # display all time by default | ||||
assert_equal '2007-03-12'.to_date, assigns(:from) | assert_equal '2007-03-12'.to_date, assigns(:from) | ||||
assert_equal '2007-04-22'.to_date, assigns(:to) | assert_equal '2007-04-22'.to_date, assigns(:to) | ||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} | |||||
end | end | ||||
def test_index_at_project_level_with_date_range | def test_index_at_project_level_with_date_range | ||||
get :index, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30' | |||||
get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30' | |||||
assert_response :success | assert_response :success | ||||
assert_template 'index' | assert_template 'index' | ||||
assert_not_nil assigns(:entries) | assert_not_nil assigns(:entries) | ||||
assert_equal "12.90", "%.2f" % assigns(:total_hours) | assert_equal "12.90", "%.2f" % assigns(:total_hours) | ||||
assert_equal '2007-03-20'.to_date, assigns(:from) | assert_equal '2007-03-20'.to_date, assigns(:from) | ||||
assert_equal '2007-04-30'.to_date, assigns(:to) | assert_equal '2007-04-30'.to_date, assigns(:to) | ||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} | |||||
end | end | ||||
def test_index_at_project_level_with_period | def test_index_at_project_level_with_period | ||||
get :index, :project_id => 1, :period => '7_days' | |||||
get :index, :project_id => 'ecookbook', :period => '7_days' | |||||
assert_response :success | assert_response :success | ||||
assert_template 'index' | assert_template 'index' | ||||
assert_not_nil assigns(:entries) | assert_not_nil assigns(:entries) | ||||
assert_not_nil assigns(:total_hours) | assert_not_nil assigns(:total_hours) | ||||
assert_equal Date.today - 7, assigns(:from) | assert_equal Date.today - 7, assigns(:from) | ||||
assert_equal Date.today, assigns(:to) | assert_equal Date.today, assigns(:to) | ||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} | |||||
end | end | ||||
def test_index_one_day | def test_index_one_day | ||||
get :index, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23" | |||||
get :index, :project_id => 'ecookbook', :from => "2007-03-23", :to => "2007-03-23" | |||||
assert_response :success | assert_response :success | ||||
assert_template 'index' | assert_template 'index' | ||||
assert_not_nil assigns(:total_hours) | assert_not_nil assigns(:total_hours) | ||||
assert_equal "4.25", "%.2f" % assigns(:total_hours) | assert_equal "4.25", "%.2f" % assigns(:total_hours) | ||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} | |||||
end | end | ||||
def test_index_at_issue_level | def test_index_at_issue_level | ||||
# display all time based on what's been logged | # display all time based on what's been logged | ||||
assert_equal '2007-03-12'.to_date, assigns(:from) | assert_equal '2007-03-12'.to_date, assigns(:from) | ||||
assert_equal '2007-04-22'.to_date, assigns(:to) | assert_equal '2007-04-22'.to_date, assigns(:to) | ||||
# TODO: remove /projects/:project_id/issues/:issue_id/time_entries routes | |||||
# to use /issues/:issue_id/time_entries | |||||
assert_tag :form, | |||||
:attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} | |||||
end | end | ||||
def test_index_atom_feed | def test_index_atom_feed |