From d6eb9f8fb6db84500bed370a29a4a8eec60176fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 21:09:56 +0200 Subject: [PATCH 1/7] Add and apply ShadowingOuterLocalVariable rule Naming two variables the same way is confusing at the very least, and can lead to hard to debug errors. That's why the Ruby interpreter issues a warning when we do so. --- .rubocop_basic.yml | 3 +++ .../tracking/budget_investments_controller.rb | 5 ++--- db/dev_seeds/polls.rb | 8 ++++---- spec/features/admin/budget_investments_spec.rb | 12 ++++++------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 6bbcb18c9..e6578c2d3 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -120,6 +120,9 @@ Layout/TrailingWhitespace: Lint/LiteralAsCondition: Enabled: true +Lint/ShadowingOuterLocalVariable: + Enabled: true + Lint/UselessAssignment: Enabled: true diff --git a/app/controllers/tracking/budget_investments_controller.rb b/app/controllers/tracking/budget_investments_controller.rb index 83a4f28d0..88315685c 100644 --- a/app/controllers/tracking/budget_investments_controller.rb +++ b/app/controllers/tracking/budget_investments_controller.rb @@ -58,14 +58,13 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController } ] - filters = investment_headings.inject(all_headings_filter) do |filters, heading| + investment_headings.inject(all_headings_filter) do |filters, heading| filters << { name: heading.name, id: heading.id, count: investments.select { |i| i.heading_id == heading.id }.size } - end - filters.uniq + end.uniq end def restrict_access_to_assigned_items diff --git a/db/dev_seeds/polls.rb b/db/dev_seeds/polls.rb index 75ee07871..d284e93ae 100644 --- a/db/dev_seeds/polls.rb +++ b/db/dev_seeds/polls.rb @@ -222,10 +222,10 @@ section "Creating Poll Questions from Proposals" do poll = Poll.current.first question = Poll::Question.new(poll: poll) question.copy_attributes_from_proposal(proposal) - title = question.title + question_title = question.title I18n.available_locales.map do |locale| Globalize.with_locale(locale) do - question.title = "#{title} (#{locale})" + question.title = "#{question_title} (#{locale})" end end question.save! @@ -252,10 +252,10 @@ section "Creating Successful Proposals" do poll = Poll.current.first question = Poll::Question.new(poll: poll) question.copy_attributes_from_proposal(proposal) - title = question.title + question_title = question.title I18n.available_locales.map do |locale| Globalize.with_locale(locale) do - question.title = "#{title} (#{locale})" + question.title = "#{question_title} (#{locale})" end end question.save! diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 2ed59f9ee..86c8b8c4b 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -1773,8 +1773,8 @@ describe "Admin budget investments" do visit admin_budget_budget_investments_path(budget) cookies = page.driver.browser.manage.all_cookies - cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" } - cookie_value = cookie[:value] + columns_cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" } + cookie_value = columns_cookie[:value] expect(cookie_value).to eq("id,title,supports,admin,valuator,geozone," + "feasibility,price,valuation_finished,visible_to_valuators,selected,incompatible") @@ -1827,8 +1827,8 @@ describe "Admin budget investments" do end cookies = page.driver.browser.manage.all_cookies - cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" } - cookie_value = cookie[:value] + columns_cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" } + cookie_value = columns_cookie[:value] expect(cookie_value).to eq("id,supports,admin,geozone," + "feasibility,valuation_finished,visible_to_valuators,selected,incompatible,author") @@ -1836,8 +1836,8 @@ describe "Admin budget investments" do visit admin_budget_budget_investments_path(budget) cookies = page.driver.browser.manage.all_cookies - cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" } - cookie_value = cookie[:value] + columns_cookie = cookies.find { |cookie| cookie[:name] == "investments-columns" } + cookie_value = columns_cookie[:value] expect(cookie_value).to eq("id,supports,admin,geozone,feasibility,valuation_finished," + "visible_to_valuators,selected,incompatible,author") From 2fed7b9db358913d4403858e8aa8f733014aa1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 21:17:51 +0200 Subject: [PATCH 2/7] Add and apply AmbiguousRegexpLiteral rule This is a very subtle behaviour: `match /attachment/i` could represent a regular expression, but it could also represent a division like `match / attachment / i`. So we need to make an exception to the usual way we omit parenthesis in RSpec expectations. --- .rubocop_basic.yml | 3 +++ spec/features/admin/emails/emails_download_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index e6578c2d3..d675de4e0 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -117,6 +117,9 @@ Layout/TrailingBlankLines: Layout/TrailingWhitespace: Enabled: true +Lint/AmbiguousRegexpLiteral: + Enabled: true + Lint/LiteralAsCondition: Enabled: true diff --git a/spec/features/admin/emails/emails_download_spec.rb b/spec/features/admin/emails/emails_download_spec.rb index 9a2e0a445..fce00f9a0 100644 --- a/spec/features/admin/emails/emails_download_spec.rb +++ b/spec/features/admin/emails/emails_download_spec.rb @@ -33,8 +33,8 @@ describe "Admin download user emails" do end header = page.response_headers["Content-Disposition"] - expect(header).to match /^attachment/ - expect(header).to match /filename="Administrators.csv"$/ + expect(header).to match(/^attachment/) + expect(header).to match(/filename="Administrators.csv"$/) file_contents = page.body.split(",") expect(file_contents).to match_array ["admin_news1@consul.dev", "admin_news2@consul.dev"] From 9c3686a6d88715c703af730a292ec630eb74e9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 21:53:22 +0200 Subject: [PATCH 3/7] Remove unused block parameters We're using `yield` in the method body. --- app/helpers/globalize_helper.rb | 2 +- app/helpers/translatable_form_helper.rb | 4 ++-- app/mailers/mailer.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/globalize_helper.rb b/app/helpers/globalize_helper.rb index 4d659919b..e7531e690 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -131,7 +131,7 @@ module GlobalizeHelper hidden_field_tag("enabled_translations[#{locale}]", (enabled ? 1 : 0)) end - def globalize(locale, &block) + def globalize(locale) Globalize.with_locale(locale) do yield end diff --git a/app/helpers/translatable_form_helper.rb b/app/helpers/translatable_form_helper.rb index 458c7a929..ecd0a16a1 100644 --- a/app/helpers/translatable_form_helper.rb +++ b/app/helpers/translatable_form_helper.rb @@ -33,7 +33,7 @@ module TranslatableFormHelper private - def fields_for_locale(locale, &block) + def fields_for_locale(locale) fields_for_translation(@translations[locale]) do |translations_form| @template.content_tag :div, translations_options(translations_form.object, locale) do @template.concat translations_form.hidden_field( @@ -49,7 +49,7 @@ module TranslatableFormHelper end end - def fields_for_translation(translation, &block) + def fields_for_translation(translation) fields_for(:translations, translation, builder: TranslationsFieldsBuilder) do |f| yield f end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index b8c473980..2b71c63b1 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -129,7 +129,7 @@ class Mailer < ApplicationMailer private - def with_user(user, &block) + def with_user(user) I18n.with_locale(user.locale) do yield end From 6ffe5632647dfc8fec551ca7003dcf05e776498f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 22:29:25 +0200 Subject: [PATCH 4/7] Add an apply StringConversionInInterpolation rule --- .rubocop_basic.yml | 3 +++ app/models/poll/partial_result.rb | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index d675de4e0..d9643ff25 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -126,6 +126,9 @@ Lint/LiteralAsCondition: Lint/ShadowingOuterLocalVariable: Enabled: true +Lint/StringConversionInInterpolation: + Enabled: true + Lint/UselessAssignment: Enabled: true diff --git a/app/models/poll/partial_result.rb b/app/models/poll/partial_result.rb index 4c29144dd..cdb332558 100644 --- a/app/models/poll/partial_result.rb +++ b/app/models/poll/partial_result.rb @@ -21,9 +21,9 @@ class Poll::PartialResult < ApplicationRecord def update_logs if amount_changed? && amount_was.present? - self.amount_log += ":#{amount_was.to_s}" - self.officer_assignment_id_log += ":#{officer_assignment_id_was.to_s}" - self.author_id_log += ":#{author_id_was.to_s}" + self.amount_log += ":#{amount_was}" + self.officer_assignment_id_log += ":#{officer_assignment_id_was}" + self.author_id_log += ":#{author_id_was}" end end end From 93a2ebd46f5dcc8c46c28458d2a1e8d1ad51bfc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 22:35:34 +0200 Subject: [PATCH 5/7] Add and apply DuplicateMethods rubocop rule These methods were defined with `attr_reader` (or accessor in some cases) and then they were redefined. --- .rubocop_basic.yml | 3 +++ app/models/budget/result.rb | 2 +- lib/comment_tree.rb | 2 +- lib/email_digest.rb | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index d9643ff25..71f369571 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -120,6 +120,9 @@ Layout/TrailingWhitespace: Lint/AmbiguousRegexpLiteral: Enabled: true +Lint/DuplicateMethods: + Enabled: true + Lint/LiteralAsCondition: Enabled: true diff --git a/app/models/budget/result.rb b/app/models/budget/result.rb index d034e50ef..b28e7b2a9 100644 --- a/app/models/budget/result.rb +++ b/app/models/budget/result.rb @@ -1,7 +1,7 @@ class Budget class Result - attr_accessor :budget, :heading, :money_spent, :current_investment + attr_accessor :budget, :heading, :current_investment def initialize(budget, heading) @budget = budget diff --git a/lib/comment_tree.rb b/lib/comment_tree.rb index eedb64d96..b06eee833 100644 --- a/lib/comment_tree.rb +++ b/lib/comment_tree.rb @@ -2,7 +2,7 @@ class CommentTree ROOT_COMMENTS_PER_PAGE = 10 - attr_reader :root_comments, :commentable, :page, :order + attr_reader :commentable, :page, :order def initialize(commentable, page, order = "confidence_score", valuations: false) @commentable = commentable diff --git a/lib/email_digest.rb b/lib/email_digest.rb index 55bb62600..55cc65ae3 100644 --- a/lib/email_digest.rb +++ b/lib/email_digest.rb @@ -1,6 +1,6 @@ class EmailDigest - attr_accessor :user, :notifications + attr_accessor :user def initialize(user) @user = user From 447c970eb3fb4859159b81782f41b63d7c858d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 22:49:37 +0200 Subject: [PATCH 6/7] Remove unused block arguments There are more cases where we have unused block arguments, but I'm only changing the obvious ones. --- spec/factories/administration.rb | 2 +- spec/features/budgets/investments_spec.rb | 2 +- spec/shared/features/remotely_translatable.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/factories/administration.rb b/spec/factories/administration.rb index 7fed42216..591453de3 100644 --- a/spec/factories/administration.rb +++ b/spec/factories/administration.rb @@ -81,7 +81,7 @@ FactoryBot.define do header { true } sequence(:button_text) { |n| "Button text #{n}" } sequence(:button_url) { |n| "Button url #{n}" } - sequence(:alignment) { |n| "background" } + alignment { "background" } end after :create do |widget_card| diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 9eb6bcadb..034691e50 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -690,7 +690,7 @@ describe "Budget Investments" do end scenario "Random order maintained when going back from show" do - per_page.times { |i| create(:budget_investment, heading: heading) } + per_page.times { create(:budget_investment, heading: heading) } visit budget_investments_path(budget, heading_id: heading.id) diff --git a/spec/shared/features/remotely_translatable.rb b/spec/shared/features/remotely_translatable.rb index 1babdab6c..ecebd8d43 100644 --- a/spec/shared/features/remotely_translatable.rb +++ b/spec/shared/features/remotely_translatable.rb @@ -253,5 +253,5 @@ end def generate_response(resource) field_text = Faker::Lorem.characters(10) - resource.translated_attribute_names.map { |field| field_text } + resource.translated_attribute_names.map { field_text } end From 871fa020a5ca9e57d2706691ae7be4f9d7f0fc89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 28 Sep 2019 23:02:02 +0200 Subject: [PATCH 7/7] Add and apply ParenthesesAsGroupedExpression rule --- .rubocop_basic.yml | 3 + .../microsoft/available_locales.rb | 4 +- spec/features/admin/dashboard/actions_spec.rb | 2 +- .../admin/legislation/processes_spec.rb | 12 +-- spec/features/admin/widgets/cards_spec.rb | 4 +- spec/lib/remote_census_api_spec.rb | 98 +++++++++---------- spec/models/budget/phase_spec.rb | 2 +- spec/models/budget_spec.rb | 8 +- spec/models/concerns/sluggable.rb | 2 +- 9 files changed, 69 insertions(+), 66 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 71f369571..4cb8f19bc 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -126,6 +126,9 @@ Lint/DuplicateMethods: Lint/LiteralAsCondition: Enabled: true +Lint/ParenthesesAsGroupedExpression: + Enabled: true + Lint/ShadowingOuterLocalVariable: Enabled: true diff --git a/lib/remote_translations/microsoft/available_locales.rb b/lib/remote_translations/microsoft/available_locales.rb index 6afbd910d..bb46b723f 100644 --- a/lib/remote_translations/microsoft/available_locales.rb +++ b/lib/remote_translations/microsoft/available_locales.rb @@ -34,13 +34,13 @@ class RemoteTranslations::Microsoft::AvailableLocales host = "https://api.cognitive.microsofttranslator.com" path = "/languages?api-version=3.0" - uri = URI (host + path) + uri = URI(host + path) request = Net::HTTP::Get.new(uri) request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http| - http.request (request) + http.request(request) end result = response.body.force_encoding("utf-8") diff --git a/spec/features/admin/dashboard/actions_spec.rb b/spec/features/admin/dashboard/actions_spec.rb index e49bb4481..2aa1aee23 100644 --- a/spec/features/admin/dashboard/actions_spec.rb +++ b/spec/features/admin/dashboard/actions_spec.rb @@ -73,7 +73,7 @@ describe "Admin dashboard actions" do before do visit admin_dashboard_actions_path - within ("#dashboard_action_#{action.id}") do + within "#dashboard_action_#{action.id}" do click_link "Edit" end end diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index f2eea400b..f75b1bfb9 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -51,13 +51,13 @@ describe "Admin collaborative legislation" do visit admin_legislation_processes_path(filter: "all") - expect(page).to have_content (process_1.start_date) - expect(page).to have_content (process_2.start_date) - expect(page).to have_content (process_3.start_date) + expect(page).to have_content process_1.start_date + expect(page).to have_content process_2.start_date + expect(page).to have_content process_3.start_date - expect(page).to have_content (process_1.end_date) - expect(page).to have_content (process_2.end_date) - expect(page).to have_content (process_3.end_date) + expect(page).to have_content process_1.end_date + expect(page).to have_content process_2.end_date + expect(page).to have_content process_3.end_date expect(process_3.title).to appear_before(process_2.title) expect(process_2.title).to appear_before(process_1.title) diff --git a/spec/features/admin/widgets/cards_spec.rb b/spec/features/admin/widgets/cards_spec.rb index bed7e28ef..cafd94fa2 100644 --- a/spec/features/admin/widgets/cards_spec.rb +++ b/spec/features/admin/widgets/cards_spec.rb @@ -161,7 +161,7 @@ describe "Cards" do card_2 = create(:widget_card, page: custom_page, title: "Card medium", columns: 4) card_3 = create(:widget_card, page: custom_page, title: "Card small", columns: 2) - visit (custom_page).url + visit custom_page.url expect(page).to have_css(".card", count: 3) @@ -174,7 +174,7 @@ describe "Cards" do card_1 = create(:widget_card, page: custom_page, title: "Card one", label: "My label") card_2 = create(:widget_card, page: custom_page, title: "Card two") - visit (custom_page).url + visit custom_page.url within("#widget_card_#{card_1.id}") do expect(page).to have_selector("span", text: "My label") diff --git a/spec/lib/remote_census_api_spec.rb b/spec/lib/remote_census_api_spec.rb index 1f6c94283..5a5fe748a 100644 --- a/spec/lib/remote_census_api_spec.rb +++ b/spec/lib/remote_census_api_spec.rb @@ -86,15 +86,15 @@ describe RemoteCensusApi do request = RemoteCensusApi.new.send(:request, document_type, document_number, nil, nil) - expect(request).to eq ({ :request => - { :codigo_institucion => 1, - :codigo_portal => 1, - :codigo_usuario => 1, - :documento => "0123456", - :tipo_documento => "1", - :codigo_idioma => "102", - :nivel => "3" } - }) + expect(request).to eq({ :request => + { :codigo_institucion => 1, + :codigo_portal => 1, + :codigo_usuario => 1, + :documento => "0123456", + :tipo_documento => "1", + :codigo_idioma => "102", + :nivel => "3" } + }) end it "when send date_of_birth and postal_code but are not configured" do @@ -105,15 +105,15 @@ describe RemoteCensusApi do request = RemoteCensusApi.new.send(:request, document_type, document_number, date_of_birth, postal_code) - expect(request).to eq ({ :request => - { :codigo_institucion => 1, - :codigo_portal => 1, - :codigo_usuario => 1, - :documento => "0123456", - :tipo_documento => "1", - :codigo_idioma => "102", - :nivel => "3" } - }) + expect(request).to eq({ :request => + { :codigo_institucion => 1, + :codigo_portal => 1, + :codigo_usuario => 1, + :documento => "0123456", + :tipo_documento => "1", + :codigo_idioma => "102", + :nivel => "3" } + }) end it "when send date_of_birth and postal_code but are configured" do @@ -137,17 +137,17 @@ describe RemoteCensusApi do request = RemoteCensusApi.new.send(:request, document_type, document_number, date_of_birth, postal_code) - expect(request).to eq ({ :request => - { :codigo_institucion => 1, - :codigo_portal => 1, - :codigo_usuario => 1, - :documento => "0123456", - :tipo_documento => "1", - :fecha_nacimiento => "1980-01-01", - :codigo_postal => "28001", - :codigo_idioma => "102", - :nivel => "3" } - }) + expect(request).to eq({ :request => + { :codigo_institucion => 1, + :codigo_portal => 1, + :codigo_usuario => 1, + :documento => "0123456", + :tipo_documento => "1", + :fecha_nacimiento => "1980-01-01", + :codigo_postal => "28001", + :codigo_idioma => "102", + :nivel => "3" } + }) end end @@ -164,26 +164,26 @@ describe RemoteCensusApi do response = RemoteCensusApi.new.send(:get_response_body, document_type, document_number, nil, nil) - expect(response).to eq ({ get_habita_datos_response: { - get_habita_datos_return: { - datos_habitante: { - item: { - fecha_nacimiento_string: "31-12-1980", - identificador_documento: "12345678Z", - descripcion_sexo: "Varón", - nombre: "José", - apellido1: "García" - } - }, - datos_vivienda: { - item: { - codigo_postal: "28013", - codigo_distrito: "01" - } - } - } - } - }) + expect(response).to eq({ get_habita_datos_response: { + get_habita_datos_return: { + datos_habitante: { + item: { + fecha_nacimiento_string: "31-12-1980", + identificador_documento: "12345678Z", + descripcion_sexo: "Varón", + nombre: "José", + apellido1: "García" + } + }, + datos_vivienda: { + item: { + codigo_postal: "28013", + codigo_distrito: "01" + } + } + } + } + }) end end diff --git a/spec/models/budget/phase_spec.rb b/spec/models/budget/phase_spec.rb index 0dc52e170..a54634724 100644 --- a/spec/models/budget/phase_spec.rb +++ b/spec/models/budget/phase_spec.rb @@ -171,7 +171,7 @@ describe Budget::Phase do second_phase.update_attributes(enabled: false, starts_at: Date.current, ends_at: Date.current + 2.days) - end.not_to (change { prev_enabled_phase.ends_at }) + end.not_to change { prev_enabled_phase.ends_at } end it "adjusts next enabled phase start date to its own start date" do diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 55cf323a3..4859621f5 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -277,28 +277,28 @@ describe Budget do budget.update(currency_symbol: "€") I18n.locale = :es - expect(budget.formatted_amount(1000.00)).to eq ("1.000 €") + expect(budget.formatted_amount(1000.00)).to eq "1.000 €" end it "correctly formats Dollars with Spanish" do budget.update(currency_symbol: "$") I18n.locale = :es - expect(budget.formatted_amount(1000.00)).to eq ("1.000 $") + expect(budget.formatted_amount(1000.00)).to eq "1.000 $" end it "correctly formats Dollars with English" do budget.update(currency_symbol: "$") I18n.locale = :en - expect(budget.formatted_amount(1000.00)).to eq ("$1,000") + expect(budget.formatted_amount(1000.00)).to eq "$1,000" end it "correctly formats Euros with English" do budget.update(currency_symbol: "€") I18n.locale = :en - expect(budget.formatted_amount(1000.00)).to eq ("€1,000") + expect(budget.formatted_amount(1000.00)).to eq "€1,000" end end diff --git a/spec/models/concerns/sluggable.rb b/spec/models/concerns/sluggable.rb index 71cce4779..bb5896f20 100644 --- a/spec/models/concerns/sluggable.rb +++ b/spec/models/concerns/sluggable.rb @@ -23,7 +23,7 @@ shared_examples_for "sluggable" do |updatable_slug_trait:| context "slug updating condition is false" do it "slug isn't updated" do expect { sluggable.update_attributes(name: "New Name") } - .not_to (change { sluggable.slug }) + .not_to change { sluggable.slug } end end end