summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-01-17 22:42:47 -0800
committerazul <azul@riseup.net>2013-01-17 22:42:47 -0800
commit19d563e2e2db98ecc5143229f554df6a09bc457e (patch)
tree954e7c9a1865150a0cf4d08842d1365b75259d57 /users/test/functional
parentc172c91d8041fbf85ec6b0054c30f31d41a1008b (diff)
parent444dbca4054ccfb7a82bb4df2a6369959ef6c9b2 (diff)
Merge pull request #17 from leapcode/feature/tickets_controllers_simplification
Refactoring of tickets controller to fetch the ticket in a before filter...
Diffstat (limited to 'users/test/functional')
-rw-r--r--users/test/functional/users_controller_test.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/users/test/functional/users_controller_test.rb b/users/test/functional/users_controller_test.rb
index 46db4d1..9fb06c9 100644
--- a/users/test/functional/users_controller_test.rb
+++ b/users/test/functional/users_controller_test.rb
@@ -10,10 +10,12 @@ class UsersControllerTest < ActionController::TestCase
end
test "failed show without login" do
- user = find_record :user
+ user = FactoryGirl.build(:user)
+ user.save
get :show, :id => user.id
assert_response :redirect
assert_redirected_to login_path
+ user.destroy
end
test "user can see user" do
@@ -42,7 +44,7 @@ class UsersControllerTest < ActionController::TestCase
assert_response :success
end
-
+
test "user cannot see other user" do
user = find_record :user,
:email => nil,
@@ -57,6 +59,25 @@ class UsersControllerTest < ActionController::TestCase
assert_access_denied
end
+ test "show for non-existing user" do
+ nonid = 'thisisnotanexistinguserid'
+
+ # when unauthenticated:
+ get :show, :id => nonid
+ assert_access_denied(true, false)
+
+ # when authenticated but not admin:
+ login
+ get :show, :id => nonid
+ assert_access_denied
+
+ # when authenticated as admin:
+ login :is_admin? => true
+ get :show, :id => nonid
+ assert_response :redirect
+ assert_equal({:alert => "No such user."}, flash.to_hash)
+ assert_redirected_to users_path
+ end
test "should create new user" do
user_attribs = record_attributes_for :user