summaryrefslogtreecommitdiff
path: root/users/test
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-01-17 09:36:27 -0800
committerjessib <jessib@riseup.net>2013-01-17 09:36:27 -0800
commitb550cd14f33b9664fe6b547dc56107fae7d12caf (patch)
tree78034e20632f9e6361deb7e1000db0bcb079f03f /users/test
parentee2ea4ac8f4c6b0c3b09be6ed49e7a1faec7a9c1 (diff)
parent9d53f7b2d1b34da6b6103e97bd6c931cedb23e9b (diff)
Merge pull request #14 from leapcode/feature/show_user
Adding show view for users.
Diffstat (limited to 'users/test')
-rw-r--r--users/test/functional/users_controller_test.rb51
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