From 102cf74b3d2f787931148b1f84d323c3460df555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 13 Aug 2021 04:15:25 +0200 Subject: [PATCH] Bump faker from 1.8.7 to 2.0 Since version 2.0 introduced many breaking changes, we're upgrading to it first. The changes have been done by installing the rubocop-faker gem and running: ``` rubocop \ --require rubocop-faker \ --only Faker/DeprecatedArguments \ --auto-correct ``` --- Gemfile | 2 +- Gemfile.lock | 4 +- db/dev_seeds/banners.rb | 4 +- db/dev_seeds/budgets.rb | 4 +- db/dev_seeds/communities.rb | 2 +- db/dev_seeds/debates.rb | 6 +-- db/dev_seeds/legislation_processes.rb | 2 +- db/dev_seeds/legislation_proposals.rb | 2 +- db/dev_seeds/notifications.rb | 2 +- db/dev_seeds/polls.rb | 8 ++-- db/dev_seeds/proposals.rb | 22 +++++----- lib/tasks/proposal_actions.rake | 4 +- spec/factories/budgets.rb | 4 +- .../microsoft/client_spec.rb | 42 +++++++++---------- spec/models/tag_spec.rb | 2 +- spec/shared/system/remotely_translatable.rb | 2 +- 16 files changed, 56 insertions(+), 56 deletions(-) diff --git a/Gemfile b/Gemfile index 0fea7d4a2..9d03141da 100644 --- a/Gemfile +++ b/Gemfile @@ -74,7 +74,7 @@ group :development, :test do gem "byebug", "~> 11.1.3" gem "database_cleaner", "~> 2.0.1" gem "factory_bot_rails", "~> 6.2.0" - gem "faker", "~> 1.8.7" + gem "faker", "~> 2.0.0" gem "i18n-tasks", "~> 0.9.34" gem "knapsack_pro", "~> 3.0.0" gem "launchy", "~> 2.5.0" diff --git a/Gemfile.lock b/Gemfile.lock index 43c5b46eb..ba90fe50d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -235,7 +235,7 @@ GEM factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (1.8.7) + faker (2.0) i18n (>= 0.7) faraday (1.7.0) faraday-em_http (~> 1.0) @@ -733,7 +733,7 @@ DEPENDENCIES email_spec (~> 2.2.0) erb_lint (~> 0.0.37) factory_bot_rails (~> 6.2.0) - faker (~> 1.8.7) + faker (~> 2.0.0) font-awesome-sass (~> 5.15.1) foundation-rails (~> 6.6.2.0) foundation_rails_helper (~> 4.0.0) diff --git a/db/dev_seeds/banners.rb b/db/dev_seeds/banners.rb index 61cfbb00e..af16f01ca 100644 --- a/db/dev_seeds/banners.rb +++ b/db/dev_seeds/banners.rb @@ -1,7 +1,7 @@ section "Creating banners" do Proposal.last(3).each do |proposal| - title = Faker::Lorem.sentence(3) - description = Faker::Lorem.sentence(12) + title = Faker::Lorem.sentence(word_count: 3) + description = Faker::Lorem.sentence(word_count: 12) target_url = Rails.application.routes.url_helpers.proposal_path(proposal) banner = Banner.new(title: title, description: description, diff --git a/db/dev_seeds/budgets.rb b/db/dev_seeds/budgets.rb index 9c803af32..42da7c03c 100644 --- a/db/dev_seeds/budgets.rb +++ b/db/dev_seeds/budgets.rb @@ -120,7 +120,7 @@ section "Creating Budgets" do end section "Creating Investments" do - tags = Faker::Lorem.words(10) + tags = Faker::Lorem.words(number: 10) 100.times do heading = Budget::Heading.all.sample @@ -179,7 +179,7 @@ section "Winner Investments" do heading: heading, group: heading.group, budget: heading.group.budget, - title: Faker::Lorem.sentence(3).truncate(60), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: "

#{Faker::Lorem.paragraphs.join("

")}

", created_at: rand((Time.current - 1.week)..Time.current), feasibility: "feasible", diff --git a/db/dev_seeds/communities.rb b/db/dev_seeds/communities.rb index 10550591a..febf5b9e3 100644 --- a/db/dev_seeds/communities.rb +++ b/db/dev_seeds/communities.rb @@ -6,7 +6,7 @@ end section "Creating Communities Topics" do Community.find_each do |community| Topic.create(community: community, author: User.all.sample, - title: Faker::Lorem.sentence(3).truncate(60), description: Faker::Lorem.sentence) + title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: Faker::Lorem.sentence) end end diff --git a/db/dev_seeds/debates.rb b/db/dev_seeds/debates.rb index 8e5de0c3d..7987b0312 100644 --- a/db/dev_seeds/debates.rb +++ b/db/dev_seeds/debates.rb @@ -1,10 +1,10 @@ section "Creating Debates" do - tags = Faker::Lorem.words(25) + tags = Faker::Lorem.words(number: 25) 30.times do author = User.all.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" debate = Debate.create!(author: author, - title: Faker::Lorem.sentence(3).truncate(60), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), created_at: rand((Time.current - 1.week)..Time.current), description: description, tag_list: tags.sample(3).join(","), @@ -25,7 +25,7 @@ section "Creating Debates" do description = "

#{Faker::Lorem.paragraphs.join("

")}

" debate = Debate.create!(author: author, - title: Faker::Lorem.sentence(3).truncate(60), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), created_at: rand((Time.current - 1.week)..Time.current), description: description, tag_list: tags.sample(3).join(","), diff --git a/db/dev_seeds/legislation_processes.rb b/db/dev_seeds/legislation_processes.rb index f932549f7..82798207e 100644 --- a/db/dev_seeds/legislation_processes.rb +++ b/db/dev_seeds/legislation_processes.rb @@ -1,6 +1,6 @@ section "Creating collaborative legislation" do 9.times do |i| - Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60), + Legislation::Process.create!(title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: Faker::Lorem.paragraphs.join("\n\n"), summary: Faker::Lorem.paragraph, additional_info: Faker::Lorem.paragraphs.join("\n\n"), diff --git a/db/dev_seeds/legislation_proposals.rb b/db/dev_seeds/legislation_proposals.rb index 3f6a19955..a305219c5 100644 --- a/db/dev_seeds/legislation_proposals.rb +++ b/db/dev_seeds/legislation_proposals.rb @@ -1,6 +1,6 @@ section "Creating legislation proposals" do 10.times do - Legislation::Proposal.create!(title: Faker::Lorem.sentence(3).truncate(60), + Legislation::Proposal.create!(title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: Faker::Lorem.paragraphs.join("\n\n"), summary: Faker::Lorem.paragraph, author: User.all.sample, diff --git a/db/dev_seeds/notifications.rb b/db/dev_seeds/notifications.rb index 237d42215..8f0177740 100644 --- a/db/dev_seeds/notifications.rb +++ b/db/dev_seeds/notifications.rb @@ -1,7 +1,7 @@ section "Creating comment notifications" do User.find_each do |user| debate = Debate.create!(author: user, - title: Faker::Lorem.sentence(3).truncate(60), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), description: "

#{Faker::Lorem.paragraphs.join("

")}

", tag_list: Tag.all.sample(3).join(","), geozone: Geozone.sample, diff --git a/db/dev_seeds/polls.rb b/db/dev_seeds/polls.rb index 9813865dc..6ed23e601 100644 --- a/db/dev_seeds/polls.rb +++ b/db/dev_seeds/polls.rb @@ -48,7 +48,7 @@ end section "Creating Poll Questions & Answers" do Poll.find_each do |poll| (1..4).to_a.sample.times do - question_title = Faker::Lorem.sentence(3).truncate(60) + "?" + question_title = Faker::Lorem.sentence(word_count: 3).truncate(60) + "?" question = Poll::Question.new(author: User.all.sample, title: question_title, poll: poll) @@ -58,7 +58,7 @@ section "Creating Poll Questions & Answers" do end end question.save! - Faker::Lorem.words((2..4).to_a.sample).each_with_index do |title, index| + Faker::Lorem.words(number: (2..4).to_a.sample).each_with_index do |title, index| description = "

#{Faker::Lorem.paragraphs.join("

")}

" answer = Poll::Question::Answer.new(question: question, title: title.capitalize, @@ -226,7 +226,7 @@ section "Creating Poll Questions from Proposals" do end end question.save! - Faker::Lorem.words((2..4).to_a.sample).each_with_index do |title, index| + Faker::Lorem.words(number: (2..4).to_a.sample).each_with_index do |title, index| description = "

#{Faker::ChuckNorris.fact}

" answer = Poll::Question::Answer.new(question: question, title: title.capitalize, @@ -256,7 +256,7 @@ section "Creating Successful Proposals" do end end question.save! - Faker::Lorem.words((2..4).to_a.sample).each_with_index do |title, index| + Faker::Lorem.words(number: (2..4).to_a.sample).each_with_index do |title, index| description = "

#{Faker::ChuckNorris.fact}

" answer = Poll::Question::Answer.new(question: question, title: title.capitalize, diff --git a/db/dev_seeds/proposals.rb b/db/dev_seeds/proposals.rb index 31675c023..8341fd58b 100644 --- a/db/dev_seeds/proposals.rb +++ b/db/dev_seeds/proposals.rb @@ -22,10 +22,10 @@ def add_image_to(imageable) end section "Creating Proposals" do - tags = Faker::Lorem.words(25) + tags = Faker::Lorem.words(number: 25) 30.times do - title = Faker::Lorem.sentence(3).truncate(60) - summary = Faker::Lorem.sentence(3) + title = Faker::Lorem.sentence(word_count: 3).truncate(60) + summary = Faker::Lorem.sentence(word_count: 3) author = User.all.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" @@ -52,14 +52,14 @@ section "Creating Proposals" do end section "Creating Archived Proposals" do - tags = Faker::Lorem.words(25) + tags = Faker::Lorem.words(number: 25) 5.times do author = User.all.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" months_to_archive_proposals = Setting["months_to_archive_proposals"] proposal = Proposal.create!(author: author, - title: Faker::Lorem.sentence(3).truncate(60), - summary: Faker::Lorem.sentence(3), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), + summary: Faker::Lorem.sentence(word_count: 3), responsible_name: Faker::Name.name, description: description, tag_list: tags.sample(3).join(","), @@ -80,13 +80,13 @@ section "Creating Archived Proposals" do end section "Creating Successful Proposals" do - tags = Faker::Lorem.words(25) + tags = Faker::Lorem.words(number: 25) 10.times do author = User.all.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, - title: Faker::Lorem.sentence(3).truncate(60), - summary: Faker::Lorem.sentence(3), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), + summary: Faker::Lorem.sentence(word_count: 3), responsible_name: Faker::Name.name, description: description, created_at: rand((Time.current - 1.week)..Time.current), @@ -111,8 +111,8 @@ section "Creating Successful Proposals" do author = User.all.sample description = "

#{Faker::Lorem.paragraphs.join("

")}

" proposal = Proposal.create!(author: author, - title: Faker::Lorem.sentence(4).truncate(60), - summary: Faker::Lorem.sentence(3), + title: Faker::Lorem.sentence(word_count: 4).truncate(60), + summary: Faker::Lorem.sentence(word_count: 3), responsible_name: Faker::Name.name, description: description, created_at: rand((Time.current - 1.week)..Time.current), diff --git a/lib/tasks/proposal_actions.rake b/lib/tasks/proposal_actions.rake index a5670e23a..033fe5ab1 100644 --- a/lib/tasks/proposal_actions.rake +++ b/lib/tasks/proposal_actions.rake @@ -391,8 +391,8 @@ namespace :proposal_actions do author = User.all.sample description = "

This is an example of a successful proposal with an ideal progress.

" proposal = Proposal.create!(author: author, - title: Faker::Lorem.sentence(3).truncate(60), - summary: Faker::Lorem.sentence(3), + title: Faker::Lorem.sentence(word_count: 3).truncate(60), + summary: Faker::Lorem.sentence(word_count: 3), responsible_name: Faker::Name.name, description: description, created_at: Time.current - expected_supports.length.days, diff --git a/spec/factories/budgets.rb b/spec/factories/budgets.rb index 1c6a371e2..ed78d2a32 100644 --- a/spec/factories/budgets.rb +++ b/spec/factories/budgets.rb @@ -227,8 +227,8 @@ FactoryBot.define do factory :budget_phase, class: "Budget::Phase" do budget kind { :balloting } - summary { Faker::Lorem.sentence(3) } - description { Faker::Lorem.sentence(10) } + summary { Faker::Lorem.sentence(word_count: 3) } + description { Faker::Lorem.sentence(word_count: 10) } starts_at { Date.yesterday } ends_at { Date.tomorrow } enabled { true } diff --git a/spec/lib/remote_translations/microsoft/client_spec.rb b/spec/lib/remote_translations/microsoft/client_spec.rb index 8259219be..e478e7dfb 100644 --- a/spec/lib/remote_translations/microsoft/client_spec.rb +++ b/spec/lib/remote_translations/microsoft/client_spec.rb @@ -29,11 +29,11 @@ describe RemoteTranslations::Microsoft::Client do context "when characters from request are greater than characters limit" do it "response has the expected result when the request has 2 texts, where both less than CHARACTERS_LIMIT_PER_REQUEST" do stub_const("RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST", 20) - text_en = Faker::Lorem.characters(11) - another_text_en = Faker::Lorem.characters(11) + text_en = Faker::Lorem.characters(number: 11) + another_text_en = Faker::Lorem.characters(number: 11) - translated_text_es = Faker::Lorem.characters(11) - another_translated_text_es = Faker::Lorem.characters(11) + translated_text_es = Faker::Lorem.characters(number: 11) + another_translated_text_es = Faker::Lorem.characters(number: 11) response_text = create_response(translated_text_es) response_another_text = create_response(another_translated_text_es) @@ -51,12 +51,12 @@ describe RemoteTranslations::Microsoft::Client do it "response has the expected result when the request has 2 texts and both are greater than CHARACTERS_LIMIT_PER_REQUEST" do stub_const("RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST", 20) - start_text_en = Faker::Lorem.characters(10) + " " - end_text_en = Faker::Lorem.characters(10) + start_text_en = Faker::Lorem.characters(number: 10) + " " + end_text_en = Faker::Lorem.characters(number: 10) text_en = start_text_en + end_text_en - start_translated_text_es = Faker::Lorem.characters(10) + " " - end_translated_text_es = Faker::Lorem.characters(10) + start_translated_text_es = Faker::Lorem.characters(number: 10) + " " + end_translated_text_es = Faker::Lorem.characters(number: 10) translated_text_es = start_translated_text_es + end_translated_text_es response_start_text = create_response(start_translated_text_es) response_end_text = create_response(end_translated_text_es) @@ -70,12 +70,12 @@ describe RemoteTranslations::Microsoft::Client do .times .and_return(response_end_text) - start_another_text_en = Faker::Lorem.characters(12) + "." - end_another_text_en = Faker::Lorem.characters(12) + start_another_text_en = Faker::Lorem.characters(number: 12) + "." + end_another_text_en = Faker::Lorem.characters(number: 12) another_text_en = start_another_text_en + end_another_text_en - another_start_translated_text_es = Faker::Lorem.characters(12) + "." - another_end_translated_text_es = Faker::Lorem.characters(12) + another_start_translated_text_es = Faker::Lorem.characters(number: 12) + "." + another_end_translated_text_es = Faker::Lorem.characters(number: 12) another_translated_text_es = another_start_translated_text_es + another_end_translated_text_es response_another_start_text = create_response(another_start_translated_text_es) response_another_end_text = create_response(another_end_translated_text_es) @@ -100,7 +100,7 @@ describe RemoteTranslations::Microsoft::Client do context "text has less characters than characters limit" do it "does not split the text" do stub_const("RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST", 20) - text_to_translate = Faker::Lorem.characters(10) + text_to_translate = Faker::Lorem.characters(number: 10) result = client.fragments_for(text_to_translate) @@ -111,8 +111,8 @@ describe RemoteTranslations::Microsoft::Client do context "text has more characters than characters limit" do it "to split text by first valid dot when there is a dot for split" do stub_const("RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST", 20) - start_text = Faker::Lorem.characters(10) + "." - end_text = Faker::Lorem.characters(10) + start_text = Faker::Lorem.characters(number: 10) + "." + end_text = Faker::Lorem.characters(number: 10) text_to_translate = start_text + end_text result = client.fragments_for(text_to_translate) @@ -122,8 +122,8 @@ describe RemoteTranslations::Microsoft::Client do it "to split text by first valid space when there is not a dot for split but there is a space" do stub_const("RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST", 20) - start_text = Faker::Lorem.characters(10) + " " - end_text = Faker::Lorem.characters(10) + start_text = Faker::Lorem.characters(number: 10) + " " + end_text = Faker::Lorem.characters(number: 10) text_to_translate = start_text + end_text result = client.fragments_for(text_to_translate) @@ -133,10 +133,10 @@ describe RemoteTranslations::Microsoft::Client do it "to split text in the middle of a word when there are not valid dots and spaces" do stub_const("RemoteTranslations::Microsoft::Client::CHARACTERS_LIMIT_PER_REQUEST", 40) - sub_part_text_1 = Faker::Lorem.characters(5) + " ." - sub_part_text_2 = Faker::Lorem.characters(5) - sub_part_text_3 = Faker::Lorem.characters(9) - sub_part_text_4 = Faker::Lorem.characters(30) + sub_part_text_1 = Faker::Lorem.characters(number: 5) + " ." + sub_part_text_2 = Faker::Lorem.characters(number: 5) + sub_part_text_3 = Faker::Lorem.characters(number: 9) + sub_part_text_4 = Faker::Lorem.characters(number: 30) text_to_translate = sub_part_text_1 + sub_part_text_2 + sub_part_text_3 + sub_part_text_4 result = client.fragments_for(text_to_translate) diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 2a9f098f7..42a87c8fa 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -27,7 +27,7 @@ describe Tag do describe "name validation" do it "160 char name should be valid" do - tag = build(:tag, name: Faker::Lorem.characters(160)) + tag = build(:tag, name: Faker::Lorem.characters(number: 160)) expect(tag).to be_valid end end diff --git a/spec/shared/system/remotely_translatable.rb b/spec/shared/system/remotely_translatable.rb index 060c3ae51..65206b412 100644 --- a/spec/shared/system/remotely_translatable.rb +++ b/spec/shared/system/remotely_translatable.rb @@ -237,6 +237,6 @@ def commentable?(resource) end def generate_response(resource) - field_text = Faker::Lorem.characters(10) + field_text = Faker::Lorem.characters(number: 10) resource.translated_attribute_names.map { field_text } end