diff --git a/Gemfile b/Gemfile index eb0e94300..70956313a 100644 --- a/Gemfile +++ b/Gemfile @@ -152,7 +152,7 @@ group :test do gem 'timecop' #"0.1.0", #:path => '~/workspace/diaspora-client' - gem 'factory_girl_rails', '1.7.0' + gem 'factory_girl_rails' gem 'fixture_builder', '0.3.3' gem 'fuubar', '>= 1.0' gem 'mongrel', :require => false, :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index 75174e853..b59e90cf5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,10 +170,10 @@ GEM excon (0.13.4) execjs (1.3.2) multi_json (~> 1.0) - factory_girl (2.6.4) - activesupport (>= 2.3.9) - factory_girl_rails (1.7.0) - factory_girl (~> 2.6.0) + factory_girl (3.3.0) + activesupport (>= 3.0.0) + factory_girl_rails (3.3.0) + factory_girl (~> 3.3.0) railties (>= 3.0.0) faraday (0.7.6) addressable (~> 2.2) @@ -517,7 +517,7 @@ DEPENDENCIES devise (= 1.5.3) diaspora-client! em-synchrony (= 1.0.0) - factory_girl_rails (= 1.7.0) + factory_girl_rails faraday faraday_middleware fastercsv (= 1.5.4) diff --git a/features/step_definitions/message_steps.rb b/features/step_definitions/message_steps.rb index 004acffca..a4e93a305 100644 --- a/features/step_definitions/message_steps.rb +++ b/features/step_definitions/message_steps.rb @@ -1,7 +1,7 @@ Then /^I should see the "(.*)" message$/ do |message| text = case message when "alice is excited" - @alice ||= Factory(:user, :username => "Alice") + @alice ||= FactoryGirl.create(:user, :username => "Alice") I18n.translate('invitation_codes.excited', :name => @alice.name) when "welcome to diaspora" I18n.translate('users.getting_started.well_hello_there') diff --git a/features/step_definitions/session_steps.rb b/features/step_definitions/session_steps.rb index 5d5e16ac4..d9eefb4d4 100644 --- a/features/step_definitions/session_steps.rb +++ b/features/step_definitions/session_steps.rb @@ -4,7 +4,7 @@ Given /^(?:I am signed in|I sign in)$/ do end When /^I try to sign in$/ do - @me ||= Factory(:user_with_aspect, :getting_started => false) + @me ||= FactoryGirl.create(:user_with_aspect, :getting_started => false) page.driver.visit(new_integration_sessions_path(:user_id => @me.id)) step %(I press "Login") # To save time as compared to: diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index c2a7897a0..cb56312b5 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -1,5 +1,5 @@ Given /^a user with username "([^\"]*)" and password "([^\"]*)"$/ do |username, password| - @me ||= Factory(:user, :username => username, :password => password, + @me ||= FactoryGirl.create(:user, :username => username, :password => password, :password_confirmation => password, :getting_started => false) @me.aspects.create(:name => "Besties") @me.aspects.create(:name => "Unicorns") @@ -26,14 +26,14 @@ Given /^a nsfw user with email "([^\"]*)"$/ do |email| end Given /^I have been invited by an admin$/ do - admin = Factory(:user) + admin = FactoryGirl.create(:user) admin.invitation_code i = EmailInviter.new("new_invitee@example.com", admin) i.send! end Given /^I have been invited by bob$/ do - @inviter = Factory(:user, :email => 'bob@bob.bob') + @inviter = FactoryGirl.create(:user, :email => 'bob@bob.bob') @inviter_invite_count = @inviter.invitation_code.count i = EmailInviter.new("new_invitee@example.com", @inviter) i.send! @@ -80,8 +80,8 @@ Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag| end Given /^many posts from alice for bob$/ do - alice = Factory(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false) - bob = Factory(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false) + alice = FactoryGirl.create(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false) + bob = FactoryGirl.create(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false) connect_users_with_aspects(alice, bob) time_fulcrum = Time.now - 40000 time_interval = 1000 @@ -132,7 +132,7 @@ end When /^"([^\"]+)" has posted a status message with a photo$/ do |email| user = User.find_for_database_authentication(:username => email) - post = Factory(:status_message_with_photo, :text => "Look at this dog", :author => user.person) + post = FactoryGirl.create(:status_message_with_photo, :text => "Look at this dog", :author => user.person) [post, post.photos.first].each do |p| user.add_to_streams(p, user.aspects) user.dispatch_post(p) @@ -151,7 +151,7 @@ Given /^I have (\d+) contacts$/ do |n| aspect_memberships = [] count.times do - person = Factory(:person) + person = FactoryGirl.create(:person) people << person end @@ -175,7 +175,7 @@ When /^I view "([^\"]*)"'s first post$/ do |email| end Given /^I visit alice's invitation code url$/ do - @alice ||= Factory(:user, :username => 'alice', :getting_started => false) + @alice ||= FactoryGirl.create(:user, :username => 'alice', :getting_started => false) invite_code = InvitationCode.find_or_create_by_user_id(@alice.id) visit invite_code_path(invite_code) end diff --git a/features/support/post_generation_helpers.rb b/features/support/post_generation_helpers.rb index 4b42db79e..50bdab55e 100644 --- a/features/support/post_generation_helpers.rb +++ b/features/support/post_generation_helpers.rb @@ -5,7 +5,7 @@ module PostGenerationHelpers TemplatePicker::TEMPLATES.each do |template| Timecop.travel time += 1.minute - Factory(template, :author => user.person) + FactoryGirl.create(template, :author => user.person) end Timecop.return diff --git a/features/support/user_cuke_helpers.rb b/features/support/user_cuke_helpers.rb index 0a71edbb5..ec5da9920 100644 --- a/features/support/user_cuke_helpers.rb +++ b/features/support/user_cuke_helpers.rb @@ -6,7 +6,7 @@ module UserCukeHelpers :getting_started => false } - user = Factory(:user, default_attrs.merge(overrides)) + user = FactoryGirl.create(:user, default_attrs.merge(overrides)) add_standard_aspects(user) user end diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb index c1fd96123..eb0d4b2c2 100644 --- a/spec/controllers/admins_controller_spec.rb +++ b/spec/controllers/admins_controller_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe AdminsController do before do - @user = Factory :user + @user = FactoryGirl.create:user sign_in :user, @user end diff --git a/spec/controllers/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb index ae066c520..37ed98ef1 100644 --- a/spec/controllers/apps_controller_spec.rb +++ b/spec/controllers/apps_controller_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe AppsController do describe '#show' do it 'works as long as you pass something as id' do - Factory(:activity_streams_photo) + FactoryGirl.create(:activity_streams_photo) get :show, :id => 'cubbies' response.should be_success end diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 71725617b..5bb46ab72 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -98,7 +98,7 @@ describe AspectsController do end it "doesn't overwrite random attributes" do - new_user = Factory :user + new_user = FactoryGirl.create:user params = {"name" => "Bruisers"} params[:user_id] = new_user.id put('update', :id => @alices_aspect_1.id, "aspect" => params) @@ -118,11 +118,11 @@ describe AspectsController do eve.profile.save eve.save - @zed = Factory(:user_with_aspect, :username => "zed") + @zed = FactoryGirl.create(:user_with_aspect, :username => "zed") @zed.profile.first_name = "zed" @zed.profile.save @zed.save - @katz = Factory(:user_with_aspect, :username => "katz") + @katz = FactoryGirl.create(:user_with_aspect, :username => "katz") @katz.profile.first_name = "katz" @katz.profile.save @katz.save diff --git a/spec/controllers/authorizations_controller_spec.rb b/spec/controllers/authorizations_controller_spec.rb index 65d56b930..4c6a018e5 100644 --- a/spec/controllers/authorizations_controller_spec.rb +++ b/spec/controllers/authorizations_controller_spec.rb @@ -33,7 +33,7 @@ describe AuthorizationsController do describe '#new' do before do - @app = Factory(:app, :name => "Authorized App") + @app = FactoryGirl.create(:app, :name => "Authorized App") @params = { :scope => "profile", :redirect_uri => @manifest['application_base_url'] << '/callback', @@ -167,8 +167,8 @@ describe AuthorizationsController do end it 'assigns the auth. & apps for the current user' do - app1 = Factory(:app, :name => "Authorized App") - app2 = Factory(:app, :name => "Unauthorized App") + app1 = FactoryGirl.create(:app, :name => "Authorized App") + app2 = FactoryGirl.create(:app, :name => "Unauthorized App") auth = OAuth2::Provider.authorization_class.create(:client => app1, :resource_owner => alice) OAuth2::Provider.authorization_class.create(:client => app1, :resource_owner => bob) @@ -182,7 +182,7 @@ describe AuthorizationsController do describe "#destroy" do before do - @app1 = Factory(:app) + @app1 = FactoryGirl.create(:app) @auth1 = OAuth2::Provider.authorization_class.create(:client => @app1, :resource_owner => alice) @auth2 = OAuth2::Provider.authorization_class.create(:client => @app1, :resource_owner => bob) end @@ -260,7 +260,7 @@ describe AuthorizationsController do describe 'valid_nonce' do before do @nonce = "abc123" - Factory(:app, :nonce => @nonce) + FactoryGirl.create(:app, :nonce => @nonce) end it 'returns true if its a new nonce' do diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 6a9ce2406..d4286de90 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -46,7 +46,7 @@ describe CommentsController do end it "doesn't overwrite author_id" do - new_user = Factory(:user) + new_user = FactoryGirl.create(:user) comment_hash[:author_id] = new_user.person.id.to_s post :create, comment_hash Comment.find_by_text(comment_hash[:text]).author_id.should == alice.person.id diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index ae3468786..ef4cdd86a 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -90,7 +90,7 @@ describe ConversationsController do end it 'sets the author to the current_user' do - @hash[:author] = Factory(:user) + @hash[:author] = FactoryGirl.create(:user) post :create, @hash Message.first.author.should == alice.person Conversation.first.author.should == alice.person diff --git a/spec/controllers/jasmine_fixtures/streams_spec.rb b/spec/controllers/jasmine_fixtures/streams_spec.rb index e1feb3499..df5280d2d 100644 --- a/spec/controllers/jasmine_fixtures/streams_spec.rb +++ b/spec/controllers/jasmine_fixtures/streams_spec.rb @@ -20,7 +20,7 @@ describe StreamsController do Timecop.travel time += 1.minute posts << alice.post(:status_message, :text => "hella infos yo!", :to => alice.aspects.first.id) Timecop.travel time += 1.minute - posts << alice.post(:reshare, :root_guid => Factory(:status_message, :public => true).guid, :to => 'all') + posts << alice.post(:reshare, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => 'all') Timecop.travel time += 1.minute if i == 9 posts << alice.post(:status_message, diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb index 573898c66..b57c631d2 100644 --- a/spec/controllers/messages_controller_spec.rb +++ b/spec/controllers/messages_controller_spec.rb @@ -73,7 +73,7 @@ describe MessagesController do end it "doesn't overwrite author_id" do - new_user = Factory(:user) + new_user = FactoryGirl.create(:user) @message_hash[:author_id] = new_user.person.id.to_s post :create, @message_hash Message.find_by_text(@message_hash[:message][:text]).author_id.should == @user1.person.id diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index f5e5c1c3e..34659b84b 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -33,8 +33,8 @@ describe NotificationsController do it 'only lets you read your own notifications' do user2 = bob - Factory(:notification, :recipient => alice) - note = Factory(:notification, :recipient => user2) + FactoryGirl.create(:notification, :recipient => alice) + note = FactoryGirl.create(:notification, :recipient => user2) get :update, "id" => note.id, :set_unread => "false" @@ -45,25 +45,25 @@ describe NotificationsController do describe "#read_all" do it 'marks all notifications as read' do request.env["HTTP_REFERER"] = "I wish I were spelled right" - Factory(:notification, :recipient => alice) - Factory(:notification, :recipient => alice) + FactoryGirl.create(:notification, :recipient => alice) + FactoryGirl.create(:notification, :recipient => alice) Notification.where(:unread => true).count.should == 2 get :read_all Notification.where(:unread => true).count.should == 0 end it "should redirect to the stream in the html version" do - Factory(:notification, :recipient => alice) + FactoryGirl.create(:notification, :recipient => alice) get :read_all, :format => :html response.should redirect_to(stream_path) end it "should redirect to the stream in the mobile version" do - Factory(:notification, :recipient => alice) + FactoryGirl.create(:notification, :recipient => alice) get :read_all, :format => :mobile response.should redirect_to(stream_path) end it "should return a dummy value in the json version" do - Factory(:notification, :recipient => alice) + FactoryGirl.create(:notification, :recipient => alice) get :read_all, :format => :json response.should_not be_redirect end @@ -71,8 +71,8 @@ describe NotificationsController do describe '#index' do before do - @post = Factory(:status_message) - Factory(:notification, :recipient => alice, :target => @post) + @post = FactoryGirl.create(:status_message) + FactoryGirl.create(:notification, :recipient => alice, :target => @post) end it 'succeeds for notification dropdown' do @@ -87,7 +87,7 @@ describe NotificationsController do end it 'paginates the notifications' do - 25.times { Factory(:notification, :recipient => alice, :target => @post) } + 25.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } get :index assigns[:notifications].count.should == 25 get :index, "page" => 2 @@ -95,20 +95,20 @@ describe NotificationsController do end it "supports a limit per_page parameter" do - 5.times { Factory(:notification, :recipient => alice, :target => @post) } + 5.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } get :index, "per_page" => 5 assigns[:notifications].count.should == 5 end describe "special case for start sharing notifications" do it "should not provide a contacts menu for standard notifications" do - 2.times { Factory(:notification, :recipient => alice, :target => @post) } + 2.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } get :index, "per_page" => 5 Nokogiri(response.body).css('.aspect_membership').should be_empty end it "should provide a contacts menu for start sharing notifications" do - 2.times { Factory(:notification, :recipient => alice, :target => @post) } + 2.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } eve.share_with(alice.person, eve.aspects.first) get :index, "per_page" => 5 diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 73ae0a554..ecbe70e4f 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -13,10 +13,10 @@ describe PeopleController do describe '#index (search)' do before do - @eugene = Factory(:person, - :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w")) - @korth = Factory(:person, - :profile => Factory.build(:profile, :first_name => "Evan", :last_name => "Korth")) + @eugene = FactoryGirl.create(:person, + :profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w")) + @korth = FactoryGirl.create(:person, + :profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth")) end describe 'via json' do @@ -39,8 +39,8 @@ describe PeopleController do describe 'via html' do context 'query is a diaspora ID' do before do - @unsearchable_eugene = Factory(:person, :diaspora_handle => "eugene@example.org", - :profile => Factory.build(:profile, :first_name => "Eugene", + @unsearchable_eugene = FactoryGirl.create(:person, :diaspora_handle => "eugene@example.org", + :profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) end it 'finds people even if they have searchable off' do @@ -93,8 +93,8 @@ describe PeopleController do end it "assigns people" do - eugene2 = Factory(:person, - :profile => Factory.build(:profile, :first_name => "Eugene", + eugene2 = FactoryGirl.create(:person, + :profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w")) get :index, :q => "Eug" assigns[:people].map { |x| x.id }.should =~ [@eugene.id, eugene2.id] @@ -123,8 +123,8 @@ describe PeopleController do end it "excludes people who have searchable off" do - eugene2 = Factory(:person, - :profile => Factory.build(:profile, :first_name => "Eugene", + eugene2 = FactoryGirl.create(:person, + :profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) get :index, :q => "Eug" assigns[:people].should_not =~ [eugene2] @@ -140,7 +140,7 @@ describe PeopleController do end it 'returns awesome people who have that tag' do - f = Factory(:person) + f = FactoryGirl.create(:person) f.profile.tag_string = "#seeded" f.profile.save get :tag_index, :name => 'seeded', :format => :js @@ -154,7 +154,7 @@ describe PeopleController do @posts = [] @users = [] 8.times do |n| - user = Factory(:user) + user = FactoryGirl.create(:user) @users << user aspect = user.aspects.create(:name => 'people') connect_users(@user, @user.aspects.first, user, aspect) @@ -192,7 +192,7 @@ describe PeopleController do end it 'redirects home for closed account' do - @person = Factory(:person, :closed_account => true) + @person = FactoryGirl.create(:person, :closed_account => true) get :show, :id => @person.to_param response.should be_redirect flash[:notice].should_not be_blank @@ -271,7 +271,7 @@ describe PeopleController do end it "posts include reshares" do - reshare = @user.post(:reshare, :public => true, :root_guid => Factory(:status_message, :public => true).guid, :to => alice.aspects) + reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects) get :show, :id => @user.person.to_param assigns[:stream].posts.map { |x| x.id }.should include(reshare.id) end @@ -288,7 +288,7 @@ describe PeopleController do end it 'throws 404 if the person is remote' do - p = Factory(:person) + p = FactoryGirl.create(:person) get :show, :id => p.to_param response.status.should == 404 @@ -326,7 +326,7 @@ describe PeopleController do end it "posts include reshares" do - reshare = @user.post(:reshare, :public => true, :root_guid => Factory(:status_message, :public => true).guid, :to => alice.aspects) + reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects) get :show, :id => @user.person.to_param assigns[:stream].posts.map { |x| x.id }.should include(reshare.id) end @@ -359,7 +359,7 @@ describe PeopleController do end it "posts include reshares" do - reshare = @user.post(:reshare, :public => true, :root_guid => Factory(:status_message, :public => true).guid, :to => alice.aspects) + reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects) get :show, :id => @user.person.to_param assigns[:stream].posts.map { |x| x.id }.should include(reshare.id) end @@ -370,10 +370,10 @@ describe PeopleController do describe '#refresh_search ' do before(:each)do - @eugene = Factory(:person, - :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w")) - @korth = Factory(:person, - :profile => Factory.build(:profile, :first_name => "Evan", :last_name => "Korth")) + @eugene = FactoryGirl.create(:person, + :profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w")) + @korth = FactoryGirl.create(:person, + :profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth")) end describe 'via json' do diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index dfeb6a18a..198b66c53 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -64,7 +64,7 @@ describe PhotosController do describe '#index' do it "succeeds without any available pictures" do - get :index, :person_id => Factory(:person).guid.to_s + get :index, :person_id => FactoryGirl.create(:person).guid.to_s response.should be_success end @@ -138,7 +138,7 @@ describe PhotosController do end it "doesn't overwrite random attributes" do - new_user = Factory(:user) + new_user = FactoryGirl.create(:user) params = { :text => "now with lasers!", :author_id => new_user.id } put :update, :id => @alices_photo.id, :photo => params @alices_photo.reload.author_id.should == alice.person.id diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index ad74d2d9a..9d07853ff 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -36,7 +36,7 @@ describe PostsController do end it 'succeeds on mobile with a reshare' do - get :show, "id" => Factory(:reshare, :author => alice.person).id, :format => :mobile + get :show, "id" => FactoryGirl.create(:reshare, :author => alice.person).id, :format => :mobile response.should be_success end @@ -50,7 +50,7 @@ describe PostsController do end it 'succeeds with a AS/photo' do - photo = Factory(:activity_streams_photo, :author => bob.person) + photo = FactoryGirl.create(:activity_streams_photo, :author => bob.person) get :show, :id => photo.id response.should be_success end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 94cc429fa..3cf86e3cd 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -143,7 +143,7 @@ describe ProfilesController do context 'mass assignment' do before do - new_person = Factory(:person) + new_person = FactoryGirl.create(:person) @profile_params = {:profile =>{ :person_id => new_person.id, :diaspora_handle => 'abc@a.com'}} end diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 0f2689c55..e425616b5 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -8,7 +8,7 @@ describe PublicsController do let(:fixture_path) { File.join(Rails.root, 'spec', 'fixtures')} before do @user = alice - @person = Factory(:person) + @person = FactoryGirl.create(:person) end describe '#host_meta' do @@ -55,7 +55,7 @@ describe PublicsController do aspect = @user.aspects.create(:name => 'foo') post1 = @user.post(:status_message, :text => 'moms', :to => [aspect.id]) xml2 = post1.to_diaspora_xml - user2 = Factory(:user) + user2 = FactoryGirl.create(:user) salmon_factory = Salmon::EncryptedSlap.create_by_user_and_activity(@user, xml2) enc_xml = salmon_factory.xml_for(user2.person) diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 4b02cd0f9..7cb972bee 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -16,7 +16,7 @@ describe RegistrationsController do :password_confirmation => "password" } } - Webfinger.stub_chain(:new, :fetch).and_return(Factory(:person)) + Webfinger.stub_chain(:new, :fetch).and_return(FactoryGirl.create(:person)) end describe '#check_registrations_open!' do @@ -61,7 +61,7 @@ describe RegistrationsController do end before do - user = Factory.build(:user) + user = FactoryGirl.build(:user) User.stub!(:build).and_return(user) end diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb index 9b400fa82..5766c49e0 100644 --- a/spec/controllers/reshares_controller_spec.rb +++ b/spec/controllers/reshares_controller_spec.rb @@ -7,7 +7,7 @@ describe ResharesController do } before do - @post_guid = Factory(:status_message, :public => true).guid + @post_guid = FactoryGirl.create(:status_message, :public => true).guid end it 'requires authentication' do diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 7d250251b..9e39a470b 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -27,7 +27,7 @@ describe ServicesController do describe '#index' do it 'displays all connected serivices for a user' do 4.times do - Factory(:service, :user => @user) + FactoryGirl.create(:service, :user => @user) end get :index @@ -97,7 +97,7 @@ describe ServicesController do describe '#destroy' do before do - @service1 = Factory(:service, :user => @user) + @service1 = FactoryGirl.create(:service, :user => @user) end it 'destroys a service selected by id' do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 9a2d27255..5d74aebac 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -41,13 +41,13 @@ describe UsersController do describe '#public' do it 'renders xml if atom is requested' do - sm = Factory(:status_message, :public => true, :author => @user.person) + sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person) get :public, :username => @user.username, :format => :atom response.body.should include(sm.text) end it 'renders xml if atom is requested with clickalbe urls' do - sm = Factory(:status_message, :public => true, :author => @user.person) + sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person) @user.person.posts.each do |p| p.text = "Goto http://diasporaproject.org/ now!" p.save diff --git a/spec/factories.rb b/spec/factories.rb index dcb35458d..0c765446f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -30,24 +30,24 @@ FactoryGirl.define do sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@example.net" } sequence(:url) { |n| AppConfig[:pod_url] } serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export - after_build do |person| - person.profile = Factory.build(:profile, :person => person) unless person.profile.first_name.present? + after(:build) do |person| + person.profile = FactoryGirl.build(:profile, :person => person) unless person.profile.first_name.present? end - after_create do |person| + after(:create) do |person| person.profile.save end end factory :account_deletion do association :person - after_build do |delete| + after(:build) do |delete| delete.diaspora_handle = delete.person.diaspora_handle end end factory :searchable_person, :parent => :person do - after_build do |person| - person.profile = Factory.build(:profile, :person => person, :searchable => true) + after(:build) do |person| + person.profile = FactoryGirl.build(:profile, :person => person, :searchable => true) end end @@ -63,20 +63,20 @@ FactoryGirl.define do password "bluepin7" password_confirmation { |u| u.password } serialized_private_key OpenSSL::PKey::RSA.generate(1024).export - after_build do |u| - u.person = Factory.build(:person, :profile => Factory.build(:profile), + after(:build) do |u| + u.person = FactoryGirl.build(:person, :profile => FactoryGirl.build(:profile), :owner_id => u.id, :serialized_public_key => u.encryption_key.public_key.export, :diaspora_handle => "#{u.username}#{User.diaspora_id_host}") end - after_create do |u| + after(:create) do |u| u.person.save u.person.profile.save end end factory :user_with_aspect, :parent => :user do - after_create { |u| Factory(:aspect, :user => u) } + after(:create) { |u| FactoryGirl.create(:aspect, :user => u) } end factory :aspect do @@ -87,22 +87,22 @@ FactoryGirl.define do factory(:status_message) do sequence(:text) { |n| "jimmy's #{n} whales" } association :author, :factory => :person - after_build do |sm| + after(:build) do |sm| sm.diaspora_handle = sm.author.diaspora_handle end end factory(:status_message_with_photo, :parent => :status_message) do sequence(:text) { |n| "There are #{n} ninjas in this photo." } - after_build do |sm| - Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => public) + after(:build) do |sm| + FactoryGirl.create(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => sm.public) end end factory(:photo) do sequence(:random_string) {|n| SecureRandom.hex(10) } association :author, :factory => :person - after_build do |p| + after(:build) do |p| p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png')) p.update_remote_path end @@ -125,7 +125,7 @@ FactoryGirl.define do service "email" identifier "bob.smith@smith.com" association :sender, :factory => :user_with_aspect - after_build do |i| + after(:build) do |i| i.aspect = i.sender.aspects.first end end @@ -163,8 +163,8 @@ FactoryGirl.define do association :target, :factory => :comment type 'Notifications::AlsoCommented' - after_build do |note| - note.actors << Factory.build(:person) + after(:build) do |note| + note.actors << FactoryGirl.build(:person) end end @@ -225,8 +225,8 @@ FactoryGirl.define do #templates factory(:multi_photo, :parent => :status_message_with_photo) do - after_build do |sm| - 2.times{ Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => public)} + after(:build) do |sm| + 2.times{ FactoryGirl.create(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => sm.public)} end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 19079a273..7a439a9ca 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe ApplicationHelper do before do @user = alice - @person = Factory(:person) + @person = FactoryGirl.create(:person) end describe "#contacts_link" do @@ -18,7 +18,7 @@ describe ApplicationHelper do end it 'links to community spotlight' do - @current_user = Factory(:user) + @current_user = FactoryGirl.create(:user) contacts_link.should == community_spotlight_path end @@ -39,7 +39,7 @@ describe ApplicationHelper do end it 'returns true if all networks are connected' do - 3.times { |t| @current_user.services << Factory.build(:service) } + 3.times { |t| @current_user.services << FactoryGirl.build(:service) } all_services_connected?.should be_true end diff --git a/spec/helpers/getting_started_helper_spec.rb b/spec/helpers/getting_started_helper_spec.rb index c6d7ac49a..d65a27e27 100644 --- a/spec/helpers/getting_started_helper_spec.rb +++ b/spec/helpers/getting_started_helper_spec.rb @@ -14,7 +14,7 @@ describe GettingStartedHelper do describe "#has_connected_cubbies?" do it 'returns true if the current user has connected cubbies to their account' do - @current_user.authorizations << Factory(:oauth_authorization) + @current_user.authorizations << FactoryGirl.create(:oauth_authorization) has_connected_cubbies?.should be_true end diff --git a/spec/helpers/markdownify_helper_spec.rb b/spec/helpers/markdownify_helper_spec.rb index 84124544a..dce5d70c5 100644 --- a/spec/helpers/markdownify_helper_spec.rb +++ b/spec/helpers/markdownify_helper_spec.rb @@ -35,7 +35,7 @@ describe MarkdownifyHelper do context 'when formatting status messages' do it "should leave tags intact" do - message = Factory(:status_message, + message = FactoryGirl.create(:status_message, :author => alice.person, :text => "I love #markdown") formatted = markdownify(message) @@ -43,7 +43,7 @@ describe MarkdownifyHelper do end it 'should leave multi-underscore tags intact' do - message = Factory( + message = FactoryGirl.create( :status_message, :author => alice.person, :text => "Here is a #multi_word tag" @@ -51,7 +51,7 @@ describe MarkdownifyHelper do formatted = markdownify(message) formatted.should =~ %r{Here is a #multi_word tag} - message = Factory( + message = FactoryGirl.create( :status_message, :author => alice.person, :text => "Here is a #multi_word_tag yo" @@ -61,7 +61,7 @@ describe MarkdownifyHelper do end it "should leave mentions intact" do - message = Factory(:status_message, + message = FactoryGirl.create(:status_message, :author => alice.person, :text => "Hey @{Bob; #{bob.diaspora_handle}}!") formatted = markdownify(message) @@ -69,8 +69,8 @@ describe MarkdownifyHelper do end it "should leave mentions intact for real diaspora handles" do - new_person = Factory(:person, :diaspora_handle => 'maxwell@joindiaspora.com') - message = Factory(:status_message, + new_person = FactoryGirl.create(:person, :diaspora_handle => 'maxwell@joindiaspora.com') + message = FactoryGirl.create(:status_message, :author => alice.person, :text => "Hey @{maxwell@joindiaspora.com; #{new_person.diaspora_handle}}!") formatted = markdownify(message) @@ -78,7 +78,7 @@ describe MarkdownifyHelper do end it 'should process text with both a hashtag and a link' do - message = Factory(:status_message, + message = FactoryGirl.create(:status_message, :author => alice.person, :text => "Test #tag?\nhttps://joindiaspora.com\n") formatted = markdownify(message) diff --git a/spec/helpers/mobile_helper_spec.rb b/spec/helpers/mobile_helper_spec.rb index b53630cc9..18a870bdf 100644 --- a/spec/helpers/mobile_helper_spec.rb +++ b/spec/helpers/mobile_helper_spec.rb @@ -10,7 +10,7 @@ describe MobileHelper do it "adds an all option to the list of aspects" do # options_from_collection_for_select(@aspects, "id", "name", @aspect.id) - n = Factory(:aspect) + n = FactoryGirl.create(:aspect) options = aspect_select_options([n], n).split('\n') options.first.should =~ /All/ diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 7ce660bc1..267b3fbad 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -5,12 +5,12 @@ describe NotificationsHelper do include ApplicationHelper before do - @user = Factory(:user) - @person = Factory(:person) - @post = Factory(:status_message, :author => @user.person) - @person2 = Factory(:person) - @notification = Notification.notify(@user, Factory(:like, :author => @person, :target => @post), @person) - @notification = Notification.notify(@user, Factory(:like, :author => @person2, :target => @post), @person2) + @user = FactoryGirl.create(:user) + @person = FactoryGirl.create(:person) + @post = FactoryGirl.create(:status_message, :author => @user.person) + @person2 = FactoryGirl.create(:person) + @notification = Notification.notify(@user, FactoryGirl.create(:like, :author => @person, :target => @post), @person) + @notification = Notification.notify(@user, FactoryGirl.create(:like, :author => @person2, :target => @post), @person2) end describe '#notification_people_link' do @@ -19,19 +19,19 @@ describe NotificationsHelper do let(:output){ strip_tags(notification_people_link(@note)) } before do - @max = Factory(:person) + @max = FactoryGirl.create(:person) @max.profile.first_name = 'max' @max.profile.last_name = 'salzberg' - @sarah = Factory(:person) + @sarah = FactoryGirl.create(:person) @sarah.profile.first_name = 'sarah' @sarah.profile.last_name = 'mei' - @daniel = Factory(:person) + @daniel = FactoryGirl.create(:person) @daniel.profile.first_name = 'daniel' @daniel.profile.last_name = 'grippi' - @ilya = Factory(:person) + @ilya = FactoryGirl.create(:person) @ilya.profile.first_name = 'ilya' @ilya.profile.last_name = 'zhit' @note = mock() diff --git a/spec/helpers/notifier_helper_spec.rb b/spec/helpers/notifier_helper_spec.rb index 0f99f0c6c..421679585 100644 --- a/spec/helpers/notifier_helper_spec.rb +++ b/spec/helpers/notifier_helper_spec.rb @@ -9,7 +9,7 @@ describe NotifierHelper do describe '#comment_message' do before do - @comment = Factory(:comment) + @comment = FactoryGirl.create(:comment) end it 'truncates the comment' do diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index e6dc2838b..78de68723 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe PeopleHelper do before do @user = alice - @person = Factory(:person) + @person = FactoryGirl.create(:person) end describe "#person_image_link" do @@ -32,7 +32,7 @@ describe PeopleHelper do describe '#person_link' do before do - @person = Factory(:person) + @person = FactoryGirl.create(:person) end it 'includes the name of the person if they have a first name' do @@ -76,7 +76,7 @@ describe PeopleHelper do describe '#local_or_remote_person_path' do before do - @user = Factory(:user) + @user = FactoryGirl.create(:user) end it "links by id if there is a period in the user's username" do diff --git a/spec/integration/account_deletion_spec.rb b/spec/integration/account_deletion_spec.rb index 26bb0f5b4..3b7d041fe 100644 --- a/spec/integration/account_deletion_spec.rb +++ b/spec/integration/account_deletion_spec.rb @@ -11,7 +11,7 @@ describe 'deleteing your account' do #@bob2's own content @bob2.post(:status_message, :text => 'asldkfjs', :to => @bob2.aspects.first) - f = Factory(:photo, :author => @bob2.person) + f = FactoryGirl.create(:photo, :author => @bob2.person) @aspect_vis = AspectVisibility.where(:aspect_id => @bob2.aspects.map(&:id)) @@ -35,20 +35,20 @@ describe 'deleteing your account' do # notifications @notifications = [] 3.times do |n| - @notifications << Factory(:notification, :recipient => @bob2) + @notifications << FactoryGirl.create(:notification, :recipient => @bob2) end # services @services = [] 3.times do |n| - @services << Factory(:service, :user => @bob2) + @services << FactoryGirl.create(:service, :user => @bob2) end # block @block = @bob2.blocks.create!(:person => eve.person) #authorization - @authorization = Factory(:oauth_authorization, :resource_owner => @bob2) + @authorization = FactoryGirl.create(:oauth_authorization, :resource_owner => @bob2) AccountDeleter.new(@bob2.person.diaspora_handle).perform! @bob2.reload @@ -109,7 +109,7 @@ describe 'deleteing your account' do #posts @posts = (1..3).map do - Factory(:status_message, :author => @person) + FactoryGirl.create(:status_message, :author => @person) end @persons_sv = @posts.each do |post| @@ -119,11 +119,11 @@ describe 'deleteing your account' do end #photos - @photo = Factory(:photo, :author => @person) + @photo = FactoryGirl.create(:photo, :author => @person) #mentions @mentions = 3.times do - Factory(:mention, :person => @person) + FactoryGirl.create(:mention, :person => @person) end #conversations diff --git a/spec/integration/activity_streams/photos_controller_spec.rb b/spec/integration/activity_streams/photos_controller_spec.rb index e95a3ae4e..6af9aaa72 100644 --- a/spec/integration/activity_streams/photos_controller_spec.rb +++ b/spec/integration/activity_streams/photos_controller_spec.rb @@ -33,7 +33,7 @@ JSON @url = activity_streams_photos_path end it 'allows oauth authentication' do - token = Factory(:oauth_access_token) + token = FactoryGirl.create(:oauth_access_token) post @url, @json.merge!(:oauth_token => token.access_token) response.should be_success end diff --git a/spec/integration/attack_vectors_spec.rb b/spec/integration/attack_vectors_spec.rb index c75129abc..e10d5fd4b 100644 --- a/spec/integration/attack_vectors_spec.rb +++ b/spec/integration/attack_vectors_spec.rb @@ -14,7 +14,7 @@ def receive(post, opts) end def temporary_user(&block) - user = Factory(:user) + user = FactoryGirl.create(:user) block_return_value = yield user user.delete block_return_value @@ -131,7 +131,7 @@ describe "attack vectors" do original_message = legit_post_from_user1_to_user2(eve, bob) #someone else tries to make a message with the same guid - malicious_message = Factory.build(:status_message, :id => original_message.id, :guid => original_message.guid, :author => alice.person) + malicious_message = FactoryGirl.build(:status_message, :id => original_message.id, :guid => original_message.guid, :author => alice.person) expect{ receive(malicious_message, :from => alice, :by => bob) @@ -144,7 +144,7 @@ describe "attack vectors" do original_message = legit_post_from_user1_to_user2(eve, bob) #eve tries to send me another message with the same ID - malicious_message = Factory.build( :status_message, :id => original_message.id, :text => 'BAD!!!', :author => eve.person) + malicious_message = FactoryGirl.build( :status_message, :id => original_message.id, :text => 'BAD!!!', :author => eve.person) expect { receive(malicious_message, :from => eve, :by => bob) diff --git a/spec/integration/dispatching_spec.rb b/spec/integration/dispatching_spec.rb index fb7168363..07422338b 100644 --- a/spec/integration/dispatching_spec.rb +++ b/spec/integration/dispatching_spec.rb @@ -5,7 +5,7 @@ describe "Dispatching" do it "should trigger a private dispatch" do luke, leia, raph = set_up_friends # Luke has a public post and comments on it - post = Factory(:status_message, :public => true, :author => luke.person) + post = FactoryGirl.create(:status_message, :public => true, :author => luke.person) fantasy_resque do comment = luke.comment!(post, "awesomesauseum") diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index 3a3ac786c..93a087863 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -70,12 +70,12 @@ describe 'a user receives a post' do end it 'notifies local users who are mentioned' do - @remote_person = Factory(:person, :diaspora_handle => "foobar@foobar.com") + @remote_person = FactoryGirl.create(:person, :diaspora_handle => "foobar@foobar.com") Contact.create!(:user => alice, :person => @remote_person, :aspects => [@alices_aspect]) Notification.should_receive(:notify).with(alice, anything(), @remote_person) - @sm = Factory.build(:status_message, :text => "hello @{#{alice.name}; #{alice.diaspora_handle}}", :diaspora_handle => @remote_person.diaspora_handle, :author => @remote_person) + @sm = FactoryGirl.build(:status_message, :text => "hello @{#{alice.name}; #{alice.diaspora_handle}}", :diaspora_handle => @remote_person.diaspora_handle, :author => @remote_person) @sm.save zord = Postzord::Receiver::Private.new(alice, :object => @sm, :person => bob.person) @@ -151,10 +151,10 @@ describe 'a user receives a post' do context 'dependent delete' do it 'deletes share_visibilities on disconnected by' do - @person = Factory(:person) + @person = FactoryGirl.create(:person) alice.contacts.create(:person => @person, :aspects => [@alices_aspect]) - @post = Factory(:status_message, :author => @person) + @post = FactoryGirl.create(:status_message, :author => @person) @post.share_visibilities.should be_empty receive_with_zord(alice, @person, @post.to_diaspora_xml) @contact = alice.contact_for(@person) @@ -210,7 +210,7 @@ describe 'a user receives a post' do Webfinger.should_receive(:new).twice.with(eve.person.diaspora_handle).and_return(m) m.should_receive(:fetch).twice.and_return{ remote_person.save(:validate => false) - remote_person.profile = Factory(:profile, :person => remote_person) + remote_person.profile = FactoryGirl.create(:profile, :person => remote_person) remote_person } @@ -253,11 +253,11 @@ describe 'a user receives a post' do describe 'receiving mulitple versions of the same post from a remote pod' do before do @local_luke, @local_leia, @remote_raphael = set_up_friends - @post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago) + @post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago) end it 'does not update created_at or updated_at when two people save the same post' do - @post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago) + @post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago) xml = @post.to_diaspora_xml receive_with_zord(@local_luke, @remote_raphael, xml) old_time = Time.now+1 @@ -267,11 +267,11 @@ describe 'a user receives a post' do end it 'does not update the post if a new one is sent with a new created_at' do - @post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 5.days.ago) + @post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 5.days.ago) old_time = @post.created_at xml = @post.to_diaspora_xml receive_with_zord(@local_luke, @remote_raphael, xml) - @post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 2.days.ago) + @post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 2.days.ago) receive_with_zord(@local_luke, @remote_raphael, xml) (Post.find_by_guid @post.guid).created_at.day.should == old_time.day end diff --git a/spec/lib/diaspora/encryptable_spec.rb b/spec/lib/diaspora/encryptable_spec.rb index eb62e5e90..7d0e13252 100644 --- a/spec/lib/diaspora/encryptable_spec.rb +++ b/spec/lib/diaspora/encryptable_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe Diaspora::Encryptable do before do - @comment = Factory(:comment, :author => bob.person) + @comment = FactoryGirl.create(:comment, :author => bob.person) end describe '#sign_with_key' do it 'signs the object with RSA256 signature' do diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index 23f132080..a3b015bfb 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -9,7 +9,7 @@ describe Diaspora::Exporter do before do @user1 = alice - @user2 = Factory(:user) + @user2 = FactoryGirl.create(:user) @user3 = bob @aspect = @user1.aspects.first diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 08eb14601..4a7e6cf38 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -14,13 +14,13 @@ describe Diaspora::Parser do @aspect2 = @user2.aspects.first @aspect3 = @user3.aspects.first - @person = Factory(:person) + @person = FactoryGirl.create(:person) end describe "parsing compliant XML object" do it 'should be able to correctly parse comment fields' do post = @user1.post :status_message, :text => "hello", :to => @aspect1.id - comment = Factory(:comment, :post => post, :author => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!") + comment = FactoryGirl.create(:comment, :post => post, :author => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!") comment.delete xml = comment.to_diaspora_xml comment_from_xml = Diaspora::Parser.from_xml(xml) diff --git a/spec/lib/evil_query_spec.rb b/spec/lib/evil_query_spec.rb index 05446e730..4b08377f4 100644 --- a/spec/lib/evil_query_spec.rb +++ b/spec/lib/evil_query_spec.rb @@ -11,7 +11,7 @@ end describe EvilQuery::Participation do before do - @status_message = Factory(:status_message, :author => bob.person) + @status_message = FactoryGirl.create(:status_message, :author => bob.person) end it "includes posts liked by the user" do @@ -30,11 +30,11 @@ describe EvilQuery::Participation do describe "ordering" do before do - @status_messageA = Factory(:status_message, :author => bob.person) - @status_messageB = Factory(:status_message, :author => bob.person) - @photoC = Factory(:activity_streams_photo, :author => bob.person) - @status_messageD = Factory(:status_message, :author => bob.person) - @status_messageE = Factory(:status_message, :author => bob.person) + @status_messageA = FactoryGirl.create(:status_message, :author => bob.person) + @status_messageB = FactoryGirl.create(:status_message, :author => bob.person) + @photoC = FactoryGirl.create(:activity_streams_photo, :author => bob.person) + @status_messageD = FactoryGirl.create(:status_message, :author => bob.person) + @status_messageE = FactoryGirl.create(:status_message, :author => bob.person) time = Time.now diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index c7f5f915f..862d97b20 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -8,9 +8,9 @@ require File.join(Rails.root, 'lib/postzord/dispatcher') describe Postzord::Dispatcher do before do - @sm = Factory(:status_message, :public => true, :author => alice.person) + @sm = FactoryGirl.create(:status_message, :public => true, :author => alice.person) @subscribers = [] - 5.times{@subscribers << Factory(:person)} + 5.times{@subscribers << FactoryGirl.create(:person)} @sm.stub(:subscribers).and_return(@subscribers) @xml = @sm.to_diaspora_xml end @@ -31,7 +31,7 @@ describe Postzord::Dispatcher do end it 'accepts additional subscribers from opts' do - new_person = Factory(:person) + new_person = FactoryGirl.create(:person) @sm.should_receive(:subscribers).and_return(@subscribers) zord = Postzord::Dispatcher.build(alice, @sm, :additional_subscribers => new_person) @@ -130,7 +130,7 @@ describe Postzord::Dispatcher do context "remote raphael" do before do - @comment = Factory.build(:comment, :author => @remote_raphael, :post => @post) + @comment = FactoryGirl.build(:comment, :author => @remote_raphael, :post => @post) @comment.save @mailman = Postzord::Dispatcher.build(@local_luke, @comment) end @@ -177,7 +177,7 @@ describe Postzord::Dispatcher do context "remote raphael's post is commented on by local luke" do before do - @post = Factory(:status_message, :author => @remote_raphael) + @post = FactoryGirl.create(:status_message, :author => @remote_raphael) @comment = @local_luke.build_comment :text => "yo", :post => @post @comment.save @mailman = Postzord::Dispatcher.build(@local_luke, @comment) @@ -244,28 +244,28 @@ describe Postzord::Dispatcher do describe '#object_should_be_processed_as_public?' do it 'returns true with a comment on a public post' do - f = Factory(:comment, :post => Factory(:status_message, :public => true)) + f = FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => true)) Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_true end it 'returns false with a comment on a private post' do - f = Factory(:comment, :post => Factory(:status_message, :public => false)) + f = FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => false)) Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false end it 'returns true with a like on a comment on a public post' do - f = Factory(:like, :target => Factory(:comment, :post => Factory(:status_message, :public => true))) + f = FactoryGirl.create(:like, :target => FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => true))) Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_true end it 'returns false with a like on a comment on a private post' do - f = Factory(:like, :target => Factory(:comment, :post => Factory(:status_message, :public => false))) + f = FactoryGirl.create(:like, :target => FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => false))) Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false end it 'returns false for a relayable_retraction' do f = RelayableRetraction.new - f.target = Factory(:status_message, :public => true) + f.target = FactoryGirl.create(:status_message, :public => true) Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false end end @@ -285,7 +285,7 @@ describe Postzord::Dispatcher do end it 'does not push to hub for non-public posts' do - @sm = Factory(:status_message) + @sm = FactoryGirl.create(:status_message) mailman = Postzord::Dispatcher.build(alice, @sm, :url => "http://joindiaspora.com/p/123") mailman.should_not_receive(:deliver_to_hub) @@ -293,11 +293,11 @@ describe Postzord::Dispatcher do end it 'only pushes to specified services' do - @s1 = Factory(:service, :user_id => alice.id) + @s1 = FactoryGirl.create(:service, :user_id => alice.id) alice.services << @s1 - @s2 = Factory(:service, :user_id => alice.id) + @s2 = FactoryGirl.create(:service, :user_id => alice.id) alice.services << @s2 - mailman = Postzord::Dispatcher.build(alice, Factory(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1]) + mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1]) Resque.stub!(:enqueue).with(Jobs::PublishToHub, anything) Resque.stub!(:enqueue).with(Jobs::HttpMulti, anything, anything, anything) @@ -306,7 +306,7 @@ describe Postzord::Dispatcher do end it 'does not push to services if none are specified' do - mailman = Postzord::Dispatcher.build(alice, Factory(:status_message), :url => "http://joindiaspora.com/p/123") + mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123") Resque.stub!(:enqueue).with(Jobs::PublishToHub, anything) Resque.should_not_receive(:enqueue).with(Jobs::PostToService, anything, anything, anything) diff --git a/spec/lib/postzord/receiver/local_batch_spec.rb b/spec/lib/postzord/receiver/local_batch_spec.rb index fdfc40c52..383b4a4c5 100644 --- a/spec/lib/postzord/receiver/local_batch_spec.rb +++ b/spec/lib/postzord/receiver/local_batch_spec.rb @@ -3,7 +3,7 @@ require File.join(Rails.root, 'lib','postzord', 'receiver', 'local_batch') describe Postzord::Receiver::LocalBatch do before do - @object = Factory(:status_message, :author => alice.person) + @object = FactoryGirl.create(:status_message, :author => alice.person) @ids = [bob.id.to_s] end @@ -43,7 +43,7 @@ describe Postzord::Receiver::LocalBatch do describe '#notify_mentioned_users' do it 'calls notify person for a mentioned person' do - sm = Factory(:status_message, + sm = FactoryGirl.create(:status_message, :author => alice.person, :text => "Hey @{Bob; #{bob.diaspora_handle}}") @@ -60,14 +60,14 @@ describe Postzord::Receiver::LocalBatch do describe '#notify_users' do it 'calls notify for posts with notification type' do - reshare = Factory(:reshare) + reshare = FactoryGirl.create(:reshare) Notification.should_receive(:notify) receiver = Postzord::Receiver::LocalBatch.new(reshare, @ids) receiver.notify_users end it 'calls notify for posts with notification type' do - sm = Factory(:status_message, :author => alice.person) + sm = FactoryGirl.create(:status_message, :author => alice.person) receiver = Postzord::Receiver::LocalBatch.new(sm, @ids) Notification.should_not_receive(:notify) receiver.notify_users @@ -76,8 +76,8 @@ describe Postzord::Receiver::LocalBatch do context 'integrates with a comment' do before do - sm = Factory(:status_message, :author => alice.person) - @object = Factory(:comment, :author => bob.person, :post => sm) + sm = FactoryGirl.create(:status_message, :author => alice.person) + @object = FactoryGirl.create(:comment, :author => bob.person, :post => sm) end it 'calls notify_users' do diff --git a/spec/lib/postzord/receiver/private_spec.rb b/spec/lib/postzord/receiver/private_spec.rb index d76dfc012..19067431f 100644 --- a/spec/lib/postzord/receiver/private_spec.rb +++ b/spec/lib/postzord/receiver/private_spec.rb @@ -53,7 +53,7 @@ describe Postzord::Receiver::Private do end it 'if the author does not match the signature' do - @zord.instance_variable_set(:@sender, Factory(:person)) + @zord.instance_variable_set(:@sender, FactoryGirl.create(:person)) @zord.receive!.should == false end end diff --git a/spec/lib/postzord/receiver/public_spec.rb b/spec/lib/postzord/receiver/public_spec.rb index 5d3ee3fff..f4e004536 100644 --- a/spec/lib/postzord/receiver/public_spec.rb +++ b/spec/lib/postzord/receiver/public_spec.rb @@ -9,14 +9,14 @@ require File.join(Rails.root, 'lib/postzord/receiver/public') describe Postzord::Receiver::Public do before do - @post = Factory.build(:status_message, :author => alice.person, :public => true) + @post = FactoryGirl.build(:status_message, :author => alice.person, :public => true) @created_salmon = Salmon::Slap.create_by_user_and_activity(alice, @post.to_diaspora_xml) @xml = @created_salmon.xml_for(nil) end context 'round trips works with' do it 'a comment' do - comment = bob.build_comment(:text => 'yo', :post => Factory(:status_message)) + comment = bob.build_comment(:text => 'yo', :post => FactoryGirl.create(:status_message)) comment.save xml = Salmon::Slap.create_by_user_and_activity(bob, comment.to_diaspora_xml).xml_for(nil) comment.destroy @@ -91,7 +91,7 @@ describe Postzord::Receiver::Public do describe '#receive_relayable' do before do - @comment = bob.build_comment(:text => 'yo', :post => Factory(:status_message)) + @comment = bob.build_comment(:text => 'yo', :post => FactoryGirl.create(:status_message)) @comment.save created_salmon = Salmon::Slap.create_by_user_and_activity(alice, @comment.to_diaspora_xml) xml = created_salmon.xml_for(nil) diff --git a/spec/lib/rake_helper_spec.rb b/spec/lib/rake_helper_spec.rb index 48b617fc7..5a345bac9 100644 --- a/spec/lib/rake_helper_spec.rb +++ b/spec/lib/rake_helper_spec.rb @@ -13,7 +13,7 @@ describe RakeHelpers do before do Devise.mailer.deliveries = [] @old_admin = AppConfig[:admin_account] - AppConfig[:admin_account] = Factory(:user).username + AppConfig[:admin_account] = FactoryGirl.create(:user).username end after do diff --git a/spec/lib/salmon/slap_spec.rb b/spec/lib/salmon/slap_spec.rb index 91d854bda..880b8b322 100644 --- a/spec/lib/salmon/slap_spec.rb +++ b/spec/lib/salmon/slap_spec.rb @@ -68,7 +68,7 @@ describe Salmon::Slap do end it 'verifies the signature for the sender' do - parsed_salmon.verified_for_key?(Factory(:person).public_key).should be_false + parsed_salmon.verified_for_key?(FactoryGirl.create(:person).public_key).should be_false end it 'contains the original data' do diff --git a/spec/lib/statistics_spec.rb b/spec/lib/statistics_spec.rb index a2ea2fb16..d7aa47d1d 100644 --- a/spec/lib/statistics_spec.rb +++ b/spec/lib/statistics_spec.rb @@ -25,14 +25,14 @@ describe Statistics do describe '#posts_count_sql' do it "pulls back an array of post counts and ids" do - Factory(:status_message, :author => bob.person) + FactoryGirl.create(:status_message, :author => bob.person) result_should_equal User.connection.select_all(@stats.posts_count_sql) end end describe '#comments_count_sql' do it "pulls back an array of post counts and ids" do - status_message = Factory(:status_message, :author => alice.person) + status_message = FactoryGirl.create(:status_message, :author => alice.person) bob.comment!(status_message, "sup") result_should_equal User.connection.select_all(@stats.comments_count_sql) end @@ -55,7 +55,7 @@ describe Statistics do describe '#mentions_count_sql' do it "pulls back an array of mentions following counts and ids" do - post = Factory(:status_message, :author => bob.person) + post = FactoryGirl.create(:status_message, :author => bob.person) Mention.create(:post => post, :person => bob.person) result_should_equal User.connection.select_all(@stats.mentions_count_sql) end @@ -86,10 +86,10 @@ describe Statistics do describe "#fb_connected_distribution_sql" do it "pulls back an array of sign_in_counts, connected, uids" do bob.sign_in_count = 1 - bob.services << Factory(:service, :type => "Services::Facebook", :user => bob) + bob.services << FactoryGirl.create(:service, :type => "Services::Facebook", :user => bob) bob.save! - eve.services << Factory(:service, :type => "Services::Facebook", :user => eve) + eve.services << FactoryGirl.create(:service, :type => "Services::Facebook", :user => eve) eve.save! diff --git a/spec/lib/stream/base_spec.rb b/spec/lib/stream/base_spec.rb index 29c8e7b12..4eb136aa8 100644 --- a/spec/lib/stream/base_spec.rb +++ b/spec/lib/stream/base_spec.rb @@ -25,7 +25,7 @@ describe Stream::Base do before do bob.post(:status_message, :text => "sup", :to => bob.aspects.first.id) @liked_status = bob.posts.last - @like = Factory(:like, :target => @liked_status, :author => alice.person) + @like = FactoryGirl.create(:like, :target => @liked_status, :author => alice.person) end it "marks the posts as liked" do @@ -36,33 +36,33 @@ describe Stream::Base do describe '.can_comment?' do before do - @person = Factory(:person) + @person = FactoryGirl.create(:person) @stream.stub(:people).and_return([bob.person, eve.person, @person]) end it 'allows me to comment on my local contacts post' do - post = Factory(:status_message, :author => bob.person) + post = FactoryGirl.create(:status_message, :author => bob.person) @stream.can_comment?(post).should be_true end it 'allows me to comment on my own post' do - post = Factory(:status_message, :author => alice.person) + post = FactoryGirl.create(:status_message, :author => alice.person) @stream.can_comment?(post).should be_true end it 'allows me to comment on any local public post' do - post = Factory(:status_message, :author => eve.person) + post = FactoryGirl.create(:status_message, :author => eve.person) @stream.can_comment?(post).should be_true end it 'allows me to comment on a remote contacts post' do Contact.create!(:user => @stream.user, :person => @person) - post = Factory(:status_message, :author => @person) + post = FactoryGirl.create(:status_message, :author => @person) @stream.can_comment?(post).should be_true end it 'returns false if person is remote and not a contact' do - post = Factory(:status_message, :author => @person) + post = FactoryGirl.create(:status_message, :author => @person) @stream.can_comment?(post).should be_false end end diff --git a/spec/lib/stream/multi_spec.rb b/spec/lib/stream/multi_spec.rb index 60dba1b17..9649d34f2 100644 --- a/spec/lib/stream/multi_spec.rb +++ b/spec/lib/stream/multi_spec.rb @@ -45,7 +45,7 @@ describe Stream::Multi do context 'when invited by another user' do before do - @user = Factory(:user, :invited_by => alice) + @user = FactoryGirl.create(:user, :invited_by => alice) @inviter = alice.person @stream = Stream::Multi.new(@user) diff --git a/spec/lib/stream/tag_spec.rb b/spec/lib/stream/tag_spec.rb index e7f71001a..faebcf15a 100644 --- a/spec/lib/stream/tag_spec.rb +++ b/spec/lib/stream/tag_spec.rb @@ -28,7 +28,7 @@ describe Stream::Tag do end it 'displays a public post that was sent to no one' do - stranger = Factory(:user_with_aspect) + stranger = FactoryGirl.create(:user_with_aspect) stranger_post = stranger.post(:status_message, :text => "#what", :public => true, :to => 'all') @stream.posts.should == [stranger_post] end @@ -36,7 +36,7 @@ describe Stream::Tag do it 'displays a post with a comment containing the tag search' do pending "this code is way too slow. need to re-implement in a way that doesn't suck" other_post = bob.post(:status_message, :text => "sup y'all", :to => 'all') - Factory(:comment, :text => "#what", :post => other_post) + FactoryGirl.create(:comment, :text => "#what", :post => other_post) @stream.posts.should == [other_post] end end @@ -74,7 +74,7 @@ describe Stream::Tag do describe 'shared behaviors' do before do - @stream = Stream::Tag.new(Factory(:user), "test") + @stream = Stream::Tag.new(FactoryGirl.create(:user), "test") end it_should_behave_like 'it is a stream' end diff --git a/spec/lib/template_picker_spec.rb b/spec/lib/template_picker_spec.rb index be75fb455..21f5e0550 100644 --- a/spec/lib/template_picker_spec.rb +++ b/spec/lib/template_picker_spec.rb @@ -73,7 +73,7 @@ describe TemplatePicker do TemplatePicker::TEMPLATES.each do |template| describe "#{template} factory" do it 'works' do - post = Factory.build(template.to_sym, :author => alice.person) + post = FactoryGirl.build(template.to_sym, :author => alice.person) template_name = TemplatePicker.new(post).template_name.gsub('-', '_') template_name.should == template end diff --git a/spec/lib/webfinger_spec.rb b/spec/lib/webfinger_spec.rb index 89a6948de..ab4402798 100644 --- a/spec/lib/webfinger_spec.rb +++ b/spec/lib/webfinger_spec.rb @@ -85,7 +85,7 @@ describe Webfinger do describe 'existing_person_with_profile?' do it 'returns true if cached_person is present and has a profile' do - finger.should_receive(:cached_person).twice.and_return(Factory(:person)) + finger.should_receive(:cached_person).twice.and_return(FactoryGirl.create(:person)) finger.existing_person_with_profile?.should be_true end @@ -95,7 +95,7 @@ describe Webfinger do end it 'returns false if the person has no profile' do - p = Factory(:person) + p = FactoryGirl.create(:person) p.profile = nil finger.stub(:cached_person).and_return(p) finger.existing_person_with_profile?.should be_false diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index b0ca06b9e..e310031a1 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Notifier do include ActionView::Helpers::TextHelper - let(:person) { Factory(:person) } + let(:person) { FactoryGirl.create(:person) } before do Notifier.deliveries = [] @@ -23,7 +23,7 @@ describe Notifier do before do @users = [] 5.times do - @users << Factory(:user) + @users << FactoryGirl.create(:user) end end it 'has a body' do @@ -84,7 +84,7 @@ describe Notifier do describe ".mentioned" do before do @user = alice - @sm = Factory(:status_message) + @sm = FactoryGirl.create(:status_message) @m = Mention.create(:person => @user.person, :post=> @sm) @mail = Notifier.mentioned(@user.id, @sm.author.id, @m.id) @@ -109,7 +109,7 @@ describe Notifier do describe ".liked" do before do - @sm = Factory(:status_message, :author => alice.person) + @sm = FactoryGirl.create(:status_message, :author => alice.person) @like = @sm.likes.create!(:author => bob.person) @mail = Notifier.liked(alice.id, @like.author.id, @like.id) end @@ -131,13 +131,13 @@ describe Notifier do end it 'can handle a reshare' do - reshare = Factory(:reshare) + reshare = FactoryGirl.create(:reshare) like = reshare.likes.create!(:author => bob.person) mail = Notifier.liked(alice.id, like.author.id, like.id) end it 'can handle a activity streams photo' do - as_photo = Factory(:activity_streams_photo) + as_photo = FactoryGirl.create(:activity_streams_photo) like = as_photo.likes.create!(:author => bob.person) mail = Notifier.liked(alice.id, like.author.id, like.id) end @@ -145,8 +145,8 @@ describe Notifier do describe ".reshared" do before do - @sm = Factory(:status_message, :author => alice.person, :public => true) - @reshare = Factory(:reshare, :root => @sm, :author => bob.person) + @sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true) + @reshare = FactoryGirl.create(:reshare, :root => @sm, :author => bob.person) @mail = Notifier.reshared(alice.id, @reshare.author.id, @reshare.id) end @@ -248,7 +248,7 @@ describe Notifier do [:reshare, :activity_streams_photo].each do |post_type| context post_type.to_s do - let(:commented_post) { Factory(post_type, :author => bob.person) } + let(:commented_post) { FactoryGirl.create(post_type, :author => bob.person) } it 'succeeds' do proc { comment_mail @@ -288,7 +288,7 @@ describe Notifier do end [:reshare, :activity_streams_photo].each do |post_type| context post_type.to_s do - let(:commented_post) { Factory(post_type, :author => bob.person) } + let(:commented_post) { FactoryGirl.create(post_type, :author => bob.person) } it 'succeeds' do proc { comment_mail diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index f5b159815..a7a0d6c3b 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe 'making sure the spec runner works' do it 'factory creates a user with a person saved' do - user = Factory(:user) + user = FactoryGirl.create(:user) loaded_user = User.find(user.id) loaded_user.person.owner_id.should == user.id end diff --git a/spec/models/account_deletion_spec.rb b/spec/models/account_deletion_spec.rb index 5bd96f79f..793a33b98 100644 --- a/spec/models/account_deletion_spec.rb +++ b/spec/models/account_deletion_spec.rb @@ -61,9 +61,9 @@ describe AccountDeletion do it 'includes remote resharers' do @ad = AccountDeletion.new(:person => alice.person) - sm = Factory( :status_message, :public => true, :author => alice.person) - r1 = Factory( :reshare, :author => remote_raphael, :root => sm) - r2 = Factory( :reshare, :author => local_luke.person, :root => sm) + sm = FactoryGirl.create( :status_message, :public => true, :author => alice.person) + r1 = FactoryGirl.create( :reshare, :author => remote_raphael, :root => sm) + r2 = FactoryGirl.create( :reshare, :author => local_luke.person, :root => sm) @ad.subscribers(alice).should == [remote_raphael] end diff --git a/spec/models/activity_streams/photo_spec.rb b/spec/models/activity_streams/photo_spec.rb index c5d2ab20a..0db0d03fc 100644 --- a/spec/models/activity_streams/photo_spec.rb +++ b/spec/models/activity_streams/photo_spec.rb @@ -29,7 +29,7 @@ JSON describe 'serialization' do before do - @photo = Factory(:activity_streams_photo) + @photo = FactoryGirl.create(:activity_streams_photo) xml = @photo.to_diaspora_xml.to_s @marshalled = Diaspora::Parser.from_xml(xml) end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index b2d79b5f0..8c343696f 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -68,7 +68,7 @@ describe Comment do describe 'xml' do before do - @commenter = Factory(:user) + @commenter = FactoryGirl.create(:user) @commenter_aspect = @commenter.aspects.create(:name => "bruisers") connect_users(alice, @alices_aspect, @commenter, @commenter_aspect) @post = alice.post :status_message, :text => "hello", :to => @alices_aspect.id @@ -102,7 +102,7 @@ describe Comment do describe 'it is relayable' do before do @local_luke, @local_leia, @remote_raphael = set_up_friends - @remote_parent = Factory(:status_message, :author => @remote_raphael) + @remote_parent = FactoryGirl.create(:status_message, :author => @remote_raphael) @local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first @object_by_parent_author = @local_luke.comment!(@local_parent, "yo") @@ -118,7 +118,7 @@ describe Comment do describe 'tags' do before do - @object = Factory.build(:comment) + @object = FactoryGirl.build(:comment) end it_should_behave_like 'it is taggable' end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 0fc6f2d7e..7f4881cef 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -35,7 +35,7 @@ describe Contact do end it 'validates uniqueness' do - person = Factory(:person) + person = FactoryGirl.create(:person) contact2 = alice.contacts.create(:person=>person) contact2.should be_valid @@ -46,7 +46,7 @@ describe Contact do end it "validates that the person's account is not closed" do - person = Factory(:person, :closed_account => true) + person = FactoryGirl.create(:person, :closed_account => true) contact = alice.contacts.new(:person=>person) @@ -59,8 +59,8 @@ describe Contact do describe 'sharing' do it 'returns contacts with sharing true' do lambda { - alice.contacts.create!(:sharing => true, :person => Factory(:person)) - alice.contacts.create!(:sharing => false, :person => Factory(:person)) + alice.contacts.create!(:sharing => true, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:sharing => false, :person => FactoryGirl.create(:person)) }.should change{ Contact.sharing.count }.by(1) @@ -70,8 +70,8 @@ describe Contact do describe 'receiving' do it 'returns contacts with sharing true' do lambda { - alice.contacts.create!(:receiving => true, :person => Factory(:person)) - alice.contacts.create!(:receiving => false, :person => Factory(:person)) + alice.contacts.create!(:receiving => true, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:receiving => false, :person => FactoryGirl.create(:person)) }.should change{ Contact.receiving.count }.by(1) @@ -81,10 +81,10 @@ describe Contact do describe 'only_sharing' do it 'returns contacts with sharing true and receiving false' do lambda { - alice.contacts.create!(:receiving => true, :sharing => true, :person => Factory(:person)) - alice.contacts.create!(:receiving => false, :sharing => true, :person => Factory(:person)) - alice.contacts.create!(:receiving => false, :sharing => true, :person => Factory(:person)) - alice.contacts.create!(:receiving => true, :sharing => false, :person => Factory(:person)) + alice.contacts.create!(:receiving => true, :sharing => true, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:receiving => false, :sharing => true, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:receiving => false, :sharing => true, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:receiving => true, :sharing => false, :person => FactoryGirl.create(:person)) }.should change{ Contact.receiving.count }.by(2) @@ -93,9 +93,9 @@ describe Contact do describe "all_contacts_of_person" do it 'returns all contacts where the person is the passed in person' do - person = Factory(:person) - contact1 = Factory(:contact, :person => person) - contact2 = Factory(:contact) + person = FactoryGirl.create(:person) + contact1 = FactoryGirl.create(:contact, :person => person) + contact2 = FactoryGirl.create(:contact) contacts = Contact.all_contacts_of_person(person) contacts.should == [contact1] end @@ -117,12 +117,12 @@ describe Contact do @people2 = [] 1.upto(5) do - person = Factory(:person) + person = FactoryGirl.create(:person) @bob.contacts.create(:person => person, :aspects => [@original_aspect]) @people1 << person end 1.upto(5) do - person = Factory(:person) + person = FactoryGirl.create(:person) @bob.contacts.create(:person => person, :aspects => [@new_aspect]) @people2 << person end @@ -166,8 +166,8 @@ describe Contact do context 'requesting' do before do @contact = Contact.new - @user = Factory(:user) - @person = Factory(:person) + @user = FactoryGirl.create(:user) + @person = FactoryGirl.create(:person) @contact.user = @user @contact.person = @person diff --git a/spec/models/invitation_code_spec.rb b/spec/models/invitation_code_spec.rb index c902c6c36..5ac687ac2 100644 --- a/spec/models/invitation_code_spec.rb +++ b/spec/models/invitation_code_spec.rb @@ -2,17 +2,17 @@ require 'spec_helper' describe InvitationCode do it 'has a valid factory' do - Factory(:invitation_code).should be_valid + FactoryGirl.create(:invitation_code).should be_valid end it 'sets the count to a default value' do - code = Factory(:invitation_code) + code = FactoryGirl.create(:invitation_code) code.count.should > 0 end describe '#use!' do it 'decrements the count of the code' do - code = Factory(:invitation_code) + code = FactoryGirl.create(:invitation_code) expect{ code.use! @@ -22,7 +22,7 @@ describe InvitationCode do describe '.beta?' do it 'returns true if the invite code user is beta' do - code = Factory(:invitation_code) + code = FactoryGirl.create(:invitation_code) Role.add_beta(code.user.person) code.user.should be_beta code.should be_beta diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index c379ee819..00a111bd6 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -13,7 +13,7 @@ describe Invitation do end describe 'validations' do before do - @invitation = Factory.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de") + @invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de") end it 'is valid' do @@ -25,25 +25,25 @@ describe Invitation do end it 'ensures the sender is placing the recipient into one of his aspects' do - @invitation.aspect = Factory(:aspect) + @invitation.aspect = FactoryGirl.create(:aspect) @invitation.should_not be_valid end end describe '#language' do it 'returns the correct language if the language is set' do - @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de") + @invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de") @invitation.language.should == "de" end it 'returns en if no language is set' do - @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first) + @invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first) @invitation.language.should == "en" end end it 'has a message' do - @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language) + @invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language) @invitation.message = "!" @invitation.message.should == "!" end @@ -62,7 +62,7 @@ describe Invitation do end it 'shares with people who are already on the pod' do - Factory(:user, :email => @emails.first) + FactoryGirl.create(:user, :email => @emails.first) invites = nil expect{ invites = Invitation.batch_invite(@emails, @opts) diff --git a/spec/models/jobs/fetch_profile_photo_spec.rb b/spec/models/jobs/fetch_profile_photo_spec.rb index eee17ee6c..3a2ac98a6 100644 --- a/spec/models/jobs/fetch_profile_photo_spec.rb +++ b/spec/models/jobs/fetch_profile_photo_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Jobs::FetchProfilePhoto do before do @user = alice - @service = Factory(:service, :user => alice) + @service = FactoryGirl.create(:service, :user => alice) @url = "https://service.com/user/profile_image" diff --git a/spec/models/jobs/gather_o_embed_data_spec.rb b/spec/models/jobs/gather_o_embed_data_spec.rb index a253bac84..406cc31f6 100644 --- a/spec/models/jobs/gather_o_embed_data_spec.rb +++ b/spec/models/jobs/gather_o_embed_data_spec.rb @@ -22,7 +22,7 @@ describe Jobs::GatherOEmbedData do @no_oembed_url = 'http://www.we-do-not-support-oembed.com/index.html' - @status_message = Factory(:status_message) + @status_message = FactoryGirl.create(:status_message) stub_request(:get, @flickr_oembed_get_request).to_return(:status => 200, :body => @flickr_oembed_data.to_json) stub_request(:get, @no_oembed_url).to_return(:status => 200, :body => '
hello there') diff --git a/spec/models/jobs/http_multi_spec.rb b/spec/models/jobs/http_multi_spec.rb index cf0061c00..063e5a587 100644 --- a/spec/models/jobs/http_multi_spec.rb +++ b/spec/models/jobs/http_multi_spec.rb @@ -9,7 +9,7 @@ describe Jobs::HttpMulti do end before do - @people = [Factory(:person), Factory(:person)] + @people = [FactoryGirl.create(:person), FactoryGirl.create(:person)] @post_xml = Base64.encode64("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH") diff --git a/spec/models/jobs/mail/mentioned_spec.rb b/spec/models/jobs/mail/mentioned_spec.rb index e380dba33..a645bcbd0 100644 --- a/spec/models/jobs/mail/mentioned_spec.rb +++ b/spec/models/jobs/mail/mentioned_spec.rb @@ -8,7 +8,7 @@ describe Jobs::Mail::Mentioned do describe '#perfom' do it 'should call .deliver on the notifier object' do user = alice - sm = Factory(:status_message) + sm = FactoryGirl.create(:status_message) m = Mention.new(:person => user.person, :post=> sm) mail_mock = mock() diff --git a/spec/models/jobs/mail/reshared_spec.rb b/spec/models/jobs/mail/reshared_spec.rb index e5d746076..766786322 100644 --- a/spec/models/jobs/mail/reshared_spec.rb +++ b/spec/models/jobs/mail/reshared_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' describe Jobs::Mail::Reshared do describe '#perfom' do it 'should call .deliver on the notifier object' do - sm = Factory(:status_message, :author => bob.person, :public => true) - reshare = Factory(:reshare, :author => alice.person, :root=> sm) + sm = FactoryGirl.create(:status_message, :author => bob.person, :public => true) + reshare = FactoryGirl.create(:reshare, :author => alice.person, :root=> sm) mail_mock = mock() mail_mock.should_receive(:deliver) diff --git a/spec/models/jobs/notify_local_users_spec.rb b/spec/models/jobs/notify_local_users_spec.rb index 30cec5047..0246473a7 100644 --- a/spec/models/jobs/notify_local_users_spec.rb +++ b/spec/models/jobs/notify_local_users_spec.rb @@ -7,8 +7,8 @@ require 'spec_helper' describe Jobs::NotifyLocalUsers do describe '#perfom' do it 'should call Notification.notify for each participant user' do - person = Factory :person - post = Factory :status_message + person = FactoryGirl.create:person + post = FactoryGirl.create:status_message StatusMessage.should_receive(:find_by_id).with(post.id).and_return(post) #User.should_receive(:where).and_return([alice, eve]) diff --git a/spec/models/jobs/process_photo_spec.rb b/spec/models/jobs/process_photo_spec.rb index 3f1039745..1e1622343 100644 --- a/spec/models/jobs/process_photo_spec.rb +++ b/spec/models/jobs/process_photo_spec.rb @@ -56,7 +56,7 @@ describe Jobs::ProcessPhoto do end it 'does not throw an error if it is called on a remote photo' do - p = Factory(:remote_photo) + p = FactoryGirl.create(:remote_photo) p.unprocessed_image = nil expect{ result = Jobs::ProcessPhoto.perform(p.id) diff --git a/spec/models/jobs/receive_spec.rb b/spec/models/jobs/receive_spec.rb index f97439c44..800287d9d 100644 --- a/spec/models/jobs/receive_spec.rb +++ b/spec/models/jobs/receive_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Jobs::Receive do before do @user = alice - @person = Factory(:person) + @person = FactoryGirl.create(:person) @xml = '