diff options
author | jessib <jessib@leap.se> | 2013-01-17 11:28:27 -0800 |
---|---|---|
committer | jessib <jessib@leap.se> | 2013-01-17 11:28:27 -0800 |
commit | a4105f068e6f8ce89fbba475048f2a1e02e0fcbc (patch) | |
tree | 91353015c71c5e2b73c416f1b6974423c1298632 /users/test/functional/users_controller_test.rb | |
parent | dc16c6f8e5382f9e5470eb2a40081d41f4112437 (diff) | |
parent | 6347fdbe0d932e78dfa8259bf81355edb19508e9 (diff) |
Merge branch 'master' into feature/tickets_controllers_simplification
Conflicts:
users/app/controllers/users_controller.rb
Diffstat (limited to 'users/test/functional/users_controller_test.rb')
-rw-r--r-- | users/test/functional/users_controller_test.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb index 8f1ee15..46db4d1 100644 --- a/users/test/functional/users_controller_test.rb +++ b/users/test/functional/users_controller_test.rb @@ -9,13 +9,64 @@ class UsersControllerTest < ActionController::TestCase assert_response :success end + test "failed show without login" do + user = find_record :user + get :show, :id => user.id + assert_response :redirect + assert_redirected_to login_path + end + + test "user can see user" do + user = find_record :user, + :email => nil, + :email_forward => nil, + :email_aliases => [], + :created_at => Time.now, + :updated_at => Time.now, + :most_recent_tickets => [] + login user + get :show, :id => user.id + assert_response :success + end + + test "admin can see other user" do + user = find_record :user, + :email => nil, + :email_forward => nil, + :email_aliases => [], + :created_at => Time.now, + :updated_at => Time.now, + :most_recent_tickets => [] + login :is_admin? => true + get :show, :id => user.id + assert_response :success + + end + + test "user cannot see other user" do + user = find_record :user, + :email => nil, + :email_forward => nil, + :email_aliases => [], + :created_at => Time.now, + :updated_at => Time.now, + :most_recent_tickets => [] + login + get :show, :id => user.id + assert_response :redirect + assert_access_denied + end + + test "should create new user" do user_attribs = record_attributes_for :user user = User.new(user_attribs) User.expects(:create).with(user_attribs).returns(user) + post :create, :user => user_attribs, :format => :json + assert_nil session[:user_id] assert_json_response user assert_response :success |