Commit e68b4d65e6230fe7de98e62bc07fa9f20a75dd8c
1 parent
2168439b
Exists in
api_tasks
and in
3 other branches
api: removes obsolete user tests and fixes person creation test
Showing
3 changed files
with
4 additions
and
51 deletions
Show diff stats
lib/noosfero/api/v1/people.rb
... | ... | @@ -57,7 +57,9 @@ module Noosfero |
57 | 57 | user_data[:password] = params[:person].delete(:password) |
58 | 58 | user_data[:password_confirmation] = params[:person].delete(:password_confirmation) |
59 | 59 | user = User.build(user_data, params[:person], environment) |
60 | - if !user.signup! | |
60 | + begin | |
61 | + user.signup! | |
62 | + rescue ActiveRecord::RecordInvalid | |
61 | 63 | render_api_errors!(user.errors.full_messages) |
62 | 64 | end |
63 | 65 | ... | ... |
test/unit/api/people_test.rb
... | ... | @@ -112,7 +112,7 @@ class PeopleTest < ActiveSupport::TestCase |
112 | 112 | |
113 | 113 | should 'return 400 status for invalid person creation' do |
114 | 114 | params[:person] = {:login => 'some'} |
115 | - post "/api/v1/users?#{params.to_query}" | |
115 | + post "/api/v1/people?#{params.to_query}" | |
116 | 116 | json = JSON.parse(last_response.body) |
117 | 117 | assert_equal 400, last_response.status |
118 | 118 | end | ... | ... |
test/unit/api/users_test.rb
... | ... | @@ -1,49 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/test_helper' | |
2 | - | |
3 | -class UsersTest < ActiveSupport::TestCase | |
4 | - | |
5 | - def setup | |
6 | - login_api | |
7 | - end | |
8 | - | |
9 | - should 'list users' do | |
10 | - get "/api/v1/users/?#{params.to_query}" | |
11 | - json = JSON.parse(last_response.body) | |
12 | - assert_includes json["users"].map { |a| a["login"] }, user.login | |
13 | - end | |
14 | - | |
15 | - should 'create a user' do | |
16 | - params[:user] = {:login => 'some', :password => '123456', :password_confirmation => '123456', :email => 'some@some.com'} | |
17 | - post "/api/v1/users?#{params.to_query}" | |
18 | - json = JSON.parse(last_response.body) | |
19 | - assert_equal 'some', json['user']['login'] | |
20 | - end | |
21 | - | |
22 | - should 'return 400 status for invalid user creation' do | |
23 | - params[:user] = {:login => 'some'} | |
24 | - post "/api/v1/users?#{params.to_query}" | |
25 | - json = JSON.parse(last_response.body) | |
26 | - assert_equal 400, last_response.status | |
27 | - end | |
28 | - | |
29 | - should 'get user' do | |
30 | - get "/api/v1/users/#{user.id}?#{params.to_query}" | |
31 | - json = JSON.parse(last_response.body) | |
32 | - assert_equal user.id, json['user']['id'] | |
33 | - end | |
34 | - | |
35 | - should 'list user permissions' do | |
36 | - community = fast_create(Community) | |
37 | - community.add_admin(person) | |
38 | - get "/api/v1/users/#{user.id}/?#{params.to_query}" | |
39 | - json = JSON.parse(last_response.body) | |
40 | - assert_includes json["user"]["permissions"], community.identifier | |
41 | - end | |
42 | - | |
43 | - should 'get logged user' do | |
44 | - get "/api/v1/users/me?#{params.to_query}" | |
45 | - json = JSON.parse(last_response.body) | |
46 | - assert_equal user.id, json['user']['id'] | |
47 | - end | |
48 | - | |
49 | -end |