diff --git a/.hound.yml b/.hound.yml index a8568704c..2c4f3544b 100644 --- a/.hound.yml +++ b/.hound.yml @@ -1,6 +1,6 @@ rubocop: - config_file: .rubocop_basic.yml - version: 0.72.0 + config_file: .rubocop.yml + version: 0.75.0 scss: config_file: .scss-lint.yml erblint: diff --git a/.rubocop.yml b/.rubocop.yml index 1f4d68f62..d89574c31 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,172 @@ -inherit_from: .rubocop_basic.yml +require: + - rubocop-performance + - rubocop-rails + - rubocop-rspec + +AllCops: + DisplayCopNames: true + DisplayStyleGuide: true + Exclude: + - "db/schema.rb" + DisabledByDefault: true + +Bundler/DuplicatedGem: + Enabled: true + +Bundler/OrderedGems: + Enabled: true + +Capybara/CurrentPathExpectation: + Enabled: true + +Capybara/FeatureMethods: + Enabled: true + EnabledMethods: + - scenario + - xscenario + +FactoryBot/AttributeDefinedStatically: + Enabled: true + +Layout/EmptyLineAfterGuardClause: + Enabled: true + +Layout/EmptyLineBetweenDefs: + Enabled: true + +Layout/EmptyLines: + Enabled: true + +Layout/EmptyLinesAroundAccessModifier: + Enabled: true + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +Layout/EmptyLinesAroundClassBody: + Enabled: true + +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/EndOfLine: + EnforcedStyle: lf + +Layout/ExtraSpacing: + Enabled: true + +Layout/IndentationConsistency: + EnforcedStyle: indented_internal_methods + +Layout/IndentationWidth: + Enabled: true + +Layout/MultilineBlockLayout: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAfterMethodName: + Enabled: true + +Layout/SpaceAfterNot: + Enabled: true + +Layout/SpaceAfterSemicolon: + Enabled: true + +Layout/SpaceAroundBlockParameters: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeBlockBraces: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeComment: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Layout/SpaceBeforeSemicolon: + Enabled: true + +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: true + +Layout/SpaceInsideArrayPercentLiteral: + Enabled: true + +Layout/SpaceInsideBlockBraces: + Enabled: true + +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + EnforcedStyle: compact + +Layout/SpaceInsideParens: + Enabled: true + +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: true + +Layout/SpaceInsideRangeLiteral: + Enabled: true + +Layout/SpaceInsideReferenceBrackets: + Enabled: true + +Layout/SpaceInsideStringInterpolation: + Enabled: true + +Layout/Tab: + Enabled: true + +Layout/TrailingBlankLines: + Enabled: true + +Layout/TrailingWhitespace: + Enabled: true + +Lint/AmbiguousRegexpLiteral: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/LiteralAsCondition: + Enabled: true + +Lint/ParenthesesAsGroupedExpression: + Enabled: true + +Lint/ShadowingOuterLocalVariable: + Enabled: true + +Lint/StringConversionInInterpolation: + Enabled: true + +Lint/UselessAssignment: + Enabled: true + +Metrics/LineLength: + Max: 110 + Severity: refactor Performance/CompareWithBlock: Enabled: true @@ -15,17 +183,186 @@ Performance/EndWith: Performance/StartWith: Enabled: true -Rails/HasManyOrHasOneDependent: +Rails/ActionFilter: Enabled: true +Rails/ApplicationJob: + Enabled: true + +Rails/ApplicationRecord: + Enabled: true + +Rails/CreateTableWithTimestamps: + Enabled: true + Exclude: + - "db/migrate/201[5-8]*" + +Rails/Date: + Enabled: true + +Rails/DynamicFindBy: + Enabled: true + Severity: refactor + +Rails/EnumUniqueness: + Enabled: true + +Rails/EnvironmentComparison: + Enabled: true + +Rails/FindBy: + Enabled: true + +Rails/FindEach: + Enabled: true + +Rails/HasAndBelongsToMany: + Enabled: true + +Rails/HasManyOrHasOneDependent: + Enabled: true + Severity: refactor + +Rails/HttpPositionalArguments: + Enabled: true + +Rails/InverseOf: + Enabled: true + Exclude: + - "app/models/related_content.rb" + +Rails/NotNullColumn: + Enabled: true + Exclude: + - "db/migrate/201[5-7]*" + +Rails/OutputSafety: + Enabled: true + Severity: warning + Exclude: + - app/helpers/text_with_links_helper.rb + +Rails/PluralizationGrammar: + Enabled: true + +Rails/Presence: + Enabled: true + +Rails/RelativeDateConstant: + Enabled: true + +Rails/RequestReferer: + Enabled: true + +Rails/ReversibleMigration: + Enabled: true + +Rails/SafeNavigation: + Enabled: true + ConvertTry: true + +Rails/SaveBang: + Enabled: true + Severity: refactor + Rails/SkipsModelValidations: Enabled: true + Blacklist: + - update_attribute + Exclude: + - lib/acts_as_paranoid_aliases.rb + +Rails/TimeZone: + Enabled: true + +Rails/UnknownEnv: + Enabled: true + Environments: + - development + - test + - production + - preproduction + - staging + +Rails/Validation: + Enabled: true + +RSpec/AroundBlock: + Enabled: true + +RSpec/BeforeAfterAll: + Enabled: true + +RSpec/DescribedClass: + Enabled: true + EnforcedStyle: explicit + +RSpec/EmptyExampleGroup: + Enabled: true + Exclude: + - spec/factories/**/* + +RSpec/EmptyLineAfterExampleGroup: + Enabled: true + Exclude: + - spec/factories/**/* + +RSpec/ExampleWording: + Enabled: true + +RSpec/Focus: + Enabled: true + +RSpec/HookArgument: + Enabled: true + +RSpec/InstanceVariable: + Enabled: true + Exclude: + - spec/controllers/concerns/has_filters_spec.rb + - spec/controllers/concerns/has_orders_spec.rb + +RSpec/LetBeforeExamples: + Enabled: true + +RSpec/LetSetup: + Enabled: true + +RSpec/NotToNot: + Enabled: true + +RSpec/OverwritingSetup: + Enabled: true + +RSpec/RepeatedExample: + Enabled: true + +RSpec/ScatteredLet: + Enabled: true + +RSpec/ScatteredSetup: + Enabled: true + +RSpec/VoidExpect: + Enabled: true + +Security/Eval: + Enabled: true Security/JSONLoad: Enabled: true -Security/MarshalLoad: - Enabled: true - Security/YAMLLoad: Enabled: true + +Style/BlockDelimiters: + Enabled: true + +Style/PercentLiteralDelimiters: + Enabled: true + +Style/SafeNavigation: + Enabled: true + +Style/StringLiterals: + EnforcedStyle: double_quotes diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml deleted file mode 100644 index 364ae1b84..000000000 --- a/.rubocop_basic.yml +++ /dev/null @@ -1,338 +0,0 @@ -require: - - rubocop-performance - - rubocop-rails - - rubocop-rspec - -AllCops: - DisplayCopNames: true - DisplayStyleGuide: true - Exclude: - - "db/schema.rb" - # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop - # to ignore them, so only the ones explicitly set in this file are enabled. - DisabledByDefault: true - -Bundler/DuplicatedGem: - Enabled: true - -Bundler/OrderedGems: - Enabled: true - -Capybara/CurrentPathExpectation: - Enabled: true - -Capybara/FeatureMethods: - Enabled: true - EnabledMethods: - - scenario - - xscenario - -FactoryBot/AttributeDefinedStatically: - Enabled: true - -Layout/EmptyLineAfterGuardClause: - Enabled: true - -Layout/EmptyLineBetweenDefs: - Enabled: true - -Layout/EmptyLinesAroundAccessModifier: - Enabled: true - -Layout/EmptyLinesAroundBlockBody: - Enabled: true - -Layout/EmptyLinesAroundClassBody: - Enabled: true - -Layout/EmptyLinesAroundMethodBody: - Enabled: true - -Layout/EmptyLinesAroundModuleBody: - Enabled: true - -Layout/ExtraSpacing: - Enabled: true - -Layout/SpaceAroundEqualsInParameterDefault: - Enabled: true - -Layout/IndentationConsistency: - EnforcedStyle: indented_internal_methods - -Layout/IndentationWidth: - Enabled: true - -Layout/EmptyLines: - Enabled: true - -Layout/EndOfLine: - EnforcedStyle: lf - -Layout/MultilineBlockLayout: - Enabled: true - -Layout/SpaceAfterColon: - Enabled: true - -Layout/SpaceAfterComma: - Enabled: true - -Layout/SpaceAfterMethodName: - Enabled: true - -Layout/SpaceAfterNot: - Enabled: true - -Layout/SpaceAfterSemicolon: - Enabled: true - -Layout/SpaceAroundBlockParameters: - Enabled: true - -Layout/SpaceAroundOperators: - Enabled: true - -Layout/SpaceBeforeBlockBraces: - Enabled: true - -Layout/SpaceBeforeComma: - Enabled: true - -Layout/SpaceBeforeComment: - Enabled: true - -Layout/SpaceBeforeFirstArg: - Enabled: true - -Layout/SpaceBeforeSemicolon: - Enabled: true - -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: true - -Layout/SpaceInsideArrayPercentLiteral: - Enabled: true - -Layout/SpaceInsideBlockBraces: - Enabled: true - -Layout/SpaceInsideHashLiteralBraces: - Enabled: true - EnforcedStyle: compact - -Layout/SpaceInsideParens: - Enabled: true - -Layout/SpaceInsidePercentLiteralDelimiters: - Enabled: true - -Layout/SpaceInsideRangeLiteral: - Enabled: true - -Layout/SpaceInsideReferenceBrackets: - Enabled: true - -Layout/SpaceInsideStringInterpolation: - Enabled: true - -Layout/Tab: - Enabled: true - -Layout/TrailingBlankLines: - Enabled: true - -Layout/TrailingWhitespace: - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Enabled: true - -Lint/DuplicateMethods: - Enabled: true - -Lint/LiteralAsCondition: - Enabled: true - -Lint/ParenthesesAsGroupedExpression: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/StringConversionInInterpolation: - Enabled: true - -Lint/UselessAssignment: - Enabled: true - -Metrics/LineLength: - Max: 110 - Severity: refactor - -Rails/ActionFilter: - Enabled: true - -Rails/ApplicationJob: - Enabled: true - -Rails/ApplicationRecord: - Enabled: true - -Rails/CreateTableWithTimestamps: - Enabled: true - Exclude: - - "db/migrate/201[5-8]*" - -Rails/Date: - Enabled: true - -Rails/DynamicFindBy: - Enabled: true - Severity: refactor - -Rails/EnumUniqueness: - Enabled: true - -Rails/EnvironmentComparison: - Enabled: true - -Rails/FindBy: - Enabled: true - -Rails/FindEach: - Enabled: true - -Rails/HttpPositionalArguments: - Enabled: true - -Rails/HasAndBelongsToMany: - Enabled: true - -Rails/InverseOf: - Enabled: true - Exclude: - - "app/models/related_content.rb" - -Rails/NotNullColumn: - Enabled: true - Exclude: - - "db/migrate/201[5-7]*" - -Rails/OutputSafety: - Enabled: true - Severity: warning - Exclude: - - app/helpers/text_with_links_helper.rb - -Rails/PluralizationGrammar: - Enabled: true - -Rails/Presence: - Enabled: true - -Rails/RelativeDateConstant: - Enabled: true - -Rails/RequestReferer: - Enabled: true - -Rails/ReversibleMigration: - Enabled: true - -Rails/SafeNavigation: - Enabled: true - ConvertTry: true - -Rails/SaveBang: - Enabled: true - Severity: refactor - -Rails/TimeZone: - Enabled: true - -Rails/UnknownEnv: - Enabled: true - Environments: - - development - - test - - production - - preproduction - - staging - -Rails/Validation: - Enabled: true - -RSpec/AroundBlock: - Enabled: true - -RSpec/BeforeAfterAll: - Enabled: true - -RSpec/DescribedClass: - Enabled: true - EnforcedStyle: explicit - -RSpec/EmptyExampleGroup: - Enabled: true - Exclude: - - spec/factories/**/* - -RSpec/EmptyLineAfterExampleGroup: - Enabled: true - Exclude: - - spec/factories/**/* - -RSpec/ExampleWording: - Enabled: true - -RSpec/Focus: - Enabled: true - -RSpec/HookArgument: - Enabled: true - -RSpec/InstanceVariable: - Enabled: true - Exclude: - - spec/controllers/concerns/has_filters_spec.rb - - spec/controllers/concerns/has_orders_spec.rb - -RSpec/LetBeforeExamples: - Enabled: true - -RSpec/LetSetup: - Enabled: true - -RSpec/NotToNot: - Enabled: true - -RSpec/OverwritingSetup: - Enabled: true - -RSpec/RepeatedExample: - Enabled: true - -RSpec/ScatteredLet: - Enabled: true - -RSpec/ScatteredSetup: - Enabled: true - -RSpec/VoidExpect: - Enabled: true - -Security/Eval: - Enabled: true - -Style/BlockDelimiters: - Enabled: true - -Style/PercentLiteralDelimiters: - Enabled: true - -Style/SafeNavigation: - Enabled: true - -Style/StringLiterals: - EnforcedStyle: double_quotes diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 67ff502d4..ee2103ee2 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -36,12 +36,12 @@ class DebatesController < ApplicationController end def unmark_featured - @debate.update_attribute(:featured_at, nil) + @debate.update!(featured_at: nil) redirect_to request.query_parameters.merge(action: :index) end def mark_featured - @debate.update_attribute(:featured_at, Time.current) + @debate.update!(featured_at: Time.current) redirect_to request.query_parameters.merge(action: :index) end diff --git a/app/models/budget/phase.rb b/app/models/budget/phase.rb index 6432a13b1..de90075a7 100644 --- a/app/models/budget/phase.rb +++ b/app/models/budget/phase.rb @@ -11,7 +11,7 @@ class Budget include Globalizable include Sanitizable - belongs_to :budget + belongs_to :budget, touch: true belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase has_one :prev_phase, class_name: self.name, foreign_key: :next_phase_id, inverse_of: :next_phase @@ -24,7 +24,6 @@ class Budget validate :next_phase_dates_valid? after_save :adjust_date_ranges - after_save :touch_budget scope :enabled, -> { where(enabled: true) } scope :published, -> { enabled.where.not(kind: "drafting") } @@ -70,10 +69,6 @@ class Budget end end - def touch_budget - budget.touch - end - def prev_phase_dates_valid? if enabled? && starts_at.present? && prev_enabled_phase.present? prev_enabled_phase.assign_attributes(ends_at: starts_at) diff --git a/app/models/poll/question/answer.rb b/app/models/poll/question/answer.rb index cb431b9b2..91320743c 100644 --- a/app/models/poll/question/answer.rb +++ b/app/models/poll/question/answer.rb @@ -21,7 +21,7 @@ class Poll::Question::Answer < ApplicationRecord def self.order_answers(ordered_array) ordered_array.each_with_index do |answer_id, order| - find(answer_id).update_attribute(:given_order, (order + 1)) + find(answer_id).update_column(:given_order, (order + 1)) end end diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 9ec1af021..6f9cfc9b2 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -27,7 +27,7 @@ describe CommentsController do it "does not create a comment if the comments are closed" do sign_in user - legal_process.update_attribute(:debate_end_date, Date.current - 1.day) + legal_process.update!(debate_end_date: Date.current - 1.day) expect do post :create, xhr: true, diff --git a/spec/controllers/legislation/annotations_controller_spec.rb b/spec/controllers/legislation/annotations_controller_spec.rb index b309d7910..1768b4a3d 100644 --- a/spec/controllers/legislation/annotations_controller_spec.rb +++ b/spec/controllers/legislation/annotations_controller_spec.rb @@ -81,7 +81,7 @@ describe Legislation::AnnotationsController do it "does not create an annotation if the process allegations phase is not open" do sign_in user - legal_process.update_attribute(:allegations_end_date, Date.current - 1.day) + legal_process.update!(allegations_end_date: Date.current - 1.day) expect do post :create, xhr: true, diff --git a/spec/controllers/legislation/answers_controller_spec.rb b/spec/controllers/legislation/answers_controller_spec.rb index b45b97e6f..e05731801 100644 --- a/spec/controllers/legislation/answers_controller_spec.rb +++ b/spec/controllers/legislation/answers_controller_spec.rb @@ -41,7 +41,7 @@ describe Legislation::AnswersController do it "does not create an answer if the process debate phase is not open" do sign_in user - legal_process.update_attribute(:debate_end_date, Date.current - 1.day) + legal_process.update!(debate_end_date: Date.current - 1.day) expect do post :create, xhr: true, diff --git a/spec/features/admin/admin_notifications_spec.rb b/spec/features/admin/admin_notifications_spec.rb index 1829e2d60..6e8f69c9e 100644 --- a/spec/features/admin/admin_notifications_spec.rb +++ b/spec/features/admin/admin_notifications_spec.rb @@ -23,7 +23,7 @@ describe "Admin Notifications" do scenario "Notification with invalid segment recipient" do invalid_notification = create(:admin_notification) - invalid_notification.update_attribute(:segment_recipient, "invalid_segment") + invalid_notification.update_column(:segment_recipient, "invalid_segment") visit admin_admin_notification_path(invalid_notification) @@ -56,7 +56,7 @@ describe "Admin Notifications" do scenario "Notifications with invalid segment recipient" do invalid_notification = create(:admin_notification) - invalid_notification.update_attribute(:segment_recipient, "invalid_segment") + invalid_notification.update_column(:segment_recipient, "invalid_segment") visit admin_admin_notifications_path @@ -209,7 +209,7 @@ describe "Admin Notifications" do scenario "Admin notification with invalid segment recipient cannot be sent", :js do invalid_notification = create(:admin_notification) - invalid_notification.update_attribute(:segment_recipient, "invalid_segment") + invalid_notification.update_column(:segment_recipient, "invalid_segment") visit admin_admin_notification_path(invalid_notification) expect(page).not_to have_link("Send") diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 93d55e92a..3bb12abdb 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -1832,7 +1832,7 @@ describe "Admin budget investments" do end scenario "Select an investment when some columns are not displayed", :js do - investment.update_attribute(:title, "Don't display me, please!") + investment.update!(title: "Don't display me, please!") visit admin_budget_budget_investments_path(budget) within("#js-columns-selector") { find("strong", text: "Columns").click } diff --git a/spec/features/admin/emails/emails_download_spec.rb b/spec/features/admin/emails/emails_download_spec.rb index 382107199..9c29a0742 100644 --- a/spec/features/admin/emails/emails_download_spec.rb +++ b/spec/features/admin/emails/emails_download_spec.rb @@ -19,7 +19,7 @@ describe "Admin download user emails" do admin_without_email = create(:user, newsletter: true, email: "no_email@consul.dev") create(:administrator, user: admin_without_email) - admin_without_email.update_attribute(:email, nil) + admin_without_email.update_column(:email, nil) end scenario "returns the selected users segment csv file" do diff --git a/spec/features/admin/emails/newsletters_spec.rb b/spec/features/admin/emails/newsletters_spec.rb index a1acb8ef4..d78b3c0fe 100644 --- a/spec/features/admin/emails/newsletters_spec.rb +++ b/spec/features/admin/emails/newsletters_spec.rb @@ -23,7 +23,7 @@ describe "Admin newsletter emails" do scenario "Invalid newsletter" do invalid_newsletter = create(:newsletter) - invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment") + invalid_newsletter.update_column(:segment_recipient, "invalid_segment") visit admin_newsletter_path(invalid_newsletter) @@ -50,7 +50,7 @@ describe "Admin newsletter emails" do scenario "Invalid newsletter" do invalid_newsletter = create(:newsletter) - invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment") + invalid_newsletter.update_column(:segment_recipient, "invalid_segment") visit admin_newsletters_path @@ -136,7 +136,7 @@ describe "Admin newsletter emails" do scenario "Invalid newsletter cannot be sent", :js do invalid_newsletter = create(:newsletter) - invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment") + invalid_newsletter.update_column(:segment_recipient, "invalid_segment") visit admin_newsletter_path(invalid_newsletter) expect(page).not_to have_link("Send") diff --git a/spec/features/legislation/questions_spec.rb b/spec/features/legislation/questions_spec.rb index 32d416c77..10deb9a95 100644 --- a/spec/features/legislation/questions_spec.rb +++ b/spec/features/legislation/questions_spec.rb @@ -94,7 +94,7 @@ describe "Legislation" do end scenario "cannot answer question when phase not open" do - process.update_attribute(:debate_end_date, Date.current - 1.day) + process.update!(debate_end_date: Date.current - 1.day) question = process.questions.first create(:legislation_question_option, question: question, value: "Yes") create(:legislation_question_option, question: question, value: "No") diff --git a/spec/lib/email_digests_spec.rb b/spec/lib/email_digests_spec.rb index ab96fc0d6..d079691c9 100644 --- a/spec/lib/email_digests_spec.rb +++ b/spec/lib/email_digests_spec.rb @@ -133,7 +133,7 @@ describe EmailDigest do it "returns false if email does not exist" do user = create(:user) - user.update_attribute(:email, nil) + user.email = nil email_digest = EmailDigest.new(user) expect(email_digest.valid_email?).to be(false) diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 4f87927d0..ae896819c 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -989,7 +989,7 @@ describe Budget::Investment do user.erase user.update!(document_number: nil) expect(user.document_number).to be_blank - investment.touch + investment.valid? expect(investment.responsible_name).to eq("123456") end end diff --git a/spec/models/budget/phase_spec.rb b/spec/models/budget/phase_spec.rb index c0b4852b7..e44a2e234 100644 --- a/spec/models/budget/phase_spec.rb +++ b/spec/models/budget/phase_spec.rb @@ -115,6 +115,18 @@ describe Budget::Phase do end end + describe "#save" do + it "touches the budget when it's updated" do + budget = create(:budget) + + travel(10.seconds) do + budget.current_phase.update!(enabled: false) + + expect(budget.updated_at).to eq Time.current + end + end + end + describe "#adjust_date_ranges" do let(:prev_enabled_phase) { second_phase.prev_enabled_phase } let(:next_enabled_phase) { second_phase.next_enabled_phase } diff --git a/spec/models/concerns/globalizable.rb b/spec/models/concerns/globalizable.rb index fc4c01e61..c72de6499 100644 --- a/spec/models/concerns/globalizable.rb +++ b/spec/models/concerns/globalizable.rb @@ -13,11 +13,11 @@ shared_examples_for "globalizable" do |factory_name| let(:attribute) { required_fields.sample || fields.sample } before do - record.update_attribute(attribute, "In English") + record.update!(attribute => "In English") I18n.with_locale(:es) do record.update!(required_fields.map { |field| [field, "En español"] }.to_h) - record.update_attribute(attribute, "En español") + record.update!(attribute => "En español") end record.reload @@ -156,7 +156,7 @@ shared_examples_for "globalizable" do |factory_name| before do I18n.with_locale(:de) do record.update!(required_fields.map { |field| [field, "Deutsch"] }.to_h) - record.update_attribute(attribute, "Deutsch") + record.update!(attribute => "Deutsch") end end diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index e75660a53..3cc07c438 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -253,7 +253,7 @@ describe Proposal do proposal = create(:proposal) tag_list = ["tag1", "tag2", "tag3", "tag4", "tag5", "tag6", "tag7"] - proposal.update_attribute(:tag_list, tag_list) + proposal.update!(tag_list: tag_list) expect(proposal.update_cached_votes).to eq(true) end