From fed9b6d74adea68fff894d75ca5bd58f157edcb9 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Tue, 5 Feb 2013 11:23:21 -0500 Subject: [PATCH 01/14] Comment clarification. --- lib/paper_trail/has_paper_trail.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 061f4c53..a6605b13 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -85,7 +85,7 @@ module PaperTrail def serialize_attributes_for_paper_trail(attributes) serialized_attributes.each do |key, coder| if attributes.key?(key) - coder = PaperTrail::Serializers::Yaml unless coder.respond_to?(:dump) # Rails 3.0.x's default serializers don't have a `dump` method + coder = PaperTrail::Serializers::Yaml unless coder.respond_to?(:dump) # Fall back to YAML if `coder` has no `dump` method attributes[key] = coder.dump(attributes[key]) end end @@ -104,7 +104,7 @@ module PaperTrail def serialize_attribute_changes(changes) serialized_attributes.each do |key, coder| if changes.key?(key) - coder = PaperTrail::Serializers::Yaml unless coder.respond_to?(:dump) # Rails 3.0.x's default serializers don't have a `dump` method + coder = PaperTrail::Serializers::Yaml unless coder.respond_to?(:dump) # Fall back to YAML if `coder` has no `dump` method old_value, new_value = changes[key] changes[key] = [coder.dump(old_value), coder.dump(new_value)] From 143d1ac4259131da1ec07370f1c0d6f298d11846 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Tue, 5 Feb 2013 13:45:59 -0500 Subject: [PATCH 02/14] Fixed :next_version method to return the live model when appropriate. Close #200 --- CHANGELOG.md | 2 ++ lib/paper_trail/has_paper_trail.rb | 12 +++++++----- test/unit/model_test.rb | 27 +++++++++++++++------------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 850e31c0..4d0bec7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 2.7.1 (Unreleased) + - [#200](https://github.com/airblade/paper_trail/issues/200) - Fixed `next_version` method so that it returns the live model + when called on latest reified version of a model prior to the live model. - [#197](https://github.com/airblade/paper_trail/issues/197) - PaperTrail now falls back on using YAML for serialization of serialized model attributes for storage in the `object` and `object_changes` columns in the `Version` table. This fixes compatibility for `Rails 3.0.x` for projects that employ the `serialize` declaration on a model. diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index a6605b13..215f952e 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -155,15 +155,17 @@ module PaperTrail # Returns the object (not a Version) as it was most recently. def previous_version preceding_version = source_version ? source_version.previous : send(self.class.versions_association_name).last - preceding_version.try :reify + preceding_version.reify if preceding_version end # Returns the object (not a Version) as it became next. + # NOTE: if self (the item) was not reified from a version, i.e. it is the + # "live" item, we return nil. Perhaps we should return self instead? def next_version - # NOTE: if self (the item) was not reified from a version, i.e. it is the - # "live" item, we return nil. Perhaps we should return self instead? - subsequent_version = source_version ? source_version.next : nil - subsequent_version.reify if subsequent_version + subsequent_version = source_version.next + subsequent_version ? subsequent_version.reify : self.class.find(self.id) + rescue + nil end # Executes the given method or block without creating a new version. diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index 76b8300b..5a45fc0b 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -795,10 +795,10 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase end should 'have a previous version' do - assert_equal @widget.versions.last.reify, @widget.previous_version + assert_equal @widget.versions.last.reify.name, @widget.previous_version.name end - should 'have a next version' do + should 'not have a next version' do assert_nil @widget.next_version end end @@ -806,21 +806,20 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase context 'A reified item' do setup do - widget = Widget.create :name => 'Bob' - %w( Tom Dick Jane ).each { |name| widget.update_attributes :name => name } - @versions = widget.versions - @second_widget = @versions[1].reify # first widget is null - @last_widget = @versions.last.reify + @widget = Widget.create :name => 'Bob' + %w(Tom Dick Jane).each { |name| @widget.update_attributes :name => name } + @second_widget = @widget.versions[1].reify # first widget is `nil` + @last_widget = @widget.versions.last.reify end should 'have a previous version' do - assert_nil @second_widget.previous_version - assert_equal @versions[-2].reify, @last_widget.previous_version + assert_nil @second_widget.previous_version # `create` events return `nil` for `reify` + assert_equal @widget.versions[-2].reify.name, @last_widget.previous_version.name end should 'have a next version' do - assert_equal @versions[2].reify, @second_widget.next_version - assert_nil @last_widget.next_version + assert_equal @widget.versions[2].reify.name, @second_widget.next_version.name + assert_equal @last_widget.next_version.name, @widget.name end end @@ -1106,7 +1105,11 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase assert_equal 2, @doc.paper_trail_versions.length end - should 'respond to previous_version as normal' do + should 'respond to `next_version` as normal' do + assert_equal @doc.paper_trail_versions.last.reify.next_version.name, @doc.name + end + + should 'respond to `previous_version` as normal' do @doc.update_attributes :name => 'Doc 2' assert_equal 3, @doc.paper_trail_versions.length assert_equal 'Doc 1', @doc.previous_version.name From 99805aa23f1b73b655a991d5e2f9afb399cd6792 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Thu, 7 Feb 2013 15:15:25 -0500 Subject: [PATCH 03/14] Updated config/application.rb and the Environment configuration files for the dummy app to match those generated by Rails 3.2 --- test/dummy/config/application.rb | 28 ++++++++++-- test/dummy/config/environments/development.rb | 20 +++++++-- test/dummy/config/environments/production.rb | 44 +++++++++++++------ test/dummy/config/environments/test.rb | 20 +++++---- 4 files changed, 82 insertions(+), 30 deletions(-) diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 3e5ee2b6..7bf62d48 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -5,7 +5,7 @@ require "active_record/railtie" require "action_controller/railtie" require "action_view/railtie" -Bundler.require +Bundler.require(:default, Rails.env) if defined?(Bundler) require 'paper_trail' module Dummy @@ -32,13 +32,33 @@ module Dummy # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - # JavaScript files you want as :defaults (application.js is always included). - # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] + + # Enable escaping HTML in JSON. + config.active_support.escape_html_entities_in_json = true + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + # + # This is uncommented in new rails apps by default but for our testing purposes its more convenient + # to leave it commented out. + # config.active_record.whitelist_attributes = true + + # Enable the asset pipeline + config.assets.enabled = false + + # Version of your assets, change this if you want to expire all your assets + # config.assets.version = '1.0' end end diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index d6a79987..b51afe5c 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -2,8 +2,8 @@ Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. @@ -11,16 +11,28 @@ Dummy::Application.configure do # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send - config.action_mailer.raise_delivery_errors = false + # config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger config.active_support.deprecation = :log # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index 659e5835..bdac56a7 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,7 +1,6 @@ Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb - # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true @@ -9,31 +8,46 @@ Dummy::Application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' - - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true # See everything in the log (default is :info) # config.log_level = :debug + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + # Use a different logger for distributed setups - # config.logger = SyslogLogger.new + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production # config.cache_store = :mem_cache_store - # Disable Rails's static asset server - # In production, Apache or nginx will already do this - config.serve_static_assets = false - - # Enable serving of images, stylesheets, and javascripts from an asset server + # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false @@ -46,4 +60,8 @@ Dummy::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 7127f82a..2175c5e0 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -2,12 +2,16 @@ Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that + # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! + # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching @@ -18,17 +22,15 @@ Dummy::Application.configure do config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. - config.action_mailer.delivery_method = :test if config.respond_to?(:action_mailer) + # config.action_mailer.delivery_method = :test - # Use SQL instead of Active Record's schema dumper when creating the test database. - # This is necessary if your schema can't be completely dumped by the schema dumper, - # like if you have constraints or database-specific column types - # config.active_record.schema_format = :sql + # Raise exception on mass assignment protection for Active Record models + config.active_record.mass_assignment_sanitizer = :strict # Print deprecation notices to the stderr config.active_support.deprecation = :stderr From 01a1be4438e55e93c199be9ec2cdd4857c520fff Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Thu, 7 Feb 2013 15:27:29 -0500 Subject: [PATCH 04/14] Added basic test coverage for a model that invokes for protection from mass assignment. --- test/dummy/app/models/protected_widget.rb | 3 ++ test/unit/protected_attrs_test.rb | 41 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/dummy/app/models/protected_widget.rb create mode 100644 test/unit/protected_attrs_test.rb diff --git a/test/dummy/app/models/protected_widget.rb b/test/dummy/app/models/protected_widget.rb new file mode 100644 index 00000000..51fbae8a --- /dev/null +++ b/test/dummy/app/models/protected_widget.rb @@ -0,0 +1,3 @@ +class ProtectedWidget < Widget + attr_accessible :name, :a_text +end diff --git a/test/unit/protected_attrs_test.rb b/test/unit/protected_attrs_test.rb new file mode 100644 index 00000000..69095bb3 --- /dev/null +++ b/test/unit/protected_attrs_test.rb @@ -0,0 +1,41 @@ +require 'test_helper' + +class ProtectedAttrsTest < ActiveSupport::TestCase + subject { ProtectedWidget.new } + + accessible_attrs = ProtectedWidget.accessible_attributes.to_a + accessible_attrs.each do |attr_name| + should allow_mass_assignment_of(attr_name.to_sym) + end + ProtectedWidget.column_names.reject { |column_name| accessible_attrs.include?(column_name) }.each do |attr_name| + should_not allow_mass_assignment_of(attr_name.to_sym) + end + + context 'A model with `attr_accessible` created' do + setup do + @widget = ProtectedWidget.create! :name => 'Henry' + @initial_attributes = @widget.attributes + end + + should 'be `nil` in its previous version' do + assert_nil @widget.previous_version + end + + context 'which is then updated' do + setup do + @widget.assign_attributes(:name => 'Jeff', :a_text => 'Short statement') + @widget.an_integer = 42 + @widget.save! + end + + should 'not be `nil` in its previous version' do + assert_not_nil @widget.previous_version + end + + should 'the previous version should contain right attributes' do + assert_equal @widget.previous_version.attributes, @initial_attributes + end + end + + end +end From 588af563b97a582b04d147d5b151a3be63edaaff Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Mon, 11 Feb 2013 12:49:08 -0500 Subject: [PATCH 05/14] Swapping in :select for :keep_if on changes array in :changes_for_paper_trail method for Ruby1.8.7 compatibility. Close #206 --- CHANGELOG.md | 1 + lib/paper_trail/has_paper_trail.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0bec7c..91af6818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 2.7.1 (Unreleased) + - [#206](https://github.com/airblade/paper_trail/issues/206) - Fixed Ruby 1.8.7 compatibility for tracking `object_changes`. - [#200](https://github.com/airblade/paper_trail/issues/200) - Fixed `next_version` method so that it returns the live model when called on latest reified version of a model prior to the live model. - [#197](https://github.com/airblade/paper_trail/issues/197) - PaperTrail now falls back on using YAML for serialization of diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 215f952e..09db8c71 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -217,7 +217,7 @@ module PaperTrail end def changes_for_paper_trail - self.changes.keep_if do |key, value| + self.changes.select do |key, value| notably_changed.include?(key) end.tap do |changes| self.class.serialize_attribute_changes(changes) # Use serialized value for attributes when necessary From 51b450a5ba48a9745239ca1a69576a05815ccfd3 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Mon, 11 Feb 2013 13:10:22 -0500 Subject: [PATCH 06/14] Fixing issues stemming from previous commit in Ruby 1.8.x. --- lib/paper_trail/has_paper_trail.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 09db8c71..b6940edf 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -217,8 +217,8 @@ module PaperTrail end def changes_for_paper_trail - self.changes.select do |key, value| - notably_changed.include?(key) + self.changes.delete_if do |key, value| + !notably_changed.include?(key) end.tap do |changes| self.class.serialize_attribute_changes(changes) # Use serialized value for attributes when necessary end From 9384af520fbc85a1e3a6945a9dae3a8779887bbf Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Thu, 14 Feb 2013 12:09:14 -0500 Subject: [PATCH 07/14] Fixing the SerializerTest so that it doesn't engage an assertion for equality when the test suite is run in Ruby1.8, which cant consistently pass in Ruby1.8 due to the nature of hashes being unordered. --- test/unit/serializer_test.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/unit/serializer_test.rb b/test/unit/serializer_test.rb index 4d9a9b67..9f0690b1 100644 --- a/test/unit/serializer_test.rb +++ b/test/unit/serializer_test.rb @@ -19,10 +19,13 @@ class SerializerTest < ActiveSupport::TestCase assert_nil @fluxor.versions[0].reify assert_equal 'Some text.', @fluxor.versions[1].reify.name - # Check values are stored as YAML. - assert_equal YAML.dump(@original_fluxor_attributes), @fluxor.versions[1].object assert_equal @original_fluxor_attributes, YAML.load(@fluxor.versions[1].object) + # This test can't consistently pass in Ruby1.8 because hashes do no preserve order, which means the order of the + # attributes in the YAML can't be ensured. + if RUBY_VERSION.to_f >= 1.9 + assert_equal YAML.dump(@original_fluxor_attributes), @fluxor.versions[1].object + end end end @@ -52,8 +55,12 @@ class SerializerTest < ActiveSupport::TestCase assert_equal 'Some text.', @fluxor.versions[1].reify.name # Check values are stored as JSON. - assert_equal ActiveSupport::JSON.encode(@original_fluxor_attributes), @fluxor.versions[1].object assert_equal @original_fluxor_attributes, ActiveSupport::JSON.decode(@fluxor.versions[1].object) + # This test can't consistently pass in Ruby1.8 because hashes do no preserve order, which means the order of the + # attributes in the JSON can't be ensured. + if RUBY_VERSION.to_f >= 1.9 + assert_equal ActiveSupport::JSON.encode(@original_fluxor_attributes), @fluxor.versions[1].object + end end should 'store object_changes' do From 0619d811f41a7f8a09d00219c7e60107ed8a1642 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Fri, 15 Feb 2013 13:04:28 -0500 Subject: [PATCH 08/14] Updating notes for setting custom serializer on README to use shortened syntax available in pending release. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed277084..35fe148c 100644 --- a/README.md +++ b/README.md @@ -746,7 +746,7 @@ end By default, PaperTrail stores your changes as a YAML dump. You can override this with the serializer config option: ```ruby ->> PaperTrail.config.serializer = MyCustomSerializer +>> PaperTrail.serializer = MyCustomSerializer ``` A valid serializer is a `module` (or `class`) that defines a `load` and `dump` method. These serializers are included in the gem for your convenience: From 3a8a21152c4e16165eb0146fc0e7e66326ad458a Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Fri, 15 Feb 2013 13:06:20 -0500 Subject: [PATCH 09/14] Bump to 2.7.1 --- CHANGELOG.md | 2 +- lib/paper_trail/version_number.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91af6818..ac4507d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 2.7.1 (Unreleased) +## 2.7.1 - [#206](https://github.com/airblade/paper_trail/issues/206) - Fixed Ruby 1.8.7 compatibility for tracking `object_changes`. - [#200](https://github.com/airblade/paper_trail/issues/200) - Fixed `next_version` method so that it returns the live model diff --git a/lib/paper_trail/version_number.rb b/lib/paper_trail/version_number.rb index e6f33fd1..3d6c13b6 100644 --- a/lib/paper_trail/version_number.rb +++ b/lib/paper_trail/version_number.rb @@ -1,3 +1,3 @@ module PaperTrail - VERSION = '2.7.0' + VERSION = '2.7.1' end From b0dd5cdb313666ad04b5c9f7f1248213766f4b3f Mon Sep 17 00:00:00 2001 From: Olivier Brisse Date: Tue, 26 Feb 2013 12:27:41 +1100 Subject: [PATCH 10/14] Fix Gemfile to use 'https://rubygems.org' --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index e45e65f8..851fabc2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,2 @@ -source :rubygems +source 'https://rubygems.org' gemspec From 08ee2e2ee9c12cbd337d413931116c760dbd78bd Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Thu, 28 Feb 2013 15:43:34 -0500 Subject: [PATCH 11/14] Adding a test to confirm #161 is not an issue. --- test/unit/model_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index 5a45fc0b..0d5c4b4f 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -628,6 +628,15 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase should 'return the current object for version_at after latest update' do assert_equal 'Digit', @widget.version_at(1.day.from_now).name end + + context 'passing in a string representation of a timestamp' do + should 'still return a widget when appropriate' do + # need to add 1 second onto the timestamps before casting to a string, since casting a Time to a string drops the microseconds + assert_equal 'Widget', @widget.version_at((@created + 1.second).to_s).name + assert_equal 'Fidget', @widget.version_at((@first_update + 1.second).to_s).name + assert_equal 'Digit', @widget.version_at((@second_update + 1.second).to_s).name + end + end end context '.versions_between' do From 6e1845c450f2adac4c8efc2345c9134b06c2dc2c Mon Sep 17 00:00:00 2001 From: Piotr Usewicz Date: Thu, 7 Mar 2013 06:50:37 +0000 Subject: [PATCH 12/14] Add Ruby 1.9.3 and 2.0.0 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c93b293a..e3e338fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: ruby rvm: + - 2.0.0 + - 1.9.3 - 1.9.2 - 1.8.7 - ree From f5df2a656c4aaf87fa446b6f170f0e8cf6fbd5a6 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Thu, 7 Mar 2013 11:15:41 -0500 Subject: [PATCH 13/14] Removing ruby 2.0 from .travis.yml since there are some compatibility issues with the current release of Rails 3.2 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e3e338fe..62307b27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: ruby rvm: - - 2.0.0 - 1.9.3 - 1.9.2 - 1.8.7 From 2e578d44dc3556b36a5bb6fdea7da52e338f1aec Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Fri, 8 Mar 2013 11:12:23 -0500 Subject: [PATCH 14/14] Adding Ruby2 back onto .travis.yml but with failures allowed, as per req #210 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 62307b27..f80347f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: ruby rvm: + - 2.0.0 - 1.9.3 - 1.9.2 - 1.8.7 - ree +matrix: + allow_failures: + - rvm: 2.0.0