From 3d7d8b51d2283aacabbd82fde45b915c4fff579f Mon Sep 17 00:00:00 2001 From: Raphael <raphael@joindiaspora.com> Date: Sun, 26 Dec 2010 21:05:48 -0800 Subject: [PATCH] Add a spec to user, fix a cucumber step for mysql --- app/models/user.rb | 2 +- features/step_definitions/custom_web_steps.rb | 2 +- spec/models/user_spec.rb | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index aeced510cc..13b74a0f1b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,7 +27,7 @@ class User < ActiveRecord::Base validates_associated :person has_one :person, :foreign_key => :owner_id - delegate :public_key, :posts, :owns?, :diaspora_handle, :name, :public_url, :profile, :to => :person + delegate :public_key, :posts, :owns?, :diaspora_handle, :name, :public_url, :profile, :first_name, :last_name, :to => :person has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 88a82d4e44..e12e383f08 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -37,7 +37,7 @@ When /^I wait for the aspects page to load$/ do end When /^I wait for the request's profile page to load$/ do - wait_until { current_path == person_path(Request.to(@me).first.from) } + wait_until { current_path == person_path(Request.where(:recipient_id => @me.id).first.sender) } end When /^I wait for the ajax to finish$/ do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index a41f807867..03f6e28518 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -262,6 +262,16 @@ describe User do user.update_profile(params).should be_true user.reload.profile.image_url.should == "http://clown.com" end + + it 'only pushes to a given person once' do + connect_users(user, aspect, user2, aspect2) + user.add_contact_to_aspect(user.contact_for(user2.person), + user.aspects.create(:name => "Newsies")) + + user.should_receive(:push_to_person).once + user.update_profile(@params).should be_true + end + it "only pushes to non-pending contacts" do connect_users(user, aspect, user2, aspect2) user.contacts.count.should == 1 -- GitLab