Revision 355bce36
Added by Ohad Levy over 10 years ago
test/functional/users_controller_test.rb | ||
---|---|---|
|
||
test "should modify session when locale is updated" do
|
||
User.current = User.admin
|
||
put :update, {:id => User.admin.id, :user => { :locale => "cs" } }, set_session_user
|
||
put :update, { :id => User.admin.id, :user => { :locale => "cs" } }, set_session_user
|
||
assert_redirected_to users_url
|
||
assert User.admin.locale == "cs"
|
||
assert_equal "cs", User.admin.locale
|
||
|
||
put :update, { :id => User.admin.id, :user => { :locale => "" } }, set_session_user
|
||
assert User.admin.locale.nil?
|
||
assert session[:locale].nil?
|
||
assert_nil User.admin.locale
|
||
assert_nil session[:locale]
|
||
end
|
||
|
||
test "should not delete same user" do
|
||
... | ... | |
|
||
test 'user with viewer rights should fail to edit a user' do
|
||
get :edit, {:id => User.first.id}
|
||
assert_equal @response.status, 403
|
||
assert_response 403
|
||
end
|
||
|
||
test 'user with viewer rights should succeed in viewing users' do
|
||
... | ... | |
assert_redirected_to edit_user_path(User.find_by_login('ares'))
|
||
end
|
||
|
||
test 'non admin user should edit itself' do
|
||
User.current = users(:one)
|
||
get :edit, { :id => User.current.id }
|
||
assert_response :success
|
||
end
|
||
|
||
test 'non admin user should be able to update itself' do
|
||
User.current = users(:one)
|
||
put :update, { :id => users(:one).id, :user => { :firstname => 'test' } }
|
||
assert_response :success
|
||
end
|
||
|
||
test 'non admin user should not be able to edit another user' do
|
||
User.current = users(:one)
|
||
get :edit, { :id => users(:two) }
|
||
assert_response 403
|
||
end
|
||
|
||
test 'non admin user should not be able to update another user' do
|
||
User.current = users(:one)
|
||
put :update, { :id => users(:two).id, :user => { :firstname => 'test' } }
|
||
assert_response 403
|
||
end
|
||
|
||
end
|
Also available in: Unified diff
fixes #3930 - refactoring of edit_self implementation.