diff --git a/Gemfile.lock b/Gemfile.lock index a7c4f983b..cf74a0edf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -148,10 +148,10 @@ GEM abstract (>= 1.0.0) eventmachine (0.12.10) excon (0.9.4) - factory_girl (2.4.2) + factory_girl (2.5.0) activesupport - factory_girl_rails (1.5.0) - factory_girl (~> 2.4.0) + factory_girl_rails (1.6.0) + factory_girl (~> 2.5.0) railties (>= 3.0.0) faraday (0.7.0) addressable (~> 2.2.4) diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index f7bb1e590..421572411 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -23,7 +23,7 @@ end Given /^a user named "([^\"]*)" with email "([^\"]*)"$/ do |name, email| first, last = name.split username = "#{first}_#{last}" if first - user = Factory.create(:user, :email => email, :password => 'password', :username => "#{first}_#{last}", + user = Factory(:user, :email => email, :password => 'password', :username => "#{first}_#{last}", :password_confirmation => 'password', :getting_started => false) user.profile.update_attributes!(:first_name => first, :last_name => last) if first @@ -151,7 +151,7 @@ Given /^I have (\d+) contacts$/ do |n| aspect_memberships = [] count.times do - person = Factory.create(:person) + person = Factory(:person) people << person end diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 697670fc4..bcb07d779 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -98,7 +98,7 @@ describe AspectsController do end it "doesn't overwrite random attributes" do - new_user = Factory.create :user + new_user = Factory :user params = {"name" => "Bruisers"} params[:user_id] = new_user.id put('update', :id => @alices_aspect_1.id, "aspect" => params) diff --git a/spec/controllers/authorizations_controller_spec.rb b/spec/controllers/authorizations_controller_spec.rb index a9f498399..65d56b930 100644 --- a/spec/controllers/authorizations_controller_spec.rb +++ b/spec/controllers/authorizations_controller_spec.rb @@ -33,7 +33,7 @@ describe AuthorizationsController do describe '#new' do before do - @app = Factory.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 = Factory.create(:app, :name => "Authorized App") - app2 = Factory.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 = Factory.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" - Factory.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 e2560fd77..8f060937e 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -45,7 +45,7 @@ describe CommentsController do end it "doesn't overwrite author_id" do - new_user = Factory.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 4057527d4..c3e94af30 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -78,7 +78,7 @@ describe ConversationsController do end it 'sets the author to the current_user' do - @hash[:author] = Factory.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/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb index ddf5f48bf..573898c66 100644 --- a/spec/controllers/messages_controller_spec.rb +++ b/spec/controllers/messages_controller_spec.rb @@ -73,7 +73,7 @@ describe MessagesController do end it "doesn't overwrite author_id" do - new_user = Factory.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/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 332033cd8..9feed1c14 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -13,9 +13,9 @@ describe PeopleController do describe '#index (search)' do before do - @eugene = Factory.create(:person, + @eugene = Factory(:person, :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w")) - @korth = Factory.create(:person, + @korth = Factory(:person, :profile => Factory.build(:profile, :first_name => "Evan", :last_name => "Korth")) end @@ -35,7 +35,7 @@ describe PeopleController do end it "assigns people" do - eugene2 = Factory.create(:person, + eugene2 = Factory(:person, :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w")) get :index, :q => "Eug" @@ -43,7 +43,7 @@ describe PeopleController do end it "excludes people that are not searchable" do - eugene2 = Factory.create(:person, + eugene2 = Factory(:person, :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) get :index, :q => "Eug" @@ -51,7 +51,7 @@ describe PeopleController do end it "allows unsearchable people to be found by handle" do - eugene2 = Factory.create(:person, :diaspora_handle => "eugene@example.org", + eugene2 = Factory(:person, :diaspora_handle => "eugene@example.org", :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) get :index, :q => "eugene@example.org" @@ -65,7 +65,7 @@ describe PeopleController do end it "downcases the handle before trying to find someone by it" do - eugene2 = Factory.create(:person, :diaspora_handle => "eugene@example.org", + eugene2 = Factory(:person, :diaspora_handle => "eugene@example.org", :profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) get :index, :q => "Eugene@Example.ORG" @@ -124,7 +124,7 @@ describe PeopleController do @posts = [] @users = [] 8.times do |n| - user = Factory.create(:user) + user = Factory(:user) @users << user aspect = user.aspects.create(:name => 'people') connect_users(@user, @user.aspects.first, user, aspect) @@ -162,7 +162,7 @@ describe PeopleController do end it 'redirects home for closed account' do - @person = Factory.create(:person, :closed_account => true) + @person = Factory(:person, :closed_account => true) get :show, :id => @person.id response.should be_redirect flash[:notice].should_not be_blank diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index c0a5502b2..a025702cf 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -230,7 +230,7 @@ describe PhotosController do end it "doesn't overwrite random attributes" do - new_user = Factory.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/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index cb0fe3b90..a4c9172d6 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -111,7 +111,7 @@ describe ServicesController do describe '#destroy' do before do - @service1 = Factory.create(:service, :user => @user) + @service1 = Factory(:service, :user => @user) end it 'destroys a service selected by id' do diff --git a/spec/factories.rb b/spec/factories.rb index e2cba1be7..25f8ab5aa 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,5 +1,5 @@ -# Copyright (c) 2010-2011, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See +# Copyright (c) 2010-2011, Diaspora In This file is +# licensed under the Affero General Public License version 3 or late See # the COPYRIGHT file. #For Guidance @@ -10,203 +10,205 @@ def r_str ActiveSupport::SecureRandom.hex(3) end -Factory.define :profile do |p| - p.sequence(:first_name) { |n| "Robert#{n}#{r_str}" } - p.sequence(:last_name) { |n| "Grimm#{n}#{r_str}" } - p.bio "I am a cat lover and I love to run" - p.gender "robot" - p.location "Earth" - p.birthday Date.today -end - -Factory.define :profile_with_image_url, :parent => :profile do |p| - p.image_url "http://example.com/image.jpg" - p.image_url_medium "http://example.com/image_mid.jpg" - p.image_url_small "http://example.com/image_small.jpg" -end - -Factory.define :person do |p| - p.sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@example.net" } - p.sequence(:url) { |n| AppConfig[:pod_url] } - p.serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export - p.after_build do |person| - person.profile = Factory.build(:profile, :person => person) unless person.profile.first_name.present? +FactoryGirl.define do + factory :profile do + sequence(:first_name) { |n| "Robert#{n}#{r_str}" } + sequence(:last_name) { |n| "Grimm#{n}#{r_str}" } + bio "I am a cat lover and I love to run" + gender "robot" + location "Earth" + birthday Date.today end - p.after_create do |person| - person.profile.save + + factory :profile_with_image_url, :parent => :profile do + image_url "http://example.com/image.jpg" + image_url_medium "http://example.com/image_mid.jpg" + image_url_small "http://example.com/image_small.jpg" end -end -Factory.define :account_deletion do |d| - d.association :person - d.after_build do |delete| - delete.diaspora_handle= delete.person.diaspora_handle + factory :person do + sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@example.net" } + sequence(:url) { |n| AppConfig[:pod_url] } + serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export + after_build do |person| + person.profile = Factory.build(:profile, :person => person) unless person.profile.first_name.present? + end + after_create do |person| + person.profile.save + end end -end -Factory.define :searchable_person, :parent => :person do |p| - p.after_build do |person| - person.profile = Factory.build(:profile, :person => person, :searchable => true) + factory :account_deletion do + association :person + after_build do |delete| + delete.diaspora_handle = delete.person.diaspora_handle + end end -end -Factory.define :like do |x| - x.association :author, :factory => :person - x.association :target, :factory => :status_message -end - -Factory.define :user do |u| - u.getting_started false - u.sequence(:username) { |n| "bob#{n}#{r_str}" } - u.sequence(:email) { |n| "bob#{n}#{r_str}@pivotallabs.com" } - u.password "bluepin7" - u.password_confirmation { |u| u.password } - u.serialized_private_key OpenSSL::PKey::RSA.generate(1024).export - u.after_build do |user| - user.person = Factory.build(:person, :profile => Factory.build(:profile), - :owner_id => user.id, - :serialized_public_key => user.encryption_key.public_key.export, - :diaspora_handle => "#{user.username}#{User.diaspora_id_host}") + factory :searchable_person, :parent => :person do + after_build do |person| + person.profile = Factory.build(:profile, :person => person, :searchable => true) + end end - u.after_create do |user| - user.person.save - user.person.profile.save + + factory :like do + association :author, :factory => :person + association :target, :factory => :status_message end -end -Factory.define :user_with_aspect, :parent => :user do |u| - u.after_create { |user| Factory(:aspect, :user => user) } -end - -Factory.define :aspect do |aspect| - aspect.name "generic" - aspect.association :user -end - -Factory.define(:status_message) do |m| - m.sequence(:text) { |n| "jimmy's #{n} whales" } - m.association :author, :factory => :person - m.after_build do|m| - m.diaspora_handle = m.author.diaspora_handle + factory :user do + getting_started false + sequence(:username) { |n| "bob#{n}#{r_str}" } + sequence(:email) { |n| "bob#{n}#{r_str}@pivotallabs.com" } + password "bluepin7" + password_confirmation { |u| u.password } + serialized_private_key OpenSSL::PKey::RSA.generate(1024).export + after_build do |u| + u.person = Factory.build(:person, :profile => Factory.build(:profile), + :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| + u.person.save + u.person.profile.save + end end -end -Factory.define(:status_message_with_photo, :parent => :status_message) do |m| - m.sequence(:text) { |n| "There are #{n} ninjas in this photo." } - m.after_build do |m| - p = Factory(:photo, :author => m.author, :status_message => m, :pending => false, :public => m.public) + factory :user_with_aspect, :parent => :user do + after_create { |u| Factory(:aspect, :user => u) } end -end -Factory.define(:photo) do |p| - p.sequence(:random_string) {|n| ActiveSupport::SecureRandom.hex(10) } - p.association :author, :factory => :person - p.after_build do |p| - p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png')) - p.update_remote_path + factory :aspect do + name "generic" + association :user end -end -Factory.define(:remote_photo, :parent => :photo) do |p| - p.remote_photo_path 'https://photo.com/images/' - p.remote_photo_name 'kittehs.jpg' - p.association :author,:factory => :person - p.processed_image nil - p.unprocessed_image nil -end - -Factory.define :reshare do |r| - r.association(:root, :public => true, :factory => :status_message) - r.association(:author, :factory => :person) -end - -Factory.define :invitation do |i| - i.service "email" - i.identifier "bob.smith@smith.com" - i.association :sender, :factory => :user_with_aspect - i.after_build do |i| - i.aspect = i.sender.aspects.first + factory(:status_message) do + sequence(:text) { |n| "jimmy's #{n} whales" } + association :author, :factory => :person + after_build do |sm| + sm.diaspora_handle = sm.author.diaspora_handle + end end -end -Factory.define :service do |service| - service.nickname "sirrobertking" - service.type "Services::Twitter" - - service.sequence(:uid) { |token| "00000#{token}" } - service.sequence(:access_token) { |token| "12345#{token}" } - service.sequence(:access_secret) { |token| "98765#{token}" } -end - -Factory.define :service_user do |s_user| - s_user.sequence(:uid) { |id| "a#{id}"} - s_user.sequence(:name) { |num| "Rob Fergus the #{num.ordinalize}" } - s_user.association :service - s_user.photo_url "/images/user/adams.jpg" -end - -Factory.define(:comment) do |comment| - comment.sequence(:text) {|n| "#{n} cats"} - comment.association(:author, :factory => :person) - comment.association(:post, :factory => :status_message) -end - -Factory.define(:notification) do |n| - n.association :recipient, :factory => :user - n.association :target, :factory => :comment - n.type 'Notifications::AlsoCommented' - - n.after_build do |note| - note.actors << Factory.build( :person ) + factory(:status_message_with_photo, :parent => :status_message) do + sequence(:text) { |n| "There are #{n} ninjas in this photo." } + after_build do |sm| + Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => public) + end end -end -Factory.define(:activity_streams_photo, :class => ActivityStreams::Photo) do |p| - p.association(:author, :factory => :person) - p.image_url "#{AppConfig[:pod_url]}/images/asterisk.png" - p.image_height 154 - p.image_width 154 - p.object_url "http://example.com/awesome_things.gif" - p.objectId "http://example.com/awesome_things.gif" - p.actor_url "http://notcubbi.es/cubber" - p.provider_display_name "not cubbies" - p.public true -end + factory(:photo) do + sequence(:random_string) {|n| ActiveSupport::SecureRandom.hex(10) } + association :author, :factory => :person + after_build do |p| + p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png')) + p.update_remote_path + end + end -Factory.define(:app, :class => OAuth2::Provider.client_class) do |a| - a.sequence(:name) { |token| "Chubbies#{token}" } - a.sequence(:application_base_url) { |token| "http://chubbi#{token}.es/" } + factory(:remote_photo, :parent => :photo) do + remote_photo_path 'https://photo.com/images/' + remote_photo_name 'kittehs.jpg' + association :author,:factory => :person + processed_image nil + unprocessed_image nil + end - a.description "The best way to chub on the net." - a.icon_url "/images/chubbies48.png" - a.permissions_overview "I will use the permissions this way!" - a.sequence(:public_key) {|n| OpenSSL::PKey::RSA.new(2048) } -end + factory :reshare do + association(:root, :public => true, :factory => :status_message) + association(:author, :factory => :person) + end -Factory.define(:oauth_authorization, :class => OAuth2::Provider.authorization_class) do |a| - a.association(:client, :factory => :app) - a.association(:resource_owner, :factory => :user) -end + factory :invitation do + service "email" + identifier "bob.smith@smith.com" + association :sender, :factory => :user_with_aspect + after_build do |i| + i.aspect = i.sender.aspects.first + end + end -Factory.define(:oauth_access_token, :class => OAuth2::Provider.access_token_class) do |a| - a.association(:authorization, :factory => :oauth_authorization) -end + factory :service do |service| + nickname "sirrobertking" + type "Services::Twitter" -Factory.define(:tag, :class => ActsAsTaggableOn::Tag) do |t| - t.name "partytimeexcellent" -end + sequence(:uid) { |token| "00000#{token}" } + sequence(:access_token) { |token| "12345#{token}" } + sequence(:access_secret) { |token| "98765#{token}" } + end -Factory.define(:tag_following) do |a| - a.association(:tag, :factory => :tag) - a.association(:user, :factory => :user) -end + factory :service_user do + sequence(:uid) { |id| "a#{id}"} + sequence(:name) { |num| "Rob Fergus the #{num.ordinalize}" } + association :service + photo_url "/images/user/adams.jpg" + end -Factory.define(:contact) do |c| - c.association(:person, :factory => :person) - c.association(:user, :factory => :user) -end + factory(:comment) do + sequence(:text) {|n| "#{n} cats"} + association(:author, :factory => :person) + association(:post, :factory => :status_message) + end -Factory.define(:mention) do |c| - c.association(:person, :factory => :person) - c.association(:post, :factory => :status_message) -end + factory(:notification) do + association :recipient, :factory => :user + association :target, :factory => :comment + type 'Notifications::AlsoCommented' + + after_build do |note| + note.actors << Factory.build(:person) + end + end + + factory(:activity_streams_photo, :class => ActivityStreams::Photo) do + association(:author, :factory => :person) + image_url "#{AppConfig[:pod_url]}/images/asterisk.png" + image_height 154 + image_width 154 + object_url "http://example.com/awesome_things.gif" + objectId "http://example.com/awesome_things.gif" + actor_url "http://notcubbes/cubber" + provider_display_name "not cubbies" + public true + end + + factory(:app, :class => OAuth2::Provider.client_class) do + sequence(:name) { |token| "Chubbies#{token}" } + sequence(:application_base_url) { |token| "http://chubbi#{token}.es/" } + + description "The best way to chub on the ne" + icon_url "/images/chubbies48.png" + permissions_overview "I will use the permissions this way!" + sequence(:public_key) {|n| OpenSSL::PKey::RSA.new(2048) } + end + + factory(:oauth_authorization, :class => OAuth2::Provider.authorization_class) do + association(:client, :factory => :app) + association(:resource_owner, :factory => :user) + end + + factory(:oauth_access_token, :class => OAuth2::Provider.access_token_class) do + association(:authorization, :factory => :oauth_authorization) + end + + factory(:tag, :class => ActsAsTaggableOn::Tag) do + name "partytimeexcellent" + end + + factory(:tag_following) do + association(:tag, :factory => :tag) + association(:user, :factory => :user) + end + + factory(:contact) do + association(:person, :factory => :person) + association(:user, :factory => :user) + end + + factory(:mention) do + association(:person, :factory => :person) + association(:post, :factory => :status_message) + end +end \ No newline at end of file diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 0a21ea13d..271fd662b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe ApplicationHelper do before do @user = alice - @person = Factory.create(:person) + @person = Factory(:person) end describe "#contacts_link" do diff --git a/spec/helpers/markdownify_helper_spec.rb b/spec/helpers/markdownify_helper_spec.rb index c4dc4ff20..84124544a 100644 --- a/spec/helpers/markdownify_helper_spec.rb +++ b/spec/helpers/markdownify_helper_spec.rb @@ -35,7 +35,7 @@ describe MarkdownifyHelper do context 'when formatting status messages' do it "should leave tags intact" do - message = Factory.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 = Factory.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 #multi_word tag} - message = Factory.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 = Factory.create(:status_message, + message = Factory(:status_message, :author => alice.person, :text => "Hey @{Bob; #{bob.diaspora_handle}}!") formatted = markdownify(message) @@ -70,7 +70,7 @@ describe MarkdownifyHelper do it "should leave mentions intact for real diaspora handles" do new_person = Factory(:person, :diaspora_handle => 'maxwell@joindiaspora.com') - message = Factory.create(:status_message, + 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 = Factory.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/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index d97038d64..945b330ba 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -7,7 +7,7 @@ require 'spec_helper' describe PeopleHelper do before do @user = alice - @person = Factory.create(:person) + @person = Factory(:person) end describe "#person_image_link" do it "returns an empty string if person is nil" do diff --git a/spec/integration/account_deletion_spec.rb b/spec/integration/account_deletion_spec.rb index ae350f1f5..292d0aebb 100644 --- a/spec/integration/account_deletion_spec.rb +++ b/spec/integration/account_deletion_spec.rb @@ -48,7 +48,7 @@ describe 'deleteing your account' do @block = @bob2.blocks.create!(:person => eve.person) #authorization - @authorization = Factory.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 - Factory.create(:status_message, :author => @person) + Factory(:status_message, :author => @person) end @persons_sv = @posts.each do |post| @@ -123,7 +123,7 @@ describe 'deleteing your account' do #mentions @mentions = 3.times do - Factory.create(:mention, :person => @person) + Factory(:mention, :person => @person) end #conversations diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index f552bad70..662d58f15 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -70,7 +70,7 @@ describe 'a user receives a post' do end it 'notifies local users who are mentioned' do - @remote_person = Factory.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) @@ -154,7 +154,7 @@ describe 'a user receives a post' do @person = Factory(:person) alice.contacts.create(:person => @person, :aspects => [@alices_aspect]) - @post = Factory.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) diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index 809f88934..23f132080 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -9,7 +9,7 @@ describe Diaspora::Exporter do before do @user1 = alice - @user2 = Factory.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 69ac72d87..08eb14601 100644 --- a/spec/lib/diaspora/parser_spec.rb +++ b/spec/lib/diaspora/parser_spec.rb @@ -14,13 +14,13 @@ describe Diaspora::Parser do @aspect2 = @user2.aspects.first @aspect3 = @user3.aspects.first - @person = Factory.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 = Factory.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/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index de81d07a2..a73d69db9 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -290,9 +290,9 @@ describe Postzord::Dispatcher do end it 'only pushes to specified services' do - @s1 = Factory.create(:service, :user_id => alice.id) + @s1 = Factory(:service, :user_id => alice.id) alice.services << @s1 - @s2 = Factory.create(:service, :user_id => alice.id) + @s2 = Factory(:service, :user_id => alice.id) alice.services << @s2 mailman = Postzord::Dispatcher.build(alice, Factory(:status_message)) diff --git a/spec/lib/postzord/receiver/local_batch_spec.rb b/spec/lib/postzord/receiver/local_batch_spec.rb index 06aad60f9..79914700e 100644 --- a/spec/lib/postzord/receiver/local_batch_spec.rb +++ b/spec/lib/postzord/receiver/local_batch_spec.rb @@ -60,14 +60,14 @@ describe Postzord::Receiver::LocalBatch do describe '#notify_users' do it 'calls notify for posts with notification type' do - reshare = Factory.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 = Factory.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 diff --git a/spec/lib/statistics_spec.rb b/spec/lib/statistics_spec.rb index 6e775e636..98e5eff02 100644 --- a/spec/lib/statistics_spec.rb +++ b/spec/lib/statistics_spec.rb @@ -25,14 +25,14 @@ describe Statistics do describe '#posts_count_sql' do it "pulls back an array of post counts and ids" do - Factory.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 - sm = Factory.create(:status_message, :author => alice.person) + sm = Factory(:status_message, :author => alice.person) bob.comment("sup", :post => sm) result_should_equal User.connection.select_all(@stats.comments_count_sql) end @@ -55,7 +55,7 @@ describe Statistics do describe '#mentions_count_sql' do it "pulls back an array of mentions following counts and ids" do - post = Factory.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 diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 178662c29..c36f31402 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -23,7 +23,7 @@ describe Notifier do before do @users = [] 5.times do - @users << Factory.create(:user) + @users << Factory(:user) end end it 'has a body' do @@ -145,8 +145,8 @@ describe Notifier do describe ".reshared" do before do - @sm = Factory.create(:status_message, :author => alice.person, :public => true) - @reshare = Factory.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 diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 642ccc477..92e1157bc 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' describe 'making sure the spec runner works' do it 'factory creates a user with a person saved' do - user = Factory.create(:user) + user = Factory(:user) loaded_user = User.find(user.id) loaded_user.person.owner_id.should == user.id end @@ -52,8 +52,8 @@ describe 'making sure the spec runner works' do describe '#comment' do it "should send a user's comment on a person's post to that person" do - person = Factory.create(:person) - person_status = Factory.create(:status_message, :author => person) + person = Factory(:person) + person_status = Factory(:status_message, :author => person) m = mock() m.stub!(:post) Postzord::Dispatcher.should_receive(:build).and_return(m) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 778a5ca8c..faea516e4 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -68,7 +68,7 @@ describe Comment do describe 'xml' do before do - @commenter = Factory.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 @@ -103,7 +103,7 @@ describe Comment do describe 'it is relayable' do before do @local_luke, @local_leia, @remote_raphael = set_up_friends - @remote_parent = Factory.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("yo", :post => @local_parent) diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index d93b17188..118a29399 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -46,7 +46,7 @@ describe Contact do end it "validates that the person's account is not closed" do - person = Factory.create(:person, :closed_account => true) + person = Factory(:person, :closed_account => true) contact = alice.contacts.new(:person=>person) @@ -93,7 +93,7 @@ describe Contact do describe "all_contacts_of_person" do it 'returns all contacts where the person is the passed in person' do - person = Factory.create(:person) + person = Factory(:person) contact1 = Factory(:contact, :person => person) contact2 = Factory(:contact) contacts = Contact.all_contacts_of_person(person) @@ -166,7 +166,7 @@ describe Contact do context 'requesting' do before do @contact = Contact.new - @user = Factory.create(:user) + @user = Factory(:user) @person = Factory(:person) @contact.user = @user diff --git a/spec/models/jobs/fetch_profile_photo_spec.rb b/spec/models/jobs/fetch_profile_photo_spec.rb index b4e081601..eee17ee6c 100644 --- a/spec/models/jobs/fetch_profile_photo_spec.rb +++ b/spec/models/jobs/fetch_profile_photo_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Jobs::FetchProfilePhoto do before do @user = alice - @service = Factory.create(:service, :user => alice) + @service = Factory(:service, :user => alice) @url = "https://service.com/user/profile_image" diff --git a/spec/models/jobs/mail/reshared_spec.rb b/spec/models/jobs/mail/reshared_spec.rb index 39d0693ee..e5d746076 100644 --- a/spec/models/jobs/mail/reshared_spec.rb +++ b/spec/models/jobs/mail/reshared_spec.rb @@ -8,7 +8,7 @@ describe Jobs::Mail::Reshared do describe '#perfom' do it 'should call .deliver on the notifier object' do sm = Factory(:status_message, :author => bob.person, :public => true) - reshare = Factory.create(:reshare, :author => alice.person, :root=> sm) + reshare = Factory(:reshare, :author => alice.person, :root=> sm) mail_mock = mock() mail_mock.should_receive(:deliver) diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index 4c3047572..a166fff38 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -73,7 +73,7 @@ describe Like do describe 'xml' do before do - @liker = Factory.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 @@ -102,7 +102,7 @@ describe Like do describe 'it is relayable' do before do @local_luke, @local_leia, @remote_raphael = set_up_friends - @remote_parent = Factory.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(1, :target => @local_parent) diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index b6b973124..cc795e7bf 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -28,7 +28,7 @@ describe Notification do describe '.for' do it 'returns all of a users notifications' do - user2 = Factory.create(:user) + user2 = Factory(:user) 4.times do Notification.create(@opts) end diff --git a/spec/models/notifications/reshared_spec.rb b/spec/models/notifications/reshared_spec.rb index 1a1790af6..6ef319f15 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 = Factory.create(:status_message, :author => alice.person, :public => true) - @reshare1 = Factory.create(:reshare, :root => @sm) - @reshare2 = Factory.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 2d515a21e..1f82ed1ab 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 = Factory.create(:app) + @client = Factory(:app) end it 'validates uniqueness on resource owner and client' do diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 49a4f5751..1ebe394d4 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 = Factory.create(:person) + @person = Factory(:person) end it 'always has a profile' do @@ -94,8 +94,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 = Factory.create(:status_message, :author => alice.person, :public => true) - reshare = Factory.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 @@ -111,17 +111,17 @@ describe Person do describe "vaild url" do it 'should allow for https urls' do - person = Factory.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 = Factory.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 = Factory.create(:person, :url => "https://example.com:3000/") + person = Factory(:person, :url => "https://example.com:3000/") person.url.should == "https://example.com:3000/" end end @@ -223,8 +223,8 @@ describe Person do end it '#owns? posts' do - person_message = Factory.create(:status_message, :author => @person) - person_two = Factory.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 @@ -270,16 +270,16 @@ describe Person do describe '.search' do before do Person.delete_all - @user = Factory.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 = Factory.create(:searchable_person) - @eugene_weinstein = Factory.create(:searchable_person) - @yevgeniy_dodis = Factory.create(:searchable_person) - @casey_grippi = Factory.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" diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index b1ae2fe27..4904a9540 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -180,7 +180,7 @@ describe Photo do it 'should set the remote_photo on marshalling' do #security hax - user2 = Factory.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 7d17c437a..157d0c919 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -169,7 +169,7 @@ describe Post do describe 'deletion' do it 'should delete a posts comments on delete' do - post = Factory.create(:status_message, :author => @user.person) + post = Factory(:status_message, :author => @user.person) @user.comment "hey", :post => post post.destroy Post.where(:id => post.id).empty?.should == true @@ -421,7 +421,7 @@ describe Post do describe 'when post has been reshared exactly 1 time' do before :each do @post.reshares.size.should == 0 - @reshare = Factory.create(:reshare, :root => @post) + @reshare = Factory(:reshare, :root => @post) @post.reload @post.reshares.size.should == 1 end @@ -434,9 +434,9 @@ describe Post do describe 'when post has been reshared more than once' do before :each do @post.reshares.size.should == 0 - Factory.create(:reshare, :root => @post) - Factory.create(:reshare, :root => @post) - Factory.create(:reshare, :root => @post) + Factory(:reshare, :root => @post) + Factory(:reshare, :root => @post) + Factory(:reshare, :root => @post) @post.reload @post.reshares.size.should == 3 end diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 2905c6b05..ff6f9f31c 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -147,7 +147,7 @@ describe Profile do end describe 'serialization' do - let(:person) {Factory.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 @@ -244,7 +244,7 @@ describe Profile do describe 'tags' do before do - person = Factory.create(:person) + person = Factory(:person) @object = person.profile end it 'allows 5 tags' do diff --git a/spec/models/relayable_retraction_spec.rb b/spec/models/relayable_retraction_spec.rb index faaa171a2..681317e2b 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 = Factory.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/reshare_spec.rb b/spec/models/reshare_spec.rb index b8da88562..28fe156b8 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -30,7 +30,7 @@ describe Reshare do describe "#receive" do let(:receive) {@reshare.receive(@root.author.owner, @reshare.author)} before do - @reshare = Factory.create(:reshare, :root => Factory(:status_message, :author => bob.person, :public => true)) + @reshare = Factory(:reshare, :root => Factory(:status_message, :author => bob.person, :public => true)) @root = @reshare.root end @@ -55,8 +55,8 @@ describe Reshare do describe '#notification_type' do before do - sm = Factory.create(:status_message, :author => alice.person, :public => true) - @reshare = Factory.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 @@ -191,7 +191,7 @@ describe Reshare do @original_author = @reshare.root.author.dup @xml = @reshare.to_xml.to_s - different_person = Factory.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 57dda95be..67af02794 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 << Factory.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/service_user_spec.rb b/spec/models/service_user_spec.rb index 8512ee396..1ccb8e499 100644 --- a/spec/models/service_user_spec.rb +++ b/spec/models/service_user_spec.rb @@ -7,7 +7,7 @@ describe ServiceUser do @user = alice @service = Services::Facebook.new(:access_token => "yeah") @user.services << @service - @user2 = Factory.create(:user_with_aspect) + @user2 = Factory(:user_with_aspect) @user2_fb_id = '820651' @user2_fb_name = 'Maxwell Salzberg' @user2_fb_photo_url = 'http://cdn.fn.com/pic1.jpg' @@ -43,7 +43,7 @@ describe ServiceUser do @service = Services::Facebook.new(:access_token => "yeah") @user.services << @service - @user2 = Factory.create(:user_with_aspect) + @user2 = Factory(:user_with_aspect) @user2_fb_id = '820651' @user2_fb_name = 'Maxwell Salzberg' @user2_fb_photo_url = 'http://cdn.fn.com/pic1.jpg' diff --git a/spec/models/services/facebook_spec.rb b/spec/models/services/facebook_spec.rb index b4c7169e7..b638a591c 100644 --- a/spec/models/services/facebook_spec.rb +++ b/spec/models/services/facebook_spec.rb @@ -39,7 +39,7 @@ describe Services::Facebook do context 'finder' do before do - @user2 = Factory.create(:user_with_aspect) + @user2 = Factory(:user_with_aspect) @user2_fb_id = '820651' @user2_fb_name = 'Maxwell Salzberg' @user2_fb_photo_url = "http://cdn.fn.com/pic1.jpg" diff --git a/spec/models/signed_retraction_spec.rb b/spec/models/signed_retraction_spec.rb index e88f1866b..46c4f41fa 100644 --- a/spec/models/signed_retraction_spec.rb +++ b/spec/models/signed_retraction_spec.rb @@ -4,7 +4,7 @@ describe SignedRetraction do before do @post = Factory(:status_message, :author => bob.person, :public => true) @resharer = Factory(:user) - @post.reshares << Factory.create(:reshare, :root => @post, :author => @resharer.person) + @post.reshares << Factory(:reshare, :root => @post, :author => @resharer.person) @post.save! end describe '#perform' do diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 300d8b858..cd574d15b 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -23,8 +23,8 @@ describe StatusMessage do @bo = bob.person @test_string = "@{Daniel; #{@bo.diaspora_handle}} can mention people like Raph" - Factory.create(:status_message, :text => @test_string ) - Factory.create(:status_message, :text => @test_string ) + Factory(:status_message, :text => @test_string ) + Factory(:status_message, :text => @test_string ) Factory(:status_message) StatusMessage.where_person_is_mentioned(@bo).count.should == 2 @@ -33,10 +33,10 @@ describe StatusMessage do context "tag_streams" do before do - @sm1 = Factory.create(:status_message, :text => "#hashtag" , :public => true) - @sm2 = Factory.create(:status_message, :text => "#hashtag" ) - @sm3 = Factory.create(:status_message, :text => "hashtags are #awesome", :public => true ) - @sm4 = Factory.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 @@ -93,8 +93,8 @@ describe StatusMessage do describe '#diaspora_handle=' do it 'sets #author' do - person = Factory.create(:person) - post = Factory.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 @@ -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 = Factory.create(:status_message, :text => @test_string ) + @sm = Factory(:status_message, :text => @test_string ) end describe '#format_mentions' do @@ -222,7 +222,7 @@ STR end it 'returns false if the person was not mentioned' do - @sm.mentions?(Factory.create(:person)).should be_false + @sm.mentions?(Factory(:person)).should be_false end end @@ -255,7 +255,7 @@ STR describe "XML" do before do - @message = Factory.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 diff --git a/spec/models/tag_following_spec.rb b/spec/models/tag_following_spec.rb index 611c4fee3..71163c680 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 = Factory.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 3f615fc31..2b5770698 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -8,13 +8,13 @@ describe Diaspora::UserModules::Connecting do let(:aspect) { alice.aspects.first } let(:aspect1) { alice.aspects.create(:name => 'other') } - let(:person) { Factory.create(:person) } + let(:person) { Factory(:person) } let(:aspect2) { eve.aspects.create(:name => "aspect two") } - let(:person_one) { Factory.create :person } - let(:person_two) { Factory.create :person } - let(:person_three) { Factory.create :person } + let(:person_one) { Factory :person } + let(:person_two) { Factory :person } + let(:person_three) { Factory :person } describe 'disconnecting' do describe '#remove_contact' do @@ -155,7 +155,7 @@ describe Diaspora::UserModules::Connecting do end it "should mark the corresponding notification as 'read'" do - notification = Factory.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 a0314aa28..6c1b7962e 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -311,9 +311,9 @@ describe User do end context 'contact querying' do - let(:person_one) { Factory.create :person } - let(:person_two) { Factory.create :person } - let(:person_three) { Factory.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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 11e707a5b..4eeeb49c1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -131,7 +131,7 @@ describe User do describe 'overwriting people' do it 'does not overwrite old users with factory' do lambda { - new_user = Factory.create(:user, :id => alice.id) + new_user = Factory(:user, :id => alice.id) }.should raise_error ActiveRecord::StatementInvalid end @@ -367,7 +367,7 @@ describe User do end describe "with malicious params" do - let(:person) {Factory.create :person} + let(:person) {Factory :person} before do @invalid_params = {:username => "ohai", :email => "ohai@example.com", @@ -591,7 +591,7 @@ describe User do describe '#notify_if_mentioned' do before do - @post = Factory.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 @@ -609,7 +609,7 @@ describe User do end it 'does not notify the user if the post author is not a contact' do - @post = Factory.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) @@ -856,7 +856,7 @@ describe User do describe "#accept_invitation!" do before do fantasy_resque do - @invitation = Factory.create(:invitation, :sender => eve, :identifier => 'invitee@example.org', :aspect => eve.aspects.first) + @invitation = Factory(:invitation, :sender => eve, :identifier => 'invitee@example.org', :aspect => eve.aspects.first) end @invitation.reload @@ -1003,7 +1003,7 @@ describe User do describe "#clearable_attributes" do it 'returns the clearable fields' do - user = Factory.create :user + user = Factory :user user.send(:clearable_fields).sort.should == %w{ language invitation_token diff --git a/spec/multi_server/comment_spec.rb b/spec/multi_server/comment_spec.rb index 56ca77e24..0b8ccb6dd 100644 --- a/spec/multi_server/comment_spec.rb +++ b/spec/multi_server/comment_spec.rb @@ -15,7 +15,7 @@ unless Server.all.empty? Server.truncate_databases @post = nil Server[0].in_scope do - poster = Factory.create(:user_with_aspect, :username => "poster") + poster = Factory(:user_with_aspect, :username => "poster") @post = poster.post(:status_message, :public => true, :text => "Awesome Sauce!", @@ -23,7 +23,7 @@ unless Server.all.empty? end Server[1].in_scope do - commenter = Factory.create(:user_with_aspect, :username => "commenter") + commenter = Factory(:user_with_aspect, :username => "commenter") person = Webfinger.new("poster@localhost:#{Server[0].port}").fetch person.save! Reshare.fetch_post(person, @post.guid).save! diff --git a/spec/multi_server/post_spec.rb b/spec/multi_server/post_spec.rb index 70116a4d0..e21ebd9e0 100644 --- a/spec/multi_server/post_spec.rb +++ b/spec/multi_server/post_spec.rb @@ -13,11 +13,11 @@ unless Server.all.empty? Server.truncate_databases @post = nil Server[0].in_scope do - Factory.create(:user_with_aspect, :username => "poster") + Factory(:user_with_aspect, :username => "poster") end Server[1].in_scope do - recipient = Factory.create(:user_with_aspect, :username => "recipient") + recipient = Factory(:user_with_aspect, :username => "recipient") recipients_aspect = recipient.aspects.where(:name => "generic").first person = Webfinger.new("poster@localhost:#{Server[0].port}").fetch person.save! diff --git a/spec/multi_server/reshare_spec.rb b/spec/multi_server/reshare_spec.rb index 14f7f3f76..6c36ae9d1 100644 --- a/spec/multi_server/reshare_spec.rb +++ b/spec/multi_server/reshare_spec.rb @@ -15,8 +15,8 @@ unless Server.all.empty? Server.truncate_databases @original_post = nil Server[0].in_scope do - original_poster = Factory.create(:user_with_aspect, :username => "original_poster") - resharer = Factory.create(:user_with_aspect, :username => "resharer") + original_poster = Factory(:user_with_aspect, :username => "original_poster") + resharer = Factory(:user_with_aspect, :username => "resharer") connect_users_with_aspects(original_poster, resharer) @@ -27,7 +27,7 @@ unless Server.all.empty? end Server[1].in_scope do - recipient = Factory.create(:user_with_aspect, :username => "recipient") + recipient = Factory(:user_with_aspect, :username => "recipient") end Server[0].in_scope do diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 224066a73..20e0376c1 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -34,5 +34,4 @@ FixtureBuilder.configure do |fbuilder| local_leia.contacts.create(:person => remote_raphael, :aspects => [leias_aspect]) local_luke.contacts.create(:person => remote_raphael, :aspects => [lukes_aspect]) end -end - +end \ No newline at end of file