Upgrade factory_bot, faker

This commit is contained in:
wvengen 2019-10-28 09:40:43 +01:00 committed by wvengen
parent e6a1bfcb45
commit f2cb17bcd6
10 changed files with 33 additions and 33 deletions

View file

@ -139,7 +139,7 @@ GEM
execjs execjs
coffee-script-source (1.12.2) coffee-script-source (1.12.2)
commonjs (0.2.7) commonjs (0.2.7)
concurrent-ruby (1.1.4) concurrent-ruby (1.1.5)
connection_pool (2.2.2) connection_pool (2.2.2)
content_for_in_controllers (0.0.2) content_for_in_controllers (0.0.2)
coveralls (0.8.22) coveralls (0.8.22)
@ -148,7 +148,7 @@ GEM
term-ansicolor (~> 1.3) term-ansicolor (~> 1.3)
thor (~> 0.19.4) thor (~> 0.19.4)
tins (~> 1.6) tins (~> 1.6)
crass (1.0.4) crass (1.0.5)
daemons (1.2.6) daemons (1.2.6)
database_cleaner (1.7.0) database_cleaner (1.7.0)
date_time_attribute (0.1.2) date_time_attribute (0.1.2)
@ -174,13 +174,13 @@ GEM
activesupport (>= 4.0, < 6) activesupport (>= 4.0, < 6)
execjs (2.7.0) execjs (2.7.0)
expression_parser (0.9.0) expression_parser (0.9.0)
factory_bot (4.8.2) factory_bot (5.1.1)
activesupport (>= 3.0.0) activesupport (>= 4.2.0)
factory_bot_rails (4.8.2) factory_bot_rails (5.1.1)
factory_bot (~> 4.8.2) factory_bot (~> 5.1.0)
railties (>= 3.0.0) railties (>= 4.2.0)
faker (1.8.4) faker (2.2.1)
i18n (~> 0.5) i18n (>= 0.8)
ffi (1.9.25) ffi (1.9.25)
gaffe (1.2.0) gaffe (1.2.0)
rails (>= 4.0.0) rails (>= 4.0.0)
@ -249,7 +249,7 @@ GEM
sprockets (> 2, < 4) sprockets (> 2, < 4)
tilt tilt
libv8 (3.16.14.19) libv8 (3.16.14.19)
loofah (2.2.3) loofah (2.3.1)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.1) mail (2.7.1)
@ -275,11 +275,11 @@ GEM
mime-types-data (3.2018.0812) mime-types-data (3.2018.0812)
mini_mime (1.0.1) mini_mime (1.0.1)
mini_portile2 (2.4.0) mini_portile2 (2.4.0)
minitest (5.11.3) minitest (5.12.2)
mono_logger (1.1.0) mono_logger (1.1.0)
multi_json (1.13.1) multi_json (1.13.1)
mysql2 (0.4.10) mysql2 (0.4.10)
nokogiri (1.9.1) nokogiri (1.10.4)
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
pdf-core (0.7.0) pdf-core (0.7.0)
polyglot (0.3.5) polyglot (0.3.5)
@ -329,8 +329,8 @@ GEM
activesupport (>= 4.2.0, < 5.0) activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6) nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1) rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.4) rails-html-sanitizer (1.3.0)
loofah (~> 2.2, >= 2.2.2) loofah (~> 2.3)
rails-i18n (4.0.9) rails-i18n (4.0.9)
i18n (~> 0.7) i18n (~> 0.7)
railties (~> 4.0) railties (~> 4.0)
@ -344,7 +344,7 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (3.0.0) rainbow (3.0.0)
rake (12.3.2) rake (13.0.0)
ransack (1.8.9) ransack (1.8.9)
actionpack (>= 3.0, <= 5.1.1) actionpack (>= 3.0, <= 5.1.1)
activerecord (>= 3.0, <= 5.1.1) activerecord (>= 3.0, <= 5.1.1)

View file

@ -10,20 +10,20 @@ FactoryBot.define do
unit_quantity { rand(5) < 3 ? 1 : rand(1..20) } unit_quantity { rand(5) < 3 ? 1 : rand(1..20) }
factory :article do factory :article do
sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " ##{n}" } sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" }
supplier { create :supplier } supplier { create :supplier }
article_category { create :article_category } article_category { create :article_category }
end end
factory :shared_article, class: SharedArticle do factory :shared_article, class: SharedArticle do
sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " s##{n}" } sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " s##{n}" }
order_number { Faker::Lorem.characters(rand(1..12)) } order_number { Faker::Lorem.characters(number: rand(1..12)) }
supplier { create :shared_supplier } supplier { create :shared_supplier }
end end
end end
factory :article_category do factory :article_category do
sequence(:name) { |n| Faker::Lorem.characters(rand(2..12)) + " ##{n}" } sequence(:name) { |n| Faker::Lorem.characters(number: rand(2..12)) + " ##{n}" }
end end
end end

View file

@ -5,7 +5,7 @@ FactoryBot.define do
factory :oauth2_application, class: Doorkeeper::Application do factory :oauth2_application, class: Doorkeeper::Application do
name { Faker::App.name } name { Faker::App.name }
redirect_uri 'https://example.com:1234/app' redirect_uri { 'https://example.com:1234/app' }
end end
factory :oauth2_access_token, class: Doorkeeper::AccessToken do factory :oauth2_access_token, class: Doorkeeper::AccessToken do

View file

@ -3,12 +3,12 @@ require 'factory_bot'
FactoryBot.define do FactoryBot.define do
factory :financial_transaction_class do factory :financial_transaction_class do
sequence(:name) { |n| Faker::Lorem.characters(rand(2..12)) + " ##{n}" } sequence(:name) { |n| Faker::Lorem.characters(number: rand(2..12)) + " ##{n}" }
end end
factory :financial_transaction_type do factory :financial_transaction_type do
financial_transaction_class financial_transaction_class
sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " ##{n}" } sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " ##{n}" }
end end
end end

View file

@ -8,12 +8,12 @@ FactoryBot.define do
article_ids { supplier.articles.map(&:id) unless supplier.nil? } article_ids { supplier.articles.map(&:id) unless supplier.nil? }
transient do transient do
article_count true article_count { true }
end end
# for an order from stock; need to add articles # for an order from stock; need to add articles
factory :stock_order do factory :stock_order do
supplier_id 0 supplier_id { 0 }
# article_ids needs to be supplied # article_ids needs to be supplied
end end

View file

@ -8,7 +8,7 @@ FactoryBot.define do
address { Faker::Address.street_address } address { Faker::Address.street_address }
transient do transient do
article_count 0 article_count { 0 }
end end
after :create do |supplier, evaluator| after :create do |supplier, evaluator|

View file

@ -10,7 +10,7 @@ FactoryBot.define do
factory :admin do factory :admin do
sequence(:nick) { |n| "admin#{n}" } sequence(:nick) { |n| "admin#{n}" }
first_name 'Administrator' first_name { 'Administrator' }
after :create do |user, evaluator| after :create do |user, evaluator|
create :workgroup, role_admin: true, user_ids: [user.id] create :workgroup, role_admin: true, user_ids: [user.id]
end end
@ -35,11 +35,11 @@ FactoryBot.define do
sequence(:name) {|n| "Group ##{n}"} sequence(:name) {|n| "Group ##{n}"}
factory :workgroup do factory :workgroup do
type '' type { '' }
end end
factory :ordergroup do factory :ordergroup do
type 'Ordergroup' type { 'Ordergroup' }
sequence(:name) {|n| "Order group ##{n}"} sequence(:name) {|n| "Order group ##{n}"}
# workaround to avoid needing to save the ordergroup # workaround to avoid needing to save the ordergroup
# avoids e.g. error after logging in related to applebar # avoids e.g. error after logging in related to applebar

View file

@ -1,7 +1,7 @@
require_relative '../spec_helper' require_relative '../spec_helper'
feature 'admin/configs' do feature 'admin/configs' do
let(:name) { Faker::Lorem.words(rand(2..4)).join(' ') } let(:name) { Faker::Lorem.words(number: rand(2..4)).join(' ') }
let(:email) { Faker::Internet.email } let(:email) { Faker::Internet.email }
let(:admin) { create :admin } let(:admin) { create :admin }

View file

@ -1,8 +1,8 @@
require_relative '../spec_helper' require_relative '../spec_helper'
describe FoodsoftConfig do describe FoodsoftConfig do
let(:name) { Faker::Lorem.words(rand(2..4)).join(' ') } let(:name) { Faker::Lorem.words(number: rand(2..4)).join(' ') }
let(:other_name) { Faker::Lorem.words(rand(2..4)).join(' ') } let(:other_name) { Faker::Lorem.words(number: rand(2..4)).join(' ') }
it 'returns a default value' do it 'returns a default value' do
expect(FoodsoftConfig[:protected][:database]).to be true expect(FoodsoftConfig[:protected][:database]).to be true

View file

@ -23,7 +23,7 @@ describe TokenVerifier do
msg msg
oldscope = FoodsoftConfig.scope oldscope = FoodsoftConfig.scope
begin begin
FoodsoftConfig.scope = Faker::Lorem.words(1) FoodsoftConfig.scope = Faker::Lorem.words(number: 1)
v2 = TokenVerifier.new(prefix) v2 = TokenVerifier.new(prefix)
expect{ v2.verify(msg) }.to raise_error(TokenVerifier::InvalidScope) expect{ v2.verify(msg) }.to raise_error(TokenVerifier::InvalidScope)
ensure ensure
@ -32,7 +32,7 @@ describe TokenVerifier do
end end
it 'does not validate a random string' do it 'does not validate a random string' do
expect{ v.verify(Faker::Lorem.characters(100)) }.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature) expect{ v.verify(Faker::Lorem.characters(number: 100)) }.to raise_error(ActiveSupport::MessageVerifier::InvalidSignature)
end end
it 'returns the message' do it 'returns the message' do