From a92a374b967902b0783bf55b3a1e2f59b6a6cfe4 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Thu, 6 Jan 2011 17:14:39 -0800 Subject: [PATCH] added the files and fixed the tests --- spec/mailers/notifier_spec.rb | 4 ++-- spec/models/notification_spec.rb | 32 ++++++++--------------------- spec/models/user/connecting_spec.rb | 8 -------- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index f5b8d9e0c..dd125138c 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -87,7 +87,7 @@ describe Notifier do let!(:comment) { user2.comment("Totally is", :on => sm )} describe "#comment_on_post" do - let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment).deliver} + let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver} it 'goes to the right person' do comment_mail.to.should == [user.email] @@ -108,7 +108,7 @@ describe Notifier do end describe "#also commented" do - let!(:comment_mail) {Notifier.also_commented(user.id, person.id, comment)} + let!(:comment_mail) {Notifier.also_commented(user.id, person.id, comment.id)} it 'goes to the right person' do comment_mail.to.should == [user.email] diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index e973afe09..e3a9fb825 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -68,34 +68,18 @@ describe Notification do Notification.notify(@user, request, @person) end - context 'emails the user' do - it 'email with notifications enabled' do - request = Request.instantiate(:from => @user.person, :to => @user2.person, :into => @aspect) - opts = {:target_id => request.id, - :kind => request.notification_type(@user, @person), + describe '#emails_the_user' do + it 'calls mail' do + opts = { + :kind => "new_request", :person_id => @person.id, :user_id => @user.id} - n = Notification.create(opts) - Notification.stub!(:create).and_return n + n = Notification.new(opts) + n.stub!(:user).and_return @user - n.should_receive(:email_the_user).once - Notification.notify(@user, request, @person) - end - - it 'does not email with emails disabled' do - request = Request.instantiate(:from => @user.person, :to => @user2.person, :into => @aspect) - opts = {:target_id => request.id, - :kind => request.notification_type(@user, @person), - :person_id => @person.id, - :user_id => @user.id} - - n = Notification.create(opts) - Notification.stub!(:create).and_return n - - @user.disable_mail = true - n.should_not_receive(:email_the_user) - Notification.notify(@user, request, @person) + @user.should_receive(:mail) + n.email_the_user("mock") end end end diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 42fa524ad..819b8ae3d 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -60,14 +60,6 @@ describe Diaspora::UserModules::Connecting do Resque.should_receive(:enqueue).with(Jobs::MailRequestReceived, user.id, person.id) user.receive_object(@r, person) end - - it 'should not lock the connection after ignore' do - user.send_friend_request_to(user2, aspect) - user2.pending_request.count.should == 1 - user2.ignore_request(user2.pending_requests.first) - user.send_friend_request_to(user2, aspect) - user2.pending_request.count.should == 1 - end end describe '#receive_request_acceptance' do