Skip to content
Extraits de code Groupes Projets
user_spec.rb 1,45 ko
Newer Older
Raphael's avatar
Raphael a validé
#   Copyright (c) 2010, Diaspora Inc.  This file is
Raphael's avatar
Raphael a validé
#   licensed under the Affero General Public License version 3.  See
#   the COPYRIGHT file.
maxwell's avatar
maxwell a validé
require File.dirname(__FILE__) + '/../spec_helper'

describe User do
danielvincent's avatar
danielvincent a validé
  let(:user)   { Factory(:user) }
  let(:aspect) { user.aspect(:name => 'heroes') }

  describe '#diaspora_handle' do 
    it 'uses the pod config url to set the diaspora_handle' do
danielvincent's avatar
danielvincent a validé
      user.diaspora_handle.should == user.username + "@example.org"
danielvincent's avatar
danielvincent a validé
  context 'profiles' do
Jamie Wilkinson's avatar
Jamie Wilkinson a validé
    it 'should be able to update their profile and send it to their friends' do
danielvincent's avatar
danielvincent a validé
      updated_profile = { :profile => {
                            :first_name => 'bob',
                            :last_name => 'billytown',
                            :image_url => "http://clown.com"} }
danielvincent's avatar
danielvincent a validé
      user.update_profile(updated_profile).should be true
      user.profile.image_url.should == "http://clown.com"
maxwell's avatar
maxwell a validé
  end
danielvincent's avatar
danielvincent a validé

danielvincent's avatar
danielvincent a validé
  context 'aspects' do
    let(:user2)   { Factory(:user) }
    let(:aspect2) { user2.aspect(:name => 'stuff') }
danielvincent's avatar
danielvincent a validé

danielvincent's avatar
danielvincent a validé
    it 'should delete an empty aspect' do
      user.drop_aspect(aspect)
      user.aspects.include?(aspect).should == false
danielvincent's avatar
danielvincent a validé
    end

    it 'should not delete an aspect with friends' do
danielvincent's avatar
danielvincent a validé
      friend_users(user, Aspect.find_by_id(aspect.id), user2, Aspect.find_by_id(aspect2.id))
      aspect.reload
      proc{user.drop_aspect(aspect)}.should raise_error /Aspect not empty/
      user.aspects.include?(aspect).should == true
danielvincent's avatar
danielvincent a validé
    end
  end
danielvincent's avatar
danielvincent a validé