Newer
Older
# licensed under the Affero General Public License version 3 or later. See
Daniel Vincent Grippi
a validé
let(:aspect) { user.aspect(:name => 'heroes') }
let(:user2) { Factory(:user) }
let(:aspect2) { user2.aspect(:name => 'stuff') }
let(:user3) { Factory(:user) }
let(:aspect3) { user3.aspect(:name => 'stuff') }
describe "validations" do
it "requires a username" do
user = Factory.build(:user, :username => nil)
user.should_not be_valid
end
it "downcases the username" do
user = Factory.build(:user, :username => "ALLUPPERCASE")
user.valid?
user.username.should == "alluppercase"
user = Factory.build(:user, :username => "someUPPERCASE")
user.valid?
user.username.should == "someuppercase"
it "confirms the password" do
pending "I cannot figure out why this doesn't work. --Raphael"
user = User.instantiate!(
:email => "tom@tom.joindiaspora.com",
:username => "tom",
:password => "evankorth",
:password_confirmation => "potatoes",
:person => Person.new(
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
)
user.created_at.should be_nil
user.valid?.should be_false
end
it 'uses the pod config url to set the diaspora_handle' do
user.diaspora_handle.should == user.username + "@" + APP_CONFIG[:terse_pod_url]
end
end
it 'should be able to update their profile and send it to their friends' do
updated_profile = { :profile => {
:first_name => 'bob',
:last_name => 'billytown',
:image_url => "http://clown.com"} }
user.update_profile(updated_profile).should be true
user.profile.image_url.should == "http://clown.com"
it 'should delete an empty aspect' do
user.drop_aspect(aspect)
user.aspects.include?(aspect).should == false
end
it 'should not delete an aspect with friends' do
aspect.reload
proc{user.drop_aspect(aspect)}.should raise_error /Aspect not empty/
user.aspects.include?(aspect).should == true
context 'account removal' do
before do
friend_users(user, aspect, user2, aspect2)
friend_users(user, aspect, user3, aspect3)
end
it 'should unfriend everyone' do
user.should_receive(:unfriend_everyone)
user.destroy
end
it 'should remove person' do
user.should_receive(:remove_person)
user.destroy
end
it 'should remove all aspects' do
pending "this should use :dependant => :destroy on the many assoc...but that screws this test suite..."
aspects = user.aspects
user.destroy
proc{ aspects.reload }.should raise_error /does not exist/
end
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
describe '#remove_person' do
it 'should remove the person object' do
person = user.person
user.destroy
person.reload
person.should be nil
end
it 'should remove the posts' do
message = user.post(:status_message, :message => "hi", :to => aspect.id)
user.reload
user.destroy
proc{ message.reload }.should raise_error /does not exist/
end
end
describe '#unfriend_everyone' do
before do
user3.delete
end
it 'should send retractions to remote poeple' do
user.should_receive(:unfriend).once
user.destroy
end
it 'should unfriend local people' do
user2.friends.count.should be 1
user.destroy
user2.reload
user2.friends.count.should be 0
end
end
end