Migrate fabricators to factory bot factories (#626)

* Remove factory_girl include from dev rake task

No longer needed after 92b125b4a7

* Add missing factories

* Use FactoryBot factories instead of fabricators

* Remove all fabricators

* Remove unused method

* Remove fabrication gem

* Rename FactoryGirl to FactoryBot

https://robots.thoughtbot.com/factory_bot
This commit is contained in:
Artur Beljajev 2017-11-16 10:18:53 +02:00 committed by Georg
parent acfe0552fc
commit 2da578a437
88 changed files with 356 additions and 610 deletions

View file

@ -8,7 +8,7 @@ describe Registrar do
it 'is not valid' do
@registrar.valid?
@registrar.errors.full_messages.should match_array([
@registrar.errors.full_messages.should include(*[
'Contact e-mail is missing',
'Country code is missing',
'Name is missing',
@ -39,7 +39,7 @@ describe Registrar do
context 'with valid attributes' do
before :all do
@registrar = Fabricate(:registrar)
@registrar = create(:registrar)
end
it 'should be valid' do
@ -48,13 +48,13 @@ describe Registrar do
end
it 'should be valid twice' do
@registrar = Fabricate(:registrar)
@registrar = create(:registrar)
@registrar.valid?
@registrar.errors.full_messages.should match_array([])
end
it 'should remove blank from code' do
registrar = Fabricate.build(:registrar, code: 'with blank')
registrar = build(:registrar, code: 'with blank')
registrar.valid?
registrar.errors.full_messages.should match_array([
])
@ -62,7 +62,7 @@ describe Registrar do
end
it 'should remove colon from code' do
registrar = Fabricate.build(:registrar, code: 'with colon:and:blank')
registrar = build(:registrar, code: 'with colon:and:blank')
registrar.valid?
registrar.errors.full_messages.should match_array([
])
@ -70,7 +70,7 @@ describe Registrar do
end
it 'should allow dot in code' do
registrar = Fabricate.build(:registrar, code: 'with.dot')
registrar = build(:registrar, code: 'with.dot')
registrar.valid?
registrar.errors.full_messages.should match_array([
])
@ -88,21 +88,19 @@ describe Registrar do
end
it 'should return full address' do
@registrar.address.should == 'Street 999, Town, County, Postal'
end
it 'should have code' do
@registrar.code.should =~ /REGISTRAR/
registrar = described_class.new(street: 'Street 999', city: 'Town', state: 'County', zip: 'Postal')
registrar.address.should == 'Street 999, Town, County, Postal'
end
it 'should not be able to change code' do
@registrar.code = 'not-updated'
@registrar.code.should =~ /REGISTRAR/
registrar = create(:registrar, code: 'TEST')
registrar.code = 'new-code'
expect(registrar.code).to eq('TEST')
end
it 'should be able to issue a prepayment invoice' do
Setting.days_to_keep_invoices_active = 30
Fabricate(:registrar, name: 'EIS', reg_no: '90010019')
create(:registrar, name: 'EIS', reg_no: '90010019')
@registrar.issue_prepayment_invoice(200, 'add some money')
@registrar.invoices.count.should == 1
i = @registrar.invoices.first
@ -112,7 +110,7 @@ describe Registrar do
end
it 'should not allaw to use CID as code for leagcy reasons' do
registrar = Fabricate.build(:registrar, code: 'CID')
registrar = build(:registrar, code: 'CID')
registrar.valid?
registrar.errors.full_messages.should == ['Code is forbidden to use']
end