diff --git a/app/models/user.rb b/app/models/user.rb index 7a849a7074e..22fd45063a6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -24,7 +24,7 @@ def to_json(options = {}) end def to_yaml(*args) - { :email => email }.to_yaml(*args) + { 'email' => email }.to_yaml(*args) end protected diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index a801f464a0f..46e55a01ef5 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -11,10 +11,19 @@ class UserTest < ActiveSupport::TestCase @user = Factory(:user) end + should "only have email when boiling down to json or yaml" do + json = JSON.parse(@user.to_json) + yaml = YAML.load(@user.to_yaml) + + hash = {"email" => @user.email} + assert_equal hash, json + assert_equal hash, yaml + end + should "create api key" do assert_not_nil @user.api_key end - + should "reset api key" do assert_changed(@user, :api_key) do @user.reset_api_key!