summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/user.rb3
-rw-r--r--test/integration/api/signup_test.rb2
-rw-r--r--test/unit/user_test.rb8
3 files changed, 11 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 704700b..6541305 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -78,7 +78,8 @@ class User < CouchRest::Model::Base
:login => self.login,
:ok => self.valid?,
:id => self.id,
- :enabled => self.enabled?
+ :enabled => self.enabled?,
+ :is_admin => self.is_admin?
}.to_json(options)
end
diff --git a/test/integration/api/signup_test.rb b/test/integration/api/signup_test.rb
index dc24420..2e515c1 100644
--- a/test/integration/api/signup_test.rb
+++ b/test/integration/api/signup_test.rb
@@ -8,7 +8,7 @@ class SignupTest < SrpTest
end
test "signup response" do
- assert_json_response :login => @login, :ok => true, :id => @user.id, :enabled => true
+ assert_json_response :login => @login, :ok => true, :is_admin => false, :id => @user.id, :enabled => true
assert last_response.successful?
end
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 9501d34..55d0648 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -71,6 +71,14 @@ class UserTest < ActiveSupport::TestCase
assert_equal key, @user.public_key
end
+ test "user to json includes id, login, valid, is_admin and enabled" do
+ json_content = JSON.parse @user.to_json
+ assert_equal @user.id, json_content["id"]
+ assert_equal @user.valid?, json_content["ok"]
+ assert_equal @user.login, json_content["login"]
+ assert_equal @user.enabled?, json_content["enabled"]
+ assert_equal @user.is_admin?, json_content["is_admin"]
+ end
#