Merge pull request #904 from airblade/various_20161204181017
Various 20161204181017
This commit is contained in:
commit
5ee9545a8a
|
@ -18,7 +18,9 @@ Please use our [bug report template][1].
|
|||
|
||||
## Development
|
||||
|
||||
Install gems with `bundle exec appraisal install`.
|
||||
Install gems with `bundle exec appraisal install`. This requires ruby >= 2.0.
|
||||
(It is still possible to run the `ar-4.2` gemfile locally on ruby 1.9.3, but
|
||||
not the `ar-5.0` gemfile.)
|
||||
|
||||
Testing is a little awkward because the test suite:
|
||||
|
||||
|
|
|
@ -5,8 +5,12 @@ Gem::Specification.new do |s|
|
|||
s.name = "paper_trail"
|
||||
s.version = PaperTrail::VERSION::STRING.dup # The `dup` is for ruby 1.9.3
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.summary = "Track changes to your models' data. Good for auditing or versioning."
|
||||
s.description = s.summary
|
||||
s.summary = "Track changes to your models."
|
||||
s.description = <<-EOS
|
||||
Track changes to your models, for auditing or versioning. See how a model looked
|
||||
at any stage in its lifecycle, revert it to any version, or restore it after it
|
||||
has been destroyed.
|
||||
EOS
|
||||
s.homepage = "https://github.com/airblade/paper_trail"
|
||||
s.authors = ["Andy Stewart", "Ben Atkins"]
|
||||
s.email = "batkinz@gmail.com"
|
||||
|
@ -28,15 +32,31 @@ Gem::Specification.new do |s|
|
|||
s.add_development_dependency "rake", "~> 10.4.2"
|
||||
s.add_development_dependency "shoulda", "~> 3.5.0"
|
||||
s.add_development_dependency "ffaker", "~> 2.1.0"
|
||||
s.add_development_dependency "railties", [">= 3.0", "< 6.0"]
|
||||
|
||||
# Why `railties`? Possibly used by `test/dummy` boot up?
|
||||
s.add_development_dependency "railties", [">= 4.0", "< 5.2"]
|
||||
|
||||
s.add_development_dependency "rack-test", "~> 0.6.3"
|
||||
s.add_development_dependency "rspec-rails", "~> 3.5"
|
||||
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"
|
||||
|
||||
# We cannot upgrade rubocop until we drop support for ruby 1.9.3.
|
||||
# Rubocop 0.42 requires ruby >= 2.0. We could add a conditional, as we do
|
||||
# below for rack and pg, but that means our config files (e.g. `.rubocop.yml`
|
||||
# would have to simultaneously be valid in two different versions of rubocop.
|
||||
# That is currently possible, but probably won't be in the future, and is
|
||||
# not worth the effort.) Because of pain points like this, I think we'll
|
||||
# have to drop support for ruby 1.9.3 soon.
|
||||
s.add_development_dependency "rubocop", "~> 0.41.1"
|
||||
|
||||
s.add_development_dependency "timecop", "~> 0.8.0"
|
||||
|
||||
if ::Gem.ruby_version < ::Gem::Version.new("2.0.0")
|
||||
s.add_development_dependency "rack", "< 2"
|
||||
end
|
||||
|
||||
if defined?(JRUBY_VERSION)
|
||||
s.add_development_dependency "activerecord-jdbcsqlite3-adapter", "~> 1.3.15"
|
||||
s.add_development_dependency "activerecord-jdbcpostgresql-adapter", "~> 1.3.15"
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe ArticlesController, type: :controller do
|
||||
describe "PaperTrail.enabled_for_controller?" do
|
||||
context "PaperTrail.enabled? == true" do
|
||||
before { PaperTrail.enabled = true }
|
||||
|
||||
it "returns true" do
|
||||
assert PaperTrail.enabled?
|
||||
post :create, params_wrapper(article: { title: "Doh", content: FFaker::Lorem.sentence })
|
||||
expect(assigns(:article)).to_not be_nil
|
||||
assert PaperTrail.enabled_for_controller?
|
||||
assert_equal 1, assigns(:article).versions.length
|
||||
end
|
||||
|
||||
after { PaperTrail.enabled = false }
|
||||
end
|
||||
|
||||
context "PaperTrail.enabled? == false" do
|
||||
it "returns false" do
|
||||
assert !PaperTrail.enabled?
|
||||
post :create, params_wrapper(article: { title: "Doh", content: FFaker::Lorem.sentence })
|
||||
assert !PaperTrail.enabled_for_controller?
|
||||
assert_equal 0, assigns(:article).versions.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
require "test_helper"
|
||||
|
||||
class EnabledForControllerTest < ActionController::TestCase
|
||||
tests ArticlesController
|
||||
|
||||
context "`PaperTrail.enabled? == true`" do
|
||||
should "enabled_for_controller?.should == true" do
|
||||
assert PaperTrail.enabled?
|
||||
post :create, params_wrapper(article: { title: "Doh", content: FFaker::Lorem.sentence })
|
||||
assert_not_nil assigns(:article)
|
||||
assert PaperTrail.enabled_for_controller?
|
||||
assert_equal 1, assigns(:article).versions.length
|
||||
end
|
||||
end
|
||||
|
||||
context "`PaperTrail.enabled? == false`" do
|
||||
setup { PaperTrail.enabled = false }
|
||||
|
||||
should "enabled_for_controller?.should == false" do
|
||||
assert !PaperTrail.enabled?
|
||||
post :create, params_wrapper(article: { title: "Doh", content: FFaker::Lorem.sentence })
|
||||
assert !PaperTrail.enabled_for_controller?
|
||||
assert_equal 0, assigns(:article).versions.length
|
||||
end
|
||||
|
||||
teardown { PaperTrail.enabled = true }
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue