From b124d3e5a1bbd7fd7b6bf078157a19b63ff8a18d Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg <maxwell@joindiaspora.com> Date: Wed, 16 May 2012 17:43:56 -0700 Subject: [PATCH] Revert "update factory girl" new version does not support 1.8.7 :( This reverts commit c52342b7cb38d25a0f4cb42b5b947d98569eaa37. --- Gemfile | 2 +- Gemfile.lock | 10 ++-- features/step_definitions/message_steps.rb | 2 +- features/step_definitions/session_steps.rb | 2 +- features/step_definitions/user_steps.rb | 16 +++--- features/support/post_generation_helpers.rb | 2 +- features/support/user_cuke_helpers.rb | 2 +- spec/controllers/admins_controller_spec.rb | 2 +- spec/controllers/apps_controller_spec.rb | 2 +- spec/controllers/aspects_controller_spec.rb | 6 +-- .../authorizations_controller_spec.rb | 10 ++-- spec/controllers/comments_controller_spec.rb | 2 +- .../conversations_controller_spec.rb | 2 +- .../jasmine_fixtures/streams_spec.rb | 2 +- spec/controllers/messages_controller_spec.rb | 2 +- .../notifications_controller_spec.rb | 26 +++++----- spec/controllers/people_controller_spec.rb | 42 +++++++-------- spec/controllers/photos_controller_spec.rb | 4 +- spec/controllers/posts_controller_spec.rb | 4 +- spec/controllers/profiles_controller_spec.rb | 2 +- spec/controllers/publics_controller_spec.rb | 4 +- .../registrations_controller_spec.rb | 4 +- spec/controllers/reshares_controller_spec.rb | 2 +- spec/controllers/services_controller_spec.rb | 4 +- spec/controllers/users_controller_spec.rb | 4 +- spec/factories.rb | 38 +++++++------- spec/helpers/application_helper_spec.rb | 6 +-- spec/helpers/getting_started_helper_spec.rb | 2 +- spec/helpers/markdownify_helper_spec.rb | 14 ++--- spec/helpers/mobile_helper_spec.rb | 2 +- spec/helpers/notifications_helper_spec.rb | 20 +++---- spec/helpers/notifier_helper_spec.rb | 2 +- spec/helpers/people_helper_spec.rb | 6 +-- spec/integration/account_deletion_spec.rb | 14 ++--- .../photos_controller_spec.rb | 2 +- spec/integration/attack_vectors_spec.rb | 6 +-- spec/integration/dispatching_spec.rb | 2 +- spec/integration/receiving_spec.rb | 18 +++---- spec/lib/diaspora/encryptable_spec.rb | 2 +- spec/lib/diaspora/exporter_spec.rb | 2 +- spec/lib/diaspora/parser_spec.rb | 4 +- spec/lib/evil_query_spec.rb | 12 ++--- spec/lib/postzord/dispatcher_spec.rb | 30 +++++------ .../lib/postzord/receiver/local_batch_spec.rb | 12 ++--- spec/lib/postzord/receiver/private_spec.rb | 2 +- spec/lib/postzord/receiver/public_spec.rb | 6 +-- spec/lib/rake_helper_spec.rb | 2 +- spec/lib/salmon/slap_spec.rb | 2 +- spec/lib/statistics_spec.rb | 10 ++-- spec/lib/stream/base_spec.rb | 14 ++--- spec/lib/stream/multi_spec.rb | 2 +- spec/lib/stream/tag_spec.rb | 6 +-- spec/lib/template_picker_spec.rb | 2 +- spec/lib/webfinger_spec.rb | 4 +- spec/mailers/notifier_spec.rb | 20 +++---- spec/misc_spec.rb | 2 +- spec/models/account_deletion_spec.rb | 6 +-- spec/models/activity_streams/photo_spec.rb | 2 +- spec/models/comment_spec.rb | 6 +-- spec/models/contact_spec.rb | 34 ++++++------ spec/models/invitation_code_spec.rb | 8 +-- spec/models/invitation_spec.rb | 12 ++--- spec/models/jobs/fetch_profile_photo_spec.rb | 2 +- spec/models/jobs/gather_o_embed_data_spec.rb | 2 +- spec/models/jobs/http_multi_spec.rb | 2 +- spec/models/jobs/mail/mentioned_spec.rb | 2 +- spec/models/jobs/mail/reshared_spec.rb | 4 +- spec/models/jobs/notify_local_users_spec.rb | 4 +- spec/models/jobs/process_photo_spec.rb | 2 +- spec/models/jobs/receive_spec.rb | 2 +- spec/models/jobs/resend_invitation_spec.rb | 2 +- spec/models/jobs/reset_password_spec.rb | 2 +- spec/models/like_spec.rb | 8 +-- spec/models/notification_spec.rb | 22 ++++---- spec/models/notifications/reshared_spec.rb | 6 +-- ..._models_activerecord_authorization_spec.rb | 2 +- spec/models/participation_spec.rb | 2 +- spec/models/person_spec.rb | 52 +++++++++---------- spec/models/photo_spec.rb | 6 +-- spec/models/post_spec.rb | 42 +++++++-------- spec/models/profile_spec.rb | 42 +++++++-------- spec/models/relayable_retraction_spec.rb | 2 +- spec/models/request_spec.rb | 4 +- spec/models/reshare_spec.rb | 28 +++++----- spec/models/retraction_spec.rb | 2 +- spec/models/share_visibility_spec.rb | 2 +- spec/models/signed_retraction_spec.rb | 8 +-- spec/models/status_message_spec.rb | 48 ++++++++--------- spec/models/tag_following_spec.rb | 2 +- spec/models/user/connecting_spec.rb | 12 ++--- spec/models/user/querying_spec.rb | 18 +++---- spec/models/user_spec.rb | 38 +++++++------- spec/presenters/o_embed_presenter_spec.rb | 4 +- spec/presenters/person_presenter_spec.rb | 4 +- spec/presenters/post_presenter_spec.rb | 4 +- spec/support/fixture_builder.rb | 14 ++--- 96 files changed, 445 insertions(+), 445 deletions(-) diff --git a/Gemfile b/Gemfile index 70956313af..eb0e94300a 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' + gem 'factory_girl_rails', '1.7.0' 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 b59e90cf5b..75174e8538 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 (3.3.0) - activesupport (>= 3.0.0) - factory_girl_rails (3.3.0) - factory_girl (~> 3.3.0) + factory_girl (2.6.4) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.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 + factory_girl_rails (= 1.7.0) faraday faraday_middleware fastercsv (= 1.5.4) diff --git a/features/step_definitions/message_steps.rb b/features/step_definitions/message_steps.rb index a4e93a3058..004acffca7 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 ||= FactoryGirl.create(:user, :username => "Alice") + @alice ||= Factory(: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 d9eefb4d4e..5d5e16ac49 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 ||= FactoryGirl.create(:user_with_aspect, :getting_started => false) + @me ||= Factory(: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 cb56312b53..c2a7897a0d 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 ||= FactoryGirl.create(:user, :username => username, :password => password, + @me ||= Factory(: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 = FactoryGirl.create(:user) + admin = Factory(:user) admin.invitation_code i = EmailInviter.new("new_invitee@example.com", admin) i.send! end Given /^I have been invited by bob$/ do - @inviter = FactoryGirl.create(:user, :email => 'bob@bob.bob') + @inviter = Factory(: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 = 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) + 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) 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 = FactoryGirl.create(:status_message_with_photo, :text => "Look at this dog", :author => user.person) + post = Factory(: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 = FactoryGirl.create(:person) + person = Factory(: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 ||= FactoryGirl.create(:user, :username => 'alice', :getting_started => false) + @alice ||= Factory(: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 50bdab55e7..4b42db79ee 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 - FactoryGirl.create(template, :author => user.person) + Factory(template, :author => user.person) end Timecop.return diff --git a/features/support/user_cuke_helpers.rb b/features/support/user_cuke_helpers.rb index ec5da99203..0a71edbb5a 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 = FactoryGirl.create(:user, default_attrs.merge(overrides)) + user = Factory(: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 eb0d4b2c26..c1fd961231 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 = FactoryGirl.create:user + @user = Factory :user sign_in :user, @user end diff --git a/spec/controllers/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb index 37ed98ef1e..ae066c5203 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 - FactoryGirl.create(:activity_streams_photo) + Factory(: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 5bb46ab723..71725617b3 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 = FactoryGirl.create:user + new_user = Factory :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 = FactoryGirl.create(:user_with_aspect, :username => "zed") + @zed = Factory(:user_with_aspect, :username => "zed") @zed.profile.first_name = "zed" @zed.profile.save @zed.save - @katz = FactoryGirl.create(:user_with_aspect, :username => "katz") + @katz = Factory(: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 4c6a018e5d..65d56b930b 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 = FactoryGirl.create(:app, :name => "Authorized App") + @app = Factory(: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 = FactoryGirl.create(:app, :name => "Authorized App") - app2 = FactoryGirl.create(:app, :name => "Unauthorized App") + app1 = Factory(:app, :name => "Authorized App") + app2 = Factory(: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 = FactoryGirl.create(:app) + @app1 = Factory(: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" - FactoryGirl.create(:app, :nonce => @nonce) + Factory(: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 d4286de90a..6a9ce24062 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 = FactoryGirl.create(:user) + new_user = Factory(: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 ef4cdd86ab..ae3468786e 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] = FactoryGirl.create(:user) + @hash[:author] = Factory(: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 df5280d2da..e1feb34990 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 => FactoryGirl.create(:status_message, :public => true).guid, :to => 'all') + posts << alice.post(:reshare, :root_guid => Factory(: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 b57c631d20..573898c660 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 = FactoryGirl.create(:user) + new_user = Factory(: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 34659b84bb..f5e5c1c3ee 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 - FactoryGirl.create(:notification, :recipient => alice) - note = FactoryGirl.create(:notification, :recipient => user2) + Factory(:notification, :recipient => alice) + note = Factory(: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" - FactoryGirl.create(:notification, :recipient => alice) - FactoryGirl.create(:notification, :recipient => alice) + Factory(:notification, :recipient => alice) + Factory(: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 - FactoryGirl.create(:notification, :recipient => alice) + Factory(: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 - FactoryGirl.create(:notification, :recipient => alice) + Factory(: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 - FactoryGirl.create(:notification, :recipient => alice) + Factory(: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 = FactoryGirl.create(:status_message) - FactoryGirl.create(:notification, :recipient => alice, :target => @post) + @post = Factory(:status_message) + Factory(: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 { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } + 25.times { Factory(: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 { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } + 5.times { Factory(: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 { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } + 2.times { Factory(: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 { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } + 2.times { Factory(: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 ecbe70e4fa..73ae0a5542 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 = 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")) + @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")) 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 = FactoryGirl.create(:person, :diaspora_handle => "eugene@example.org", - :profile => FactoryGirl.build(:profile, :first_name => "Eugene", + @unsearchable_eugene = Factory(:person, :diaspora_handle => "eugene@example.org", + :profile => Factory.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 = FactoryGirl.create(:person, - :profile => FactoryGirl.build(:profile, :first_name => "Eugene", + eugene2 = Factory(:person, + :profile => Factory.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 = FactoryGirl.create(:person, - :profile => FactoryGirl.build(:profile, :first_name => "Eugene", + eugene2 = Factory(:person, + :profile => Factory.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 = FactoryGirl.create(:person) + f = Factory(: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 = FactoryGirl.create(:user) + user = Factory(: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 = FactoryGirl.create(:person, :closed_account => true) + @person = Factory(: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 => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects) + reshare = @user.post(:reshare, :public => true, :root_guid => Factory(: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 = FactoryGirl.create(:person) + p = Factory(: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 => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects) + reshare = @user.post(:reshare, :public => true, :root_guid => Factory(: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 => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects) + reshare = @user.post(:reshare, :public => true, :root_guid => Factory(: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 = 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")) + @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")) end describe 'via json' do diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 198b66c531..dfeb6a18af 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 => FactoryGirl.create(:person).guid.to_s + get :index, :person_id => Factory(: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 = FactoryGirl.create(:user) + new_user = Factory(: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 9d07853ff9..ad74d2d9a6 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" => FactoryGirl.create(:reshare, :author => alice.person).id, :format => :mobile + get :show, "id" => Factory(: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 = FactoryGirl.create(:activity_streams_photo, :author => bob.person) + photo = Factory(: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 3cf86e3cd5..94cc429faa 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 = FactoryGirl.create(:person) + new_person = Factory(: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 e425616b59..0f2689c55a 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 = FactoryGirl.create(:person) + @person = Factory(: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 = FactoryGirl.create(:user) + user2 = Factory(: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 7cb972bee8..4b02cd0f94 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(FactoryGirl.create(:person)) + Webfinger.stub_chain(:new, :fetch).and_return(Factory(:person)) end describe '#check_registrations_open!' do @@ -61,7 +61,7 @@ describe RegistrationsController do end before do - user = FactoryGirl.build(:user) + user = Factory.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 5766c49e09..9b400fa822 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 = FactoryGirl.create(:status_message, :public => true).guid + @post_guid = Factory(: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 9e39a470bb..7d250251b1 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 - FactoryGirl.create(:service, :user => @user) + Factory(:service, :user => @user) end get :index @@ -97,7 +97,7 @@ describe ServicesController do describe '#destroy' do before do - @service1 = FactoryGirl.create(:service, :user => @user) + @service1 = Factory(: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 5d74aebacf..9a2d272555 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 = FactoryGirl.create(:status_message, :public => true, :author => @user.person) + sm = Factory(: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 = FactoryGirl.create(:status_message, :public => true, :author => @user.person) + sm = Factory(: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 0c765446f5..dcb35458d7 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 = FactoryGirl.build(:profile, :person => person) unless person.profile.first_name.present? + after_build do |person| + person.profile = Factory.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 = FactoryGirl.build(:profile, :person => person, :searchable => true) + after_build do |person| + person.profile = Factory.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 = FactoryGirl.build(:person, :profile => FactoryGirl.build(:profile), + after_build do |u| + u.person = Factory.build(:person, :profile => Factory.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| FactoryGirl.create(:aspect, :user => u) } + after_create { |u| Factory(: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| - FactoryGirl.create(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => sm.public) + after_build do |sm| + Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => 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 << FactoryGirl.build(:person) + after_build do |note| + note.actors << Factory.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{ FactoryGirl.create(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => sm.public)} + after_build do |sm| + 2.times{ Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => public)} end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 7a439a9ca2..19079a2736 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 = FactoryGirl.create(:person) + @person = Factory(:person) end describe "#contacts_link" do @@ -18,7 +18,7 @@ describe ApplicationHelper do end it 'links to community spotlight' do - @current_user = FactoryGirl.create(:user) + @current_user = Factory(: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 << FactoryGirl.build(:service) } + 3.times { |t| @current_user.services << Factory.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 d65a27e279..c6d7ac49a5 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 << FactoryGirl.create(:oauth_authorization) + @current_user.authorizations << Factory(: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 dce5d70c5f..84124544a3 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 = FactoryGirl.create(:status_message, + message = Factory(: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 = FactoryGirl.create( + message = Factory( :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 <a href="/tags/multi_word" class="tag">#multi_word</a> tag} - message = FactoryGirl.create( + message = Factory( :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 = FactoryGirl.create(:status_message, + message = Factory(: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 = FactoryGirl.create(:person, :diaspora_handle => 'maxwell@joindiaspora.com') - message = FactoryGirl.create(:status_message, + new_person = Factory(:person, :diaspora_handle => 'maxwell@joindiaspora.com') + message = Factory(: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 = FactoryGirl.create(:status_message, + message = Factory(: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 18a870bdf2..b53630cc91 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 = FactoryGirl.create(:aspect) + n = Factory(: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 267b3fbad7..7ce660bc1f 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 = 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) + @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) end describe '#notification_people_link' do @@ -19,19 +19,19 @@ describe NotificationsHelper do let(:output){ strip_tags(notification_people_link(@note)) } before do - @max = FactoryGirl.create(:person) + @max = Factory(:person) @max.profile.first_name = 'max' @max.profile.last_name = 'salzberg' - @sarah = FactoryGirl.create(:person) + @sarah = Factory(:person) @sarah.profile.first_name = 'sarah' @sarah.profile.last_name = 'mei' - @daniel = FactoryGirl.create(:person) + @daniel = Factory(:person) @daniel.profile.first_name = 'daniel' @daniel.profile.last_name = 'grippi' - @ilya = FactoryGirl.create(:person) + @ilya = Factory(: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 4216795854..0f99f0c6ce 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 = FactoryGirl.create(:comment) + @comment = Factory(:comment) end it 'truncates the comment' do diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index 78de68723c..e6dc2838bd 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 = FactoryGirl.create(:person) + @person = Factory(:person) end describe "#person_image_link" do @@ -32,7 +32,7 @@ describe PeopleHelper do describe '#person_link' do before do - @person = FactoryGirl.create(:person) + @person = Factory(: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 = FactoryGirl.create(:user) + @user = Factory(: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 3b7d041fe9..26bb0f5b4c 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 = FactoryGirl.create(:photo, :author => @bob2.person) + f = Factory(: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 << FactoryGirl.create(:notification, :recipient => @bob2) + @notifications << Factory(:notification, :recipient => @bob2) end # services @services = [] 3.times do |n| - @services << FactoryGirl.create(:service, :user => @bob2) + @services << Factory(:service, :user => @bob2) end # block @block = @bob2.blocks.create!(:person => eve.person) #authorization - @authorization = FactoryGirl.create(:oauth_authorization, :resource_owner => @bob2) + @authorization = Factory(: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 - FactoryGirl.create(:status_message, :author => @person) + Factory(:status_message, :author => @person) end @persons_sv = @posts.each do |post| @@ -119,11 +119,11 @@ describe 'deleteing your account' do end #photos - @photo = FactoryGirl.create(:photo, :author => @person) + @photo = Factory(:photo, :author => @person) #mentions @mentions = 3.times do - FactoryGirl.create(:mention, :person => @person) + Factory(: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 6af9aaa72a..e95a3ae4eb 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 = FactoryGirl.create(:oauth_access_token) + token = Factory(: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 e10d5fd4be..c75129abc2 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 = FactoryGirl.create(:user) + user = Factory(: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 = FactoryGirl.build(:status_message, :id => original_message.id, :guid => original_message.guid, :author => alice.person) + malicious_message = Factory.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 = FactoryGirl.build( :status_message, :id => original_message.id, :text => 'BAD!!!', :author => eve.person) + malicious_message = Factory.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 07422338bf..fb7168363a 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 = FactoryGirl.create(:status_message, :public => true, :author => luke.person) + post = Factory(: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 93a0878632..3a3ac786cc 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 = FactoryGirl.create(:person, :diaspora_handle => "foobar@foobar.com") + @remote_person = Factory(: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 = FactoryGirl.build(:status_message, :text => "hello @{#{alice.name}; #{alice.diaspora_handle}}", :diaspora_handle => @remote_person.diaspora_handle, :author => @remote_person) + @sm = Factory.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 = FactoryGirl.create(:person) + @person = Factory(:person) alice.contacts.create(:person => @person, :aspects => [@alices_aspect]) - @post = FactoryGirl.create(:status_message, :author => @person) + @post = Factory(: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 = FactoryGirl.create(:profile, :person => remote_person) + remote_person.profile = Factory(: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 = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago) + @post = Factory.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 = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago) + @post = Factory.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 = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 5.days.ago) + @post = Factory.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 = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 2.days.ago) + @post = Factory.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 7d0e13252e..eb62e5e900 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 = FactoryGirl.create(:comment, :author => bob.person) + @comment = Factory(: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 a3b015bfbe..23f1320800 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 = FactoryGirl.create(:user) + @user2 = Factory(:user) @user3 = bob @aspect = @user1.aspects.first diff --git a/spec/lib/diaspora/parser_spec.rb b/spec/lib/diaspora/parser_spec.rb index 4a7e6cf381..08eb14601a 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 = FactoryGirl.create(:person) + @person = Factory(: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 = FactoryGirl.create(:comment, :post => post, :author => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!") + comment = Factory(: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 4b08377f41..05446e7300 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 = FactoryGirl.create(:status_message, :author => bob.person) + @status_message = Factory(: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 = 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) + @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) time = Time.now diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index 862d97b204..c7f5f915fc 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 = FactoryGirl.create(:status_message, :public => true, :author => alice.person) + @sm = Factory(:status_message, :public => true, :author => alice.person) @subscribers = [] - 5.times{@subscribers << FactoryGirl.create(:person)} + 5.times{@subscribers << Factory(: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 = FactoryGirl.create(:person) + new_person = Factory(: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 = FactoryGirl.build(:comment, :author => @remote_raphael, :post => @post) + @comment = Factory.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 = FactoryGirl.create(:status_message, :author => @remote_raphael) + @post = Factory(: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 = FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => true)) + f = Factory(:comment, :post => Factory(: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 = FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => false)) + f = Factory(:comment, :post => Factory(: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 = FactoryGirl.create(:like, :target => FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => true))) + f = Factory(:like, :target => Factory(:comment, :post => Factory(: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 = FactoryGirl.create(:like, :target => FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => false))) + f = Factory(:like, :target => Factory(:comment, :post => Factory(: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 = FactoryGirl.create(:status_message, :public => true) + f.target = Factory(: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 = FactoryGirl.create(:status_message) + @sm = Factory(: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 = FactoryGirl.create(:service, :user_id => alice.id) + @s1 = Factory(:service, :user_id => alice.id) alice.services << @s1 - @s2 = FactoryGirl.create(:service, :user_id => alice.id) + @s2 = Factory(:service, :user_id => alice.id) alice.services << @s2 - mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1]) + mailman = Postzord::Dispatcher.build(alice, Factory(: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, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123") + mailman = Postzord::Dispatcher.build(alice, Factory(: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 383b4a4c5c..fdfc40c52c 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 = FactoryGirl.create(:status_message, :author => alice.person) + @object = Factory(: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 = FactoryGirl.create(:status_message, + sm = Factory(: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 = FactoryGirl.create(:reshare) + reshare = Factory(: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 = FactoryGirl.create(:status_message, :author => alice.person) + sm = Factory(: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 = FactoryGirl.create(:status_message, :author => alice.person) - @object = FactoryGirl.create(:comment, :author => bob.person, :post => sm) + sm = Factory(:status_message, :author => alice.person) + @object = Factory(: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 19067431fa..d76dfc0122 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, FactoryGirl.create(:person)) + @zord.instance_variable_set(:@sender, Factory(: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 f4e004536e..5d3ee3fff0 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 = FactoryGirl.build(:status_message, :author => alice.person, :public => true) + @post = Factory.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 => FactoryGirl.create(:status_message)) + comment = bob.build_comment(:text => 'yo', :post => Factory(: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 => FactoryGirl.create(:status_message)) + @comment = bob.build_comment(:text => 'yo', :post => Factory(: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 5a345bac97..48b617fc72 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] = FactoryGirl.create(:user).username + AppConfig[:admin_account] = Factory(:user).username end after do diff --git a/spec/lib/salmon/slap_spec.rb b/spec/lib/salmon/slap_spec.rb index 880b8b3227..91d854bda2 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?(FactoryGirl.create(:person).public_key).should be_false + parsed_salmon.verified_for_key?(Factory(: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 d7aa47d1d2..a2ea2fb165 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 - FactoryGirl.create(:status_message, :author => bob.person) + Factory(: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 = FactoryGirl.create(:status_message, :author => alice.person) + status_message = Factory(: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 = FactoryGirl.create(:status_message, :author => bob.person) + post = Factory(: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 << FactoryGirl.create(:service, :type => "Services::Facebook", :user => bob) + bob.services << Factory(:service, :type => "Services::Facebook", :user => bob) bob.save! - eve.services << FactoryGirl.create(:service, :type => "Services::Facebook", :user => eve) + eve.services << Factory(: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 4eb136aa8e..29c8e7b127 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 = FactoryGirl.create(:like, :target => @liked_status, :author => alice.person) + @like = Factory(: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 = FactoryGirl.create(:person) + @person = Factory(:person) @stream.stub(:people).and_return([bob.person, eve.person, @person]) end it 'allows me to comment on my local contacts post' do - post = FactoryGirl.create(:status_message, :author => bob.person) + post = Factory(:status_message, :author => bob.person) @stream.can_comment?(post).should be_true end it 'allows me to comment on my own post' do - post = FactoryGirl.create(:status_message, :author => alice.person) + post = Factory(: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 = FactoryGirl.create(:status_message, :author => eve.person) + post = Factory(: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 = FactoryGirl.create(:status_message, :author => @person) + post = Factory(: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 = FactoryGirl.create(:status_message, :author => @person) + post = Factory(: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 9649d34f2d..60dba1b175 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 = FactoryGirl.create(:user, :invited_by => alice) + @user = Factory(: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 faebcf15a7..e7f71001a7 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 = FactoryGirl.create(:user_with_aspect) + stranger = Factory(: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') - FactoryGirl.create(:comment, :text => "#what", :post => other_post) + Factory(: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(FactoryGirl.create(:user), "test") + @stream = Stream::Tag.new(Factory(: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 21f5e05509..be75fb4555 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 = FactoryGirl.build(template.to_sym, :author => alice.person) + post = Factory.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 ab44027984..89a6948deb 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(FactoryGirl.create(:person)) + finger.should_receive(:cached_person).twice.and_return(Factory(: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 = FactoryGirl.create(:person) + p = Factory(: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 e310031a10..b0ca06b9e1 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) { FactoryGirl.create(:person) } + let(:person) { Factory(:person) } before do Notifier.deliveries = [] @@ -23,7 +23,7 @@ describe Notifier do before do @users = [] 5.times do - @users << FactoryGirl.create(:user) + @users << Factory(:user) end end it 'has a body' do @@ -84,7 +84,7 @@ describe Notifier do describe ".mentioned" do before do @user = alice - @sm = FactoryGirl.create(:status_message) + @sm = Factory(: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 = FactoryGirl.create(:status_message, :author => alice.person) + @sm = Factory(: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 = FactoryGirl.create(:reshare) + reshare = Factory(: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 = FactoryGirl.create(:activity_streams_photo) + as_photo = Factory(: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 = FactoryGirl.create(:status_message, :author => alice.person, :public => true) - @reshare = FactoryGirl.create(:reshare, :root => @sm, :author => bob.person) + @sm = Factory(:status_message, :author => alice.person, :public => true) + @reshare = Factory(: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) { FactoryGirl.create(post_type, :author => bob.person) } + let(:commented_post) { Factory(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) { FactoryGirl.create(post_type, :author => bob.person) } + let(:commented_post) { Factory(post_type, :author => bob.person) } it 'succeeds' do proc { comment_mail diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index a7a0d6c3b0..f5b1598157 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 = FactoryGirl.create(:user) + user = Factory(: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 793a33b98c..5bd96f79f0 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 = 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) + 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) @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 0db0d03fca..c5d2ab20ad 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 = FactoryGirl.create(:activity_streams_photo) + @photo = Factory(: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 8c343696ff..b2d79b5f01 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 = FactoryGirl.create(:user) + @commenter = Factory(: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 = FactoryGirl.create(:status_message, :author => @remote_raphael) + @remote_parent = Factory(: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 = FactoryGirl.build(:comment) + @object = Factory.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 7f4881cef5..0fc6f2d7e4 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 = FactoryGirl.create(:person) + person = Factory(: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 = FactoryGirl.create(:person, :closed_account => true) + person = Factory(: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 => FactoryGirl.create(:person)) - alice.contacts.create!(:sharing => false, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:sharing => true, :person => Factory(:person)) + alice.contacts.create!(:sharing => false, :person => Factory(: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 => FactoryGirl.create(:person)) - alice.contacts.create!(:receiving => false, :person => FactoryGirl.create(:person)) + alice.contacts.create!(:receiving => true, :person => Factory(:person)) + alice.contacts.create!(:receiving => false, :person => Factory(: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 => 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)) + 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)) }.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 = FactoryGirl.create(:person) - contact1 = FactoryGirl.create(:contact, :person => person) - contact2 = FactoryGirl.create(:contact) + person = Factory(:person) + contact1 = Factory(:contact, :person => person) + contact2 = Factory(: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 = FactoryGirl.create(:person) + person = Factory(:person) @bob.contacts.create(:person => person, :aspects => [@original_aspect]) @people1 << person end 1.upto(5) do - person = FactoryGirl.create(:person) + person = Factory(: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 = FactoryGirl.create(:user) - @person = FactoryGirl.create(:person) + @user = Factory(:user) + @person = Factory(:person) @contact.user = @user @contact.person = @person diff --git a/spec/models/invitation_code_spec.rb b/spec/models/invitation_code_spec.rb index 5ac687ac2c..c902c6c363 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 - FactoryGirl.create(:invitation_code).should be_valid + Factory(:invitation_code).should be_valid end it 'sets the count to a default value' do - code = FactoryGirl.create(:invitation_code) + code = Factory(:invitation_code) code.count.should > 0 end describe '#use!' do it 'decrements the count of the code' do - code = FactoryGirl.create(:invitation_code) + code = Factory(: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 = FactoryGirl.create(:invitation_code) + code = Factory(: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 00a111bd6a..c379ee8193 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 = FactoryGirl.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de") + @invitation = Factory.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 = FactoryGirl.create(:aspect) + @invitation.aspect = Factory(:aspect) @invitation.should_not be_valid end end describe '#language' do it 'returns the correct language if the language is set' do - @invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de") + @invitation = Factory.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 = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first) + @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first) @invitation.language.should == "en" end end it 'has a message' do - @invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language) + @invitation = Factory.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 - FactoryGirl.create(:user, :email => @emails.first) + Factory(: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 3a2ac98a61..eee17ee6c6 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 = FactoryGirl.create(:service, :user => alice) + @service = Factory(: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 406cc31f65..a253bac847 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 = FactoryGirl.create(:status_message) + @status_message = Factory(: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 => '<html><body>hello there</body></html>') diff --git a/spec/models/jobs/http_multi_spec.rb b/spec/models/jobs/http_multi_spec.rb index 063e5a587e..cf0061c009 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 = [FactoryGirl.create(:person), FactoryGirl.create(:person)] + @people = [Factory(:person), Factory(: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 a645bcbd06..e380dba338 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 = FactoryGirl.create(:status_message) + sm = Factory(: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 7667863223..e5d746076a 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 = FactoryGirl.create(:status_message, :author => bob.person, :public => true) - reshare = FactoryGirl.create(:reshare, :author => alice.person, :root=> sm) + sm = Factory(:status_message, :author => bob.person, :public => true) + reshare = Factory(: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 0246473a78..30cec50479 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 = FactoryGirl.create:person - post = FactoryGirl.create:status_message + person = Factory :person + post = Factory :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 1e1622343d..3f10397451 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 = FactoryGirl.create(:remote_photo) + p = Factory(: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 800287d9df..f97439c44d 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 = FactoryGirl.create(:person) + @person = Factory(:person) @xml = '<xml></xml>' User.stub(:find){ |id| if id == @user.id diff --git a/spec/models/jobs/resend_invitation_spec.rb b/spec/models/jobs/resend_invitation_spec.rb index 690566589d..6810c2b1d7 100644 --- a/spec/models/jobs/resend_invitation_spec.rb +++ b/spec/models/jobs/resend_invitation_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe Jobs::ResendInvitation do describe '#perfom' do it 'should call .resend on the object' do - invite = FactoryGirl.create(:invitation, :service => 'email', :identifier => 'foo@bar.com') + invite = Factory(:invitation, :service => 'email', :identifier => 'foo@bar.com') Invitation.stub(:find).and_return(invite) invite.should_receive(:resend) diff --git a/spec/models/jobs/reset_password_spec.rb b/spec/models/jobs/reset_password_spec.rb index 65da81c024..8abfc04193 100644 --- a/spec/models/jobs/reset_password_spec.rb +++ b/spec/models/jobs/reset_password_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Jobs::ResetPassword do describe "#perform" do it "given a user id it sends the reset password instructions for that user" do - user = FactoryGirl.create:user + user = Factory :user expect { mail = Jobs::ResetPassword.perform(user.id) mail.to.should == [user.email] diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index dea7dc0237..46d676b76a 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -11,7 +11,7 @@ describe Like do end it 'has a valid factory' do - FactoryGirl.create(:like).should be_valid + Factory(:like).should be_valid end describe '#notification_type' do @@ -40,7 +40,7 @@ describe Like do end it 'increments the counter cache on its comment' do - comment = FactoryGirl.create(:comment, :post => @status) + comment = Factory(:comment, :post => @status) lambda { alice.like!(comment) }.should change{ comment.reload.likes_count }.by(1) @@ -51,7 +51,7 @@ describe Like do before do alices_aspect = alice.aspects.first - @liker = FactoryGirl.create(:user) + @liker = Factory(:user) @liker_aspect = @liker.aspects.create(:name => "dummies") connect_users(alice, alices_aspect, @liker, @liker_aspect) @post = alice.post(:status_message, :text => "huhu", :to => alices_aspect.id) @@ -80,7 +80,7 @@ describe Like do describe 'it is relayable' do before do @local_luke, @local_leia, @remote_raphael = set_up_friends - @remote_parent = FactoryGirl.create(:status_message, :author => @remote_raphael) + @remote_parent = Factory(:status_message, :author => @remote_raphael) @local_parent = @local_luke.post :status_message, :text => "foobar", :to => @local_luke.aspects.first @object_by_parent_author = @local_luke.like!(@local_parent) diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 63303cf1ec..facd6ce2d9 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' describe Notification do before do - @sm = FactoryGirl.create(:status_message) - @person = FactoryGirl.create(:person) + @sm = Factory(:status_message) + @person = Factory(:person) @user = alice @user2 = eve @aspect = @user.aspects.create(:name => "dudes") @@ -26,7 +26,7 @@ describe Notification do describe '.for' do it 'returns all of a users notifications' do - user2 = FactoryGirl.create(:user) + user2 = Factory(:user) 4.times do Notification.create(@opts) end @@ -89,20 +89,20 @@ describe Notification do context 'multiple likes' do it 'concatinates the like notifications' do - p = FactoryGirl.create(:status_message, :author => @user.person) - person2 = FactoryGirl.create(:person) - notification = Notification.notify(@user, FactoryGirl.create(:like, :author => @person, :target => p), @person) - notification2 = Notification.notify(@user, FactoryGirl.create(:like, :author => person2, :target => p), person2) + p = Factory(:status_message, :author => @user.person) + person2 = Factory(:person) + notification = Notification.notify(@user, Factory(:like, :author => @person, :target => p), @person) + notification2 = Notification.notify(@user, Factory(:like, :author => person2, :target => p), person2) notification.id.should == notification2.id end end context 'multiple comments' do it 'concatinates the comment notifications' do - p = FactoryGirl.create(:status_message, :author => @user.person) - person2 = FactoryGirl.create(:person) - notification = Notification.notify(@user, FactoryGirl.create(:comment, :author => @person, :post => p), @person) - notification2 = Notification.notify(@user, FactoryGirl.create(:comment, :author => person2, :post => p), person2) + p = Factory(:status_message, :author => @user.person) + person2 = Factory(:person) + notification = Notification.notify(@user, Factory(:comment, :author => @person, :post => p), @person) + notification2 = Notification.notify(@user, Factory(:comment, :author => person2, :post => p), person2) notification.id.should == notification2.id end end diff --git a/spec/models/notifications/reshared_spec.rb b/spec/models/notifications/reshared_spec.rb index 6c526667eb..6ef319f151 100644 --- a/spec/models/notifications/reshared_spec.rb +++ b/spec/models/notifications/reshared_spec.rb @@ -6,9 +6,9 @@ require 'spec_helper' describe Notifications::Reshared do before do - @sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true) - @reshare1 = FactoryGirl.create(:reshare, :root => @sm) - @reshare2 = FactoryGirl.create(:reshare, :root => @sm) + @sm = Factory(:status_message, :author => alice.person, :public => true) + @reshare1 = Factory(:reshare, :root => @sm) + @reshare2 = Factory(:reshare, :root => @sm) end describe 'Notification.notify' do diff --git a/spec/models/oauth2_provider_models_activerecord_authorization_spec.rb b/spec/models/oauth2_provider_models_activerecord_authorization_spec.rb index 90161b5d04..1f82ed1ab8 100644 --- a/spec/models/oauth2_provider_models_activerecord_authorization_spec.rb +++ b/spec/models/oauth2_provider_models_activerecord_authorization_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe OAuth2::Provider::Models::ActiveRecord::Authorization do describe 'validations'do before do - @client = FactoryGirl.create(:app) + @client = Factory(:app) end it 'validates uniqueness on resource owner and client' do diff --git a/spec/models/participation_spec.rb b/spec/models/participation_spec.rb index 5164fb0c89..61a8fdac8d 100644 --- a/spec/models/participation_spec.rb +++ b/spec/models/participation_spec.rb @@ -6,7 +6,7 @@ describe Participation do @status = bob.post(:status_message, :text => "hello", :to => bob.aspects.first.id) @local_luke, @local_leia, @remote_raphael = set_up_friends - @remote_parent = FactoryGirl.create(:status_message, :author => @remote_raphael) + @remote_parent = Factory(:status_message, :author => @remote_raphael) @local_parent = @local_luke.post :status_message, :text => "foobar", :to => @local_luke.aspects.first @object_by_parent_author = @local_luke.participate!(@local_parent) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index ab5ee6387f..7eec550511 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -8,7 +8,7 @@ describe Person do before do @user = bob - @person = FactoryGirl.create(:person) + @person = Factory(:person) end it 'always has a profile' do @@ -92,8 +92,8 @@ describe Person do describe ".who_have_reshared a user's posts" do it 'pulls back users who reshared the status message of a user' do - sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true) - reshare = FactoryGirl.create(:reshare, :root => sm) + sm = Factory(:status_message, :author => alice.person, :public => true) + reshare = Factory(:reshare, :root => sm) Person.who_have_reshared_a_users_posts(alice).should == [reshare.author] end end @@ -109,17 +109,17 @@ describe Person do describe "vaild url" do it 'should allow for https urls' do - person = FactoryGirl.create(:person, :url => "https://example.com") + person = Factory(:person, :url => "https://example.com") person.should be_valid end it 'should always return the correct receive url' do - person = FactoryGirl.create(:person, :url => "https://example.com/a/bit/messed/up") + person = Factory(:person, :url => "https://example.com/a/bit/messed/up") person.receive_url.should == "https://example.com/receive/users/#{person.guid}/" end it 'should allow ports in the url' do - person = FactoryGirl.create(:person, :url => "https://example.com:3000/") + person = Factory(:person, :url => "https://example.com:3000/") person.url.should == "https://example.com:3000/" end end @@ -148,12 +148,12 @@ describe Person do describe 'validation' do it 'is unique' do - person_two = FactoryGirl.build(:person, :diaspora_handle => @person.diaspora_handle) + person_two = Factory.build(:person, :diaspora_handle => @person.diaspora_handle) person_two.should_not be_valid end it 'is case insensitive' do - person_two = FactoryGirl.build(:person, :diaspora_handle => @person.diaspora_handle.upcase) + person_two = Factory.build(:person, :diaspora_handle => @person.diaspora_handle.upcase) person_two.should_not be_valid end end @@ -221,8 +221,8 @@ describe Person do end it '#owns? posts' do - person_message = FactoryGirl.create(:status_message, :author => @person) - person_two = FactoryGirl.create(:person) + person_message = Factory(:status_message, :author => @person) + person_two = Factory(:person) @person.owns?(person_message).should be true person_two.owns?(person_message).should be false @@ -230,7 +230,7 @@ describe Person do describe "disconnecting" do before do - @user2 = FactoryGirl.create(:user) + @user2 = Factory(:user) @aspect = @user.aspects.create(:name => "Dudes") @aspect2 = @user2.aspects.create(:name => "Abscence of Babes") end @@ -268,16 +268,16 @@ describe Person do describe '.search' do before do Person.delete_all - @user = FactoryGirl.create(:user_with_aspect) + @user = Factory(:user_with_aspect) user_profile = @user.person.profile user_profile.first_name = "aiofj" user_profile.last_name = "asdji" user_profile.save - @robert_grimm = FactoryGirl.create(:searchable_person) - @eugene_weinstein = FactoryGirl.create(:searchable_person) - @yevgeniy_dodis = FactoryGirl.create(:searchable_person) - @casey_grippi = FactoryGirl.create(:searchable_person) + @robert_grimm = Factory(:searchable_person) + @eugene_weinstein = Factory(:searchable_person) + @yevgeniy_dodis = Factory(:searchable_person) + @casey_grippi = Factory(:searchable_person) @robert_grimm.profile.first_name = "Robert" @robert_grimm.profile.last_name = "Grimm" @@ -348,7 +348,7 @@ describe Person do end it 'only displays searchable people' do - invisible_person = FactoryGirl.create(:person, :profile => FactoryGirl.build(:profile, :searchable => false, :first_name => "johnson")) + invisible_person = Factory(:person, :profile => Factory.build(:profile, :searchable => false, :first_name => "johnson")) Person.search("johnson", @user).should_not include invisible_person Person.search("", @user).should_not include invisible_person end @@ -379,8 +379,8 @@ describe Person do end context 'people finders for webfinger' do - let(:user) { FactoryGirl.create(:user) } - let(:person) { FactoryGirl.create(:person) } + let(:user) { Factory(:user) } + let(:person) { Factory(:person) } describe '.by_account_identifier' do it 'should find a local users person' do @@ -399,28 +399,28 @@ describe Person do end it "finds a local person with a mixed-case username" do - user = FactoryGirl.create(:user, :username => "SaMaNtHa") + user = Factory(:user, :username => "SaMaNtHa") person = Person.by_account_identifier(user.person.diaspora_handle) person.should == user.person end it "is case insensitive" do - user1 = FactoryGirl.create(:user, :username => "SaMaNtHa") + user1 = Factory(:user, :username => "SaMaNtHa") person = Person.by_account_identifier(user1.person.diaspora_handle.upcase) person.should == user1.person end it 'should only find people who are exact matches (1/2)' do - user = FactoryGirl.create(:user, :username => "SaMaNtHa") - person = FactoryGirl.create(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com") + user = Factory(:user, :username => "SaMaNtHa") + person = Factory(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com") user.person.diaspora_handle = "tom@tom.joindiaspora.com" user.person.save Person.by_account_identifier("tom@tom.joindiaspora.com").diaspora_handle.should == "tom@tom.joindiaspora.com" end it 'should only find people who are exact matches (2/2)' do - person = FactoryGirl.create(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com") - person1 = FactoryGirl.create(:person, :diaspora_handle => "tom@tom.joindiaspora.comm") + person = Factory(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com") + person1 = Factory(:person, :diaspora_handle => "tom@tom.joindiaspora.comm") f = Person.by_account_identifier("tom@tom.joindiaspora.com") f.should be nil end @@ -522,7 +522,7 @@ describe Person do describe "#clear_profile!!" do before do - @person = FactoryGirl.create(:person) + @person = Factory(:person) end it 'calls Profile#tombstone!' do diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index f236e14e9e..57605223a4 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -29,12 +29,12 @@ describe Photo do describe "protected attributes" do it "doesn't allow mass assignment of person" do @photo.save! - @photo.update_attributes(:author => FactoryGirl.create(:person)) + @photo.update_attributes(:author => Factory(:person)) @photo.reload.author.should == @user.person end it "doesn't allow mass assignment of person_id" do @photo.save! - @photo.update_attributes(:author_id => FactoryGirl.create(:person).id) + @photo.update_attributes(:author_id => Factory(:person).id) @photo.reload.author.should == @user.person end it 'allows assignment of text' do @@ -202,7 +202,7 @@ describe Photo do it 'should set the remote_photo on marshalling' do #security hax - user2 = FactoryGirl.create(:user) + user2 = Factory(:user) aspect2 = user2.aspects.create(:name => "foobars") connect_users(@user, @aspect, user2, aspect2) diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 72b6aebe08..a86b613c48 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -14,10 +14,10 @@ describe Post do describe '.owned_or_visible_by_user' do before do @you = bob - @public_post = FactoryGirl.create(:status_message, :public => true) - @your_post = FactoryGirl.create(:status_message, :author => @you.person) + @public_post = Factory(:status_message, :public => true) + @your_post = Factory(:status_message, :author => @you.person) @post_from_contact = eve.post(:status_message, :text => 'wooo', :to => eve.aspects.where(:name => 'generic').first) - @post_from_stranger = FactoryGirl.create(:status_message, :public => false) + @post_from_stranger = Factory(:status_message, :public => false) end it 'returns post from your contacts' do @@ -33,7 +33,7 @@ describe Post do end it 'returns public post from your contact' do - sm = FactoryGirl.create(:status_message, :author => eve.person, :public => true) + sm = Factory(:status_message, :author => eve.person, :public => true) StatusMessage.owned_or_visible_by_user(@you).should include(sm) end @@ -68,8 +68,8 @@ describe Post do describe '.excluding_blocks' do before do - @post = FactoryGirl.create(:status_message, :author => alice.person) - @other_post = FactoryGirl.create(:status_message, :author => eve.person) + @post = Factory(:status_message, :author => alice.person) + @other_post = Factory(:status_message, :author => eve.person) bob.blocks.create(:person => alice.person) end @@ -89,8 +89,8 @@ describe Post do describe '.excluding_hidden_shareables' do before do - @post = FactoryGirl.create(:status_message, :author => alice.person) - @other_post = FactoryGirl.create(:status_message, :author => eve.person) + @post = Factory(:status_message, :author => alice.person) + @other_post = Factory(:status_message, :author => eve.person) bob.toggle_hidden_shareable(@post) end it 'excludes posts the user has hidden' do @@ -169,21 +169,21 @@ describe Post do describe 'validations' do it 'validates uniqueness of guid and does not throw a db error' do - message = FactoryGirl.create(:status_message) - FactoryGirl.build(:status_message, :guid => message.guid).should_not be_valid + message = Factory(:status_message) + Factory.build(:status_message, :guid => message.guid).should_not be_valid end end describe 'post_type' do it 'returns the class constant' do - status_message = FactoryGirl.create(:status_message) + status_message = Factory(:status_message) status_message.post_type.should == "StatusMessage" end end describe 'deletion' do it 'should delete a posts comments on delete' do - post = FactoryGirl.create(:status_message, :author => @user.person) + post = Factory(:status_message, :author => @user.person) @user.comment!(post, "hey") post.destroy Post.where(:id => post.id).empty?.should == true @@ -203,7 +203,7 @@ describe Post do describe '.diaspora_initialize' do it 'takes provider_display_name' do - sm = FactoryGirl.build(:status_message, :provider_display_name => 'mobile') + sm = Factory.build(:status_message, :provider_display_name => 'mobile') StatusMessage.diaspora_initialize(sm.attributes.merge(:author => bob.person)).provider_display_name.should == 'mobile' end end @@ -245,7 +245,7 @@ describe Post do describe "#receive" do it 'returns false if the post does not verify' do - @post = FactoryGirl.create(:status_message, :author => bob.person) + @post = Factory(:status_message, :author => bob.person) @post.should_receive(:verify_persisted_shareable).and_return(false) @post.receive(bob, eve.person).should == false end @@ -253,7 +253,7 @@ describe Post do describe "#receive_persisted" do before do - @post = FactoryGirl.build(:status_message, :author => bob.person) + @post = Factory.build(:status_message, :author => bob.person) @known_post = Post.new bob.stub(:contact_for).with(eve.person).and_return(stub(:receive_shareable => true)) end @@ -298,7 +298,7 @@ describe Post do describe '#receive_non_persisted' do context "the user does not know about the post" do before do - @post = FactoryGirl.build(:status_message, :author => bob.person) + @post = Factory.build(:status_message, :author => bob.person) bob.stub(:find_visible_shareable_by_id).and_return(nil) bob.stub(:notify_if_mentioned).and_return(true) end @@ -337,7 +337,7 @@ describe Post do describe 'when post has been reshared exactly 1 time' do before :each do @post.reshares.size.should == 0 - @reshare = FactoryGirl.create(:reshare, :root => @post) + @reshare = Factory(:reshare, :root => @post) @post.reload @post.reshares.size.should == 1 end @@ -350,9 +350,9 @@ describe Post do describe 'when post has been reshared more than once' do before :each do @post.reshares.size.should == 0 - FactoryGirl.create(:reshare, :root => @post) - FactoryGirl.create(:reshare, :root => @post) - FactoryGirl.create(:reshare, :root => @post) + Factory(:reshare, :root => @post) + Factory(:reshare, :root => @post) + Factory(:reshare, :root => @post) @post.reload @post.reshares.size.should == 3 end @@ -365,7 +365,7 @@ describe Post do describe "#after_create" do it "sets #interacted_at" do - post = FactoryGirl.create(:status_message) + post = Factory(:status_message) post.interacted_at.should_not be_blank end end diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index acafb33a6f..be2b311f19 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -8,23 +8,23 @@ describe Profile do describe 'validation' do describe "of first_name" do it "strips leading and trailing whitespace" do - profile = FactoryGirl.build(:profile, :first_name => " Shelly ") + profile = Factory.build(:profile, :first_name => " Shelly ") profile.should be_valid profile.first_name.should == "Shelly" end it "can be 32 characters long" do - profile = FactoryGirl.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon") + profile = Factory.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon") profile.should be_valid end it "cannot be 33 characters" do - profile = FactoryGirl.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon") + profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon") profile.should_not be_valid end it 'cannot have ;' do - profile = FactoryGirl.build(:profile, :first_name => "Hex;agon") + profile = Factory.build(:profile, :first_name => "Hex;agon") profile.should_not be_valid end end @@ -54,7 +54,7 @@ describe Profile do describe '#contruct_full_name' do it 'generates a full name given only first name' do - profile = FactoryGirl.create(:person).profile + profile = Factory(:person).profile profile.first_name = "casimiro" profile.last_name = nil @@ -64,7 +64,7 @@ describe Profile do end it 'generates a full name given only last name' do - profile = FactoryGirl.create(:person).profile + profile = Factory(:person).profile profile.first_name = nil profile.last_name = "grippi" @@ -74,7 +74,7 @@ describe Profile do end it 'generates a full name given first and last names' do - profile = FactoryGirl.create(:person).profile + profile = Factory(:person).profile profile.first_name = "casimiro" profile.last_name = "grippi" @@ -86,27 +86,27 @@ describe Profile do describe "of last_name" do it "strips leading and trailing whitespace" do - profile = FactoryGirl.build(:profile, :last_name => " Ohba ") + profile = Factory.build(:profile, :last_name => " Ohba ") profile.should be_valid profile.last_name.should == "Ohba" end it "can be 32 characters long" do - profile = FactoryGirl.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon") + profile = Factory.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon") profile.should be_valid end it "cannot be 33 characters" do - profile = FactoryGirl.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon") + profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon") profile.should_not be_valid end it 'cannot have ;' do - profile = FactoryGirl.build(:profile, :last_name => "Hex;agon") + profile = Factory.build(:profile, :last_name => "Hex;agon") profile.should_not be_valid end it 'disallows ; with a newline in the string' do - profile = FactoryGirl.build(:profile, :last_name => "H\nex;agon") + profile = Factory.build(:profile, :last_name => "H\nex;agon") profile.should_not be_valid end end @@ -114,7 +114,7 @@ describe Profile do describe '#image_url=' do before do - @profile = FactoryGirl.build(:profile) + @profile = Factory.build(:profile) @profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" @pod_url = (AppConfig[:pod_url][-1,1] == '/' ? AppConfig[:pod_url].chop : AppConfig[:pod_url]) end @@ -136,7 +136,7 @@ describe Profile do describe '#from_xml' do it 'should make a valid profile object' do - @profile = FactoryGirl.build(:profile) + @profile = Factory.build(:profile) @profile.tag_string = '#big #rafi #style' xml = @profile.to_xml @@ -147,7 +147,7 @@ describe Profile do end describe 'serialization' do - let(:person) {FactoryGirl.create(:person,:diaspora_handle => "foobar" )} + let(:person) {Factory(:person,:diaspora_handle => "foobar" )} it 'should include persons diaspora handle' do xml = person.profile.to_diaspora_xml @@ -172,7 +172,7 @@ describe Profile do describe '#image_url' do before do - @profile = FactoryGirl.build(:profile) + @profile = Factory.build(:profile) end it 'returns a default rather than nil' do @@ -197,7 +197,7 @@ describe Profile do end describe 'date=' do - let(:profile) { FactoryGirl.build(:profile) } + let(:profile) { Factory.build(:profile) } it 'accepts form data' do profile.birthday = nil @@ -244,7 +244,7 @@ describe Profile do describe 'tags' do before do - person = FactoryGirl.create(:person) + person = Factory(:person) @object = person.profile end it 'allows 5 tags' do @@ -265,7 +265,7 @@ describe Profile do describe '#formatted_birthday' do before do - @profile = FactoryGirl.build(:profile) + @profile = Factory.build(:profile) @profile_hash = { 'year' => '2000', 'month' => '01', 'day' => '01' } @profile.date = @profile_hash end @@ -290,7 +290,7 @@ describe Profile do describe '#receive' do it 'updates the profile in place' do local_luke, local_leia, remote_raphael = set_up_friends - new_profile = FactoryGirl.build :profile + new_profile = Factory.build :profile lambda{ new_profile.receive(local_leia, remote_raphael) }.should_not change(Profile, :count) @@ -321,7 +321,7 @@ describe Profile do describe "#clearable_fields" do it 'returns the current profile fields' do - profile = FactoryGirl.build :profile + profile = Factory.build :profile profile.send(:clearable_fields).sort.should == ["diaspora_handle", "first_name", diff --git a/spec/models/relayable_retraction_spec.rb b/spec/models/relayable_retraction_spec.rb index d0ffb1b7dd..0b54ae1fa6 100644 --- a/spec/models/relayable_retraction_spec.rb +++ b/spec/models/relayable_retraction_spec.rb @@ -8,7 +8,7 @@ require File.join(Rails.root, "spec", "shared_behaviors", "relayable") describe RelayableRetraction do before do @local_luke, @local_leia, @remote_raphael = set_up_friends - @remote_parent = FactoryGirl.create(:status_message, :author => @remote_raphael) + @remote_parent = Factory(:status_message, :author => @remote_raphael) @local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 431cece62d..280c31ed80 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -49,7 +49,7 @@ describe Request do describe '#notification_type' do it 'returns request_accepted' do - person = FactoryGirl.create:person + person = Factory :person request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect) alice.contacts.create(:person_id => person.id) @@ -120,7 +120,7 @@ describe Request do alice.auto_follow_back_aspect = alice.aspects.first alice.save - contact = FactoryGirl.create:contact, :user => alice, :person => eve.person, + contact = Factory :contact, :user => alice, :person => eve.person, :receiving => true, :sharing => false contact.save diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 13e42d047a..b8311a3ca0 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -9,28 +9,28 @@ describe Reshare do it 'has a valid Factory' do - FactoryGirl.create(:reshare).should be_valid + Factory(:reshare).should be_valid end it 'requires root' do - reshare = FactoryGirl.build(:reshare, :root => nil) + reshare = Factory.build(:reshare, :root => nil) reshare.should_not be_valid end it 'require public root' do - reshare = FactoryGirl.build(:reshare, :root => FactoryGirl.build(:status_message, :public => false)) + reshare = Factory.build(:reshare, :root => Factory.build(:status_message, :public => false)) reshare.should_not be_valid reshare.errors[:base].should include('Only posts which are public may be reshared.') end it 'forces public' do - FactoryGirl.create(:reshare, :public => false).public.should be_true + Factory(:reshare, :public => false).public.should be_true end describe "#receive" do let(:receive) {@reshare.receive(@root.author.owner, @reshare.author)} before do - @reshare = FactoryGirl.create(:reshare, :root => FactoryGirl.create(:status_message, :author => bob.person, :public => true)) + @reshare = Factory(:reshare, :root => Factory(:status_message, :author => bob.person, :public => true)) @root = @reshare.root end @@ -55,10 +55,10 @@ describe Reshare do describe '#nsfw' do before do - sfw = FactoryGirl.create(:status_message, :author => alice.person, :public => true) - nsfw = FactoryGirl.create(:status_message, :author => alice.person, :public => true, :text => "This is #nsfw") - @sfw_reshare = FactoryGirl.create(:reshare, :root => sfw) - @nsfw_reshare = FactoryGirl.create(:reshare, :root => nsfw) + sfw = Factory(:status_message, :author => alice.person, :public => true) + nsfw = Factory(:status_message, :author => alice.person, :public => true, :text => "This is #nsfw") + @sfw_reshare = Factory(:reshare, :root => sfw) + @nsfw_reshare = Factory(:reshare, :root => nsfw) end it 'deletates #nsfw to the root post' do @@ -69,8 +69,8 @@ describe Reshare do describe '#notification_type' do before do - sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true) - @reshare = FactoryGirl.create(:reshare, :root => sm) + sm = Factory(:status_message, :author => alice.person, :public => true) + @reshare = Factory(:reshare, :root => sm) end it 'does not return anything for non-author of the original post' do @reshare.notification_type(bob, @reshare.author).should be_nil @@ -83,7 +83,7 @@ describe Reshare do describe "XML" do before do - @reshare = FactoryGirl.create(:reshare) + @reshare = Factory(:reshare) @xml = @reshare.to_xml.to_s end @@ -121,7 +121,7 @@ describe Reshare do describe 'destroy' do it 'allows you to destroy the reshare if the root post is missing' do - reshare = FactoryGirl.create(:reshare) + reshare = Factory(:reshare) reshare.root = nil expect{ @@ -205,7 +205,7 @@ describe Reshare do @original_author = @reshare.root.author.dup @xml = @reshare.to_xml.to_s - different_person = FactoryGirl.create(:person) + different_person = Factory(:person) wf_prof_mock = mock wf_prof_mock.should_receive(:fetch).and_return(different_person) diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb index cc8a1f4b54..67af027941 100644 --- a/spec/models/retraction_spec.rb +++ b/spec/models/retraction_spec.rb @@ -32,7 +32,7 @@ describe Retraction do end it 'does not return the authors of reshares' do - @post.reshares << FactoryGirl.create(:reshare, :root => @post, :author => bob.person) + @post.reshares << Factory(:reshare, :root => @post, :author => bob.person) @post.save! @wanted_subscribers -= [bob.person] diff --git a/spec/models/share_visibility_spec.rb b/spec/models/share_visibility_spec.rb index 94aa0f832c..5c7c9c56f0 100644 --- a/spec/models/share_visibility_spec.rb +++ b/spec/models/share_visibility_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe ShareVisibility do describe '.batch_import' do before do - @post = FactoryGirl.create(:status_message, :author => alice.person) + @post = Factory(:status_message, :author => alice.person) @contact = bob.contact_for(alice.person) end diff --git a/spec/models/signed_retraction_spec.rb b/spec/models/signed_retraction_spec.rb index d76eb5be3b..46c4f41fa0 100644 --- a/spec/models/signed_retraction_spec.rb +++ b/spec/models/signed_retraction_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe SignedRetraction do before do - @post = FactoryGirl.create(:status_message, :author => bob.person, :public => true) - @resharer = FactoryGirl.create(:user) - @post.reshares << FactoryGirl.create(:reshare, :root => @post, :author => @resharer.person) + @post = Factory(:status_message, :author => bob.person, :public => true) + @resharer = Factory(:user) + @post.reshares << Factory(:reshare, :root => @post, :author => @resharer.person) @post.save! end describe '#perform' do @@ -20,7 +20,7 @@ describe SignedRetraction do retraction.perform(@resharer) end it 'relays the retraction onward even if the post does not exist' do - remote_post = FactoryGirl.create(:status_message, :public => true) + remote_post = Factory(:status_message, :public => true) bob.post(:reshare, :root_guid => remote_post.guid) alice.post(:reshare, :root_guid => remote_post.guid) diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index bfd0225a5f..02370e3d75 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -23,9 +23,9 @@ describe StatusMessage do @bo = bob.person @test_string = "@{Daniel; #{@bo.diaspora_handle}} can mention people like Raph" - FactoryGirl.create(:status_message, :text => @test_string ) - FactoryGirl.create(:status_message, :text => @test_string ) - FactoryGirl.create(:status_message) + Factory(:status_message, :text => @test_string ) + Factory(:status_message, :text => @test_string ) + Factory(:status_message) StatusMessage.where_person_is_mentioned(@bo).count.should == 2 end @@ -33,10 +33,10 @@ describe StatusMessage do context "tag_streams" do before do - @sm1 = FactoryGirl.create(:status_message, :text => "#hashtag" , :public => true) - @sm2 = FactoryGirl.create(:status_message, :text => "#hashtag" ) - @sm3 = FactoryGirl.create(:status_message, :text => "hashtags are #awesome", :public => true ) - @sm4 = FactoryGirl.create(:status_message, :text => "hashtags are #awesome" ) + @sm1 = Factory(:status_message, :text => "#hashtag" , :public => true) + @sm2 = Factory(:status_message, :text => "#hashtag" ) + @sm3 = Factory(:status_message, :text => "hashtags are #awesome", :public => true ) + @sm4 = Factory(:status_message, :text => "hashtags are #awesome" ) @tag_id = ActsAsTaggableOn::Tag.where(:name => "hashtag").first.id end @@ -68,8 +68,8 @@ describe StatusMessage do describe ".guids_for_author" do it 'returns an array of the status_message guids' do - sm1 = FactoryGirl.create(:status_message, :author => alice.person) - sm2 = FactoryGirl.create(:status_message, :author => bob.person) + sm1 = Factory(:status_message, :author => alice.person) + sm2 = Factory(:status_message, :author => bob.person) guids = StatusMessage.guids_for_author(alice.person) guids.should == [sm1.guid] end @@ -77,7 +77,7 @@ describe StatusMessage do describe '.before_create' do it 'calls build_tags' do - status = FactoryGirl.build(:status_message) + status = Factory.build(:status_message) status.should_receive(:build_tags) status.save end @@ -85,7 +85,7 @@ describe StatusMessage do describe '.after_create' do it 'calls create_mentions' do - status = FactoryGirl.build(:status_message) + status = Factory.build(:status_message) status.should_receive(:create_mentions) status.save end @@ -93,14 +93,14 @@ describe StatusMessage do describe '#diaspora_handle=' do it 'sets #author' do - person = FactoryGirl.create(:person) - post = FactoryGirl.create(:status_message, :author => @user.person) + person = Factory(:person) + post = Factory(:status_message, :author => @user.person) post.diaspora_handle = person.diaspora_handle post.author.should == person end end it "should have either a message or at least one photo" do - n = FactoryGirl.build(:status_message, :text => nil) + n = Factory.build(:status_message, :text => nil) # n.valid?.should be_false # n.text = "" @@ -127,7 +127,7 @@ describe StatusMessage do it 'should require status messages not be more than 65535 characters long' do message = 'a' * (65535+1) - status_message = FactoryGirl.build(:status_message, :text => message) + status_message = Factory.build(:status_message, :text => message) status_message.should_not be_valid end @@ -138,7 +138,7 @@ describe StatusMessage do @{Raphael; #{@people[0].diaspora_handle}} can mention people like Raphael @{Ilya; #{@people[1].diaspora_handle}} can mention people like Raphaellike Raphael @{Daniel; #{@people[2].diaspora_handle}} can mention people like Raph STR - @sm = FactoryGirl.create(:status_message, :text => @test_string ) + @sm = Factory(:status_message, :text => @test_string ) end describe '#format_mentions' do @@ -151,7 +151,7 @@ STR context 'with :plain_text option' do it 'removes the mention syntax and displays the unformatted name' do - status = FactoryGirl.create(:status_message, :text => "@{Barack Obama; barak@joindiaspora.com } is so cool @{Barack Obama; barak@joindiaspora.com } ") + status = Factory(:status_message, :text => "@{Barack Obama; barak@joindiaspora.com } is so cool @{Barack Obama; barak@joindiaspora.com } ") status.format_mentions(status.raw_message, :plain_text => true).should == 'Barack Obama is so cool Barack Obama ' end end @@ -230,18 +230,18 @@ STR end it 'returns false if the person was not mentioned' do - @sm.mentions?(FactoryGirl.create(:person)).should be_false + @sm.mentions?(Factory(:person)).should be_false end end describe "#nsfw" do it 'returns MatchObject (true) if the post contains #nsfw (however capitalised)' do - status = FactoryGirl.create(:status_message, :text => "This message is #nSFw") + status = Factory(:status_message, :text => "This message is #nSFw") status.nsfw.should be_true end it 'returns nil (false) if the post does not contain #nsfw' do - status = FactoryGirl.create(:status_message, :text => "This message is #sFW") + status = Factory(:status_message, :text => "This message is #sFW") status.nsfw.should be_false end end @@ -256,14 +256,14 @@ STR describe 'tags' do before do - @object = FactoryGirl.build(:status_message) + @object = Factory.build(:status_message) end it_should_behave_like 'it is taggable' end describe "XML" do before do - @message = FactoryGirl.create(:status_message, :text => "I hate WALRUSES!", :author => @user.person) + @message = Factory(:status_message, :text => "I hate WALRUSES!", :author => @user.person) @xml = @message.to_xml.to_s end it 'serializes the unescaped, unprocessed message' do @@ -327,14 +327,14 @@ STR end it 'should queue a GatherOembedData if it includes a link' do - sm = FactoryGirl.build(:status_message, :text => @message_text) + sm = Factory.build(:status_message, :text => @message_text) Resque.should_receive(:enqueue).with(Jobs::GatherOEmbedData, instance_of(Fixnum), instance_of(String)) sm.save end describe '#contains_oembed_url_in_text?' do it 'returns the oembed urls found in the raw message' do - sm = FactoryGirl.create(:status_message, :text => @message_text) + sm = Factory(:status_message, :text => @message_text) sm.contains_oembed_url_in_text?.should_not be_nil sm.oembed_url.should == @youtube_url end diff --git a/spec/models/tag_following_spec.rb b/spec/models/tag_following_spec.rb index 2a81454340..a5dada8ac5 100644 --- a/spec/models/tag_following_spec.rb +++ b/spec/models/tag_following_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe TagFollowing do before do - @tag = FactoryGirl.create(:tag) + @tag = Factory(:tag) TagFollowing.create!(:tag => @tag, :user => alice) end diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index 38283ce1d5..e1114ee12c 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -8,13 +8,13 @@ describe User::Connecting do let(:aspect) { alice.aspects.first } let(:aspect1) { alice.aspects.create(:name => 'other') } - let(:person) { FactoryGirl.create(:person) } + let(:person) { Factory(:person) } let(:aspect2) { eve.aspects.create(:name => "aspect two") } - let(:person_one) { FactoryGirl.create:person } - let(:person_two) { FactoryGirl.create:person } - let(:person_three) { FactoryGirl.create:person } + let(:person_one) { Factory :person } + let(:person_two) { Factory :person } + let(:person_three) { Factory :person } describe 'disconnecting' do describe '#remove_contact' do @@ -78,7 +78,7 @@ describe User::Connecting do describe '#register_share_visibilities' do it 'creates post visibilites for up to 100 posts' do - Post.stub_chain(:where, :limit).and_return([FactoryGirl.create(:status_message)]) + Post.stub_chain(:where, :limit).and_return([Factory(:status_message)]) c = Contact.create!(:user_id => alice.id, :person_id => eve.person.id) expect{ alice.register_share_visibilities(c) @@ -155,7 +155,7 @@ describe User::Connecting do end it "should mark the corresponding notification as 'read'" do - notification = FactoryGirl.create(:notification, :target => eve.person) + notification = Factory(:notification, :target => eve.person) Notification.where(:target_id => eve.person.id).first.unread.should be_true alice.share_with(eve.person, aspect) diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index 7c1a50280f..ffaeeb4a1c 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -110,7 +110,7 @@ describe User::Querying do describe "#visible_shareables" do it 'never contains posts from people not in your aspects' do - FactoryGirl.create(:status_message, :public => true) + Factory(:status_message, :public => true) bob.visible_shareables(Post).count.should == 0 end @@ -203,9 +203,9 @@ describe User::Querying do end it 'returns local/remote people objects for a users contact in each aspect' do - local_user1 = FactoryGirl.create(:user) - local_user2 = FactoryGirl.create(:user) - remote_user = FactoryGirl.create(:user) + local_user1 = Factory(:user) + local_user2 = Factory(:user) + remote_user = Factory(:user) asp1 = local_user1.aspects.create(:name => "lol") asp2 = local_user2.aspects.create(:name => "brb") @@ -226,7 +226,7 @@ describe User::Querying do end it 'does not return people not connected to user on same pod' do - 3.times { FactoryGirl.create(:user) } + 3.times { Factory(:user) } alice.people_in_aspects([@alices_aspect]).count.should == 1 end @@ -241,9 +241,9 @@ describe User::Querying do end context 'contact querying' do - let(:person_one) { FactoryGirl.create:person } - let(:person_two) { FactoryGirl.create:person } - let(:person_three) { FactoryGirl.create:person } + let(:person_one) { Factory :person } + let(:person_two) { Factory :person } + let(:person_three) { Factory :person } let(:aspect) { alice.aspects.create(:name => 'heroes') } describe '#contact_for_person_id' do @@ -309,7 +309,7 @@ describe User::Querying do describe '#posts_from' do before do - @user3 = FactoryGirl.create(:user) + @user3 = Factory(:user) @aspect3 = @user3.aspects.create(:name => "bros") @public_message = @user3.post(:status_message, :text => "hey there", :to => 'all', :public => true) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d582c01865..b68b927c97 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -39,7 +39,7 @@ describe User do describe 'hidden_shareables' do before do - @sm = FactoryGirl.create(:status_message) + @sm = Factory(:status_message) @sm_id = @sm.id.to_s @sm_class = @sm.class.base_class.to_s end @@ -55,7 +55,7 @@ describe User do end it 'handles having multiple posts' do - sm2 = FactoryGirl.create(:status_message) + sm2 = Factory(:status_message) alice.add_hidden_shareable(@sm_class, @sm_id) alice.add_hidden_shareable(sm2.class.base_class.to_s, sm2.id.to_s) @@ -63,7 +63,7 @@ describe User do end it 'handles having multiple shareable types' do - photo = FactoryGirl.create(:photo) + photo = Factory(:photo) alice.add_hidden_shareable(photo.class.base_class.to_s, photo.id.to_s) alice.add_hidden_shareable(@sm_class, @sm_id) @@ -94,13 +94,13 @@ describe User do describe '#is_shareable_hidden?' do it 'returns true if the shareable is hidden' do - post = FactoryGirl.create(:status_message) + post = Factory(:status_message) bob.toggle_hidden_shareable(post) bob.is_shareable_hidden?(post).should be_true end it 'returns false if the shareable is not present' do - post = FactoryGirl.create(:status_message) + post = Factory(:status_message) bob.is_shareable_hidden?(post).should be_false end end @@ -110,7 +110,7 @@ describe User do describe 'overwriting people' do it 'does not overwrite old users with factory' do lambda { - new_user = FactoryGirl.create(:user, :id => alice.id) + new_user = Factory(:user, :id => alice.id) }.should raise_error ActiveRecord::StatementInvalid end @@ -160,14 +160,14 @@ describe User do end it 'requires uniqueness also amount Person objects with diaspora handle' do - p = FactoryGirl.create(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}") + p = Factory(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}") alice.username = 'jimmy' alice.should_not be_valid end it "downcases username" do - user = FactoryGirl.build(:user, :username => "WeIrDcAsE") + user = Factory.build(:user, :username => "WeIrDcAsE") user.should be_valid user.username.should == "weirdcase" end @@ -178,7 +178,7 @@ describe User do end it "strips leading and trailing whitespace" do - user = FactoryGirl.build(:user, :username => " janie ") + user = Factory.build(:user, :username => " janie ") user.should be_valid user.username.should == "janie" end @@ -338,7 +338,7 @@ describe User do end describe "with malicious params" do - let(:person) {FactoryGirl.create:person} + let(:person) {Factory :person} before do @invalid_params = {:username => "ohai", :email => "ohai@example.com", @@ -384,7 +384,7 @@ describe User do describe '#process_invite_acceptence' do it 'sets the inviter on user' do inv = InvitationCode.create(:user => bob) - user = FactoryGirl.create(:user) + user = Factory(:user) user.process_invite_acceptence(inv) user.invited_by_id.should == bob.id end @@ -503,7 +503,7 @@ describe User do describe '#notify_if_mentioned' do before do - @post = FactoryGirl.create(:status_message, :author => bob.person) + @post = Factory(:status_message, :author => bob.person) end it 'notifies the user if the incoming post mentions them' do @@ -521,7 +521,7 @@ describe User do end it 'does not notify the user if the post author is not a contact' do - @post = FactoryGirl.create(:status_message, :author => eve.person) + @post = Factory(:status_message, :author => eve.person) @post.stub(:mentions?).and_return(true) @post.should_not_receive(:notify_person) @@ -532,7 +532,7 @@ describe User do describe 'account deletion' do describe '#destroy' do it 'removes invitations from the user' do - FactoryGirl.create(:invitation, :sender => alice) + Factory(:invitation, :sender => alice) lambda { alice.destroy }.should change {alice.invitations_from_me(true).count }.by(-1) @@ -769,7 +769,7 @@ describe User do describe '#retract' do before do @retraction = mock - @post = FactoryGirl.create(:status_message, :author => bob.person, :public => true) + @post = Factory(:status_message, :author => bob.person, :public => true) end context "posts" do @@ -787,8 +787,8 @@ describe User do end it 'adds resharers of target post as additional subsctibers' do - person = FactoryGirl.create(:person) - reshare = FactoryGirl.create(:reshare, :root => @post, :author => person) + person = Factory(:person) + reshare = Factory(:reshare, :root => @post, :author => person) @post.reshares << reshare dispatcher = mock @@ -816,7 +816,7 @@ describe User do end it "queues up a job to send the reset password instructions" do - user = FactoryGirl.create:user + user = Factory :user Resque.should_receive(:enqueue).with(Jobs::ResetPassword, user.id) user.send_reset_password_instructions end @@ -867,7 +867,7 @@ describe User do describe "#clearable_attributes" do it 'returns the clearable fields' do - user = FactoryGirl.create:user + user = Factory :user user.send(:clearable_fields).sort.should == %w{ language invitation_token diff --git a/spec/presenters/o_embed_presenter_spec.rb b/spec/presenters/o_embed_presenter_spec.rb index d343ba96c4..7182b6a1a4 100644 --- a/spec/presenters/o_embed_presenter_spec.rb +++ b/spec/presenters/o_embed_presenter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe OEmbedPresenter do before do - @oembed = OEmbedPresenter.new(FactoryGirl.create(:status_message)) + @oembed = OEmbedPresenter.new(Factory(:status_message)) end it 'is a hash' do @@ -10,7 +10,7 @@ describe OEmbedPresenter do context 'required options from oembed spec' do it 'supports maxheight + maxwidth(required)' do - oembed = OEmbedPresenter.new(FactoryGirl.create(:status_message), :maxwidth => 200, :maxheight => 300).as_json + oembed = OEmbedPresenter.new(Factory(:status_message), :maxwidth => 200, :maxheight => 300).as_json oembed[:width].should == 200 oembed[:height].should == 300 end diff --git a/spec/presenters/person_presenter_spec.rb b/spec/presenters/person_presenter_spec.rb index 4eb502f0a8..521291520b 100644 --- a/spec/presenters/person_presenter_spec.rb +++ b/spec/presenters/person_presenter_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe PersonPresenter do - let(:profile_user) { FactoryGirl.create(:user_with_aspect) } + let(:profile_user) { Factory(:user_with_aspect) } let(:person) { profile_user.person } describe "#as_json" do @@ -12,7 +12,7 @@ describe PersonPresenter do end context "with a current_user" do - let(:current_user) { FactoryGirl.create(:user)} + let(:current_user) { Factory(:user)} let(:presenter){ PersonPresenter.new(person, current_user) } it "doesn't share private information when the users aren't connected" do diff --git a/spec/presenters/post_presenter_spec.rb b/spec/presenters/post_presenter_spec.rb index 530e694cbb..0d3d205e8a 100644 --- a/spec/presenters/post_presenter_spec.rb +++ b/spec/presenters/post_presenter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe PostPresenter do before do - @sm = FactoryGirl.create(:status_message, :public => true) + @sm = Factory(:status_message, :public => true) @presenter = PostPresenter.new(@sm, bob) @unauthenticated_presenter = PostPresenter.new(@sm) end @@ -45,7 +45,7 @@ describe PostPresenter do describe '#root' do it 'does not raise if the root does not exists' do - reshare = FactoryGirl.create:reshare + reshare = Factory :reshare reshare.root = nil expect { PostPresenter.new(reshare).root diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index b327c26d4e..d2daa6b5eb 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -8,27 +8,27 @@ FixtureBuilder.configure do |fbuilder| # now declare objects fbuilder.factory do # Users - alice = FactoryGirl.create(:user_with_aspect, :username => "alice") + alice = Factory(:user_with_aspect, :username => "alice") alices_aspect = alice.aspects.where(:name => "generic").first - eve = FactoryGirl.create(:user_with_aspect, :username => "eve") + eve = Factory(:user_with_aspect, :username => "eve") eves_aspect = eve.aspects.where(:name => "generic").first - bob = FactoryGirl.create(:user_with_aspect, :username => "bob") + bob = Factory(:user_with_aspect, :username => "bob") bobs_aspect = bob.aspects.where(:name => "generic").first - FactoryGirl.create(:aspect, :name => "empty", :user => bob) + Factory(:aspect, :name => "empty", :user => bob) connect_users(bob, bobs_aspect, alice, alices_aspect) connect_users(bob, bobs_aspect, eve, eves_aspect) # Set up friends - 2 local, 1 remote - local_luke = FactoryGirl.create(:user_with_aspect, :username => "luke") + local_luke = Factory(:user_with_aspect, :username => "luke") lukes_aspect = local_luke.aspects.where(:name => "generic").first - local_leia = FactoryGirl.create(:user_with_aspect, :username => "leia") + local_leia = Factory(:user_with_aspect, :username => "leia") leias_aspect = local_leia.aspects.where(:name => "generic").first - remote_raphael = FactoryGirl.create(:person, :diaspora_handle => "raphael@remote.net") + remote_raphael = Factory(:person, :diaspora_handle => "raphael@remote.net") connect_users_with_aspects(local_luke, local_leia) -- GitLab