From 36e95b009a452c7c1520ce27289a24c5963412e6 Mon Sep 17 00:00:00 2001 From: Paul Padier Date: Thu, 31 Mar 2016 18:03:06 +0900 Subject: [PATCH] Fix Style/ClassAndModuleChildren offense --- .rubocop_todo.yml | 6 ------ spec/models/widget_spec.rb | 11 +++++++++++ test/unit/ar_id_map_test.rb | 26 -------------------------- 3 files changed, 11 insertions(+), 32 deletions(-) delete mode 100644 test/unit/ar_id_map_test.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0f64e2ae..8249fa4b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -38,12 +38,6 @@ Style/Alias: - 'test/dummy/app/models/song.rb' - 'test/unit/model_test.rb' -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'test/unit/ar_id_map_test.rb' - # Offense count: 33 Style/Documentation: Enabled: false diff --git a/spec/models/widget_spec.rb b/spec/models/widget_spec.rb index 1a619755..3e2ae205 100644 --- a/spec/models/widget_spec.rb +++ b/spec/models/widget_spec.rb @@ -126,6 +126,17 @@ describe Widget, type: :model do end end + if defined?(ActiveRecord::IdentityMap) && ActiveRecord::IdentityMap.respond_to?(:without) + describe "IdentityMap", versioning: true do + it "should not clobber the IdentityMap when reifying" do + widget.update_attributes name: "Henry", created_at: Time.now - 1.day + widget.update_attributes name: "Harry" + expect(ActiveRecord::IdentityMap).to receive(:without).once + widget.versions.last.reify + end + end + end + describe "Methods" do describe "Instance", versioning: true do describe '#paper_trail_originator' do diff --git a/test/unit/ar_id_map_test.rb b/test/unit/ar_id_map_test.rb deleted file mode 100644 index 8bdb217c..00000000 --- a/test/unit/ar_id_map_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -require "test_helper" - -class ARIdMapTest < ActiveSupport::TestCase - setup do - @widget = Widget.new - @widget.update_attributes name: "Henry", created_at: Time.now - 1.day - @widget.update_attributes name: "Harry" - end - - if defined?(ActiveRecord::IdentityMap) && ActiveRecord::IdentityMap.respond_to?(:without) - should "not clobber the IdentityMap when reifying" do - module ActiveRecord::IdentityMap - class << self - alias __without without - def without(&block) - @unclobbered = true - __without(&block) - end - end - end - - @widget.versions.last.reify - assert ActiveRecord::IdentityMap.instance_variable_get("@unclobbered") - end - end -end