mirror of
https://github.com/redmine/redmine.git
synced 2025-11-11 07:46:02 +01:00
shorten long line of TimelogControllerTest
git-svn-id: http://svn.redmine.org/redmine/trunk@20528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1133,10 +1133,29 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_should_sort_by_spent_on_and_created_on
|
def test_index_should_sort_by_spent_on_and_created_on
|
||||||
t1 = TimeEntry.create!(:author => User.find(1), :user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:00:00', :activity_id => 10)
|
t1 =
|
||||||
t2 = TimeEntry.create!(:author => User.find(1), :user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00', :activity_id => 10)
|
TimeEntry.create!(
|
||||||
t3 = TimeEntry.create!(:author => User.find(1), :user => User.find(1), :project => Project.find(1), :hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00', :activity_id => 10)
|
:author => User.find(1), :user => User.find(1),
|
||||||
|
:project => Project.find(1),
|
||||||
|
:hours => 1,
|
||||||
|
:spent_on => '2012-06-16', :created_on => '2012-06-16 20:00:00',
|
||||||
|
:activity_id => 10
|
||||||
|
)
|
||||||
|
t2 =
|
||||||
|
TimeEntry.create!(
|
||||||
|
:author => User.find(1), :user => User.find(1),
|
||||||
|
:project => Project.find(1),
|
||||||
|
:hours => 1,
|
||||||
|
:spent_on => '2012-06-16', :created_on => '2012-06-16 20:05:00',
|
||||||
|
:activity_id => 10
|
||||||
|
)
|
||||||
|
t3 =
|
||||||
|
TimeEntry.create!(
|
||||||
|
:author => User.find(1), :user => User.find(1),
|
||||||
|
:project => Project.find(1),
|
||||||
|
:hours => 1, :spent_on => '2012-06-15', :created_on => '2012-06-16 20:10:00',
|
||||||
|
:activity_id => 10
|
||||||
|
)
|
||||||
get :index, :params => {
|
get :index, :params => {
|
||||||
:project_id => 1,
|
:project_id => 1,
|
||||||
:f => ['spent_on'],
|
:f => ['spent_on'],
|
||||||
@@ -1144,8 +1163,10 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
:v => {'spent_on' => ['2012-06-15', '2012-06-16']}
|
:v => {'spent_on' => ['2012-06-15', '2012-06-16']}
|
||||||
}
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal [t2, t1, t3].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
assert_equal(
|
||||||
|
[t2, t1, t3].map(&:id).map(&:to_s),
|
||||||
|
css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||||
|
)
|
||||||
get(
|
get(
|
||||||
:index,
|
:index,
|
||||||
:params => {
|
:params => {
|
||||||
@@ -1157,7 +1178,10 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal [t3, t1, t2].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
assert_equal(
|
||||||
|
[t3, t1, t2].map(&:id).map(&:to_s),
|
||||||
|
css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_activity_filter
|
def test_index_with_activity_filter
|
||||||
@@ -1381,7 +1405,11 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_filter_on_issue_custom_field
|
def test_index_with_filter_on_issue_custom_field
|
||||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
|
issue =
|
||||||
|
Issue.generate!(
|
||||||
|
:project_id => 1, :tracker_id => 1,
|
||||||
|
:custom_field_values => {2 => 'filter_on_issue_custom_field'}
|
||||||
|
)
|
||||||
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
|
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
|
||||||
|
|
||||||
get :index, :params => {
|
get :index, :params => {
|
||||||
@@ -1390,11 +1418,18 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
:v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
|
:v => {'issue.cf_2' => ['filter_on_issue_custom_field']}
|
||||||
}
|
}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
assert_equal(
|
||||||
|
[entry].map(&:id).map(&:to_s),
|
||||||
|
css_select('input[name="ids[]"]').map {|e| e.attr('value')}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_index_with_issue_custom_field_column
|
def test_index_with_issue_custom_field_column
|
||||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {2 => 'filter_on_issue_custom_field'})
|
issue =
|
||||||
|
Issue.generate!(
|
||||||
|
:project_id => 1, :tracker_id => 1,
|
||||||
|
:custom_field_values => {2 => 'filter_on_issue_custom_field'}
|
||||||
|
)
|
||||||
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
|
entry = TimeEntry.generate!(:issue => issue, :hours => 2.5)
|
||||||
|
|
||||||
get :index, :params => {
|
get :index, :params => {
|
||||||
@@ -1438,8 +1473,15 @@ class TimelogControllerTest < Redmine::ControllerTest
|
|||||||
|
|
||||||
def test_index_with_invalid_date_filter_should_not_validate
|
def test_index_with_invalid_date_filter_should_not_validate
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
|
get(
|
||||||
get :index, :params => {:set_filter => '1', :f => ['spent_on'], :op => {'spent_on' => '='}, :v => {'spent_on' => ['2016-09-010']}}
|
:index,
|
||||||
|
:params => {
|
||||||
|
:set_filter => '1',
|
||||||
|
:f => ['spent_on'],
|
||||||
|
:op => {'spent_on' => '='},
|
||||||
|
:v => {'spent_on' => ['2016-09-010']}
|
||||||
|
}
|
||||||
|
)
|
||||||
assert_select_error 'Date is invalid'
|
assert_select_error 'Date is invalid'
|
||||||
assert_select 'table.time-entries', 0
|
assert_select 'table.time-entries', 0
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user