Fix whitespace
This commit is contained in:
parent
68f553d863
commit
c24d0b4780
|
@ -265,73 +265,3 @@ Style/SignalException:
|
|||
Style/SingleLineBlockParams:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/reifier.rb'
|
||||
|
||||
# Offense count: 14
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceAfterComma:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/has_paper_trail.rb'
|
||||
- 'test/custom_json_serializer.rb'
|
||||
- 'test/unit/cleaner_test.rb'
|
||||
- 'test/unit/model_test.rb'
|
||||
- 'test/unit/serializer_test.rb'
|
||||
- 'test/unit/serializers/mixin_json_test.rb'
|
||||
- 'test/unit/serializers/mixin_yaml_test.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
# SupportedStyles: space, no_space
|
||||
Style/SpaceAroundEqualsInParameterDefault:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowForAlignment.
|
||||
Style/SpaceAroundOperators:
|
||||
Exclude:
|
||||
- 'lib/paper_trail/frameworks/rails/controller.rb'
|
||||
- 'lib/paper_trail/frameworks/sinatra.rb'
|
||||
- 'spec/models/thing_spec.rb'
|
||||
- 'test/unit/cleaner_test.rb'
|
||||
- 'test/unit/serializer_test.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
# SupportedStyles: space, no_space
|
||||
Style/SpaceBeforeBlockBraces:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowForAlignment.
|
||||
Style/SpaceBeforeFirstArg:
|
||||
Exclude:
|
||||
- 'test/dummy/db/migrate/20110208155312_set_up_test_tables.rb'
|
||||
|
||||
# Offense count: 12
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
||||
# SupportedStyles: space, no_space
|
||||
Style/SpaceInsideBlockBraces:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceInsideBrackets:
|
||||
Exclude:
|
||||
- 'test/dummy/app/models/article.rb'
|
||||
|
||||
# Offense count: 26
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
|
||||
# SupportedStyles: space, no_space
|
||||
Style/SpaceInsideHashLiteralBraces:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/SpaceInsideParens:
|
||||
Exclude:
|
||||
- 'spec/models/widget_spec.rb'
|
||||
|
|
|
@ -15,7 +15,7 @@ module PaperTrail
|
|||
# causes all items to be cleaned. Defaults to `nil`.
|
||||
#
|
||||
def clean_versions!(options = {})
|
||||
options = {keeping: 1, date: :all}.merge(options)
|
||||
options = { keeping: 1, date: :all }.merge(options)
|
||||
gather_versions(options[:item_id], options[:date]).each do |_item_id, item_versions|
|
||||
group_versions_by_date(item_versions).each do |_date, date_versions|
|
||||
# Remove the number of versions we wish to keep from the collection
|
||||
|
|
|
@ -12,12 +12,12 @@ module PaperTrail
|
|||
|
||||
if base.respond_to? :before_action
|
||||
# Rails 4+
|
||||
before.map {|sym| base.before_action sym }
|
||||
after.map {|sym| base.after_action sym }
|
||||
before.map { |sym| base.before_action sym }
|
||||
after.map { |sym| base.after_action sym }
|
||||
else
|
||||
# Rails 3.
|
||||
before.map {|sym| base.before_filter sym }
|
||||
after.map {|sym| base.after_filter sym }
|
||||
before.map { |sym| base.before_filter sym }
|
||||
after.map { |sym| base.after_filter sym }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -76,7 +76,7 @@ module PaperTrail
|
|||
|
||||
# Tells PaperTrail who is responsible for any changes that occur.
|
||||
def set_paper_trail_whodunnit
|
||||
@set_paper_trail_whodunnit_called=true
|
||||
@set_paper_trail_whodunnit_called = true
|
||||
::PaperTrail.whodunnit = user_for_paper_trail if ::PaperTrail.enabled_for_controller?
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ module PaperTrail
|
|||
|
||||
# Tells PaperTrail who is responsible for any changes that occur.
|
||||
def set_paper_trail_whodunnit
|
||||
@set_paper_trail_whodunnit_called=true
|
||||
@set_paper_trail_whodunnit_called = true
|
||||
::PaperTrail.whodunnit = user_for_paper_trail if ::PaperTrail.enabled?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -201,7 +201,7 @@ module PaperTrail
|
|||
end
|
||||
|
||||
# Returns the object (not a Version) as it was at the given timestamp.
|
||||
def version_at(timestamp, reify_options={})
|
||||
def version_at(timestamp, reify_options = {})
|
||||
# Because a version stores how its object looked *before* the change,
|
||||
# we need to look for the first version created *after* the timestamp.
|
||||
v = send(self.class.versions_association_name).subsequent(timestamp, true).first
|
||||
|
@ -212,7 +212,7 @@ module PaperTrail
|
|||
# Returns the objects (not Versions) as they were between the given times.
|
||||
# TODO: Either add support for the third argument, `_reify_options`, or
|
||||
# add a deprecation warning if someone tries to use it.
|
||||
def versions_between(start_time, end_time, _reify_options={})
|
||||
def versions_between(start_time, end_time, _reify_options = {})
|
||||
versions = send(self.class.versions_association_name).between(start_time, end_time)
|
||||
versions.collect { |version| version_at(version.send PaperTrail.timestamp_field) }
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.files = `git ls-files`.split("\n")
|
||||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
||||
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
||||
s.require_paths = ["lib"]
|
||||
|
||||
s.required_rubygems_version = ">= 1.3.6"
|
||||
|
|
|
@ -7,18 +7,18 @@ describe Gadget, type: :model do
|
|||
|
||||
describe "updates", versioning: true do
|
||||
it "should generate a version for updates to `name` attribute" do
|
||||
expect { gadget.update_attribute(:name, "Hammer").to change{gadget.versions.size}.by(1) }
|
||||
expect { gadget.update_attribute(:name, "Hammer").to change { gadget.versions.size }.by(1) }
|
||||
end
|
||||
|
||||
it "should ignore for updates to `brand` attribute" do
|
||||
expect { gadget.update_attribute(:brand, "Stanley") }.to_not change{gadget.versions.size}
|
||||
expect { gadget.update_attribute(:brand, "Stanley") }.to_not change { gadget.versions.size }
|
||||
end
|
||||
|
||||
it "should still generate a version when only the `updated_at` attribute is updated" do
|
||||
# Plus 1 second because MySQL lacks sub-second resolution
|
||||
expect {
|
||||
gadget.update_attribute(:updated_at, Time.now + 1)
|
||||
}.to change{gadget.versions.size}.by(1)
|
||||
}.to change { gadget.versions.size }.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ describe PaperTrail::Version, type: :model do
|
|||
describe '#terminator' do
|
||||
it { is_expected.to respond_to(:terminator) }
|
||||
|
||||
let(:attributes) { {whodunnit: FFaker::Name.first_name} }
|
||||
let(:attributes) { { whodunnit: FFaker::Name.first_name } }
|
||||
|
||||
it "is an alias for the `whodunnit` attribute" do
|
||||
expect(subject.terminator).to eq(attributes[:whodunnit])
|
||||
|
|
|
@ -9,7 +9,7 @@ describe Widget, type: :model do
|
|||
|
||||
describe "`have_a_version_with` matcher", versioning: true do
|
||||
before do
|
||||
widget.update_attributes!(name: "Leonard", an_integer: 1 )
|
||||
widget.update_attributes!(name: "Leonard", an_integer: 1)
|
||||
widget.update_attributes!(name: "Tom")
|
||||
widget.update_attributes!(name: "Bob")
|
||||
end
|
||||
|
|
|
@ -59,7 +59,7 @@ describe PaperTrail do
|
|||
end
|
||||
|
||||
describe :controller_info do
|
||||
before(:all) { ::PaperTrail.controller_info = {foo: "bar"} }
|
||||
before(:all) { ::PaperTrail.controller_info = { foo: "bar" } }
|
||||
|
||||
it "should get set to an empty hash before each test" do
|
||||
expect(PaperTrail.controller_info).to eq({})
|
||||
|
|
|
@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
|
|||
attr_reader :current_user
|
||||
|
||||
def info_for_paper_trail
|
||||
{ip: request.remote_ip, user_agent: request.user_agent}
|
||||
{ ip: request.remote_ip, user_agent: request.user_agent }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -7,7 +7,7 @@ class Article < ActiveRecord::Base
|
|||
}
|
||||
}
|
||||
],
|
||||
only: [:content, { abstract: Proc.new { |obj| obj.abstract.present? } } ],
|
||||
only: [:content, { abstract: Proc.new { |obj| obj.abstract.present? } }],
|
||||
skip: [:file_upload],
|
||||
meta: {
|
||||
answer: 42,
|
||||
|
|
|
@ -308,7 +308,7 @@ class AssociationsTest < ActiveSupport::TestCase
|
|||
)
|
||||
assert @customer_0.
|
||||
orders.
|
||||
detect { |o| o.order_date == "order_date_1"}.
|
||||
detect { |o| o.order_date == "order_date_1" }.
|
||||
marked_for_destruction?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -95,7 +95,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
assert_equal 11, PaperTrail::Version.count
|
||||
[@animal, @dog].each do |animal|
|
||||
assert_equal 4, animal.versions.size
|
||||
assert_equal 3, animal.versions.between(@date, @date+1.day).size
|
||||
assert_equal 3, animal.versions.between(@date, @date + 1.day).size
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -106,7 +106,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
# reload the association to pick up the destructions made by the `Cleaner`
|
||||
animal.versions.reload
|
||||
assert_equal 3, animal.versions.size
|
||||
assert_equal 2, animal.versions.between(@date, @date+1.day).size
|
||||
assert_equal 2, animal.versions.between(@date, @date + 1.day).size
|
||||
end
|
||||
# ensure that the versions for the `@cat` instance wasn't touched
|
||||
assert_equal 9, PaperTrail::Version.count
|
||||
|
@ -119,7 +119,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
# reload the association to pick up the destructions made by the `Cleaner`
|
||||
@dog.versions.reload
|
||||
assert_equal 2, @dog.versions.size
|
||||
assert_equal 1, @dog.versions.between(@date, @date+1.day).size
|
||||
assert_equal 1, @dog.versions.between(@date, @date + 1.day).size
|
||||
# ensure the versions for other animals besides `@animal` weren't touched
|
||||
assert_equal 9, PaperTrail::Version.count
|
||||
end
|
||||
|
@ -131,7 +131,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
|
|||
# reload the association to pick up the destructions made by the `Cleaner`
|
||||
@dog.versions.reload
|
||||
assert_equal 3, @dog.versions.size
|
||||
assert_equal 2, @dog.versions.between(@date, @date+1.day).size
|
||||
assert_equal 2, @dog.versions.between(@date, @date + 1.day).size
|
||||
# ensure the versions for other animals besides `@animal` weren't touched
|
||||
assert_equal 10, PaperTrail::Version.count
|
||||
end
|
||||
|
|
|
@ -121,7 +121,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should "have stored only non-skipped attributes" do
|
||||
assert_equal ({"content" => [nil, "Some text here."]}),
|
||||
assert_equal ({ "content" => [nil, "Some text here."] }),
|
||||
@article.versions.last.changeset
|
||||
end
|
||||
|
||||
|
@ -328,11 +328,11 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
|
|||
actual = PaperTrail.serializer.load(last_obj_changes).reject { |k, _v|
|
||||
k.to_sym == :updated_at
|
||||
}
|
||||
assert_equal ({"name" => %w(Henry Harry)}), actual
|
||||
assert_equal ({ "name" => %w(Henry Harry) }), actual
|
||||
actual = @widget.versions.last.changeset.reject { |k, _v|
|
||||
k.to_sym == :updated_at
|
||||
}
|
||||
assert_equal ({"name" => %w(Henry Harry)}), actual
|
||||
assert_equal ({ "name" => %w(Henry Harry) }), actual
|
||||
end
|
||||
|
||||
should "return changes with indifferent access" do
|
||||
|
|
|
@ -64,8 +64,8 @@ class SerializerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should "store object_changes" do
|
||||
initial_changeset = {"name" => [nil, "Some text."], "id" => [nil, @fluxor.id]}
|
||||
second_changeset = {"name"=>["Some text.", "Some more text."]}
|
||||
initial_changeset = { "name" => [nil, "Some text."], "id" => [nil, @fluxor.id] }
|
||||
second_changeset = { "name" => ["Some text.", "Some more text."] }
|
||||
assert_equal initial_changeset, @fluxor.versions[0].changeset
|
||||
assert_equal second_changeset, @fluxor.versions[1].changeset
|
||||
end
|
||||
|
@ -109,8 +109,8 @@ class SerializerTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should "store object_changes" do
|
||||
initial_changeset = {"id" => [nil, @fluxor.id]}
|
||||
second_changeset = {"name"=>[nil, "Some more text."]}
|
||||
initial_changeset = { "id" => [nil, @fluxor.id] }
|
||||
second_changeset = { "name" => [nil, "Some more text."] }
|
||||
assert_equal initial_changeset, @fluxor.versions[0].changeset
|
||||
assert_equal second_changeset, @fluxor.versions[1].changeset
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue