replace stub! with stub
This commit is contained in:
parent
cabc6a5c92
commit
df0bff6537
26 changed files with 46 additions and 46 deletions
|
|
@ -122,7 +122,7 @@ describe ConversationsController do
|
|||
)
|
||||
|
||||
p = Postzord::Dispatcher.build(alice, cnv)
|
||||
p.class.stub!(:new).and_return(p)
|
||||
p.class.stub(:new).and_return(p)
|
||||
p.should_receive(:post)
|
||||
post :create, @hash
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe InvitationsController do
|
|||
describe "#create" do
|
||||
before do
|
||||
sign_in :user, @user
|
||||
@controller.stub!(:current_user).and_return(@user)
|
||||
@controller.stub(:current_user).and_return(@user)
|
||||
@referer = 'http://test.host/cats/foo'
|
||||
request.env["HTTP_REFERER"] = @referer
|
||||
end
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ describe PhotosController do
|
|||
|
||||
describe '#create' do
|
||||
before do
|
||||
@controller.stub!(:file_handler).and_return(uploaded_photo)
|
||||
@controller.stub(:file_handler).and_return(uploaded_photo)
|
||||
@params = {:photo => {:user_file => uploaded_photo, :aspect_ids => "all"} }
|
||||
end
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ describe PhotosController do
|
|||
end
|
||||
|
||||
it 'sends a retraction on delete' do
|
||||
@controller.stub!(:current_user).and_return(alice)
|
||||
@controller.stub(:current_user).and_return(alice)
|
||||
alice.should_receive(:retract).with(@alices_photo)
|
||||
delete :destroy, :id => @alices_photo.id
|
||||
end
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ describe PostsController do
|
|||
end
|
||||
|
||||
it 'sends a retraction on delete' do
|
||||
controller.stub!(:current_user).and_return alice
|
||||
controller.stub(:current_user).and_return alice
|
||||
message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
|
||||
alice.should_receive(:retract).with(message)
|
||||
delete :destroy, :format => :js, :id => message.id
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ describe RegistrationsController do
|
|||
before do
|
||||
AppConfig.settings.enable_registrations = true
|
||||
user = FactoryGirl.build(:user)
|
||||
User.stub!(:build).and_return(user)
|
||||
User.stub(:build).and_return(user)
|
||||
end
|
||||
|
||||
it "creates a user" do
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe ServicesController do
|
|||
|
||||
before do
|
||||
sign_in :user, user
|
||||
@controller.stub!(:current_user).and_return(user)
|
||||
@controller.stub(:current_user).and_return(user)
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
|
|
@ -110,7 +110,7 @@ describe ServicesController do
|
|||
end
|
||||
|
||||
it 'does not queue a job if the profile photo is set' do
|
||||
@controller.stub!(:no_profile_image?).and_return false
|
||||
@controller.stub(:no_profile_image?).and_return false
|
||||
|
||||
Workers::FetchProfilePhoto.should_not_receive(:perform_async)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ describe ServicesController do
|
|||
end
|
||||
|
||||
it 'queues a job to save user photo if the photo does not exist' do
|
||||
@controller.stub!(:no_profile_image?).and_return true
|
||||
@controller.stub(:no_profile_image?).and_return true
|
||||
|
||||
Workers::FetchProfilePhoto.should_receive(:perform_async).with(user.id, anything(), "https://service.com/fallback_lowres.jpg")
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe StatusMessagesController do
|
|||
|
||||
request.env["HTTP_REFERER"] = ""
|
||||
sign_in :user, alice
|
||||
@controller.stub!(:current_user).and_return(alice)
|
||||
@controller.stub(:current_user).and_return(alice)
|
||||
alice.reload
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ describe UsersController do
|
|||
|
||||
it "uses devise's update with password" do
|
||||
@user.should_receive(:update_with_password).with(hash_including(@password_params))
|
||||
@controller.stub!(:current_user).and_return(@user)
|
||||
@controller.stub(:current_user).and_return(@user)
|
||||
put :update, :id => @user.id, :user => @password_params
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,19 +38,19 @@ describe NotificationsHelper do
|
|||
end
|
||||
|
||||
it 'with two, does not comma seperate two actors' do
|
||||
@note.stub!(:actors).and_return([@max, @sarah])
|
||||
@note.stub(:actors).and_return([@max, @sarah])
|
||||
output.scan(/,/).should be_empty
|
||||
output.scan(/and/).count.should be 1
|
||||
end
|
||||
|
||||
it 'with three, comma seperates the first two, and and the last actor' do
|
||||
@note.stub!(:actors).and_return([@max, @sarah, @daniel])
|
||||
@note.stub(:actors).and_return([@max, @sarah, @daniel])
|
||||
output.scan(/,/).count.should be 2
|
||||
output.scan(/and/).count.should be 1
|
||||
end
|
||||
|
||||
it 'with more than three, lists the first three, then the others tag' do
|
||||
@note.stub!(:actors).and_return([@max, @sarah, @daniel, @ilya])
|
||||
@note.stub(:actors).and_return([@max, @sarah, @daniel, @ilya])
|
||||
output.scan(/,/).count.should be 3
|
||||
output.scan(/and/).count.should be 2
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,19 +10,19 @@ describe StreamHelper do
|
|||
@stream = Stream::Base.new(alice, :max_time => Time.now)
|
||||
end
|
||||
it 'works for public page' do
|
||||
stub!(:controller).and_return(PostsController.new)
|
||||
stub(:controller).and_return(PostsController.new)
|
||||
next_page_path.should include '/public'
|
||||
end
|
||||
|
||||
it 'works for stream page when current page is stream' do
|
||||
self.stub!("current_page?").and_return(true)
|
||||
stub!(:controller).and_return(StreamsController.new)
|
||||
self.stub("current_page?").and_return(true)
|
||||
stub(:controller).and_return(StreamsController.new)
|
||||
next_page_path.should include stream_path
|
||||
end
|
||||
|
||||
it 'works for activity page when current page is not stream' do
|
||||
self.stub!("current_page?").and_return(false)
|
||||
stub!(:controller).and_return(StreamsController.new)
|
||||
self.stub("current_page?").and_return(false)
|
||||
stub(:controller).and_return(StreamsController.new)
|
||||
next_page_path.should include activity_stream_path
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ describe Configuration::Methods do
|
|||
context "with a relative log set" do
|
||||
it "joins that with Rails.root" do
|
||||
path = "/some/path/"
|
||||
Rails.stub!(:root).and_return(stub(join: path))
|
||||
Rails.stub(:root).and_return(stub(join: path))
|
||||
@settings.environment.sidekiq.log = "relative_path"
|
||||
@settings.sidekiq_log.should match path
|
||||
end
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ describe RelayableRetraction do
|
|||
@retraction = described_class.allocate
|
||||
@retraction.sender = @remote_raphael
|
||||
@retraction.target = @comment
|
||||
@retraction.stub!(:parent_author_signature_valid?).and_return(true)
|
||||
@retraction.stub(:parent_author_signature_valid?).and_return(true)
|
||||
@recipient = @local_luke
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ describe SignedRetraction do
|
|||
r.target_type = remote_post.type
|
||||
r.target_guid = remote_post.guid
|
||||
r.sender = remote_post.author
|
||||
r.stub!(:target_author_signature_valid?).and_return(true)
|
||||
r.stub(:target_author_signature_valid?).and_return(true)
|
||||
}
|
||||
|
||||
remote_retraction.dup.perform(bob)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ STR
|
|||
@test_txt_C = "mentioning #{@mention_C}"
|
||||
@test_txt_BC = "mentioning #{@mention_B}} and #{@mention_C}"
|
||||
|
||||
Diaspora::Mentionable.stub!(:current_user).and_return(@user_A)
|
||||
Diaspora::Mentionable.stub(:current_user).and_return(@user_A)
|
||||
end
|
||||
|
||||
it 'filters mention, if contact is not in a given aspect' do
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ describe Postzord::Dispatcher do
|
|||
@remote_people << alice.person
|
||||
@mailman = Postzord::Dispatcher.build(alice, @sm)
|
||||
@hydra = mock()
|
||||
Typhoeus::Hydra.stub!(:new).and_return(@hydra)
|
||||
Typhoeus::Hydra.stub(:new).and_return(@hydra)
|
||||
end
|
||||
|
||||
it 'should queue an HttpMultiJob for the remote people' do
|
||||
|
|
@ -277,7 +277,7 @@ describe Postzord::Dispatcher do
|
|||
end
|
||||
|
||||
it 'queues a job to notify the hub' do
|
||||
Workers::PostToService.stub!(:perform_async).with(anything, anything, anything)
|
||||
Workers::PostToService.stub(:perform_async).with(anything, anything, anything)
|
||||
Workers::PublishToHub.should_receive(:perform_async).with(alice.public_url)
|
||||
@zord.send(:deliver_to_services, nil, [])
|
||||
end
|
||||
|
|
@ -297,8 +297,8 @@ describe Postzord::Dispatcher do
|
|||
alice.services << @s2
|
||||
mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1])
|
||||
|
||||
Workers::PublishToHub.stub!(:perform_async).with(anything)
|
||||
Workers::HttpMulti.stub!(:perform_async).with(anything, anything, anything)
|
||||
Workers::PublishToHub.stub(:perform_async).with(anything)
|
||||
Workers::HttpMulti.stub(:perform_async).with(anything, anything, anything)
|
||||
Workers::PostToService.should_receive(:perform_async).with(@s1.id, anything, anything)
|
||||
mailman.post
|
||||
end
|
||||
|
|
@ -306,7 +306,7 @@ describe Postzord::Dispatcher do
|
|||
it 'does not push to services if none are specified' do
|
||||
mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123")
|
||||
|
||||
Workers::PublishToHub.stub!(:perform_async).with(anything)
|
||||
Workers::PublishToHub.stub(:perform_async).with(anything)
|
||||
Workers::PostToService.should_not_receive(:perform_async).with(anything, anything, anything)
|
||||
mailman.post
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe Stream::Multi do
|
|||
.with(alice, 'updated_at', @stream.max_time,
|
||||
AppConfig.settings.community_spotlight.enable? &&
|
||||
alice.show_community_spotlight_in_stream?)
|
||||
.and_return(mock.tap { |m| m.stub!(:make_relation!)})
|
||||
.and_return(mock.tap { |m| m.stub(:make_relation!)})
|
||||
@stream.posts
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ describe AspectMembership do
|
|||
@contact = alice.contact_for(bob.person)
|
||||
|
||||
@am = alice.aspects.where(:name => "generic").first.aspect_memberships.first
|
||||
@am.stub!(:user).and_return(alice)
|
||||
@am.stub(:user).and_return(alice)
|
||||
end
|
||||
|
||||
it 'calls disconnect if its the last aspect for the contact' do
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ describe Notification do
|
|||
:recipient_id => @user.id}
|
||||
|
||||
n = Notifications::StartedSharing.new(opts)
|
||||
n.stub!(:recipient).and_return @user
|
||||
n.stub(:recipient).and_return @user
|
||||
|
||||
@user.should_receive(:mail)
|
||||
n.email_the_user(@request, @person)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ describe Notifications::PrivateMessage do
|
|||
:recipient_id => @user2.id}
|
||||
|
||||
n = Notifications::PrivateMessage.new(opts)
|
||||
Notifications::PrivateMessage.stub!(:make_notification).and_return(n)
|
||||
Notifications::PrivateMessage.stub(:make_notification).and_return(n)
|
||||
Notification.notify(@user2, @msg, @user1.person)
|
||||
n.stub!(:recipient).and_return @user2
|
||||
n.stub(:recipient).and_return @user2
|
||||
|
||||
@user2.should_receive(:mail)
|
||||
n.email_the_user(@msg, @user1.person)
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ describe User::Connecting do
|
|||
|
||||
it 'adds a contact to an aspect' do
|
||||
contact = alice.contacts.create(:person => eve.person)
|
||||
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
|
||||
alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact)
|
||||
|
||||
lambda {
|
||||
alice.share_with(eve.person, alice.aspects.first)
|
||||
|
|
@ -128,7 +128,7 @@ describe User::Connecting do
|
|||
context 'dispatching' do
|
||||
it 'dispatches a request on initial request' do
|
||||
contact = alice.contacts.new(:person => eve.person)
|
||||
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
|
||||
alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact)
|
||||
|
||||
contact.should_receive(:dispatch_request)
|
||||
alice.share_with(eve.person, alice.aspects.first)
|
||||
|
|
@ -138,7 +138,7 @@ describe User::Connecting do
|
|||
eve.share_with(alice.person, eve.aspects.first)
|
||||
|
||||
contact = alice.contact_for(eve.person)
|
||||
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
|
||||
alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact)
|
||||
|
||||
contact.should_receive(:dispatch_request)
|
||||
alice.share_with(eve.person, alice.aspects.first)
|
||||
|
|
@ -148,7 +148,7 @@ describe User::Connecting do
|
|||
a2 = alice.aspects.create(:name => "two")
|
||||
|
||||
contact = alice.contacts.create(:person => eve.person, :receiving => true)
|
||||
alice.contacts.stub!(:find_or_initialize_by_person_id).and_return(contact)
|
||||
alice.contacts.stub(:find_or_initialize_by_person_id).and_return(contact)
|
||||
|
||||
contact.should_not_receive(:dispatch_request)
|
||||
alice.share_with(eve.person, a2)
|
||||
|
|
|
|||
|
|
@ -870,14 +870,14 @@ describe User do
|
|||
describe "#send_reset_password_instructions" do
|
||||
it "generates a reset password token if it's supposed to" do
|
||||
user = User.new
|
||||
user.stub!(:should_generate_reset_token?).and_return(true)
|
||||
user.stub(:should_generate_reset_token?).and_return(true)
|
||||
user.should_receive(:generate_reset_password_token)
|
||||
user.send_reset_password_instructions
|
||||
end
|
||||
|
||||
it "does not generate a reset password token if it's not supposed to" do
|
||||
user = User.new
|
||||
user.stub!(:should_generate_reset_token?).and_return(false)
|
||||
user.stub(:should_generate_reset_token?).and_return(false)
|
||||
user.should_not_receive(:generate_reset_password_token)
|
||||
user.send_reset_password_instructions
|
||||
end
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ describe Diaspora::Relayable do
|
|||
it 'dispatches when the person receiving is the parent author' do
|
||||
p = Postzord::Dispatcher.build(@local_luke, @object_by_recipient)
|
||||
p.should_receive(:post)
|
||||
p.class.stub!(:new).and_return(p)
|
||||
p.class.stub(:new).and_return(p)
|
||||
@object_by_recipient.receive(@local_luke, @local_leia.person)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe Workers::DeletePostFromService do
|
|||
m = mock()
|
||||
url = "foobar"
|
||||
m.should_receive(:delete_post)
|
||||
Service.stub!(:find_by_id).and_return(m)
|
||||
Service.stub(:find_by_id).and_return(m)
|
||||
Workers::DeletePostFromService.new.perform("123", @post.id.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ describe Workers::FetchProfilePhoto do
|
|||
|
||||
context "service does not have a profile_photo_url" do
|
||||
it "does nothing without fallback" do
|
||||
@service.stub!(:profile_photo_url).and_return(nil)
|
||||
@service.stub(:profile_photo_url).and_return(nil)
|
||||
Photo.should_not_receive(:diaspora_initialize)
|
||||
|
||||
Workers::FetchProfilePhoto.new.perform(@user.id, @service.id)
|
||||
|
|
@ -35,7 +35,7 @@ describe Workers::FetchProfilePhoto do
|
|||
|
||||
it "fetches fallback if it's provided" do
|
||||
@photo_stub.should_receive(:save!).and_return(true)
|
||||
@service.stub!(:profile_photo_url).and_return(nil)
|
||||
@service.stub(:profile_photo_url).and_return(nil)
|
||||
Photo.should_receive(:diaspora_initialize).with(hash_including(:author => @user.person, :image_url => "https://service.com/fallback_lowres.jpg", :pending => true)).and_return(@photo_stub)
|
||||
|
||||
Workers::FetchProfilePhoto.new.perform(@user.id, @service.id, "https://service.com/fallback_lowres.jpg")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe Workers::HttpMulti do
|
|||
@post_xml = Base64.encode64 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH"
|
||||
|
||||
@hydra = Typhoeus::Hydra.new
|
||||
Typhoeus::Hydra.stub!(:new).and_return(@hydra)
|
||||
Typhoeus::Hydra.stub(:new).and_return(@hydra)
|
||||
@salmon = Salmon::EncryptedSlap.create_by_user_and_activity bob, Base64.decode64(@post_xml)
|
||||
Salmon::EncryptedSlap.stub(:create_by_user_and_activity).and_return @salmon
|
||||
@body = "encrypted things"
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ describe Workers::PostToService do
|
|||
user = alice
|
||||
aspect = user.aspects.create(:name => "yeah")
|
||||
post = user.post(:status_message, :text => 'foo', :to => aspect.id)
|
||||
User.stub!(:find_by_id).with(user.id.to_s).and_return(user)
|
||||
User.stub(:find_by_id).with(user.id.to_s).and_return(user)
|
||||
m = mock()
|
||||
url = "foobar"
|
||||
m.should_receive(:post).with(anything, url)
|
||||
Service.stub!(:find_by_id).and_return(m)
|
||||
Service.stub(:find_by_id).and_return(m)
|
||||
Workers::PostToService.new.perform("123", post.id.to_s, url)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue