summaryrefslogtreecommitdiffstats
path: root/test/integration/api_test/users_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/api_test/users_test.rb')
-rw-r--r--test/integration/api_test/users_test.rb114
1 files changed, 69 insertions, 45 deletions
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 9118a8b9c..53209f72f 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -21,7 +21,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
fixtures :users, :email_addresses, :members, :member_roles, :roles, :projects
test "GET /users.xml should return users" do
- get '/users.xml', {}, credentials('admin')
+ get '/users.xml', :headers => credentials('admin')
assert_response :success
assert_equal 'application/xml', response.content_type
@@ -31,7 +31,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
end
test "GET /users.json should return users" do
- get '/users.json', {}, credentials('admin')
+ get '/users.json', :headers => credentials('admin')
assert_response :success
assert_equal 'application/json', response.content_type
@@ -84,56 +84,58 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
end
test "GET /users/current.xml should return current user" do
- get '/users/current.xml', {}, credentials('jsmith')
+ get '/users/current.xml', :headers => credentials('jsmith')
assert_select 'user id', :text => '2'
end
test "GET /users/:id should not return login for other user" do
- get '/users/3.xml', {}, credentials('jsmith')
+ get '/users/3.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user login', 0
end
test "GET /users/:id should return login for current user" do
- get '/users/2.xml', {}, credentials('jsmith')
+ get '/users/2.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user login', :text => 'jsmith'
end
test "GET /users/:id should not return api_key for other user" do
- get '/users/3.xml', {}, credentials('jsmith')
+ get '/users/3.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user api_key', 0
end
test "GET /users/:id should return api_key for current user" do
- get '/users/2.xml', {}, credentials('jsmith')
+ get '/users/2.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user api_key', :text => User.find(2).api_key
end
test "GET /users/:id should not return status for standard user" do
- get '/users/3.xml', {}, credentials('jsmith')
+ get '/users/3.xml', :headers => credentials('jsmith')
assert_response :success
assert_select 'user status', 0
end
test "GET /users/:id should return status for administrators" do
- get '/users/2.xml', {}, credentials('admin')
+ get '/users/2.xml', :headers => credentials('admin')
assert_response :success
assert_select 'user status', :text => User.find(1).status.to_s
end
test "POST /users.xml with valid parameters should create the user" do
assert_difference('User.count') do
- post '/users.xml', {
- :user => {
- :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
- :mail => 'foo@example.net', :password => 'secret123',
- :mail_notification => 'only_assigned'}
+ post '/users.xml',
+ :params => {
+ :user => {
+ :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
+ :mail => 'foo@example.net', :password => 'secret123',
+ :mail_notification => 'only_assigned'
+ }
},
- credentials('admin')
+ :headers => credentials('admin')
end
user = User.order('id DESC').first
@@ -152,13 +154,15 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "POST /users.json with valid parameters should create the user" do
assert_difference('User.count') do
- post '/users.json', {
- :user => {
- :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
- :mail => 'foo@example.net', :password => 'secret123',
- :mail_notification => 'only_assigned'}
+ post '/users.json',
+ :params => {
+ :user => {
+ :login => 'foo', :firstname => 'Firstname', :lastname => 'Lastname',
+ :mail => 'foo@example.net', :password => 'secret123',
+ :mail_notification => 'only_assigned'
+ }
},
- credentials('admin')
+ :headers => credentials('admin')
end
user = User.order('id DESC').first
@@ -178,7 +182,13 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "POST /users.xml with with invalid parameters should return errors" do
assert_no_difference('User.count') do
- post '/users.xml', {:user => {:login => 'foo', :lastname => 'Lastname', :mail => 'foo'}}, credentials('admin')
+ post '/users.xml',
+ :params => {
+ :user =>{
+ :login => 'foo', :lastname => 'Lastname', :mail => 'foo'
+ }
+ },
+ :headers => credentials('admin')
end
assert_response :unprocessable_entity
@@ -188,7 +198,13 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "POST /users.json with with invalid parameters should return errors" do
assert_no_difference('User.count') do
- post '/users.json', {:user => {:login => 'foo', :lastname => 'Lastname', :mail => 'foo'}}, credentials('admin')
+ post '/users.json',
+ :params => {
+ :user => {
+ :login => 'foo', :lastname => 'Lastname', :mail => 'foo'
+ }
+ },
+ :headers => credentials('admin')
end
assert_response :unprocessable_entity
@@ -201,12 +217,14 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "PUT /users/:id.xml with valid parameters should update the user" do
assert_no_difference('User.count') do
- put '/users/2.xml', {
- :user => {
- :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
- :mail => 'jsmith@somenet.foo'}
+ put '/users/2.xml',
+ :params => {
+ :user => {
+ :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
+ :mail => 'jsmith@somenet.foo'
+ }
},
- credentials('admin')
+ :headers => credentials('admin')
end
user = User.find(2)
@@ -222,12 +240,14 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "PUT /users/:id.json with valid parameters should update the user" do
assert_no_difference('User.count') do
- put '/users/2.json', {
- :user => {
- :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
- :mail => 'jsmith@somenet.foo'}
+ put '/users/2.json',
+ :params => {
+ :user => {
+ :login => 'jsmith', :firstname => 'John', :lastname => 'Renamed',
+ :mail => 'jsmith@somenet.foo'
+ }
},
- credentials('admin')
+ :headers => credentials('admin')
end
user = User.find(2)
@@ -243,12 +263,14 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "PUT /users/:id.xml with invalid parameters" do
assert_no_difference('User.count') do
- put '/users/2.xml', {
- :user => {
- :login => 'jsmith', :firstname => '', :lastname => 'Lastname',
- :mail => 'foo'}
+ put '/users/2.xml',
+ :params => {
+ :user => {
+ :login => 'jsmith', :firstname => '', :lastname => 'Lastname',
+ :mail => 'foo'
+ }
},
- credentials('admin')
+ :headers => credentials('admin')
end
assert_response :unprocessable_entity
@@ -258,12 +280,14 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "PUT /users/:id.json with invalid parameters" do
assert_no_difference('User.count') do
- put '/users/2.json', {
- :user => {
- :login => 'jsmith', :firstname => '', :lastname => 'Lastname',
- :mail => 'foo'}
+ put '/users/2.json',
+ :params => {
+ :user => {
+ :login => 'jsmith', :firstname => '', :lastname => 'Lastname',
+ :mail => 'foo'
+ }
},
- credentials('admin')
+ :headers => credentials('admin')
end
assert_response :unprocessable_entity
@@ -276,7 +300,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "DELETE /users/:id.xml should delete the user" do
assert_difference('User.count', -1) do
- delete '/users/2.xml', {}, credentials('admin')
+ delete '/users/2.xml', :headers => credentials('admin')
end
assert_response :ok
@@ -285,7 +309,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "DELETE /users/:id.json should delete the user" do
assert_difference('User.count', -1) do
- delete '/users/2.json', {}, credentials('admin')
+ delete '/users/2.json', :headers => credentials('admin')
end
assert_response :ok