"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/functional/timelog_controller_test.rb" between
redmine-4.1.0.tar.gz and redmine-4.1.1.tar.gz

About: Redmine is a flexible project management and bug-tracking web application (using the Ruby on Rails framework). It supports also project wikis and forums, documents management, and multiple version control systems.

timelog_controller_test.rb  (redmine-4.1.0):timelog_controller_test.rb  (redmine-4.1.1)
skipping to change at line 49 skipping to change at line 49
get :new get :new
assert_response :success assert_response :success
assert_select 'input[name=?][type=hidden]', 'project_id', 0 assert_select 'input[name=?][type=hidden]', 'project_id', 0
assert_select 'input[name=?][type=hidden]', 'issue_id', 0 assert_select 'input[name=?][type=hidden]', 'issue_id', 0
assert_select 'span[id=?]', 'time_entry_issue' assert_select 'span[id=?]', 'time_entry_issue'
assert_select 'select[name=?]', 'time_entry[project_id]' do assert_select 'select[name=?]', 'time_entry[project_id]' do
# blank option for project # blank option for project
assert_select 'option[value=""]' assert_select 'option[value=""]'
end end
assert_select 'label[for=?]', 'time_entry_user_id', 0
assert_select 'select[name=?]', 'time_entry[user_id]', 0
end end
def test_new_with_project_id def test_new_with_project_id
@request.session[:user_id] = 3 @request.session[:user_id] = 3
get :new, :params => {:project_id => 1} get :new, :params => {:project_id => 1}
assert_response :success assert_response :success
assert_select 'input[name=?][type=hidden]', 'project_id' assert_select 'input[name=?][type=hidden]', 'project_id'
assert_select 'input[name=?][type=hidden]', 'issue_id', 0 assert_select 'input[name=?][type=hidden]', 'issue_id', 0
assert_select 'select[name=?]', 'time_entry[project_id]', 0 assert_select 'select[name=?]', 'time_entry[project_id]', 0
skipping to change at line 153 skipping to change at line 155
assert_response :success assert_response :success
assert_include '#time_entry_activity_id', response.body assert_include '#time_entry_activity_id', response.body
end end
def test_get_edit_existing_time def test_get_edit_existing_time
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :edit, :params => {:id => 2, :project_id => nil} get :edit, :params => {:id => 2, :project_id => nil}
assert_response :success assert_response :success
assert_select 'form[action=?]', '/time_entries/2' assert_select 'form[action=?]', '/time_entries/2'
# Time entry user should be shown as text
# for user without permission to log time for other users
assert_select 'label[for=?]', 'time_entry_user_id', 1
assert_select 'a.user.active', :text => 'Redmine Admin'
end end
def test_get_edit_with_an_existing_time_entry_with_inactive_activity def test_get_edit_with_an_existing_time_entry_with_inactive_activity
te = TimeEntry.find(1) te = TimeEntry.find(1)
te.activity = TimeEntryActivity.find_by_name("Inactive Activity") te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
te.save!(:validate => false) te.save!(:validate => false)
@request.session[:user_id] = 1 @request.session[:user_id] = 1
get :edit, :params => {:project_id => 1, :id => 1} get :edit, :params => {:project_id => 1, :id => 1}
assert_response :success assert_response :success
skipping to change at line 176 skipping to change at line 183
end end
def test_get_edit_should_show_projects_select def test_get_edit_should_show_projects_select
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :edit, :params => {:id => 2, :project_id => nil} get :edit, :params => {:id => 2, :project_id => nil}
assert_response :success assert_response :success
assert_select 'select[name=?]', 'time_entry[project_id]' assert_select 'select[name=?]', 'time_entry[project_id]'
end end
def test_get_edit_should_validate_back_url
@request.session[:user_id] = 2
get :edit, :params => {:id => 2, :project_id => nil, :back_url => '/valid'}
assert_response :success
assert_select 'a[href=?]', '/valid', {:text => 'Cancel'}
get :edit, :params => {:id => 2, :project_id => nil, :back_url => 'invalid'}
assert_response :success
assert_select 'a[href=?]', 'invalid', {:text => 'Cancel', :count => 0}
assert_select 'a[href=?]', '/projects/ecookbook/time_entries', {:text => 'Ca
ncel'}
end
def test_get_edit_with_an_existing_time_entry_with_locked_user
user = User.find(3)
entry = TimeEntry.generate!(:user_id => user.id, :comments => "Time entry on
a future locked user")
entry.save!
user.status = User::STATUS_LOCKED
user.save!
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
@request.session[:user_id] = 2
get :edit, :params => {
:id => entry.id
}
assert_response :success
assert_select 'select[name=?]', 'time_entry[user_id]' do
# User with id 3 should be selected even if it's locked
assert_select 'option[value="3"][selected=selected]'
end
end
def test_get_edit_for_other_user
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
@request.session[:user_id] = 2
get :edit, :params => {
:id => 1
}
assert_response :success
assert_select 'select[name=?]', 'time_entry[user_id]' do
assert_select 'option[value="2"][selected=selected]'
end
end
def test_post_create def test_post_create
@request.session[:user_id] = 3 @request.session[:user_id] = 3
assert_difference 'TimeEntry.count' do assert_difference 'TimeEntry.count' do
post :create, :params => { post :create, :params => {
:project_id => 1, :project_id => 1,
:time_entry => {:comments => 'Some work on TimelogControllerTest', :time_entry => {:comments => 'Some work on TimelogControllerTest',
# Not the default activity # Not the default activity
:activity_id => '11', :activity_id => '11',
:spent_on => '2008-03-14', :spent_on => '2008-03-14',
:issue_id => '1', :issue_id => '1',
skipping to change at line 329 skipping to change at line 386
} }
} }
assert_redirected_to '/projects/ecookbook/time_entries' assert_redirected_to '/projects/ecookbook/time_entries'
t = TimeEntry.last t = TimeEntry.last
assert_equal 3, t.user_id assert_equal 3, t.user_id
assert_equal 2, t.author_id assert_equal 2, t.author_id
end end
def test_create_for_other_user_should_deny_for_user_without_permission def test_create_for_other_user_should_fail_without_permission
Role.find_by_name('Manager').remove_permission! :log_time_for_other_users Role.find_by_name('Manager').remove_permission! :log_time_for_other_users
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :create, :params => { post :create, :params => {
:project_id => 1, :project_id => 1,
:time_entry => {:comments => 'Some work on TimelogControllerTest', :time_entry => {:comments => 'Some work on TimelogControllerTest',
# Not the default activity # Not the default activity
:activity_id => '11', :activity_id => '11',
:spent_on => '2008-03-14', :spent_on => '2008-03-14',
:issue_id => '1', :issue_id => '1',
:hours => '7.3', :hours => '7.3',
:user_id => '3' :user_id => '3'
} }
} }
assert_response 403 assert_response :success
assert_select 'p[id=?]', 'errorExplanation', :text => I18n.t(:error_not_allo assert_select_error /User is invalid/
wed_to_log_time_for_other_users)
end end
def test_create_and_continue_at_project_level def test_create_and_continue_at_project_level
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'TimeEntry.count' do assert_difference 'TimeEntry.count' do
post :create, :params => { post :create, :params => {
:time_entry => { :time_entry => {
:project_id => '1', :project_id => '1',
:activity_id => '11', :activity_id => '11',
:issue_id => '', :issue_id => '',
skipping to change at line 614 skipping to change at line 671
:id => entry.id, :id => entry.id,
:time_entry => { :time_entry => {
:project_id => '2' :project_id => '2'
} }
} }
assert_response :success assert_response :success
assert_select_error /Issue is invalid/ assert_select_error /Issue is invalid/
end end
def test_update_should_deny_changing_user_for_user_without_permission def test_update_should_fail_when_changing_user_without_permission
Role.find_by_name('Manager').remove_permission! :log_time_for_other_users Role.find_by_name('Manager').remove_permission! :log_time_for_other_users
@request.session[:user_id] = 2 @request.session[:user_id] = 2
put :update, :params => { put :update, :params => {
:id => 3, :id => 3,
:time_entry => { :time_entry => {
:user_id => '3' :user_id => '3'
} }
} }
assert_response 403 assert_response :success
assert_select 'p[id=?]', 'errorExplanation', :text => I18n.t(:error_not_allo assert_select_error /User is invalid/
wed_to_log_time_for_other_users) end
def test_update_should_allow_updating_existing_entry_logged_on_a_locked_user
entry = TimeEntry.generate!(:user_id => 2, :hours => 4, :comments => "Time e
ntry on a future locked user")
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
@request.session[:user_id] = 2
put :update, :params => {
:id => entry.id,
:time_entry => {
:hours => '6'
}
}
assert_response :redirect
entry.reload
# Ensure user didn't change
assert_equal 2, entry.user_id
assert_equal 6.0, entry.hours
end end
def test_get_bulk_edit def test_get_bulk_edit
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :bulk_edit, :params => {:ids => [1, 2]} get :bulk_edit, :params => {:ids => [1, 2]}
assert_response :success assert_response :success
assert_select 'ul#bulk-selection' do assert_select 'ul#bulk-selection' do
assert_select 'li', 2 assert_select 'li', 2
assert_select 'li a', :text => '03/23/2007 - eCookbook: 4.25 hours' assert_select 'li a', :text => '03/23/2007 - eCookbook: 4.25 hours (John S mith)'
end end
assert_select 'form#bulk_edit_form[action=?]', '/time_entries/bulk_update' d o assert_select 'form#bulk_edit_form[action=?]', '/time_entries/bulk_update' d o
assert_select 'select[name=?]', 'time_entry[project_id]' assert_select 'select[name=?]', 'time_entry[project_id]'
# Clear issue checkbox # Clear issue checkbox
assert_select 'input[name=?][value=?]', 'time_entry[issue_id]', 'none' assert_select 'input[name=?][value=?]', 'time_entry[issue_id]', 'none'
# System wide custom field # System wide custom field
assert_select 'select[name=?]', 'time_entry[custom_field_values][10]' assert_select 'select[name=?]', 'time_entry[custom_field_values][10]'
skipping to change at line 1408 skipping to change at line 1485
def test_index_csv_should_fill_issue_column_with_tracker_id_and_subject def test_index_csv_should_fill_issue_column_with_tracker_id_and_subject
issue = Issue.find(1) issue = Issue.find(1)
entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column cont ent test") entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column cont ent test")
get :index, :params => {:format => 'csv'} get :index, :params => {:format => 'csv'}
line = response.body.split("\n").detect {|l| l.include?(entry.comments)} line = response.body.split("\n").detect {|l| l.include?(entry.comments)}
assert_not_nil line assert_not_nil line
assert_include "#{issue.tracker} #1: #{issue.subject}", line assert_include "#{issue.tracker} #1: #{issue.subject}", line
end end
def test_index_csv_should_fill_issue_column_with_issue_id_if_issue_that_is_not
_visible
@request.session[:user_id] = 3
issue = Issue.generate!(:author_id => 1, :is_private => true)
entry = TimeEntry.generate!(:issue => issue, :comments => "Issue column cont
ent test")
get :index, :params => {:format => 'csv'}
assert_not issue.visible?
line = response.body.split("\n").detect {|l| l.include?(entry.comments)}
assert_not_nil line
assert_not_include "#{issue.tracker} ##{issue.id}: #{issue.subject}", line
assert_include "##{issue.id}", line
end
def test_index_grouped_by_created_on def test_index_grouped_by_created_on
skip unless TimeEntryQuery.new.groupable_columns.detect {|c| c.name == :crea ted_on} skip unless TimeEntryQuery.new.groupable_columns.detect {|c| c.name == :crea ted_on}
get :index, :params => { get :index, :params => {
:set_filter => 1, :set_filter => 1,
:group_by => 'created_on' :group_by => 'created_on'
} }
assert_response :success assert_response :success
assert_select 'tr.group span.name', :text => '03/23/2007' do assert_select 'tr.group span.name', :text => '03/23/2007' do
assert_select '+ span.count', :text => '2' assert_select '+ span.count', :text => '2'
end end
end end
def test_index_with_inline_issue_long_text_custom_field_column
field = IssueCustomField.create!(:name => 'Long text', :field_format => 'tex
t', :full_width_layout => '1',
:tracker_ids => [1], :is_for_all => true)
issue = Issue.find(1)
issue.custom_field_values = {field.id => 'This is a long text'}
issue.save!
get :index, :params => {
:set_filter => 1,
:c => ['subject', 'description', "issue.cf_#{field.id}"]
}
assert_response :success
assert_select "td.issue_cf_#{field.id}", :text => 'This is a long text'
end
end end
 End of changes. 10 change blocks. 
9 lines changed or deleted 118 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)