update factory girl

This commit is contained in:
Maxwell Salzberg 2012-05-16 16:23:14 -07:00
parent 455dc34eae
commit c52342b7cb
96 changed files with 445 additions and 445 deletions

View file

@ -152,7 +152,7 @@ group :test do
gem 'timecop'
#"0.1.0", #:path => '~/workspace/diaspora-client'
gem 'factory_girl_rails', '1.7.0'
gem 'factory_girl_rails'
gem 'fixture_builder', '0.3.3'
gem 'fuubar', '>= 1.0'
gem 'mongrel', :require => false, :platforms => :ruby_18

View file

@ -170,10 +170,10 @@ GEM
excon (0.13.4)
execjs (1.3.2)
multi_json (~> 1.0)
factory_girl (2.6.4)
activesupport (>= 2.3.9)
factory_girl_rails (1.7.0)
factory_girl (~> 2.6.0)
factory_girl (3.3.0)
activesupport (>= 3.0.0)
factory_girl_rails (3.3.0)
factory_girl (~> 3.3.0)
railties (>= 3.0.0)
faraday (0.7.6)
addressable (~> 2.2)
@ -517,7 +517,7 @@ DEPENDENCIES
devise (= 1.5.3)
diaspora-client!
em-synchrony (= 1.0.0)
factory_girl_rails (= 1.7.0)
factory_girl_rails
faraday
faraday_middleware
fastercsv (= 1.5.4)

View file

@ -1,7 +1,7 @@
Then /^I should see the "(.*)" message$/ do |message|
text = case message
when "alice is excited"
@alice ||= Factory(:user, :username => "Alice")
@alice ||= FactoryGirl.create(:user, :username => "Alice")
I18n.translate('invitation_codes.excited', :name => @alice.name)
when "welcome to diaspora"
I18n.translate('users.getting_started.well_hello_there')

View file

@ -4,7 +4,7 @@ Given /^(?:I am signed in|I sign in)$/ do
end
When /^I try to sign in$/ do
@me ||= Factory(:user_with_aspect, :getting_started => false)
@me ||= FactoryGirl.create(:user_with_aspect, :getting_started => false)
page.driver.visit(new_integration_sessions_path(:user_id => @me.id))
step %(I press "Login")
# To save time as compared to:

View file

@ -1,5 +1,5 @@
Given /^a user with username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
@me ||= Factory(:user, :username => username, :password => password,
@me ||= FactoryGirl.create(:user, :username => username, :password => password,
:password_confirmation => password, :getting_started => false)
@me.aspects.create(:name => "Besties")
@me.aspects.create(:name => "Unicorns")
@ -26,14 +26,14 @@ Given /^a nsfw user with email "([^\"]*)"$/ do |email|
end
Given /^I have been invited by an admin$/ do
admin = Factory(:user)
admin = FactoryGirl.create(:user)
admin.invitation_code
i = EmailInviter.new("new_invitee@example.com", admin)
i.send!
end
Given /^I have been invited by bob$/ do
@inviter = Factory(:user, :email => 'bob@bob.bob')
@inviter = FactoryGirl.create(:user, :email => 'bob@bob.bob')
@inviter_invite_count = @inviter.invitation_code.count
i = EmailInviter.new("new_invitee@example.com", @inviter)
i.send!
@ -80,8 +80,8 @@ Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag|
end
Given /^many posts from alice for bob$/ do
alice = Factory(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false)
bob = Factory(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false)
alice = FactoryGirl.create(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false)
bob = FactoryGirl.create(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false)
connect_users_with_aspects(alice, bob)
time_fulcrum = Time.now - 40000
time_interval = 1000
@ -132,7 +132,7 @@ end
When /^"([^\"]+)" has posted a status message with a photo$/ do |email|
user = User.find_for_database_authentication(:username => email)
post = Factory(:status_message_with_photo, :text => "Look at this dog", :author => user.person)
post = FactoryGirl.create(:status_message_with_photo, :text => "Look at this dog", :author => user.person)
[post, post.photos.first].each do |p|
user.add_to_streams(p, user.aspects)
user.dispatch_post(p)
@ -151,7 +151,7 @@ Given /^I have (\d+) contacts$/ do |n|
aspect_memberships = []
count.times do
person = Factory(:person)
person = FactoryGirl.create(:person)
people << person
end
@ -175,7 +175,7 @@ When /^I view "([^\"]*)"'s first post$/ do |email|
end
Given /^I visit alice's invitation code url$/ do
@alice ||= Factory(:user, :username => 'alice', :getting_started => false)
@alice ||= FactoryGirl.create(:user, :username => 'alice', :getting_started => false)
invite_code = InvitationCode.find_or_create_by_user_id(@alice.id)
visit invite_code_path(invite_code)
end

View file

@ -5,7 +5,7 @@ module PostGenerationHelpers
TemplatePicker::TEMPLATES.each do |template|
Timecop.travel time += 1.minute
Factory(template, :author => user.person)
FactoryGirl.create(template, :author => user.person)
end
Timecop.return

View file

@ -6,7 +6,7 @@ module UserCukeHelpers
:getting_started => false
}
user = Factory(:user, default_attrs.merge(overrides))
user = FactoryGirl.create(:user, default_attrs.merge(overrides))
add_standard_aspects(user)
user
end

View file

@ -6,7 +6,7 @@ require 'spec_helper'
describe AdminsController do
before do
@user = Factory :user
@user = FactoryGirl.create:user
sign_in :user, @user
end

View file

@ -4,7 +4,7 @@ require 'spec_helper'
describe AppsController do
describe '#show' do
it 'works as long as you pass something as id' do
Factory(:activity_streams_photo)
FactoryGirl.create(:activity_streams_photo)
get :show, :id => 'cubbies'
response.should be_success
end

View file

@ -98,7 +98,7 @@ describe AspectsController do
end
it "doesn't overwrite random attributes" do
new_user = Factory :user
new_user = FactoryGirl.create:user
params = {"name" => "Bruisers"}
params[:user_id] = new_user.id
put('update', :id => @alices_aspect_1.id, "aspect" => params)
@ -118,11 +118,11 @@ describe AspectsController do
eve.profile.save
eve.save
@zed = Factory(:user_with_aspect, :username => "zed")
@zed = FactoryGirl.create(:user_with_aspect, :username => "zed")
@zed.profile.first_name = "zed"
@zed.profile.save
@zed.save
@katz = Factory(:user_with_aspect, :username => "katz")
@katz = FactoryGirl.create(:user_with_aspect, :username => "katz")
@katz.profile.first_name = "katz"
@katz.profile.save
@katz.save

View file

@ -33,7 +33,7 @@ describe AuthorizationsController do
describe '#new' do
before do
@app = Factory(:app, :name => "Authorized App")
@app = FactoryGirl.create(:app, :name => "Authorized App")
@params = {
:scope => "profile",
:redirect_uri => @manifest['application_base_url'] << '/callback',
@ -167,8 +167,8 @@ describe AuthorizationsController do
end
it 'assigns the auth. & apps for the current user' do
app1 = Factory(:app, :name => "Authorized App")
app2 = Factory(:app, :name => "Unauthorized App")
app1 = FactoryGirl.create(:app, :name => "Authorized App")
app2 = FactoryGirl.create(:app, :name => "Unauthorized App")
auth = OAuth2::Provider.authorization_class.create(:client => app1, :resource_owner => alice)
OAuth2::Provider.authorization_class.create(:client => app1, :resource_owner => bob)
@ -182,7 +182,7 @@ describe AuthorizationsController do
describe "#destroy" do
before do
@app1 = Factory(:app)
@app1 = FactoryGirl.create(:app)
@auth1 = OAuth2::Provider.authorization_class.create(:client => @app1, :resource_owner => alice)
@auth2 = OAuth2::Provider.authorization_class.create(:client => @app1, :resource_owner => bob)
end
@ -260,7 +260,7 @@ describe AuthorizationsController do
describe 'valid_nonce' do
before do
@nonce = "abc123"
Factory(:app, :nonce => @nonce)
FactoryGirl.create(:app, :nonce => @nonce)
end
it 'returns true if its a new nonce' do

View file

@ -46,7 +46,7 @@ describe CommentsController do
end
it "doesn't overwrite author_id" do
new_user = Factory(:user)
new_user = FactoryGirl.create(:user)
comment_hash[:author_id] = new_user.person.id.to_s
post :create, comment_hash
Comment.find_by_text(comment_hash[:text]).author_id.should == alice.person.id

View file

@ -90,7 +90,7 @@ describe ConversationsController do
end
it 'sets the author to the current_user' do
@hash[:author] = Factory(:user)
@hash[:author] = FactoryGirl.create(:user)
post :create, @hash
Message.first.author.should == alice.person
Conversation.first.author.should == alice.person

View file

@ -20,7 +20,7 @@ describe StreamsController do
Timecop.travel time += 1.minute
posts << alice.post(:status_message, :text => "hella infos yo!", :to => alice.aspects.first.id)
Timecop.travel time += 1.minute
posts << alice.post(:reshare, :root_guid => Factory(:status_message, :public => true).guid, :to => 'all')
posts << alice.post(:reshare, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => 'all')
Timecop.travel time += 1.minute
if i == 9
posts << alice.post(:status_message,

View file

@ -73,7 +73,7 @@ describe MessagesController do
end
it "doesn't overwrite author_id" do
new_user = Factory(:user)
new_user = FactoryGirl.create(:user)
@message_hash[:author_id] = new_user.person.id.to_s
post :create, @message_hash
Message.find_by_text(@message_hash[:message][:text]).author_id.should == @user1.person.id

View file

@ -33,8 +33,8 @@ describe NotificationsController do
it 'only lets you read your own notifications' do
user2 = bob
Factory(:notification, :recipient => alice)
note = Factory(:notification, :recipient => user2)
FactoryGirl.create(:notification, :recipient => alice)
note = FactoryGirl.create(:notification, :recipient => user2)
get :update, "id" => note.id, :set_unread => "false"
@ -45,25 +45,25 @@ describe NotificationsController do
describe "#read_all" do
it 'marks all notifications as read' do
request.env["HTTP_REFERER"] = "I wish I were spelled right"
Factory(:notification, :recipient => alice)
Factory(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
Notification.where(:unread => true).count.should == 2
get :read_all
Notification.where(:unread => true).count.should == 0
end
it "should redirect to the stream in the html version" do
Factory(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :html
response.should redirect_to(stream_path)
end
it "should redirect to the stream in the mobile version" do
Factory(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :mobile
response.should redirect_to(stream_path)
end
it "should return a dummy value in the json version" do
Factory(:notification, :recipient => alice)
FactoryGirl.create(:notification, :recipient => alice)
get :read_all, :format => :json
response.should_not be_redirect
end
@ -71,8 +71,8 @@ describe NotificationsController do
describe '#index' do
before do
@post = Factory(:status_message)
Factory(:notification, :recipient => alice, :target => @post)
@post = FactoryGirl.create(:status_message)
FactoryGirl.create(:notification, :recipient => alice, :target => @post)
end
it 'succeeds for notification dropdown' do
@ -87,7 +87,7 @@ describe NotificationsController do
end
it 'paginates the notifications' do
25.times { Factory(:notification, :recipient => alice, :target => @post) }
25.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
get :index
assigns[:notifications].count.should == 25
get :index, "page" => 2
@ -95,20 +95,20 @@ describe NotificationsController do
end
it "supports a limit per_page parameter" do
5.times { Factory(:notification, :recipient => alice, :target => @post) }
5.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
get :index, "per_page" => 5
assigns[:notifications].count.should == 5
end
describe "special case for start sharing notifications" do
it "should not provide a contacts menu for standard notifications" do
2.times { Factory(:notification, :recipient => alice, :target => @post) }
2.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
get :index, "per_page" => 5
Nokogiri(response.body).css('.aspect_membership').should be_empty
end
it "should provide a contacts menu for start sharing notifications" do
2.times { Factory(:notification, :recipient => alice, :target => @post) }
2.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) }
eve.share_with(alice.person, eve.aspects.first)
get :index, "per_page" => 5

View file

@ -13,10 +13,10 @@ describe PeopleController do
describe '#index (search)' do
before do
@eugene = Factory(:person,
:profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w"))
@korth = Factory(:person,
:profile => Factory.build(:profile, :first_name => "Evan", :last_name => "Korth"))
@eugene = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w"))
@korth = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth"))
end
describe 'via json' do
@ -39,8 +39,8 @@ describe PeopleController do
describe 'via html' do
context 'query is a diaspora ID' do
before do
@unsearchable_eugene = Factory(:person, :diaspora_handle => "eugene@example.org",
:profile => Factory.build(:profile, :first_name => "Eugene",
@unsearchable_eugene = FactoryGirl.create(:person, :diaspora_handle => "eugene@example.org",
:profile => FactoryGirl.build(:profile, :first_name => "Eugene",
:last_name => "w", :searchable => false))
end
it 'finds people even if they have searchable off' do
@ -93,8 +93,8 @@ describe PeopleController do
end
it "assigns people" do
eugene2 = Factory(:person,
:profile => Factory.build(:profile, :first_name => "Eugene",
eugene2 = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Eugene",
:last_name => "w"))
get :index, :q => "Eug"
assigns[:people].map { |x| x.id }.should =~ [@eugene.id, eugene2.id]
@ -123,8 +123,8 @@ describe PeopleController do
end
it "excludes people who have searchable off" do
eugene2 = Factory(:person,
:profile => Factory.build(:profile, :first_name => "Eugene",
eugene2 = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Eugene",
:last_name => "w", :searchable => false))
get :index, :q => "Eug"
assigns[:people].should_not =~ [eugene2]
@ -140,7 +140,7 @@ describe PeopleController do
end
it 'returns awesome people who have that tag' do
f = Factory(:person)
f = FactoryGirl.create(:person)
f.profile.tag_string = "#seeded"
f.profile.save
get :tag_index, :name => 'seeded', :format => :js
@ -154,7 +154,7 @@ describe PeopleController do
@posts = []
@users = []
8.times do |n|
user = Factory(:user)
user = FactoryGirl.create(:user)
@users << user
aspect = user.aspects.create(:name => 'people')
connect_users(@user, @user.aspects.first, user, aspect)
@ -192,7 +192,7 @@ describe PeopleController do
end
it 'redirects home for closed account' do
@person = Factory(:person, :closed_account => true)
@person = FactoryGirl.create(:person, :closed_account => true)
get :show, :id => @person.to_param
response.should be_redirect
flash[:notice].should_not be_blank
@ -271,7 +271,7 @@ describe PeopleController do
end
it "posts include reshares" do
reshare = @user.post(:reshare, :public => true, :root_guid => Factory(:status_message, :public => true).guid, :to => alice.aspects)
reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects)
get :show, :id => @user.person.to_param
assigns[:stream].posts.map { |x| x.id }.should include(reshare.id)
end
@ -288,7 +288,7 @@ describe PeopleController do
end
it 'throws 404 if the person is remote' do
p = Factory(:person)
p = FactoryGirl.create(:person)
get :show, :id => p.to_param
response.status.should == 404
@ -326,7 +326,7 @@ describe PeopleController do
end
it "posts include reshares" do
reshare = @user.post(:reshare, :public => true, :root_guid => Factory(:status_message, :public => true).guid, :to => alice.aspects)
reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects)
get :show, :id => @user.person.to_param
assigns[:stream].posts.map { |x| x.id }.should include(reshare.id)
end
@ -359,7 +359,7 @@ describe PeopleController do
end
it "posts include reshares" do
reshare = @user.post(:reshare, :public => true, :root_guid => Factory(:status_message, :public => true).guid, :to => alice.aspects)
reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspects)
get :show, :id => @user.person.to_param
assigns[:stream].posts.map { |x| x.id }.should include(reshare.id)
end
@ -370,10 +370,10 @@ describe PeopleController do
describe '#refresh_search ' do
before(:each)do
@eugene = Factory(:person,
:profile => Factory.build(:profile, :first_name => "Eugene", :last_name => "w"))
@korth = Factory(:person,
:profile => Factory.build(:profile, :first_name => "Evan", :last_name => "Korth"))
@eugene = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w"))
@korth = FactoryGirl.create(:person,
:profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth"))
end
describe 'via json' do

View file

@ -64,7 +64,7 @@ describe PhotosController do
describe '#index' do
it "succeeds without any available pictures" do
get :index, :person_id => Factory(:person).guid.to_s
get :index, :person_id => FactoryGirl.create(:person).guid.to_s
response.should be_success
end
@ -138,7 +138,7 @@ describe PhotosController do
end
it "doesn't overwrite random attributes" do
new_user = Factory(:user)
new_user = FactoryGirl.create(:user)
params = { :text => "now with lasers!", :author_id => new_user.id }
put :update, :id => @alices_photo.id, :photo => params
@alices_photo.reload.author_id.should == alice.person.id

View file

@ -36,7 +36,7 @@ describe PostsController do
end
it 'succeeds on mobile with a reshare' do
get :show, "id" => Factory(:reshare, :author => alice.person).id, :format => :mobile
get :show, "id" => FactoryGirl.create(:reshare, :author => alice.person).id, :format => :mobile
response.should be_success
end
@ -50,7 +50,7 @@ describe PostsController do
end
it 'succeeds with a AS/photo' do
photo = Factory(:activity_streams_photo, :author => bob.person)
photo = FactoryGirl.create(:activity_streams_photo, :author => bob.person)
get :show, :id => photo.id
response.should be_success
end

View file

@ -143,7 +143,7 @@ describe ProfilesController do
context 'mass assignment' do
before do
new_person = Factory(:person)
new_person = FactoryGirl.create(:person)
@profile_params = {:profile =>{ :person_id => new_person.id,
:diaspora_handle => 'abc@a.com'}}
end

View file

@ -8,7 +8,7 @@ describe PublicsController do
let(:fixture_path) { File.join(Rails.root, 'spec', 'fixtures')}
before do
@user = alice
@person = Factory(:person)
@person = FactoryGirl.create(:person)
end
describe '#host_meta' do
@ -55,7 +55,7 @@ describe PublicsController do
aspect = @user.aspects.create(:name => 'foo')
post1 = @user.post(:status_message, :text => 'moms', :to => [aspect.id])
xml2 = post1.to_diaspora_xml
user2 = Factory(:user)
user2 = FactoryGirl.create(:user)
salmon_factory = Salmon::EncryptedSlap.create_by_user_and_activity(@user, xml2)
enc_xml = salmon_factory.xml_for(user2.person)

View file

@ -16,7 +16,7 @@ describe RegistrationsController do
:password_confirmation => "password"
}
}
Webfinger.stub_chain(:new, :fetch).and_return(Factory(:person))
Webfinger.stub_chain(:new, :fetch).and_return(FactoryGirl.create(:person))
end
describe '#check_registrations_open!' do
@ -61,7 +61,7 @@ describe RegistrationsController do
end
before do
user = Factory.build(:user)
user = FactoryGirl.build(:user)
User.stub!(:build).and_return(user)
end

View file

@ -7,7 +7,7 @@ describe ResharesController do
}
before do
@post_guid = Factory(:status_message, :public => true).guid
@post_guid = FactoryGirl.create(:status_message, :public => true).guid
end
it 'requires authentication' do

View file

@ -27,7 +27,7 @@ describe ServicesController do
describe '#index' do
it 'displays all connected serivices for a user' do
4.times do
Factory(:service, :user => @user)
FactoryGirl.create(:service, :user => @user)
end
get :index
@ -97,7 +97,7 @@ describe ServicesController do
describe '#destroy' do
before do
@service1 = Factory(:service, :user => @user)
@service1 = FactoryGirl.create(:service, :user => @user)
end
it 'destroys a service selected by id' do

View file

@ -41,13 +41,13 @@ describe UsersController do
describe '#public' do
it 'renders xml if atom is requested' do
sm = Factory(:status_message, :public => true, :author => @user.person)
sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person)
get :public, :username => @user.username, :format => :atom
response.body.should include(sm.text)
end
it 'renders xml if atom is requested with clickalbe urls' do
sm = Factory(:status_message, :public => true, :author => @user.person)
sm = FactoryGirl.create(:status_message, :public => true, :author => @user.person)
@user.person.posts.each do |p|
p.text = "Goto http://diasporaproject.org/ now!"
p.save

View file

@ -30,24 +30,24 @@ FactoryGirl.define do
sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@example.net" }
sequence(:url) { |n| AppConfig[:pod_url] }
serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export
after_build do |person|
person.profile = Factory.build(:profile, :person => person) unless person.profile.first_name.present?
after(:build) do |person|
person.profile = FactoryGirl.build(:profile, :person => person) unless person.profile.first_name.present?
end
after_create do |person|
after(:create) do |person|
person.profile.save
end
end
factory :account_deletion do
association :person
after_build do |delete|
after(:build) do |delete|
delete.diaspora_handle = delete.person.diaspora_handle
end
end
factory :searchable_person, :parent => :person do
after_build do |person|
person.profile = Factory.build(:profile, :person => person, :searchable => true)
after(:build) do |person|
person.profile = FactoryGirl.build(:profile, :person => person, :searchable => true)
end
end
@ -63,20 +63,20 @@ FactoryGirl.define do
password "bluepin7"
password_confirmation { |u| u.password }
serialized_private_key OpenSSL::PKey::RSA.generate(1024).export
after_build do |u|
u.person = Factory.build(:person, :profile => Factory.build(:profile),
after(:build) do |u|
u.person = FactoryGirl.build(:person, :profile => FactoryGirl.build(:profile),
:owner_id => u.id,
:serialized_public_key => u.encryption_key.public_key.export,
:diaspora_handle => "#{u.username}#{User.diaspora_id_host}")
end
after_create do |u|
after(:create) do |u|
u.person.save
u.person.profile.save
end
end
factory :user_with_aspect, :parent => :user do
after_create { |u| Factory(:aspect, :user => u) }
after(:create) { |u| FactoryGirl.create(:aspect, :user => u) }
end
factory :aspect do
@ -87,22 +87,22 @@ FactoryGirl.define do
factory(:status_message) do
sequence(:text) { |n| "jimmy's #{n} whales" }
association :author, :factory => :person
after_build do |sm|
after(:build) do |sm|
sm.diaspora_handle = sm.author.diaspora_handle
end
end
factory(:status_message_with_photo, :parent => :status_message) do
sequence(:text) { |n| "There are #{n} ninjas in this photo." }
after_build do |sm|
Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => public)
after(:build) do |sm|
FactoryGirl.create(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => sm.public)
end
end
factory(:photo) do
sequence(:random_string) {|n| SecureRandom.hex(10) }
association :author, :factory => :person
after_build do |p|
after(:build) do |p|
p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png'))
p.update_remote_path
end
@ -125,7 +125,7 @@ FactoryGirl.define do
service "email"
identifier "bob.smith@smith.com"
association :sender, :factory => :user_with_aspect
after_build do |i|
after(:build) do |i|
i.aspect = i.sender.aspects.first
end
end
@ -163,8 +163,8 @@ FactoryGirl.define do
association :target, :factory => :comment
type 'Notifications::AlsoCommented'
after_build do |note|
note.actors << Factory.build(:person)
after(:build) do |note|
note.actors << FactoryGirl.build(:person)
end
end
@ -225,8 +225,8 @@ FactoryGirl.define do
#templates
factory(:multi_photo, :parent => :status_message_with_photo) do
after_build do |sm|
2.times{ Factory(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => public)}
after(:build) do |sm|
2.times{ FactoryGirl.create(:photo, :author => sm.author, :status_message => sm, :pending => false, :public => sm.public)}
end
end

View file

@ -7,7 +7,7 @@ require 'spec_helper'
describe ApplicationHelper do
before do
@user = alice
@person = Factory(:person)
@person = FactoryGirl.create(:person)
end
describe "#contacts_link" do
@ -18,7 +18,7 @@ describe ApplicationHelper do
end
it 'links to community spotlight' do
@current_user = Factory(:user)
@current_user = FactoryGirl.create(:user)
contacts_link.should == community_spotlight_path
end
@ -39,7 +39,7 @@ describe ApplicationHelper do
end
it 'returns true if all networks are connected' do
3.times { |t| @current_user.services << Factory.build(:service) }
3.times { |t| @current_user.services << FactoryGirl.build(:service) }
all_services_connected?.should be_true
end

View file

@ -14,7 +14,7 @@ describe GettingStartedHelper do
describe "#has_connected_cubbies?" do
it 'returns true if the current user has connected cubbies to their account' do
@current_user.authorizations << Factory(:oauth_authorization)
@current_user.authorizations << FactoryGirl.create(:oauth_authorization)
has_connected_cubbies?.should be_true
end

View file

@ -35,7 +35,7 @@ describe MarkdownifyHelper do
context 'when formatting status messages' do
it "should leave tags intact" do
message = Factory(:status_message,
message = FactoryGirl.create(:status_message,
:author => alice.person,
:text => "I love #markdown")
formatted = markdownify(message)
@ -43,7 +43,7 @@ describe MarkdownifyHelper do
end
it 'should leave multi-underscore tags intact' do
message = Factory(
message = FactoryGirl.create(
:status_message,
:author => alice.person,
:text => "Here is a #multi_word tag"
@ -51,7 +51,7 @@ describe MarkdownifyHelper do
formatted = markdownify(message)
formatted.should =~ %r{Here is a <a href="/tags/multi_word" class="tag">#multi_word</a> tag}
message = Factory(
message = FactoryGirl.create(
:status_message,
:author => alice.person,
:text => "Here is a #multi_word_tag yo"
@ -61,7 +61,7 @@ describe MarkdownifyHelper do
end
it "should leave mentions intact" do
message = Factory(:status_message,
message = FactoryGirl.create(:status_message,
:author => alice.person,
:text => "Hey @{Bob; #{bob.diaspora_handle}}!")
formatted = markdownify(message)
@ -69,8 +69,8 @@ describe MarkdownifyHelper do
end
it "should leave mentions intact for real diaspora handles" do
new_person = Factory(:person, :diaspora_handle => 'maxwell@joindiaspora.com')
message = Factory(:status_message,
new_person = FactoryGirl.create(:person, :diaspora_handle => 'maxwell@joindiaspora.com')
message = FactoryGirl.create(:status_message,
:author => alice.person,
:text => "Hey @{maxwell@joindiaspora.com; #{new_person.diaspora_handle}}!")
formatted = markdownify(message)
@ -78,7 +78,7 @@ describe MarkdownifyHelper do
end
it 'should process text with both a hashtag and a link' do
message = Factory(:status_message,
message = FactoryGirl.create(:status_message,
:author => alice.person,
:text => "Test #tag?\nhttps://joindiaspora.com\n")
formatted = markdownify(message)

View file

@ -10,7 +10,7 @@ describe MobileHelper do
it "adds an all option to the list of aspects" do
# options_from_collection_for_select(@aspects, "id", "name", @aspect.id)
n = Factory(:aspect)
n = FactoryGirl.create(:aspect)
options = aspect_select_options([n], n).split('\n')
options.first.should =~ /All/

View file

@ -5,12 +5,12 @@ describe NotificationsHelper do
include ApplicationHelper
before do
@user = Factory(:user)
@person = Factory(:person)
@post = Factory(:status_message, :author => @user.person)
@person2 = Factory(:person)
@notification = Notification.notify(@user, Factory(:like, :author => @person, :target => @post), @person)
@notification = Notification.notify(@user, Factory(:like, :author => @person2, :target => @post), @person2)
@user = FactoryGirl.create(:user)
@person = FactoryGirl.create(:person)
@post = FactoryGirl.create(:status_message, :author => @user.person)
@person2 = FactoryGirl.create(:person)
@notification = Notification.notify(@user, FactoryGirl.create(:like, :author => @person, :target => @post), @person)
@notification = Notification.notify(@user, FactoryGirl.create(:like, :author => @person2, :target => @post), @person2)
end
describe '#notification_people_link' do
@ -19,19 +19,19 @@ describe NotificationsHelper do
let(:output){ strip_tags(notification_people_link(@note)) }
before do
@max = Factory(:person)
@max = FactoryGirl.create(:person)
@max.profile.first_name = 'max'
@max.profile.last_name = 'salzberg'
@sarah = Factory(:person)
@sarah = FactoryGirl.create(:person)
@sarah.profile.first_name = 'sarah'
@sarah.profile.last_name = 'mei'
@daniel = Factory(:person)
@daniel = FactoryGirl.create(:person)
@daniel.profile.first_name = 'daniel'
@daniel.profile.last_name = 'grippi'
@ilya = Factory(:person)
@ilya = FactoryGirl.create(:person)
@ilya.profile.first_name = 'ilya'
@ilya.profile.last_name = 'zhit'
@note = mock()

View file

@ -9,7 +9,7 @@ describe NotifierHelper do
describe '#comment_message' do
before do
@comment = Factory(:comment)
@comment = FactoryGirl.create(:comment)
end
it 'truncates the comment' do

View file

@ -7,7 +7,7 @@ require 'spec_helper'
describe PeopleHelper do
before do
@user = alice
@person = Factory(:person)
@person = FactoryGirl.create(:person)
end
describe "#person_image_link" do
@ -32,7 +32,7 @@ describe PeopleHelper do
describe '#person_link' do
before do
@person = Factory(:person)
@person = FactoryGirl.create(:person)
end
it 'includes the name of the person if they have a first name' do
@ -76,7 +76,7 @@ describe PeopleHelper do
describe '#local_or_remote_person_path' do
before do
@user = Factory(:user)
@user = FactoryGirl.create(:user)
end
it "links by id if there is a period in the user's username" do

View file

@ -11,7 +11,7 @@ describe 'deleteing your account' do
#@bob2's own content
@bob2.post(:status_message, :text => 'asldkfjs', :to => @bob2.aspects.first)
f = Factory(:photo, :author => @bob2.person)
f = FactoryGirl.create(:photo, :author => @bob2.person)
@aspect_vis = AspectVisibility.where(:aspect_id => @bob2.aspects.map(&:id))
@ -35,20 +35,20 @@ describe 'deleteing your account' do
# notifications
@notifications = []
3.times do |n|
@notifications << Factory(:notification, :recipient => @bob2)
@notifications << FactoryGirl.create(:notification, :recipient => @bob2)
end
# services
@services = []
3.times do |n|
@services << Factory(:service, :user => @bob2)
@services << FactoryGirl.create(:service, :user => @bob2)
end
# block
@block = @bob2.blocks.create!(:person => eve.person)
#authorization
@authorization = Factory(:oauth_authorization, :resource_owner => @bob2)
@authorization = FactoryGirl.create(:oauth_authorization, :resource_owner => @bob2)
AccountDeleter.new(@bob2.person.diaspora_handle).perform!
@bob2.reload
@ -109,7 +109,7 @@ describe 'deleteing your account' do
#posts
@posts = (1..3).map do
Factory(:status_message, :author => @person)
FactoryGirl.create(:status_message, :author => @person)
end
@persons_sv = @posts.each do |post|
@ -119,11 +119,11 @@ describe 'deleteing your account' do
end
#photos
@photo = Factory(:photo, :author => @person)
@photo = FactoryGirl.create(:photo, :author => @person)
#mentions
@mentions = 3.times do
Factory(:mention, :person => @person)
FactoryGirl.create(:mention, :person => @person)
end
#conversations

View file

@ -33,7 +33,7 @@ JSON
@url = activity_streams_photos_path
end
it 'allows oauth authentication' do
token = Factory(:oauth_access_token)
token = FactoryGirl.create(:oauth_access_token)
post @url, @json.merge!(:oauth_token => token.access_token)
response.should be_success
end

View file

@ -14,7 +14,7 @@ def receive(post, opts)
end
def temporary_user(&block)
user = Factory(:user)
user = FactoryGirl.create(:user)
block_return_value = yield user
user.delete
block_return_value
@ -131,7 +131,7 @@ describe "attack vectors" do
original_message = legit_post_from_user1_to_user2(eve, bob)
#someone else tries to make a message with the same guid
malicious_message = Factory.build(:status_message, :id => original_message.id, :guid => original_message.guid, :author => alice.person)
malicious_message = FactoryGirl.build(:status_message, :id => original_message.id, :guid => original_message.guid, :author => alice.person)
expect{
receive(malicious_message, :from => alice, :by => bob)
@ -144,7 +144,7 @@ describe "attack vectors" do
original_message = legit_post_from_user1_to_user2(eve, bob)
#eve tries to send me another message with the same ID
malicious_message = Factory.build( :status_message, :id => original_message.id, :text => 'BAD!!!', :author => eve.person)
malicious_message = FactoryGirl.build( :status_message, :id => original_message.id, :text => 'BAD!!!', :author => eve.person)
expect {
receive(malicious_message, :from => eve, :by => bob)

View file

@ -5,7 +5,7 @@ describe "Dispatching" do
it "should trigger a private dispatch" do
luke, leia, raph = set_up_friends
# Luke has a public post and comments on it
post = Factory(:status_message, :public => true, :author => luke.person)
post = FactoryGirl.create(:status_message, :public => true, :author => luke.person)
fantasy_resque do
comment = luke.comment!(post, "awesomesauseum")

View file

@ -70,12 +70,12 @@ describe 'a user receives a post' do
end
it 'notifies local users who are mentioned' do
@remote_person = Factory(:person, :diaspora_handle => "foobar@foobar.com")
@remote_person = FactoryGirl.create(:person, :diaspora_handle => "foobar@foobar.com")
Contact.create!(:user => alice, :person => @remote_person, :aspects => [@alices_aspect])
Notification.should_receive(:notify).with(alice, anything(), @remote_person)
@sm = Factory.build(:status_message, :text => "hello @{#{alice.name}; #{alice.diaspora_handle}}", :diaspora_handle => @remote_person.diaspora_handle, :author => @remote_person)
@sm = FactoryGirl.build(:status_message, :text => "hello @{#{alice.name}; #{alice.diaspora_handle}}", :diaspora_handle => @remote_person.diaspora_handle, :author => @remote_person)
@sm.save
zord = Postzord::Receiver::Private.new(alice, :object => @sm, :person => bob.person)
@ -151,10 +151,10 @@ describe 'a user receives a post' do
context 'dependent delete' do
it 'deletes share_visibilities on disconnected by' do
@person = Factory(:person)
@person = FactoryGirl.create(:person)
alice.contacts.create(:person => @person, :aspects => [@alices_aspect])
@post = Factory(:status_message, :author => @person)
@post = FactoryGirl.create(:status_message, :author => @person)
@post.share_visibilities.should be_empty
receive_with_zord(alice, @person, @post.to_diaspora_xml)
@contact = alice.contact_for(@person)
@ -210,7 +210,7 @@ describe 'a user receives a post' do
Webfinger.should_receive(:new).twice.with(eve.person.diaspora_handle).and_return(m)
m.should_receive(:fetch).twice.and_return{
remote_person.save(:validate => false)
remote_person.profile = Factory(:profile, :person => remote_person)
remote_person.profile = FactoryGirl.create(:profile, :person => remote_person)
remote_person
}
@ -253,11 +253,11 @@ describe 'a user receives a post' do
describe 'receiving mulitple versions of the same post from a remote pod' do
before do
@local_luke, @local_leia, @remote_raphael = set_up_friends
@post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago)
@post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago)
end
it 'does not update created_at or updated_at when two people save the same post' do
@post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago)
@post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author=> @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago)
xml = @post.to_diaspora_xml
receive_with_zord(@local_luke, @remote_raphael, xml)
old_time = Time.now+1
@ -267,11 +267,11 @@ describe 'a user receives a post' do
end
it 'does not update the post if a new one is sent with a new created_at' do
@post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 5.days.ago)
@post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 5.days.ago)
old_time = @post.created_at
xml = @post.to_diaspora_xml
receive_with_zord(@local_luke, @remote_raphael, xml)
@post = Factory.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 2.days.ago)
@post = FactoryGirl.build(:status_message, :text => 'hey', :guid => '12313123', :author => @remote_raphael, :created_at => 2.days.ago)
receive_with_zord(@local_luke, @remote_raphael, xml)
(Post.find_by_guid @post.guid).created_at.day.should == old_time.day
end

View file

@ -6,7 +6,7 @@ require 'spec_helper'
describe Diaspora::Encryptable do
before do
@comment = Factory(:comment, :author => bob.person)
@comment = FactoryGirl.create(:comment, :author => bob.person)
end
describe '#sign_with_key' do
it 'signs the object with RSA256 signature' do

View file

@ -9,7 +9,7 @@ describe Diaspora::Exporter do
before do
@user1 = alice
@user2 = Factory(:user)
@user2 = FactoryGirl.create(:user)
@user3 = bob
@aspect = @user1.aspects.first

View file

@ -14,13 +14,13 @@ describe Diaspora::Parser do
@aspect2 = @user2.aspects.first
@aspect3 = @user3.aspects.first
@person = Factory(:person)
@person = FactoryGirl.create(:person)
end
describe "parsing compliant XML object" do
it 'should be able to correctly parse comment fields' do
post = @user1.post :status_message, :text => "hello", :to => @aspect1.id
comment = Factory(:comment, :post => post, :author => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!")
comment = FactoryGirl.create(:comment, :post => post, :author => @person, :diaspora_handle => @person.diaspora_handle, :text => "Freedom!")
comment.delete
xml = comment.to_diaspora_xml
comment_from_xml = Diaspora::Parser.from_xml(xml)

View file

@ -11,7 +11,7 @@ end
describe EvilQuery::Participation do
before do
@status_message = Factory(:status_message, :author => bob.person)
@status_message = FactoryGirl.create(:status_message, :author => bob.person)
end
it "includes posts liked by the user" do
@ -30,11 +30,11 @@ describe EvilQuery::Participation do
describe "ordering" do
before do
@status_messageA = Factory(:status_message, :author => bob.person)
@status_messageB = Factory(:status_message, :author => bob.person)
@photoC = Factory(:activity_streams_photo, :author => bob.person)
@status_messageD = Factory(:status_message, :author => bob.person)
@status_messageE = Factory(:status_message, :author => bob.person)
@status_messageA = FactoryGirl.create(:status_message, :author => bob.person)
@status_messageB = FactoryGirl.create(:status_message, :author => bob.person)
@photoC = FactoryGirl.create(:activity_streams_photo, :author => bob.person)
@status_messageD = FactoryGirl.create(:status_message, :author => bob.person)
@status_messageE = FactoryGirl.create(:status_message, :author => bob.person)
time = Time.now

View file

@ -8,9 +8,9 @@ require File.join(Rails.root, 'lib/postzord/dispatcher')
describe Postzord::Dispatcher do
before do
@sm = Factory(:status_message, :public => true, :author => alice.person)
@sm = FactoryGirl.create(:status_message, :public => true, :author => alice.person)
@subscribers = []
5.times{@subscribers << Factory(:person)}
5.times{@subscribers << FactoryGirl.create(:person)}
@sm.stub(:subscribers).and_return(@subscribers)
@xml = @sm.to_diaspora_xml
end
@ -31,7 +31,7 @@ describe Postzord::Dispatcher do
end
it 'accepts additional subscribers from opts' do
new_person = Factory(:person)
new_person = FactoryGirl.create(:person)
@sm.should_receive(:subscribers).and_return(@subscribers)
zord = Postzord::Dispatcher.build(alice, @sm, :additional_subscribers => new_person)
@ -130,7 +130,7 @@ describe Postzord::Dispatcher do
context "remote raphael" do
before do
@comment = Factory.build(:comment, :author => @remote_raphael, :post => @post)
@comment = FactoryGirl.build(:comment, :author => @remote_raphael, :post => @post)
@comment.save
@mailman = Postzord::Dispatcher.build(@local_luke, @comment)
end
@ -177,7 +177,7 @@ describe Postzord::Dispatcher do
context "remote raphael's post is commented on by local luke" do
before do
@post = Factory(:status_message, :author => @remote_raphael)
@post = FactoryGirl.create(:status_message, :author => @remote_raphael)
@comment = @local_luke.build_comment :text => "yo", :post => @post
@comment.save
@mailman = Postzord::Dispatcher.build(@local_luke, @comment)
@ -244,28 +244,28 @@ describe Postzord::Dispatcher do
describe '#object_should_be_processed_as_public?' do
it 'returns true with a comment on a public post' do
f = Factory(:comment, :post => Factory(:status_message, :public => true))
f = FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => true))
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_true
end
it 'returns false with a comment on a private post' do
f = Factory(:comment, :post => Factory(:status_message, :public => false))
f = FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => false))
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false
end
it 'returns true with a like on a comment on a public post' do
f = Factory(:like, :target => Factory(:comment, :post => Factory(:status_message, :public => true)))
f = FactoryGirl.create(:like, :target => FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => true)))
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_true
end
it 'returns false with a like on a comment on a private post' do
f = Factory(:like, :target => Factory(:comment, :post => Factory(:status_message, :public => false)))
f = FactoryGirl.create(:like, :target => FactoryGirl.create(:comment, :post => FactoryGirl.create(:status_message, :public => false)))
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false
end
it 'returns false for a relayable_retraction' do
f = RelayableRetraction.new
f.target = Factory(:status_message, :public => true)
f.target = FactoryGirl.create(:status_message, :public => true)
Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false
end
end
@ -285,7 +285,7 @@ describe Postzord::Dispatcher do
end
it 'does not push to hub for non-public posts' do
@sm = Factory(:status_message)
@sm = FactoryGirl.create(:status_message)
mailman = Postzord::Dispatcher.build(alice, @sm, :url => "http://joindiaspora.com/p/123")
mailman.should_not_receive(:deliver_to_hub)
@ -293,11 +293,11 @@ describe Postzord::Dispatcher do
end
it 'only pushes to specified services' do
@s1 = Factory(:service, :user_id => alice.id)
@s1 = FactoryGirl.create(:service, :user_id => alice.id)
alice.services << @s1
@s2 = Factory(:service, :user_id => alice.id)
@s2 = FactoryGirl.create(:service, :user_id => alice.id)
alice.services << @s2
mailman = Postzord::Dispatcher.build(alice, Factory(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1])
mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123", :services => [@s1])
Resque.stub!(:enqueue).with(Jobs::PublishToHub, anything)
Resque.stub!(:enqueue).with(Jobs::HttpMulti, anything, anything, anything)
@ -306,7 +306,7 @@ describe Postzord::Dispatcher do
end
it 'does not push to services if none are specified' do
mailman = Postzord::Dispatcher.build(alice, Factory(:status_message), :url => "http://joindiaspora.com/p/123")
mailman = Postzord::Dispatcher.build(alice, FactoryGirl.create(:status_message), :url => "http://joindiaspora.com/p/123")
Resque.stub!(:enqueue).with(Jobs::PublishToHub, anything)
Resque.should_not_receive(:enqueue).with(Jobs::PostToService, anything, anything, anything)

View file

@ -3,7 +3,7 @@ require File.join(Rails.root, 'lib','postzord', 'receiver', 'local_batch')
describe Postzord::Receiver::LocalBatch do
before do
@object = Factory(:status_message, :author => alice.person)
@object = FactoryGirl.create(:status_message, :author => alice.person)
@ids = [bob.id.to_s]
end
@ -43,7 +43,7 @@ describe Postzord::Receiver::LocalBatch do
describe '#notify_mentioned_users' do
it 'calls notify person for a mentioned person' do
sm = Factory(:status_message,
sm = FactoryGirl.create(:status_message,
:author => alice.person,
:text => "Hey @{Bob; #{bob.diaspora_handle}}")
@ -60,14 +60,14 @@ describe Postzord::Receiver::LocalBatch do
describe '#notify_users' do
it 'calls notify for posts with notification type' do
reshare = Factory(:reshare)
reshare = FactoryGirl.create(:reshare)
Notification.should_receive(:notify)
receiver = Postzord::Receiver::LocalBatch.new(reshare, @ids)
receiver.notify_users
end
it 'calls notify for posts with notification type' do
sm = Factory(:status_message, :author => alice.person)
sm = FactoryGirl.create(:status_message, :author => alice.person)
receiver = Postzord::Receiver::LocalBatch.new(sm, @ids)
Notification.should_not_receive(:notify)
receiver.notify_users
@ -76,8 +76,8 @@ describe Postzord::Receiver::LocalBatch do
context 'integrates with a comment' do
before do
sm = Factory(:status_message, :author => alice.person)
@object = Factory(:comment, :author => bob.person, :post => sm)
sm = FactoryGirl.create(:status_message, :author => alice.person)
@object = FactoryGirl.create(:comment, :author => bob.person, :post => sm)
end
it 'calls notify_users' do

View file

@ -53,7 +53,7 @@ describe Postzord::Receiver::Private do
end
it 'if the author does not match the signature' do
@zord.instance_variable_set(:@sender, Factory(:person))
@zord.instance_variable_set(:@sender, FactoryGirl.create(:person))
@zord.receive!.should == false
end
end

View file

@ -9,14 +9,14 @@ require File.join(Rails.root, 'lib/postzord/receiver/public')
describe Postzord::Receiver::Public do
before do
@post = Factory.build(:status_message, :author => alice.person, :public => true)
@post = FactoryGirl.build(:status_message, :author => alice.person, :public => true)
@created_salmon = Salmon::Slap.create_by_user_and_activity(alice, @post.to_diaspora_xml)
@xml = @created_salmon.xml_for(nil)
end
context 'round trips works with' do
it 'a comment' do
comment = bob.build_comment(:text => 'yo', :post => Factory(:status_message))
comment = bob.build_comment(:text => 'yo', :post => FactoryGirl.create(:status_message))
comment.save
xml = Salmon::Slap.create_by_user_and_activity(bob, comment.to_diaspora_xml).xml_for(nil)
comment.destroy
@ -91,7 +91,7 @@ describe Postzord::Receiver::Public do
describe '#receive_relayable' do
before do
@comment = bob.build_comment(:text => 'yo', :post => Factory(:status_message))
@comment = bob.build_comment(:text => 'yo', :post => FactoryGirl.create(:status_message))
@comment.save
created_salmon = Salmon::Slap.create_by_user_and_activity(alice, @comment.to_diaspora_xml)
xml = created_salmon.xml_for(nil)

View file

@ -13,7 +13,7 @@ describe RakeHelpers do
before do
Devise.mailer.deliveries = []
@old_admin = AppConfig[:admin_account]
AppConfig[:admin_account] = Factory(:user).username
AppConfig[:admin_account] = FactoryGirl.create(:user).username
end
after do

View file

@ -68,7 +68,7 @@ describe Salmon::Slap do
end
it 'verifies the signature for the sender' do
parsed_salmon.verified_for_key?(Factory(:person).public_key).should be_false
parsed_salmon.verified_for_key?(FactoryGirl.create(:person).public_key).should be_false
end
it 'contains the original data' do

View file

@ -25,14 +25,14 @@ describe Statistics do
describe '#posts_count_sql' do
it "pulls back an array of post counts and ids" do
Factory(:status_message, :author => bob.person)
FactoryGirl.create(:status_message, :author => bob.person)
result_should_equal User.connection.select_all(@stats.posts_count_sql)
end
end
describe '#comments_count_sql' do
it "pulls back an array of post counts and ids" do
status_message = Factory(:status_message, :author => alice.person)
status_message = FactoryGirl.create(:status_message, :author => alice.person)
bob.comment!(status_message, "sup")
result_should_equal User.connection.select_all(@stats.comments_count_sql)
end
@ -55,7 +55,7 @@ describe Statistics do
describe '#mentions_count_sql' do
it "pulls back an array of mentions following counts and ids" do
post = Factory(:status_message, :author => bob.person)
post = FactoryGirl.create(:status_message, :author => bob.person)
Mention.create(:post => post, :person => bob.person)
result_should_equal User.connection.select_all(@stats.mentions_count_sql)
end
@ -86,10 +86,10 @@ describe Statistics do
describe "#fb_connected_distribution_sql" do
it "pulls back an array of sign_in_counts, connected, uids" do
bob.sign_in_count = 1
bob.services << Factory(:service, :type => "Services::Facebook", :user => bob)
bob.services << FactoryGirl.create(:service, :type => "Services::Facebook", :user => bob)
bob.save!
eve.services << Factory(:service, :type => "Services::Facebook", :user => eve)
eve.services << FactoryGirl.create(:service, :type => "Services::Facebook", :user => eve)
eve.save!

View file

@ -25,7 +25,7 @@ describe Stream::Base do
before do
bob.post(:status_message, :text => "sup", :to => bob.aspects.first.id)
@liked_status = bob.posts.last
@like = Factory(:like, :target => @liked_status, :author => alice.person)
@like = FactoryGirl.create(:like, :target => @liked_status, :author => alice.person)
end
it "marks the posts as liked" do
@ -36,33 +36,33 @@ describe Stream::Base do
describe '.can_comment?' do
before do
@person = Factory(:person)
@person = FactoryGirl.create(:person)
@stream.stub(:people).and_return([bob.person, eve.person, @person])
end
it 'allows me to comment on my local contacts post' do
post = Factory(:status_message, :author => bob.person)
post = FactoryGirl.create(:status_message, :author => bob.person)
@stream.can_comment?(post).should be_true
end
it 'allows me to comment on my own post' do
post = Factory(:status_message, :author => alice.person)
post = FactoryGirl.create(:status_message, :author => alice.person)
@stream.can_comment?(post).should be_true
end
it 'allows me to comment on any local public post' do
post = Factory(:status_message, :author => eve.person)
post = FactoryGirl.create(:status_message, :author => eve.person)
@stream.can_comment?(post).should be_true
end
it 'allows me to comment on a remote contacts post' do
Contact.create!(:user => @stream.user, :person => @person)
post = Factory(:status_message, :author => @person)
post = FactoryGirl.create(:status_message, :author => @person)
@stream.can_comment?(post).should be_true
end
it 'returns false if person is remote and not a contact' do
post = Factory(:status_message, :author => @person)
post = FactoryGirl.create(:status_message, :author => @person)
@stream.can_comment?(post).should be_false
end
end

View file

@ -45,7 +45,7 @@ describe Stream::Multi do
context 'when invited by another user' do
before do
@user = Factory(:user, :invited_by => alice)
@user = FactoryGirl.create(:user, :invited_by => alice)
@inviter = alice.person
@stream = Stream::Multi.new(@user)

View file

@ -28,7 +28,7 @@ describe Stream::Tag do
end
it 'displays a public post that was sent to no one' do
stranger = Factory(:user_with_aspect)
stranger = FactoryGirl.create(:user_with_aspect)
stranger_post = stranger.post(:status_message, :text => "#what", :public => true, :to => 'all')
@stream.posts.should == [stranger_post]
end
@ -36,7 +36,7 @@ describe Stream::Tag do
it 'displays a post with a comment containing the tag search' do
pending "this code is way too slow. need to re-implement in a way that doesn't suck"
other_post = bob.post(:status_message, :text => "sup y'all", :to => 'all')
Factory(:comment, :text => "#what", :post => other_post)
FactoryGirl.create(:comment, :text => "#what", :post => other_post)
@stream.posts.should == [other_post]
end
end
@ -74,7 +74,7 @@ describe Stream::Tag do
describe 'shared behaviors' do
before do
@stream = Stream::Tag.new(Factory(:user), "test")
@stream = Stream::Tag.new(FactoryGirl.create(:user), "test")
end
it_should_behave_like 'it is a stream'
end

View file

@ -73,7 +73,7 @@ describe TemplatePicker do
TemplatePicker::TEMPLATES.each do |template|
describe "#{template} factory" do
it 'works' do
post = Factory.build(template.to_sym, :author => alice.person)
post = FactoryGirl.build(template.to_sym, :author => alice.person)
template_name = TemplatePicker.new(post).template_name.gsub('-', '_')
template_name.should == template
end

View file

@ -85,7 +85,7 @@ describe Webfinger do
describe 'existing_person_with_profile?' do
it 'returns true if cached_person is present and has a profile' do
finger.should_receive(:cached_person).twice.and_return(Factory(:person))
finger.should_receive(:cached_person).twice.and_return(FactoryGirl.create(:person))
finger.existing_person_with_profile?.should be_true
end
@ -95,7 +95,7 @@ describe Webfinger do
end
it 'returns false if the person has no profile' do
p = Factory(:person)
p = FactoryGirl.create(:person)
p.profile = nil
finger.stub(:cached_person).and_return(p)
finger.existing_person_with_profile?.should be_false

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe Notifier do
include ActionView::Helpers::TextHelper
let(:person) { Factory(:person) }
let(:person) { FactoryGirl.create(:person) }
before do
Notifier.deliveries = []
@ -23,7 +23,7 @@ describe Notifier do
before do
@users = []
5.times do
@users << Factory(:user)
@users << FactoryGirl.create(:user)
end
end
it 'has a body' do
@ -84,7 +84,7 @@ describe Notifier do
describe ".mentioned" do
before do
@user = alice
@sm = Factory(:status_message)
@sm = FactoryGirl.create(:status_message)
@m = Mention.create(:person => @user.person, :post=> @sm)
@mail = Notifier.mentioned(@user.id, @sm.author.id, @m.id)
@ -109,7 +109,7 @@ describe Notifier do
describe ".liked" do
before do
@sm = Factory(:status_message, :author => alice.person)
@sm = FactoryGirl.create(:status_message, :author => alice.person)
@like = @sm.likes.create!(:author => bob.person)
@mail = Notifier.liked(alice.id, @like.author.id, @like.id)
end
@ -131,13 +131,13 @@ describe Notifier do
end
it 'can handle a reshare' do
reshare = Factory(:reshare)
reshare = FactoryGirl.create(:reshare)
like = reshare.likes.create!(:author => bob.person)
mail = Notifier.liked(alice.id, like.author.id, like.id)
end
it 'can handle a activity streams photo' do
as_photo = Factory(:activity_streams_photo)
as_photo = FactoryGirl.create(:activity_streams_photo)
like = as_photo.likes.create!(:author => bob.person)
mail = Notifier.liked(alice.id, like.author.id, like.id)
end
@ -145,8 +145,8 @@ describe Notifier do
describe ".reshared" do
before do
@sm = Factory(:status_message, :author => alice.person, :public => true)
@reshare = Factory(:reshare, :root => @sm, :author => bob.person)
@sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true)
@reshare = FactoryGirl.create(:reshare, :root => @sm, :author => bob.person)
@mail = Notifier.reshared(alice.id, @reshare.author.id, @reshare.id)
end
@ -248,7 +248,7 @@ describe Notifier do
[:reshare, :activity_streams_photo].each do |post_type|
context post_type.to_s do
let(:commented_post) { Factory(post_type, :author => bob.person) }
let(:commented_post) { FactoryGirl.create(post_type, :author => bob.person) }
it 'succeeds' do
proc {
comment_mail
@ -288,7 +288,7 @@ describe Notifier do
end
[:reshare, :activity_streams_photo].each do |post_type|
context post_type.to_s do
let(:commented_post) { Factory(post_type, :author => bob.person) }
let(:commented_post) { FactoryGirl.create(post_type, :author => bob.person) }
it 'succeeds' do
proc {
comment_mail

View file

@ -6,7 +6,7 @@ require 'spec_helper'
describe 'making sure the spec runner works' do
it 'factory creates a user with a person saved' do
user = Factory(:user)
user = FactoryGirl.create(:user)
loaded_user = User.find(user.id)
loaded_user.person.owner_id.should == user.id
end

View file

@ -61,9 +61,9 @@ describe AccountDeletion do
it 'includes remote resharers' do
@ad = AccountDeletion.new(:person => alice.person)
sm = Factory( :status_message, :public => true, :author => alice.person)
r1 = Factory( :reshare, :author => remote_raphael, :root => sm)
r2 = Factory( :reshare, :author => local_luke.person, :root => sm)
sm = FactoryGirl.create( :status_message, :public => true, :author => alice.person)
r1 = FactoryGirl.create( :reshare, :author => remote_raphael, :root => sm)
r2 = FactoryGirl.create( :reshare, :author => local_luke.person, :root => sm)
@ad.subscribers(alice).should == [remote_raphael]
end

View file

@ -29,7 +29,7 @@ JSON
describe 'serialization' do
before do
@photo = Factory(:activity_streams_photo)
@photo = FactoryGirl.create(:activity_streams_photo)
xml = @photo.to_diaspora_xml.to_s
@marshalled = Diaspora::Parser.from_xml(xml)
end

View file

@ -68,7 +68,7 @@ describe Comment do
describe 'xml' do
before do
@commenter = Factory(:user)
@commenter = FactoryGirl.create(:user)
@commenter_aspect = @commenter.aspects.create(:name => "bruisers")
connect_users(alice, @alices_aspect, @commenter, @commenter_aspect)
@post = alice.post :status_message, :text => "hello", :to => @alices_aspect.id
@ -102,7 +102,7 @@ describe Comment do
describe 'it is relayable' do
before do
@local_luke, @local_leia, @remote_raphael = set_up_friends
@remote_parent = Factory(:status_message, :author => @remote_raphael)
@remote_parent = FactoryGirl.create(:status_message, :author => @remote_raphael)
@local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
@object_by_parent_author = @local_luke.comment!(@local_parent, "yo")
@ -118,7 +118,7 @@ describe Comment do
describe 'tags' do
before do
@object = Factory.build(:comment)
@object = FactoryGirl.build(:comment)
end
it_should_behave_like 'it is taggable'
end

View file

@ -35,7 +35,7 @@ describe Contact do
end
it 'validates uniqueness' do
person = Factory(:person)
person = FactoryGirl.create(:person)
contact2 = alice.contacts.create(:person=>person)
contact2.should be_valid
@ -46,7 +46,7 @@ describe Contact do
end
it "validates that the person's account is not closed" do
person = Factory(:person, :closed_account => true)
person = FactoryGirl.create(:person, :closed_account => true)
contact = alice.contacts.new(:person=>person)
@ -59,8 +59,8 @@ describe Contact do
describe 'sharing' do
it 'returns contacts with sharing true' do
lambda {
alice.contacts.create!(:sharing => true, :person => Factory(:person))
alice.contacts.create!(:sharing => false, :person => Factory(:person))
alice.contacts.create!(:sharing => true, :person => FactoryGirl.create(:person))
alice.contacts.create!(:sharing => false, :person => FactoryGirl.create(:person))
}.should change{
Contact.sharing.count
}.by(1)
@ -70,8 +70,8 @@ describe Contact do
describe 'receiving' do
it 'returns contacts with sharing true' do
lambda {
alice.contacts.create!(:receiving => true, :person => Factory(:person))
alice.contacts.create!(:receiving => false, :person => Factory(:person))
alice.contacts.create!(:receiving => true, :person => FactoryGirl.create(:person))
alice.contacts.create!(:receiving => false, :person => FactoryGirl.create(:person))
}.should change{
Contact.receiving.count
}.by(1)
@ -81,10 +81,10 @@ describe Contact do
describe 'only_sharing' do
it 'returns contacts with sharing true and receiving false' do
lambda {
alice.contacts.create!(:receiving => true, :sharing => true, :person => Factory(:person))
alice.contacts.create!(:receiving => false, :sharing => true, :person => Factory(:person))
alice.contacts.create!(:receiving => false, :sharing => true, :person => Factory(:person))
alice.contacts.create!(:receiving => true, :sharing => false, :person => Factory(:person))
alice.contacts.create!(:receiving => true, :sharing => true, :person => FactoryGirl.create(:person))
alice.contacts.create!(:receiving => false, :sharing => true, :person => FactoryGirl.create(:person))
alice.contacts.create!(:receiving => false, :sharing => true, :person => FactoryGirl.create(:person))
alice.contacts.create!(:receiving => true, :sharing => false, :person => FactoryGirl.create(:person))
}.should change{
Contact.receiving.count
}.by(2)
@ -93,9 +93,9 @@ describe Contact do
describe "all_contacts_of_person" do
it 'returns all contacts where the person is the passed in person' do
person = Factory(:person)
contact1 = Factory(:contact, :person => person)
contact2 = Factory(:contact)
person = FactoryGirl.create(:person)
contact1 = FactoryGirl.create(:contact, :person => person)
contact2 = FactoryGirl.create(:contact)
contacts = Contact.all_contacts_of_person(person)
contacts.should == [contact1]
end
@ -117,12 +117,12 @@ describe Contact do
@people2 = []
1.upto(5) do
person = Factory(:person)
person = FactoryGirl.create(:person)
@bob.contacts.create(:person => person, :aspects => [@original_aspect])
@people1 << person
end
1.upto(5) do
person = Factory(:person)
person = FactoryGirl.create(:person)
@bob.contacts.create(:person => person, :aspects => [@new_aspect])
@people2 << person
end
@ -166,8 +166,8 @@ describe Contact do
context 'requesting' do
before do
@contact = Contact.new
@user = Factory(:user)
@person = Factory(:person)
@user = FactoryGirl.create(:user)
@person = FactoryGirl.create(:person)
@contact.user = @user
@contact.person = @person

View file

@ -2,17 +2,17 @@ require 'spec_helper'
describe InvitationCode do
it 'has a valid factory' do
Factory(:invitation_code).should be_valid
FactoryGirl.create(:invitation_code).should be_valid
end
it 'sets the count to a default value' do
code = Factory(:invitation_code)
code = FactoryGirl.create(:invitation_code)
code.count.should > 0
end
describe '#use!' do
it 'decrements the count of the code' do
code = Factory(:invitation_code)
code = FactoryGirl.create(:invitation_code)
expect{
code.use!
@ -22,7 +22,7 @@ describe InvitationCode do
describe '.beta?' do
it 'returns true if the invite code user is beta' do
code = Factory(:invitation_code)
code = FactoryGirl.create(:invitation_code)
Role.add_beta(code.user.person)
code.user.should be_beta
code.should be_beta

View file

@ -13,7 +13,7 @@ describe Invitation do
end
describe 'validations' do
before do
@invitation = Factory.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de")
@invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de")
end
it 'is valid' do
@ -25,25 +25,25 @@ describe Invitation do
end
it 'ensures the sender is placing the recipient into one of his aspects' do
@invitation.aspect = Factory(:aspect)
@invitation.aspect = FactoryGirl.create(:aspect)
@invitation.should_not be_valid
end
end
describe '#language' do
it 'returns the correct language if the language is set' do
@invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de")
@invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de")
@invitation.language.should == "de"
end
it 'returns en if no language is set' do
@invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first)
@invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first)
@invitation.language.should == "en"
end
end
it 'has a message' do
@invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language)
@invitation = FactoryGirl.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language)
@invitation.message = "!"
@invitation.message.should == "!"
end
@ -62,7 +62,7 @@ describe Invitation do
end
it 'shares with people who are already on the pod' do
Factory(:user, :email => @emails.first)
FactoryGirl.create(:user, :email => @emails.first)
invites = nil
expect{
invites = Invitation.batch_invite(@emails, @opts)

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe Jobs::FetchProfilePhoto do
before do
@user = alice
@service = Factory(:service, :user => alice)
@service = FactoryGirl.create(:service, :user => alice)
@url = "https://service.com/user/profile_image"

View file

@ -22,7 +22,7 @@ describe Jobs::GatherOEmbedData do
@no_oembed_url = 'http://www.we-do-not-support-oembed.com/index.html'
@status_message = Factory(:status_message)
@status_message = FactoryGirl.create(:status_message)
stub_request(:get, @flickr_oembed_get_request).to_return(:status => 200, :body => @flickr_oembed_data.to_json)
stub_request(:get, @no_oembed_url).to_return(:status => 200, :body => '<html><body>hello there</body></html>')

View file

@ -9,7 +9,7 @@ describe Jobs::HttpMulti do
end
before do
@people = [Factory(:person), Factory(:person)]
@people = [FactoryGirl.create(:person), FactoryGirl.create(:person)]
@post_xml = Base64.encode64("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH")

View file

@ -8,7 +8,7 @@ describe Jobs::Mail::Mentioned do
describe '#perfom' do
it 'should call .deliver on the notifier object' do
user = alice
sm = Factory(:status_message)
sm = FactoryGirl.create(:status_message)
m = Mention.new(:person => user.person, :post=> sm)
mail_mock = mock()

View file

@ -7,8 +7,8 @@ require 'spec_helper'
describe Jobs::Mail::Reshared do
describe '#perfom' do
it 'should call .deliver on the notifier object' do
sm = Factory(:status_message, :author => bob.person, :public => true)
reshare = Factory(:reshare, :author => alice.person, :root=> sm)
sm = FactoryGirl.create(:status_message, :author => bob.person, :public => true)
reshare = FactoryGirl.create(:reshare, :author => alice.person, :root=> sm)
mail_mock = mock()
mail_mock.should_receive(:deliver)

View file

@ -7,8 +7,8 @@ require 'spec_helper'
describe Jobs::NotifyLocalUsers do
describe '#perfom' do
it 'should call Notification.notify for each participant user' do
person = Factory :person
post = Factory :status_message
person = FactoryGirl.create:person
post = FactoryGirl.create:status_message
StatusMessage.should_receive(:find_by_id).with(post.id).and_return(post)
#User.should_receive(:where).and_return([alice, eve])

View file

@ -56,7 +56,7 @@ describe Jobs::ProcessPhoto do
end
it 'does not throw an error if it is called on a remote photo' do
p = Factory(:remote_photo)
p = FactoryGirl.create(:remote_photo)
p.unprocessed_image = nil
expect{
result = Jobs::ProcessPhoto.perform(p.id)

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe Jobs::Receive do
before do
@user = alice
@person = Factory(:person)
@person = FactoryGirl.create(:person)
@xml = '<xml></xml>'
User.stub(:find){ |id|
if id == @user.id

View file

@ -7,7 +7,7 @@ require 'spec_helper'
describe Jobs::ResendInvitation do
describe '#perfom' do
it 'should call .resend on the object' do
invite = Factory(:invitation, :service => 'email', :identifier => 'foo@bar.com')
invite = FactoryGirl.create(:invitation, :service => 'email', :identifier => 'foo@bar.com')
Invitation.stub(:find).and_return(invite)
invite.should_receive(:resend)

View file

@ -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 = Factory :user
user = FactoryGirl.create:user
expect {
mail = Jobs::ResetPassword.perform(user.id)
mail.to.should == [user.email]

View file

@ -11,7 +11,7 @@ describe Like do
end
it 'has a valid factory' do
Factory(:like).should be_valid
FactoryGirl.create(: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 = Factory(:comment, :post => @status)
comment = FactoryGirl.create(: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 = Factory(:user)
@liker = FactoryGirl.create(: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 = Factory(:status_message, :author => @remote_raphael)
@remote_parent = FactoryGirl.create(: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)

View file

@ -6,8 +6,8 @@ require 'spec_helper'
describe Notification do
before do
@sm = Factory(:status_message)
@person = Factory(:person)
@sm = FactoryGirl.create(:status_message)
@person = FactoryGirl.create(: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 = Factory(:user)
user2 = FactoryGirl.create(: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 = 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)
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)
notification.id.should == notification2.id
end
end
context 'multiple comments' do
it 'concatinates the comment notifications' do
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)
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)
notification.id.should == notification2.id
end
end

View file

@ -6,9 +6,9 @@ require 'spec_helper'
describe Notifications::Reshared do
before do
@sm = Factory(:status_message, :author => alice.person, :public => true)
@reshare1 = Factory(:reshare, :root => @sm)
@reshare2 = Factory(:reshare, :root => @sm)
@sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true)
@reshare1 = FactoryGirl.create(:reshare, :root => @sm)
@reshare2 = FactoryGirl.create(:reshare, :root => @sm)
end
describe 'Notification.notify' do

View file

@ -7,7 +7,7 @@ require 'spec_helper'
describe OAuth2::Provider::Models::ActiveRecord::Authorization do
describe 'validations'do
before do
@client = Factory(:app)
@client = FactoryGirl.create(:app)
end
it 'validates uniqueness on resource owner and client' do

View file

@ -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 = Factory(:status_message, :author => @remote_raphael)
@remote_parent = FactoryGirl.create(: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)

View file

@ -8,7 +8,7 @@ describe Person do
before do
@user = bob
@person = Factory(:person)
@person = FactoryGirl.create(: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 = Factory(:status_message, :author => alice.person, :public => true)
reshare = Factory(:reshare, :root => sm)
sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true)
reshare = FactoryGirl.create(: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 = Factory(:person, :url => "https://example.com")
person = FactoryGirl.create(:person, :url => "https://example.com")
person.should be_valid
end
it 'should always return the correct receive url' do
person = Factory(:person, :url => "https://example.com/a/bit/messed/up")
person = FactoryGirl.create(: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(:person, :url => "https://example.com:3000/")
person = FactoryGirl.create(: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 = Factory.build(:person, :diaspora_handle => @person.diaspora_handle)
person_two = FactoryGirl.build(:person, :diaspora_handle => @person.diaspora_handle)
person_two.should_not be_valid
end
it 'is case insensitive' do
person_two = Factory.build(:person, :diaspora_handle => @person.diaspora_handle.upcase)
person_two = FactoryGirl.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 = Factory(:status_message, :author => @person)
person_two = Factory(:person)
person_message = FactoryGirl.create(:status_message, :author => @person)
person_two = FactoryGirl.create(: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 = Factory(:user)
@user2 = FactoryGirl.create(: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 = Factory(:user_with_aspect)
@user = FactoryGirl.create(:user_with_aspect)
user_profile = @user.person.profile
user_profile.first_name = "aiofj"
user_profile.last_name = "asdji"
user_profile.save
@robert_grimm = Factory(:searchable_person)
@eugene_weinstein = Factory(:searchable_person)
@yevgeniy_dodis = Factory(:searchable_person)
@casey_grippi = Factory(:searchable_person)
@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.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 = Factory(:person, :profile => Factory.build(:profile, :searchable => false, :first_name => "johnson"))
invisible_person = FactoryGirl.create(:person, :profile => FactoryGirl.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) { Factory(:user) }
let(:person) { Factory(:person) }
let(:user) { FactoryGirl.create(:user) }
let(:person) { FactoryGirl.create(: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 = Factory(:user, :username => "SaMaNtHa")
user = FactoryGirl.create(:user, :username => "SaMaNtHa")
person = Person.by_account_identifier(user.person.diaspora_handle)
person.should == user.person
end
it "is case insensitive" do
user1 = Factory(:user, :username => "SaMaNtHa")
user1 = FactoryGirl.create(: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 = Factory(:user, :username => "SaMaNtHa")
person = Factory(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com")
user = FactoryGirl.create(:user, :username => "SaMaNtHa")
person = FactoryGirl.create(: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 = Factory(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com")
person1 = Factory(:person, :diaspora_handle => "tom@tom.joindiaspora.comm")
person = FactoryGirl.create(:person, :diaspora_handle => "tomtom@tom.joindiaspora.com")
person1 = FactoryGirl.create(: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 = Factory(:person)
@person = FactoryGirl.create(:person)
end
it 'calls Profile#tombstone!' do

View file

@ -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 => Factory(:person))
@photo.update_attributes(:author => FactoryGirl.create(: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 => Factory(:person).id)
@photo.update_attributes(:author_id => FactoryGirl.create(: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 = Factory(:user)
user2 = FactoryGirl.create(:user)
aspect2 = user2.aspects.create(:name => "foobars")
connect_users(@user, @aspect, user2, aspect2)

View file

@ -14,10 +14,10 @@ describe Post do
describe '.owned_or_visible_by_user' do
before do
@you = bob
@public_post = Factory(:status_message, :public => true)
@your_post = Factory(:status_message, :author => @you.person)
@public_post = FactoryGirl.create(:status_message, :public => true)
@your_post = FactoryGirl.create(:status_message, :author => @you.person)
@post_from_contact = eve.post(:status_message, :text => 'wooo', :to => eve.aspects.where(:name => 'generic').first)
@post_from_stranger = Factory(:status_message, :public => false)
@post_from_stranger = FactoryGirl.create(: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 = Factory(:status_message, :author => eve.person, :public => true)
sm = FactoryGirl.create(: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 = Factory(:status_message, :author => alice.person)
@other_post = Factory(:status_message, :author => eve.person)
@post = FactoryGirl.create(:status_message, :author => alice.person)
@other_post = FactoryGirl.create(: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 = Factory(:status_message, :author => alice.person)
@other_post = Factory(:status_message, :author => eve.person)
@post = FactoryGirl.create(:status_message, :author => alice.person)
@other_post = FactoryGirl.create(: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 = Factory(:status_message)
Factory.build(:status_message, :guid => message.guid).should_not be_valid
message = FactoryGirl.create(:status_message)
FactoryGirl.build(:status_message, :guid => message.guid).should_not be_valid
end
end
describe 'post_type' do
it 'returns the class constant' do
status_message = Factory(:status_message)
status_message = FactoryGirl.create(:status_message)
status_message.post_type.should == "StatusMessage"
end
end
describe 'deletion' do
it 'should delete a posts comments on delete' do
post = Factory(:status_message, :author => @user.person)
post = FactoryGirl.create(: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 = Factory.build(:status_message, :provider_display_name => 'mobile')
sm = FactoryGirl.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 = Factory(:status_message, :author => bob.person)
@post = FactoryGirl.create(: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 = Factory.build(:status_message, :author => bob.person)
@post = FactoryGirl.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 = Factory.build(:status_message, :author => bob.person)
@post = FactoryGirl.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 = Factory(:reshare, :root => @post)
@reshare = FactoryGirl.create(: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
Factory(:reshare, :root => @post)
Factory(:reshare, :root => @post)
Factory(:reshare, :root => @post)
FactoryGirl.create(:reshare, :root => @post)
FactoryGirl.create(:reshare, :root => @post)
FactoryGirl.create(: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 = Factory(:status_message)
post = FactoryGirl.create(:status_message)
post.interacted_at.should_not be_blank
end
end

View file

@ -8,23 +8,23 @@ describe Profile do
describe 'validation' do
describe "of first_name" do
it "strips leading and trailing whitespace" do
profile = Factory.build(:profile, :first_name => " Shelly ")
profile = FactoryGirl.build(:profile, :first_name => " Shelly ")
profile.should be_valid
profile.first_name.should == "Shelly"
end
it "can be 32 characters long" do
profile = Factory.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon")
profile = FactoryGirl.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon")
profile.should be_valid
end
it "cannot be 33 characters" do
profile = Factory.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon")
profile = FactoryGirl.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon")
profile.should_not be_valid
end
it 'cannot have ;' do
profile = Factory.build(:profile, :first_name => "Hex;agon")
profile = FactoryGirl.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 = Factory(:person).profile
profile = FactoryGirl.create(: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 = Factory(:person).profile
profile = FactoryGirl.create(: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 = Factory(:person).profile
profile = FactoryGirl.create(: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 = Factory.build(:profile, :last_name => " Ohba ")
profile = FactoryGirl.build(:profile, :last_name => " Ohba ")
profile.should be_valid
profile.last_name.should == "Ohba"
end
it "can be 32 characters long" do
profile = Factory.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon")
profile = FactoryGirl.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon")
profile.should be_valid
end
it "cannot be 33 characters" do
profile = Factory.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon")
profile = FactoryGirl.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon")
profile.should_not be_valid
end
it 'cannot have ;' do
profile = Factory.build(:profile, :last_name => "Hex;agon")
profile = FactoryGirl.build(:profile, :last_name => "Hex;agon")
profile.should_not be_valid
end
it 'disallows ; with a newline in the string' do
profile = Factory.build(:profile, :last_name => "H\nex;agon")
profile = FactoryGirl.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 = Factory.build(:profile)
@profile = FactoryGirl.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 = Factory.build(:profile)
@profile = FactoryGirl.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) {Factory(:person,:diaspora_handle => "foobar" )}
let(:person) {FactoryGirl.create(: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 = Factory.build(:profile)
@profile = FactoryGirl.build(:profile)
end
it 'returns a default rather than nil' do
@ -197,7 +197,7 @@ describe Profile do
end
describe 'date=' do
let(:profile) { Factory.build(:profile) }
let(:profile) { FactoryGirl.build(:profile) }
it 'accepts form data' do
profile.birthday = nil
@ -244,7 +244,7 @@ describe Profile do
describe 'tags' do
before do
person = Factory(:person)
person = FactoryGirl.create(:person)
@object = person.profile
end
it 'allows 5 tags' do
@ -265,7 +265,7 @@ describe Profile do
describe '#formatted_birthday' do
before do
@profile = Factory.build(:profile)
@profile = FactoryGirl.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 = Factory.build :profile
new_profile = FactoryGirl.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 = Factory.build :profile
profile = FactoryGirl.build :profile
profile.send(:clearable_fields).sort.should ==
["diaspora_handle",
"first_name",

View file

@ -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(:status_message, :author => @remote_raphael)
@remote_parent = FactoryGirl.create(:status_message, :author => @remote_raphael)
@local_parent = @local_luke.post :status_message, :text => "hi", :to => @local_luke.aspects.first
end

View file

@ -49,7 +49,7 @@ describe Request do
describe '#notification_type' do
it 'returns request_accepted' do
person = Factory :person
person = FactoryGirl.create: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 = Factory :contact, :user => alice, :person => eve.person,
contact = FactoryGirl.create:contact, :user => alice, :person => eve.person,
:receiving => true, :sharing => false
contact.save

View file

@ -9,28 +9,28 @@ describe Reshare do
it 'has a valid Factory' do
Factory(:reshare).should be_valid
FactoryGirl.create(:reshare).should be_valid
end
it 'requires root' do
reshare = Factory.build(:reshare, :root => nil)
reshare = FactoryGirl.build(:reshare, :root => nil)
reshare.should_not be_valid
end
it 'require public root' do
reshare = Factory.build(:reshare, :root => Factory.build(:status_message, :public => false))
reshare = FactoryGirl.build(:reshare, :root => FactoryGirl.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
Factory(:reshare, :public => false).public.should be_true
FactoryGirl.create(:reshare, :public => false).public.should be_true
end
describe "#receive" do
let(:receive) {@reshare.receive(@root.author.owner, @reshare.author)}
before do
@reshare = Factory(:reshare, :root => Factory(:status_message, :author => bob.person, :public => true))
@reshare = FactoryGirl.create(:reshare, :root => FactoryGirl.create(:status_message, :author => bob.person, :public => true))
@root = @reshare.root
end
@ -55,10 +55,10 @@ describe Reshare do
describe '#nsfw' do
before do
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)
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)
end
it 'deletates #nsfw to the root post' do
@ -69,8 +69,8 @@ describe Reshare do
describe '#notification_type' do
before do
sm = Factory(:status_message, :author => alice.person, :public => true)
@reshare = Factory(:reshare, :root => sm)
sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true)
@reshare = FactoryGirl.create(: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 = Factory(:reshare)
@reshare = FactoryGirl.create(: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 = Factory(:reshare)
reshare = FactoryGirl.create(: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 = Factory(:person)
different_person = FactoryGirl.create(:person)
wf_prof_mock = mock
wf_prof_mock.should_receive(:fetch).and_return(different_person)

View file

@ -32,7 +32,7 @@ describe Retraction do
end
it 'does not return the authors of reshares' do
@post.reshares << Factory(:reshare, :root => @post, :author => bob.person)
@post.reshares << FactoryGirl.create(:reshare, :root => @post, :author => bob.person)
@post.save!
@wanted_subscribers -= [bob.person]

View file

@ -7,7 +7,7 @@ require 'spec_helper'
describe ShareVisibility do
describe '.batch_import' do
before do
@post = Factory(:status_message, :author => alice.person)
@post = FactoryGirl.create(:status_message, :author => alice.person)
@contact = bob.contact_for(alice.person)
end

View file

@ -2,9 +2,9 @@ require 'spec_helper'
describe SignedRetraction do
before do
@post = Factory(:status_message, :author => bob.person, :public => true)
@resharer = Factory(:user)
@post.reshares << Factory(:reshare, :root => @post, :author => @resharer.person)
@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.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 = Factory(:status_message, :public => true)
remote_post = FactoryGirl.create(:status_message, :public => true)
bob.post(:reshare, :root_guid => remote_post.guid)
alice.post(:reshare, :root_guid => remote_post.guid)

View file

@ -23,9 +23,9 @@ describe StatusMessage do
@bo = bob.person
@test_string = "@{Daniel; #{@bo.diaspora_handle}} can mention people like Raph"
Factory(:status_message, :text => @test_string )
Factory(:status_message, :text => @test_string )
Factory(:status_message)
FactoryGirl.create(:status_message, :text => @test_string )
FactoryGirl.create(:status_message, :text => @test_string )
FactoryGirl.create(: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 = 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" )
@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" )
@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 = Factory(:status_message, :author => alice.person)
sm2 = Factory(:status_message, :author => bob.person)
sm1 = FactoryGirl.create(:status_message, :author => alice.person)
sm2 = FactoryGirl.create(: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 = Factory.build(:status_message)
status = FactoryGirl.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 = Factory.build(:status_message)
status = FactoryGirl.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 = Factory(:person)
post = Factory(:status_message, :author => @user.person)
person = FactoryGirl.create(:person)
post = FactoryGirl.create(: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 = Factory.build(:status_message, :text => nil)
n = FactoryGirl.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 = Factory.build(:status_message, :text => message)
status_message = FactoryGirl.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 = Factory(:status_message, :text => @test_string )
@sm = FactoryGirl.create(: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 = Factory(:status_message, :text => "@{Barack Obama; barak@joindiaspora.com } is so cool @{Barack Obama; barak@joindiaspora.com } ")
status = FactoryGirl.create(: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?(Factory(:person)).should be_false
@sm.mentions?(FactoryGirl.create(:person)).should be_false
end
end
describe "#nsfw" do
it 'returns MatchObject (true) if the post contains #nsfw (however capitalised)' do
status = Factory(:status_message, :text => "This message is #nSFw")
status = FactoryGirl.create(: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 = Factory(:status_message, :text => "This message is #sFW")
status = FactoryGirl.create(: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 = Factory.build(:status_message)
@object = FactoryGirl.build(:status_message)
end
it_should_behave_like 'it is taggable'
end
describe "XML" do
before do
@message = Factory(:status_message, :text => "I hate WALRUSES!", :author => @user.person)
@message = FactoryGirl.create(: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 = Factory.build(:status_message, :text => @message_text)
sm = FactoryGirl.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 = Factory(:status_message, :text => @message_text)
sm = FactoryGirl.create(:status_message, :text => @message_text)
sm.contains_oembed_url_in_text?.should_not be_nil
sm.oembed_url.should == @youtube_url
end

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe TagFollowing do
before do
@tag = Factory(:tag)
@tag = FactoryGirl.create(:tag)
TagFollowing.create!(:tag => @tag, :user => alice)
end

View file

@ -8,13 +8,13 @@ describe User::Connecting do
let(:aspect) { alice.aspects.first }
let(:aspect1) { alice.aspects.create(:name => 'other') }
let(:person) { Factory(:person) }
let(:person) { FactoryGirl.create(:person) }
let(:aspect2) { eve.aspects.create(:name => "aspect two") }
let(:person_one) { Factory :person }
let(:person_two) { Factory :person }
let(:person_three) { Factory :person }
let(:person_one) { FactoryGirl.create:person }
let(:person_two) { FactoryGirl.create:person }
let(:person_three) { FactoryGirl.create: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([Factory(:status_message)])
Post.stub_chain(:where, :limit).and_return([FactoryGirl.create(: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 = Factory(:notification, :target => eve.person)
notification = FactoryGirl.create(:notification, :target => eve.person)
Notification.where(:target_id => eve.person.id).first.unread.should be_true
alice.share_with(eve.person, aspect)

View file

@ -110,7 +110,7 @@ describe User::Querying do
describe "#visible_shareables" do
it 'never contains posts from people not in your aspects' do
Factory(:status_message, :public => true)
FactoryGirl.create(: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 = Factory(:user)
local_user2 = Factory(:user)
remote_user = Factory(:user)
local_user1 = FactoryGirl.create(:user)
local_user2 = FactoryGirl.create(:user)
remote_user = FactoryGirl.create(: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 { Factory(:user) }
3.times { FactoryGirl.create(: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) { Factory :person }
let(:person_two) { Factory :person }
let(:person_three) { Factory :person }
let(:person_one) { FactoryGirl.create:person }
let(:person_two) { FactoryGirl.create:person }
let(:person_three) { FactoryGirl.create: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 = Factory(:user)
@user3 = FactoryGirl.create(:user)
@aspect3 = @user3.aspects.create(:name => "bros")
@public_message = @user3.post(:status_message, :text => "hey there", :to => 'all', :public => true)

View file

@ -39,7 +39,7 @@ describe User do
describe 'hidden_shareables' do
before do
@sm = Factory(:status_message)
@sm = FactoryGirl.create(: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 = Factory(:status_message)
sm2 = FactoryGirl.create(: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 = Factory(:photo)
photo = FactoryGirl.create(: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 = Factory(:status_message)
post = FactoryGirl.create(: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 = Factory(:status_message)
post = FactoryGirl.create(: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 = Factory(:user, :id => alice.id)
new_user = FactoryGirl.create(: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 = Factory(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}")
p = FactoryGirl.create(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}")
alice.username = 'jimmy'
alice.should_not be_valid
end
it "downcases username" do
user = Factory.build(:user, :username => "WeIrDcAsE")
user = FactoryGirl.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 = Factory.build(:user, :username => " janie ")
user = FactoryGirl.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) {Factory :person}
let(:person) {FactoryGirl.create: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 = Factory(:user)
user = FactoryGirl.create(: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 = Factory(:status_message, :author => bob.person)
@post = FactoryGirl.create(: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 = Factory(:status_message, :author => eve.person)
@post = FactoryGirl.create(: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
Factory(:invitation, :sender => alice)
FactoryGirl.create(: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 = Factory(:status_message, :author => bob.person, :public => true)
@post = FactoryGirl.create(: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 = Factory(:person)
reshare = Factory(:reshare, :root => @post, :author => person)
person = FactoryGirl.create(:person)
reshare = FactoryGirl.create(: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 = Factory :user
user = FactoryGirl.create: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 = Factory :user
user = FactoryGirl.create:user
user.send(:clearable_fields).sort.should == %w{
language
invitation_token

View file

@ -1,7 +1,7 @@
require 'spec_helper'
describe OEmbedPresenter do
before do
@oembed = OEmbedPresenter.new(Factory(:status_message))
@oembed = OEmbedPresenter.new(FactoryGirl.create(: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(Factory(:status_message), :maxwidth => 200, :maxheight => 300).as_json
oembed = OEmbedPresenter.new(FactoryGirl.create(:status_message), :maxwidth => 200, :maxheight => 300).as_json
oembed[:width].should == 200
oembed[:height].should == 300
end

View file

@ -1,7 +1,7 @@
require "spec_helper"
describe PersonPresenter do
let(:profile_user) { Factory(:user_with_aspect) }
let(:profile_user) { FactoryGirl.create(: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) { Factory(:user)}
let(:current_user) { FactoryGirl.create(:user)}
let(:presenter){ PersonPresenter.new(person, current_user) }
it "doesn't share private information when the users aren't connected" do

View file

@ -2,7 +2,7 @@ require 'spec_helper'
describe PostPresenter do
before do
@sm = Factory(:status_message, :public => true)
@sm = FactoryGirl.create(: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 = Factory :reshare
reshare = FactoryGirl.create:reshare
reshare.root = nil
expect {
PostPresenter.new(reshare).root

View file

@ -8,27 +8,27 @@ FixtureBuilder.configure do |fbuilder|
# now declare objects
fbuilder.factory do
# Users
alice = Factory(:user_with_aspect, :username => "alice")
alice = FactoryGirl.create(:user_with_aspect, :username => "alice")
alices_aspect = alice.aspects.where(:name => "generic").first
eve = Factory(:user_with_aspect, :username => "eve")
eve = FactoryGirl.create(:user_with_aspect, :username => "eve")
eves_aspect = eve.aspects.where(:name => "generic").first
bob = Factory(:user_with_aspect, :username => "bob")
bob = FactoryGirl.create(:user_with_aspect, :username => "bob")
bobs_aspect = bob.aspects.where(:name => "generic").first
Factory(:aspect, :name => "empty", :user => bob)
FactoryGirl.create(: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 = Factory(:user_with_aspect, :username => "luke")
local_luke = FactoryGirl.create(:user_with_aspect, :username => "luke")
lukes_aspect = local_luke.aspects.where(:name => "generic").first
local_leia = Factory(:user_with_aspect, :username => "leia")
local_leia = FactoryGirl.create(:user_with_aspect, :username => "leia")
leias_aspect = local_leia.aspects.where(:name => "generic").first
remote_raphael = Factory(:person, :diaspora_handle => "raphael@remote.net")
remote_raphael = FactoryGirl.create(:person, :diaspora_handle => "raphael@remote.net")
connect_users_with_aspects(local_luke, local_leia)