Lint: rubocop 0.48.0 (was 0.41.2)
This commit is contained in:
parent
27eab748e7
commit
e185ae989f
|
@ -48,6 +48,9 @@ cd ../..
|
|||
|
||||
# Run tests
|
||||
DB=sqlite bundle exec appraisal ar-4.2 rake
|
||||
|
||||
# Run a single minitest file
|
||||
DB=sqlite bundle exec appraisal ar-4.2 ruby -I test test/unit/associations_test.rb
|
||||
```
|
||||
|
||||
### Test sqlite, AR 5
|
||||
|
|
21
.rubocop.yml
21
.rubocop.yml
|
@ -23,6 +23,10 @@ Metrics/AbcSize:
|
|||
Exclude:
|
||||
- 'test/dummy/db/migrate/*'
|
||||
|
||||
# Not a useful metric compared to, e.g. `AbcSize`.
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
|
||||
# Not a useful metric compared to, e.g. `AbcSize`.
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
|
@ -43,6 +47,13 @@ Metrics/MethodLength:
|
|||
Metrics/ModuleLength:
|
||||
Enabled: false
|
||||
|
||||
# In an ideal world, each example has a single expectation. In the real world,
|
||||
# sometimes setup is a pain and you don't want to duplicate setup in multiple
|
||||
# examples, or make the specs more confusing with many nested `context`s, and
|
||||
# the practical thing is to have multiple expectations.
|
||||
RSpec/MultipleExpectations:
|
||||
Enabled: false
|
||||
|
||||
Style/AlignParameters:
|
||||
EnforcedStyle: with_fixed_indentation
|
||||
|
||||
|
@ -59,17 +70,25 @@ Style/DotPosition:
|
|||
Style/DoubleNegation:
|
||||
Enabled: false
|
||||
|
||||
Style/FileName:
|
||||
Exclude:
|
||||
- Appraisals
|
||||
|
||||
# The decision of when to use a guard clause to improve readability is subtle,
|
||||
# and it's not clear that it can be linted. Certainly, the default
|
||||
# `MinBodyLength` of 1 can actually hurt readability.
|
||||
Style/GuardClause:
|
||||
MinBodyLength: 3
|
||||
Enabled: false
|
||||
|
||||
# Use postfix (modifier) conditionals for one-liners, unless doing so would
|
||||
# exceed 60 characters.
|
||||
Style/IfUnlessModifier:
|
||||
MaxLineLength: 60
|
||||
|
||||
Style/IndentHeredoc:
|
||||
Exclude:
|
||||
- paper_trail.gemspec
|
||||
|
||||
# The Ruby Style Guide says:
|
||||
#
|
||||
# > Use \ instead of + or << to concatenate two string literals at line end.
|
||||
|
|
|
@ -3,6 +3,9 @@ require: rubocop-rspec
|
|||
# Remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
|
||||
Lint/AmbiguousBlockAssociation:
|
||||
Enabled: false
|
||||
|
||||
Metrics/AbcSize:
|
||||
Max: 22 # Goal: 15
|
||||
|
||||
|
@ -15,20 +18,38 @@ Metrics/PerceivedComplexity:
|
|||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
||||
|
||||
RSpec/InstanceVariable:
|
||||
Enabled: false
|
||||
|
||||
RSpec/ExampleWording:
|
||||
RSpec/BeforeAfterAll:
|
||||
Enabled: false
|
||||
|
||||
RSpec/DescribedClass:
|
||||
Enabled: false
|
||||
|
||||
RSpec/ExampleWording:
|
||||
Enabled: false
|
||||
|
||||
RSpec/ExampleLength:
|
||||
Enabled: false
|
||||
|
||||
RSpec/ExpectActual:
|
||||
Enabled: false
|
||||
|
||||
RSpec/FilePath:
|
||||
Enabled: false
|
||||
|
||||
RSpec/InstanceVariable:
|
||||
Enabled: false
|
||||
|
||||
RSpec/MessageSpies:
|
||||
Enabled: false
|
||||
|
||||
RSpec/NamedSubject:
|
||||
Enabled: false
|
||||
|
||||
RSpec/NestedGroups:
|
||||
Enabled: false
|
||||
|
||||
RSpec/NotToNot:
|
||||
Enabled: false
|
||||
|
||||
RSpec/FilePath:
|
||||
Security/YAMLLoad:
|
||||
Enabled: false
|
||||
|
|
|
@ -18,7 +18,7 @@ end
|
|||
appraise "ar-5.0" do
|
||||
gem "activerecord", "~> 5.0.0"
|
||||
gem "rspec-rails", "~> 3.5.1"
|
||||
gem 'rails-controller-testing'
|
||||
gem "rails-controller-testing"
|
||||
end
|
||||
|
||||
appraise "ar_master" do
|
||||
|
|
|
@ -41,8 +41,8 @@ has been destroyed.
|
|||
s.add_development_dependency "generator_spec", "~> 0.9.3"
|
||||
s.add_development_dependency "database_cleaner", "~> 1.2"
|
||||
s.add_development_dependency "pry-nav", "~> 0.2.4"
|
||||
s.add_development_dependency "rubocop", "~> 0.41.2"
|
||||
s.add_development_dependency "rubocop-rspec", "~> 1.5.1"
|
||||
s.add_development_dependency "rubocop", "~> 0.48.0"
|
||||
s.add_development_dependency "rubocop-rspec", "~> 1.15.0"
|
||||
s.add_development_dependency "timecop", "~> 0.8.0"
|
||||
s.add_development_dependency "sqlite3", "~> 1.2"
|
||||
s.add_development_dependency "pg", "~> 0.19.0"
|
||||
|
|
|
@ -10,6 +10,7 @@ describe Boolit, type: :model do
|
|||
|
||||
describe "Versioning", versioning: true do
|
||||
subject { Boolit.create! }
|
||||
|
||||
before { subject.update_attributes!(name: FFaker::Name.name) }
|
||||
|
||||
it "should have versions" do
|
||||
|
|
|
@ -46,13 +46,15 @@ describe PaperTrail::Version, type: :model do
|
|||
end
|
||||
|
||||
context "Has previous version", versioning: true do
|
||||
subject { widget.versions.last }
|
||||
|
||||
let(:name) { FFaker::Name.name }
|
||||
let(:widget) { Widget.create!(name: FFaker::Name.name) }
|
||||
|
||||
before do
|
||||
widget.versions.first.update_attributes!(whodunnit: name)
|
||||
widget.update_attributes!(name: FFaker::Name.first_name)
|
||||
end
|
||||
subject { widget.versions.last }
|
||||
|
||||
specify { expect(subject.previous).to be_instance_of(PaperTrail::Version) }
|
||||
|
||||
|
@ -79,9 +81,10 @@ describe PaperTrail::Version, type: :model do
|
|||
end
|
||||
|
||||
describe "#terminator" do
|
||||
let(:attributes) { { whodunnit: FFaker::Name.first_name } }
|
||||
subject { PaperTrail::Version.new attributes }
|
||||
|
||||
let(:attributes) { { whodunnit: FFaker::Name.first_name } }
|
||||
|
||||
it { is_expected.to respond_to(:terminator) }
|
||||
|
||||
it "is an alias for the `whodunnit` attribute" do
|
||||
|
|
|
@ -51,7 +51,7 @@ describe Widget, type: :model do
|
|||
end
|
||||
|
||||
describe "Callbacks", versioning: true do
|
||||
describe :before_save do
|
||||
describe "before_save" do
|
||||
context ":on => :update" do
|
||||
before { widget.update_attributes!(name: "Foobar") }
|
||||
|
||||
|
@ -66,7 +66,7 @@ describe Widget, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe :after_create do
|
||||
describe "after_create" do
|
||||
let(:widget) { Widget.create!(name: "Foobar", created_at: Time.now - 1.week) }
|
||||
|
||||
it "corresponding version should use the widget's `updated_at`" do
|
||||
|
@ -74,7 +74,7 @@ describe Widget, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe :after_update do
|
||||
describe "after_update" do
|
||||
before { widget.update_attributes!(name: "Foobar", updated_at: Time.now + 1.week) }
|
||||
|
||||
subject { widget.versions.last.reify }
|
||||
|
@ -91,7 +91,7 @@ describe Widget, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe :after_destroy do
|
||||
describe "after_destroy" do
|
||||
it "should create a version for that event" do
|
||||
expect { widget.destroy }.to change(widget.versions, :count).by(1)
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ describe Widget, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe :after_rollback do
|
||||
describe "after_rollback" do
|
||||
let(:rolled_back_name) { "Big Moo" }
|
||||
|
||||
before do
|
||||
|
@ -194,7 +194,10 @@ describe Widget, type: :model do
|
|||
describe "return value" do
|
||||
let(:orig_name) { FFaker::Name.name }
|
||||
let(:new_name) { FFaker::Name.name }
|
||||
before { PaperTrail.whodunnit = orig_name }
|
||||
|
||||
before do
|
||||
PaperTrail.whodunnit = orig_name
|
||||
end
|
||||
|
||||
context "accessed from live model instance" do
|
||||
specify { expect(widget.paper_trail).to be_live }
|
||||
|
|
|
@ -4,25 +4,25 @@ describe PaperTrail::VERSION do
|
|||
describe "Constants" do
|
||||
subject { PaperTrail::VERSION }
|
||||
|
||||
describe :MAJOR do
|
||||
describe "MAJOR" do
|
||||
it { is_expected.to be_const_defined(:MAJOR) }
|
||||
it { expect(subject::MAJOR).to be_a(Integer) }
|
||||
end
|
||||
describe :MINOR do
|
||||
describe "MINOR" do
|
||||
it { is_expected.to be_const_defined(:MINOR) }
|
||||
it { expect(subject::MINOR).to be_a(Integer) }
|
||||
end
|
||||
describe :TINY do
|
||||
describe "TINY" do
|
||||
it { is_expected.to be_const_defined(:TINY) }
|
||||
it { expect(subject::TINY).to be_a(Integer) }
|
||||
end
|
||||
describe :PRE do
|
||||
describe "PRE" do
|
||||
it { is_expected.to be_const_defined(:PRE) }
|
||||
if PaperTrail::VERSION::PRE
|
||||
it { expect(subject::PRE).to be_instance_of(String) }
|
||||
end
|
||||
end
|
||||
describe :STRING do
|
||||
describe "STRING" do
|
||||
it { is_expected.to be_const_defined(:STRING) }
|
||||
it { expect(subject::STRING).to be_instance_of(String) }
|
||||
|
||||
|
|
|
@ -61,12 +61,12 @@ describe PaperTrail do
|
|||
end
|
||||
end
|
||||
|
||||
describe :version do
|
||||
describe ".version" do
|
||||
it { expect(PaperTrail).to respond_to(:version) }
|
||||
it { expect(PaperTrail.version).to eq(PaperTrail::VERSION::STRING) }
|
||||
end
|
||||
|
||||
describe :whodunnit do
|
||||
describe ".whodunnit" do
|
||||
before(:all) { PaperTrail.whodunnit = "foobar" }
|
||||
|
||||
it "should get set to `nil` by default" do
|
||||
|
@ -74,7 +74,7 @@ describe PaperTrail do
|
|||
end
|
||||
end
|
||||
|
||||
describe :controller_info do
|
||||
describe ".controller_info" do
|
||||
before(:all) { ::PaperTrail.controller_info = { foo: "bar" } }
|
||||
|
||||
it "should get set to an empty hash before each test" do
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
require "securerandom"
|
||||
|
||||
class CustomPrimaryKeyRecord < ActiveRecord::Base
|
||||
self.primary_key = :uuid
|
||||
|
||||
has_paper_trail class_name: "CustomPrimaryKeyRecordVersion"
|
||||
# this unusual default_scope is to test the case of the Version#item association
|
||||
|
||||
# This default_scope is to test the case of the Version#item association
|
||||
# not returning the item due to unmatched default_scope on the model.
|
||||
default_scope -> { where(name: "custom_primary_key_record") }
|
||||
default_scope { where(name: "custom_primary_key_record") }
|
||||
|
||||
before_create do
|
||||
self.uuid ||= SecureRandom.uuid
|
||||
|
|
|
@ -43,10 +43,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @widget_0 = @widget.versions.last.reify(has_one: true) }
|
||||
setup { @widget0 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_nil @widget_0.wotsit
|
||||
assert_nil @widget0.wotsit
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -63,10 +63,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @widget_0 = @widget.versions.last.reify(has_one: true) }
|
||||
setup { @widget0 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal "wotsit_0", @widget_0.wotsit.name
|
||||
assert_equal "wotsit_0", @widget0.wotsit.name
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -84,10 +84,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @widget_1 = @widget.versions.last.reify(has_one: true) }
|
||||
setup { @widget1 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal "wotsit_2", @widget_1.wotsit.name
|
||||
assert_equal "wotsit_2", @widget1.wotsit.name
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -96,10 +96,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified opting out of has_one reification" do
|
||||
setup { @widget_1 = @widget.versions.last.reify(has_one: false) }
|
||||
setup { @widget1 = @widget.versions.last.reify(has_one: false) }
|
||||
|
||||
should "see the associated as it is live" do
|
||||
assert_equal "wotsit_3", @widget_1.wotsit.name
|
||||
assert_equal "wotsit_3", @widget1.wotsit.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -110,10 +110,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reify" do
|
||||
setup { @widget_1 = @widget.versions.last.reify(has_one: true) }
|
||||
setup { @widget1 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal @wotsit, @widget_1.wotsit
|
||||
assert_equal @wotsit, @widget1.wotsit
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -128,10 +128,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @widget_2 = @widget.versions.last.reify(has_one: true) }
|
||||
setup { @widget2 = @widget.versions.last.reify(has_one: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_nil @widget_2.wotsit
|
||||
assert_nil @widget2.wotsit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -149,10 +149,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [], @customer_0.orders
|
||||
assert_equal [], @customer0.orders
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -162,11 +162,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
should "mark the associated for destruction" do
|
||||
@customer_0 = @customer.versions.last.reify(
|
||||
@customer0 = @customer.versions.last.reify(
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
assert_equal [true], @customer_0.orders.map(&:marked_for_destruction?)
|
||||
assert_equal [true], @customer0.orders.map(&:marked_for_destruction?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -179,10 +179,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal ["order_date_0"], @customer_0.orders.map(&:order_date)
|
||||
assert_equal ["order_date_0"], @customer0.orders.map(&:order_date)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -192,10 +192,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the live version of the nested association" do
|
||||
assert_equal ["product_0"], @customer_0.orders.first.line_items.map(&:product)
|
||||
assert_equal ["product_0"], @customer0.orders.first.line_items.map(&:product)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -210,10 +210,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal ["order_date_2"], @customer_1.orders.map(&:order_date)
|
||||
assert_equal ["order_date_2"], @customer1.orders.map(&:order_date)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -222,10 +222,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified opting out of has_many reification" do
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: false) }
|
||||
setup { @customer1 = @customer.versions.last.reify(has_many: false) }
|
||||
|
||||
should "see the associated as it is live" do
|
||||
assert_equal ["order_date_3"], @customer_1.orders.map(&:order_date)
|
||||
assert_equal ["order_date_3"], @customer1.orders.map(&:order_date)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -235,10 +235,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal ["order_date_2"], @customer_1.orders.map(&:order_date)
|
||||
assert_equal ["order_date_2"], @customer1.orders.map(&:order_date)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -254,10 +254,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [@order.order_date], @customer_1.orders.map(&:order_date)
|
||||
assert_equal [@order.order_date], @customer1.orders.map(&:order_date)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -274,10 +274,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_1 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer1 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [], @customer_1.orders
|
||||
assert_equal [], @customer1.orders
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -288,10 +288,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @customer_0 = @customer.versions.last.reify(has_many: true) }
|
||||
setup { @customer0 = @customer.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal ["order_date_0"], @customer_0.orders.map(&:order_date)
|
||||
assert_equal ["order_date_0"], @customer0.orders.map(&:order_date)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -302,11 +302,11 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
should "mark the newly associated for destruction" do
|
||||
@customer_0 = @customer.versions.last.reify(
|
||||
@customer0 = @customer.versions.last.reify(
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
assert @customer_0.
|
||||
assert @customer0.
|
||||
orders.
|
||||
detect { |o| o.order_date == "order_date_1" }.
|
||||
marked_for_destruction?
|
||||
|
@ -327,10 +327,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [], @book_0.authors
|
||||
assert_equal [], @book0.authors
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -340,18 +340,18 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
@book0 = @book.versions.last.reify(
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
should "mark the associated for destruction" do
|
||||
assert_equal [true], @book_0.authors.map(&:marked_for_destruction?)
|
||||
assert_equal [true], @book0.authors.map(&:marked_for_destruction?)
|
||||
end
|
||||
|
||||
should "mark the associated-through for destruction" do
|
||||
assert_equal [true], @book_0.authorships.map(&:marked_for_destruction?)
|
||||
assert_equal [true], @book0.authorships.map(&:marked_for_destruction?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -366,28 +366,28 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified" do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(has_many: true)
|
||||
@book0 = @book.versions.last.reify(has_many: true)
|
||||
end
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [], @book_0.authors
|
||||
assert_equal [], @book0.authors
|
||||
end
|
||||
end
|
||||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
@book0 = @book.versions.last.reify(
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
should "not mark the associated for destruction" do
|
||||
assert_equal [false], @book_0.authors.map(&:marked_for_destruction?)
|
||||
assert_equal [false], @book0.authors.map(&:marked_for_destruction?)
|
||||
end
|
||||
|
||||
should "mark the associated-through for destruction" do
|
||||
assert_equal [true], @book_0.authorships.map(&:marked_for_destruction?)
|
||||
assert_equal [true], @book0.authorships.map(&:marked_for_destruction?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -401,10 +401,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal ["author_0"], @book_0.authors.map(&:name)
|
||||
assert_equal ["author_0"], @book0.authors.map(&:name)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -418,10 +418,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal ["author_2"], @book_1.authors.map(&:name)
|
||||
assert_equal ["author_2"], @book1.authors.map(&:name)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -430,10 +430,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified opting out of has_many reification" do
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: false) }
|
||||
setup { @book1 = @book.versions.last.reify(has_many: false) }
|
||||
|
||||
should "see the associated as it is live" do
|
||||
assert_equal ["author_3"], @book_1.authors.map(&:name)
|
||||
assert_equal ["author_3"], @book1.authors.map(&:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -444,10 +444,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [@author.name], @book_1.authors.map(&:name)
|
||||
assert_equal [@author.name], @book1.authors.map(&:name)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -464,10 +464,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [], @book_1.authors
|
||||
assert_equal [], @book1.authors
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -480,10 +480,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_1 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book1 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal [], @book_1.authors
|
||||
assert_equal [], @book1.authors
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -494,10 +494,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "only see the first associated" do
|
||||
assert_equal ["author_0"], @book_0.authors.map(&:name)
|
||||
assert_equal ["author_0"], @book0.authors.map(&:name)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -507,21 +507,21 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
@book0 = @book.versions.last.reify(
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
should "mark the newly associated for destruction" do
|
||||
assert @book_0.
|
||||
assert @book0.
|
||||
authors.
|
||||
detect { |a| a.name == "author_1" }.
|
||||
marked_for_destruction?
|
||||
end
|
||||
|
||||
should "mark the newly associated-through for destruction" do
|
||||
assert @book_0.
|
||||
assert @book0.
|
||||
authorships.
|
||||
detect { |as| as.author.name == "author_1" }.
|
||||
marked_for_destruction?
|
||||
|
@ -535,10 +535,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "only see the first associated" do
|
||||
assert_equal ["author_0"], @book_0.authors.map(&:name)
|
||||
assert_equal ["author_0"], @book0.authors.map(&:name)
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -548,21 +548,21 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
setup do
|
||||
@book_0 = @book.versions.last.reify(
|
||||
@book0 = @book.versions.last.reify(
|
||||
has_many: true,
|
||||
mark_for_destruction: true
|
||||
)
|
||||
end
|
||||
|
||||
should "not mark the newly associated for destruction" do
|
||||
assert !@book_0.
|
||||
assert !@book0.
|
||||
authors.
|
||||
detect { |a| a.name == "person_existing" }.
|
||||
marked_for_destruction?
|
||||
end
|
||||
|
||||
should "mark the newly associated-through for destruction" do
|
||||
assert @book_0.
|
||||
assert @book0.
|
||||
authorships.
|
||||
detect { |as| as.author.name == "person_existing" }.
|
||||
marked_for_destruction?
|
||||
|
@ -578,10 +578,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @book_0 = @book.versions.last.reify(has_many: true) }
|
||||
setup { @book0 = @book.versions.last.reify(has_many: true) }
|
||||
|
||||
should "see the live association" do
|
||||
assert_equal ["editor_0"], @book_0.editors.map(&:name)
|
||||
assert_equal ["editor_0"], @book0.editors.map(&:name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -782,10 +782,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @wotsit_0 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
setup { @wotsit0 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_nil @wotsit_0.widget
|
||||
assert_nil @wotsit0.widget
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -803,10 +803,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @wotsit_1 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
setup { @wotsit1 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal "widget_2", @wotsit_1.widget.name
|
||||
assert_equal "widget_2", @wotsit1.widget.name
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -815,10 +815,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified opting out of belongs_to reification" do
|
||||
setup { @wotsit_1 = @wotsit.versions.last.reify(belongs_to: false) }
|
||||
setup { @wotsit1 = @wotsit.versions.last.reify(belongs_to: false) }
|
||||
|
||||
should "see the associated as it is live" do
|
||||
assert_equal "widget_3", @wotsit_1.widget.name
|
||||
assert_equal "widget_3", @wotsit1.widget.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -830,10 +830,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @wotsit_2 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
setup { @wotsit2 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
|
||||
should "see the associated as it was at the time" do
|
||||
assert_equal @widget, @wotsit_2.widget
|
||||
assert_equal @widget, @wotsit2.widget
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -848,10 +848,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @wotsit_2 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
setup { @wotsit2 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
|
||||
should "see the associated as it was the time" do
|
||||
assert_nil @wotsit_2.widget
|
||||
assert_nil @wotsit2.widget
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -867,10 +867,10 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
context "when reified" do
|
||||
setup { @wotsit_0 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
setup { @wotsit0 = @wotsit.versions.last.reify(belongs_to: true) }
|
||||
|
||||
should "see the association as it was at the time" do
|
||||
assert_equal "widget_0", @wotsit_0.widget.name
|
||||
assert_equal "widget_0", @wotsit0.widget.name
|
||||
end
|
||||
|
||||
should "not persist changes to the live association" do
|
||||
|
@ -880,7 +880,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
|
||||
context "when reified with option mark_for_destruction" do
|
||||
setup do
|
||||
@wotsit_0 = @wotsit.versions.last.
|
||||
@wotsit0 = @wotsit.versions.last.
|
||||
reify(belongs_to: true, mark_for_destruction: true)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue