From f2cb17bcd6e0319e75b67de86216eb35cdd1d593 Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 28 Oct 2019 09:40:43 +0100 Subject: [PATCH] Upgrade factory_bot, faker --- Gemfile.lock | 30 ++++++++++---------- spec/factories/article.rb | 8 +++--- spec/factories/doorkeeper.rb | 2 +- spec/factories/financial_transaction_type.rb | 4 +-- spec/factories/order.rb | 4 +-- spec/factories/supplier.rb | 2 +- spec/factories/user.rb | 6 ++-- spec/integration/config_spec.rb | 2 +- spec/lib/foodsoft_config_spec.rb | 4 +-- spec/lib/token_verifier_spec.rb | 4 +-- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bb0abd6b..dd747b91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -139,7 +139,7 @@ GEM execjs coffee-script-source (1.12.2) commonjs (0.2.7) - concurrent-ruby (1.1.4) + concurrent-ruby (1.1.5) connection_pool (2.2.2) content_for_in_controllers (0.0.2) coveralls (0.8.22) @@ -148,7 +148,7 @@ GEM term-ansicolor (~> 1.3) thor (~> 0.19.4) tins (~> 1.6) - crass (1.0.4) + crass (1.0.5) daemons (1.2.6) database_cleaner (1.7.0) date_time_attribute (0.1.2) @@ -174,13 +174,13 @@ GEM activesupport (>= 4.0, < 6) execjs (2.7.0) expression_parser (0.9.0) - factory_bot (4.8.2) - activesupport (>= 3.0.0) - factory_bot_rails (4.8.2) - factory_bot (~> 4.8.2) - railties (>= 3.0.0) - faker (1.8.4) - i18n (~> 0.5) + factory_bot (5.1.1) + activesupport (>= 4.2.0) + factory_bot_rails (5.1.1) + factory_bot (~> 5.1.0) + railties (>= 4.2.0) + faker (2.2.1) + i18n (>= 0.8) ffi (1.9.25) gaffe (1.2.0) rails (>= 4.0.0) @@ -249,7 +249,7 @@ GEM sprockets (> 2, < 4) tilt libv8 (3.16.14.19) - loofah (2.2.3) + loofah (2.3.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -275,11 +275,11 @@ GEM mime-types-data (3.2018.0812) mini_mime (1.0.1) mini_portile2 (2.4.0) - minitest (5.11.3) + minitest (5.12.2) mono_logger (1.1.0) multi_json (1.13.1) mysql2 (0.4.10) - nokogiri (1.9.1) + nokogiri (1.10.4) mini_portile2 (~> 2.4.0) pdf-core (0.7.0) polyglot (0.3.5) @@ -329,8 +329,8 @@ GEM activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rails-i18n (4.0.9) i18n (~> 0.7) railties (~> 4.0) @@ -344,7 +344,7 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (3.0.0) - rake (12.3.2) + rake (13.0.0) ransack (1.8.9) actionpack (>= 3.0, <= 5.1.1) activerecord (>= 3.0, <= 5.1.1) diff --git a/spec/factories/article.rb b/spec/factories/article.rb index e37ca713..6cf16e31 100644 --- a/spec/factories/article.rb +++ b/spec/factories/article.rb @@ -10,20 +10,20 @@ FactoryBot.define do unit_quantity { rand(5) < 3 ? 1 : rand(1..20) } 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 } article_category { create :article_category } end factory :shared_article, class: SharedArticle do - sequence(:name) { |n| Faker::Lorem.words(rand(2..4)).join(' ') + " s##{n}" } - order_number { Faker::Lorem.characters(rand(1..12)) } + sequence(:name) { |n| Faker::Lorem.words(number: rand(2..4)).join(' ') + " s##{n}" } + order_number { Faker::Lorem.characters(number: rand(1..12)) } supplier { create :shared_supplier } end end 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 diff --git a/spec/factories/doorkeeper.rb b/spec/factories/doorkeeper.rb index 8fd1a484..8880d979 100644 --- a/spec/factories/doorkeeper.rb +++ b/spec/factories/doorkeeper.rb @@ -5,7 +5,7 @@ FactoryBot.define do factory :oauth2_application, class: Doorkeeper::Application do name { Faker::App.name } - redirect_uri 'https://example.com:1234/app' + redirect_uri { 'https://example.com:1234/app' } end factory :oauth2_access_token, class: Doorkeeper::AccessToken do diff --git a/spec/factories/financial_transaction_type.rb b/spec/factories/financial_transaction_type.rb index 45882ff2..3f4a5543 100644 --- a/spec/factories/financial_transaction_type.rb +++ b/spec/factories/financial_transaction_type.rb @@ -3,12 +3,12 @@ require 'factory_bot' FactoryBot.define 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 factory :financial_transaction_type do 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 diff --git a/spec/factories/order.rb b/spec/factories/order.rb index 1b63744d..64d15f75 100644 --- a/spec/factories/order.rb +++ b/spec/factories/order.rb @@ -8,12 +8,12 @@ FactoryBot.define do article_ids { supplier.articles.map(&:id) unless supplier.nil? } transient do - article_count true + article_count { true } end # for an order from stock; need to add articles factory :stock_order do - supplier_id 0 + supplier_id { 0 } # article_ids needs to be supplied end diff --git a/spec/factories/supplier.rb b/spec/factories/supplier.rb index 27b4f414..290fbb69 100644 --- a/spec/factories/supplier.rb +++ b/spec/factories/supplier.rb @@ -8,7 +8,7 @@ FactoryBot.define do address { Faker::Address.street_address } transient do - article_count 0 + article_count { 0 } end after :create do |supplier, evaluator| diff --git a/spec/factories/user.rb b/spec/factories/user.rb index c4bcb6a2..2a83f64e 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -10,7 +10,7 @@ FactoryBot.define do factory :admin do sequence(:nick) { |n| "admin#{n}" } - first_name 'Administrator' + first_name { 'Administrator' } after :create do |user, evaluator| create :workgroup, role_admin: true, user_ids: [user.id] end @@ -35,11 +35,11 @@ FactoryBot.define do sequence(:name) {|n| "Group ##{n}"} factory :workgroup do - type '' + type { '' } end factory :ordergroup do - type 'Ordergroup' + type { 'Ordergroup' } sequence(:name) {|n| "Order group ##{n}"} # workaround to avoid needing to save the ordergroup # avoids e.g. error after logging in related to applebar diff --git a/spec/integration/config_spec.rb b/spec/integration/config_spec.rb index 8a9b043c..125b5920 100644 --- a/spec/integration/config_spec.rb +++ b/spec/integration/config_spec.rb @@ -1,7 +1,7 @@ require_relative '../spec_helper' 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(:admin) { create :admin } diff --git a/spec/lib/foodsoft_config_spec.rb b/spec/lib/foodsoft_config_spec.rb index 20ab28f5..668800e7 100644 --- a/spec/lib/foodsoft_config_spec.rb +++ b/spec/lib/foodsoft_config_spec.rb @@ -1,8 +1,8 @@ require_relative '../spec_helper' describe FoodsoftConfig do - let(:name) { Faker::Lorem.words(rand(2..4)).join(' ') } - let(:other_name) { Faker::Lorem.words(rand(2..4)).join(' ') } + let(:name) { Faker::Lorem.words(number: rand(2..4)).join(' ') } + let(:other_name) { Faker::Lorem.words(number: rand(2..4)).join(' ') } it 'returns a default value' do expect(FoodsoftConfig[:protected][:database]).to be true diff --git a/spec/lib/token_verifier_spec.rb b/spec/lib/token_verifier_spec.rb index d398a140..e3e4568e 100644 --- a/spec/lib/token_verifier_spec.rb +++ b/spec/lib/token_verifier_spec.rb @@ -23,7 +23,7 @@ describe TokenVerifier do msg oldscope = FoodsoftConfig.scope begin - FoodsoftConfig.scope = Faker::Lorem.words(1) + FoodsoftConfig.scope = Faker::Lorem.words(number: 1) v2 = TokenVerifier.new(prefix) expect{ v2.verify(msg) }.to raise_error(TokenVerifier::InvalidScope) ensure @@ -32,7 +32,7 @@ describe TokenVerifier do end 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 it 'returns the message' do