Commit 58d14480 authored by Jonne Haß's avatar Jonne Haß
Browse files

update factory girl

parent 2de0213d
......@@ -149,7 +149,7 @@ group :test do
gem 'database_cleaner', '0.8'
gem 'timecop'
gem 'factory_girl_rails', '1.7.0'
gem 'factory_girl_rails', '4.0.0'
gem 'fixture_builder', '0.3.4'
gem 'fuubar', '>= 1.0'
gem 'rspec-instafail', '>= 0.1.7', :require => false
......
......@@ -159,10 +159,10 @@ GEM
excon (0.14.3)
execjs (1.4.0)
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 (4.0.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.0.0)
factory_girl (~> 4.0.0)
railties (>= 3.0.0)
faraday (0.8.1)
multipart-post (~> 1.1)
......@@ -483,7 +483,7 @@ DEPENDENCIES
database_cleaner (= 0.8)
debugger
devise (= 1.5.3)
factory_girl_rails (= 1.7.0)
factory_girl_rails (= 4.0.0)
faraday
faraday_middleware
fastercsv (= 1.5.5)
......
......@@ -11,14 +11,14 @@ module FactoryMethods
else
table.hashes
end
klass = Factory.factories[factory_name].class_name.to_s.classify.constantize
klass = FactoryGirl.factories[factory_name].class_name.to_s.classify.constantize
@they = hashes.map do |hash|
hash = hash.merge(extra).inject({}) do |h,(k,v)|
k = k.gsub(/\W+/,'_')
v = v.split(/\s*,\s*/) if klass.serialized_attributes[k] == Array
h.update(k.to_sym => v)
end
object = Factory.build(factory_name, hash)
object = FactoryGirl.build(factory_name, hash)
yield object if block_given?
object.save!
object
......
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')
......
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")
......@@ -40,14 +40,14 @@ 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!
......@@ -100,8 +100,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
......@@ -157,7 +157,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)
......@@ -176,7 +176,7 @@ Given /^I have (\d+) contacts$/ do |n|
aspect_memberships = []
count.times do
person = Factory(:person)
person = FactoryGirl.create(:person)
people << person
end
......@@ -200,7 +200,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
......
......@@ -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
......
......@@ -10,7 +10,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
......@@ -31,7 +31,7 @@ module UserCukeHelpers
# create a new @me user, if not present, and log in using the
# integration_sessions controller (automatic)
def automatic_login
@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))
click_button "Login"
end
......
......@@ -6,7 +6,7 @@ require 'spec_helper'
describe AdminsController do
before do
@user = Factory :user
@user = FactoryGirl.create :user
sign_in :user, @user
end
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -8,7 +8,7 @@ describe PublicsController do
let(:fixture_path) { Rails.root.join('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)
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment