summaryrefslogtreecommitdiff
path: root/test/functional/users_controller_test.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2012-12-17 12:01:45 +0100
commitb80bd744ad873f6fc43018bc4bfb90677de167bd (patch)
tree072c4b0e33d442528555b82c415f5e7a1712b2b0 /test/functional/users_controller_test.rb
parent3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff)
Start of GS5.
Diffstat (limited to 'test/functional/users_controller_test.rb')
-rw-r--r--test/functional/users_controller_test.rb65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
new file mode 100644
index 0000000..d1898f7
--- /dev/null
+++ b/test/functional/users_controller_test.rb
@@ -0,0 +1,65 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+ setup do
+ @tenant = Factory.create(:tenant)
+ @user = Factory.create(:user)
+
+ @tenant.tenant_memberships.create(:user_id => @user.id)
+
+ @user.update_attributes!(:current_tenant_id => @tenant.id)
+
+ @expected_status_if_not_authorized = :redirect
+ end
+
+ test "should get index" do
+ session[:user_id] = @user.id
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:users)
+ end
+
+ test "should get new" do
+ session[:user_id] = nil
+ get :new
+ assert_response :success
+ end
+
+ # TODO Fix Test
+ #
+ # test "should create user" do
+ # session[:user_id] = nil
+ # assert_difference('User.count') do
+ # post :create, user: Factory.build(:user).attributes
+ # end
+ #
+ # # assert_redirected_to user_path(assigns(:user))
+ # end
+
+ test "should show user" do
+ session[:user_id] = @user.id
+ get :show, id: @user.to_param
+ assert_response :success
+ end
+
+
+ test "should get edit" do
+ session[:user_id] = @user.id
+ get :edit, id: @user.to_param
+ assert_response :success
+ end
+
+ test "should update user" do
+ session[:user_id] = @user.id
+ put :update, id: @user.to_param, user: @user.attributes
+ assert_redirected_to user_path(assigns(:user))
+ end
+
+ test "should not destroy itself" do
+ assert_no_difference('User.count') do
+ delete :destroy, id: @user.to_param
+ end
+
+# assert_redirected_to users_path
+ end
+end