186 |
186 |
assert_select 'a[href=?]', '/projects/ecookbook/time_entries', {:text => 'Cancel'}
|
187 |
187 |
end
|
188 |
188 |
|
|
189 |
def test_get_edit_with_an_existing_time_entry_with_locked_user
|
|
190 |
user = User.find(3)
|
|
191 |
entry = TimeEntry.generate!(:user_id => user.id, :comments => "Time entry on a future locked user")
|
|
192 |
entry.save!
|
|
193 |
|
|
194 |
user.status = User::STATUS_LOCKED
|
|
195 |
user.save!
|
|
196 |
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
|
197 |
@request.session[:user_id] = 2
|
|
198 |
|
|
199 |
get :edit, :params => {
|
|
200 |
:id => entry.id
|
|
201 |
}
|
|
202 |
|
|
203 |
assert_response :success
|
|
204 |
|
|
205 |
assert_select 'select[name=?]', 'time_entry[user_id]' do
|
|
206 |
# User with id 3 should be selected even if it's locked
|
|
207 |
assert_select 'option[value="3"][selected=selected]'
|
|
208 |
end
|
|
209 |
end
|
|
210 |
|
189 |
211 |
def test_post_create
|
190 |
212 |
@request.session[:user_id] = 3
|
191 |
213 |
assert_difference 'TimeEntry.count' do
|
... | ... | |
639 |
661 |
assert_select 'p[id=?]', 'errorExplanation', :text => I18n.t(:error_not_allowed_to_log_time_for_other_users)
|
640 |
662 |
end
|
641 |
663 |
|
|
664 |
def test_update_should_allow_updating_existing_entry_logged_on_a_locked_user
|
|
665 |
entry = TimeEntry.generate!(:user_id => 2, :hours => 4, :comments => "Time entry on a future locked user")
|
|
666 |
Role.find_by_name('Manager').add_permission! :log_time_for_other_users
|
|
667 |
@request.session[:user_id] = 2
|
|
668 |
|
|
669 |
put :update, :params => {
|
|
670 |
:id => entry.id,
|
|
671 |
:time_entry => {
|
|
672 |
:hours => '6'
|
|
673 |
}
|
|
674 |
}
|
|
675 |
|
|
676 |
assert_response :redirect
|
|
677 |
|
|
678 |
entry.reload
|
|
679 |
# Ensure user didn't change
|
|
680 |
assert_equal 2, entry.user_id
|
|
681 |
assert_equal 6.0, entry.hours
|
|
682 |
end
|
|
683 |
|
642 |
684 |
def test_get_bulk_edit
|
643 |
685 |
@request.session[:user_id] = 2
|
644 |
686 |
|