paper_trail 4.2.0 → 7.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/paper_trail/install_generator.rb +91 -17
- data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb.erb +12 -0
- data/lib/generators/paper_trail/templates/{add_transaction_id_column_to_versions.rb → add_transaction_id_column_to_versions.rb.erb} +3 -1
- data/lib/generators/paper_trail/templates/create_version_associations.rb.erb +22 -0
- data/lib/generators/paper_trail/templates/{create_versions.rb → create_versions.rb.erb} +9 -7
- data/lib/paper_trail.rb +180 -148
- data/lib/paper_trail/attribute_serializers/README.md +10 -0
- data/lib/paper_trail/attribute_serializers/cast_attribute_serializer.rb +80 -0
- data/lib/paper_trail/attribute_serializers/legacy_active_record_shim.rb +48 -0
- data/lib/paper_trail/attribute_serializers/object_attribute.rb +39 -0
- data/lib/paper_trail/attribute_serializers/object_changes_attribute.rb +42 -0
- data/lib/paper_trail/cleaner.rb +16 -10
- data/lib/paper_trail/config.rb +28 -27
- data/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb +5 -1
- data/lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb +6 -2
- data/lib/paper_trail/frameworks/cucumber.rb +1 -0
- data/lib/paper_trail/frameworks/rails.rb +2 -7
- data/lib/paper_trail/frameworks/rails/controller.rb +20 -18
- data/lib/paper_trail/frameworks/rails/engine.rb +6 -1
- data/lib/paper_trail/frameworks/rspec.rb +17 -6
- data/lib/paper_trail/frameworks/rspec/helpers.rb +3 -1
- data/lib/paper_trail/has_paper_trail.rb +25 -503
- data/lib/paper_trail/model_config.rb +207 -0
- data/lib/paper_trail/queries/versions/where_object.rb +60 -0
- data/lib/paper_trail/queries/versions/where_object_changes.rb +68 -0
- data/lib/paper_trail/record_history.rb +2 -12
- data/lib/paper_trail/record_trail.rb +573 -0
- data/lib/paper_trail/reifier.rb +164 -215
- data/lib/paper_trail/reifiers/belongs_to.rb +48 -0
- data/lib/paper_trail/reifiers/has_and_belongs_to_many.rb +50 -0
- data/lib/paper_trail/reifiers/has_many.rb +110 -0
- data/lib/paper_trail/reifiers/has_many_through.rb +90 -0
- data/lib/paper_trail/reifiers/has_one.rb +76 -0
- data/lib/paper_trail/serializers/json.rb +16 -7
- data/lib/paper_trail/serializers/yaml.rb +9 -13
- data/lib/paper_trail/version_association_concern.rb +3 -5
- data/lib/paper_trail/version_concern.rb +138 -111
- data/lib/paper_trail/version_number.rb +10 -9
- metadata +95 -327
- data/.gitignore +0 -22
- data/.rspec +0 -2
- data/.travis.yml +0 -41
- data/CHANGELOG.md +0 -362
- data/CONTRIBUTING.md +0 -84
- data/Gemfile +0 -2
- data/MIT-LICENSE +0 -20
- data/README.md +0 -1535
- data/Rakefile +0 -30
- data/doc/bug_report_template.rb +0 -65
- data/gemfiles/ar3.gemfile +0 -61
- data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb +0 -10
- data/lib/generators/paper_trail/templates/create_version_associations.rb +0 -17
- data/lib/paper_trail/attributes_serialization.rb +0 -89
- data/lib/paper_trail/frameworks/sinatra.rb +0 -38
- data/paper_trail.gemspec +0 -59
- data/spec/generators/install_generator_spec.rb +0 -67
- data/spec/models/animal_spec.rb +0 -36
- data/spec/models/boolit_spec.rb +0 -48
- data/spec/models/callback_modifier_spec.rb +0 -96
- data/spec/models/fluxor_spec.rb +0 -19
- data/spec/models/gadget_spec.rb +0 -70
- data/spec/models/joined_version_spec.rb +0 -47
- data/spec/models/json_version_spec.rb +0 -103
- data/spec/models/kitchen/banana_spec.rb +0 -14
- data/spec/models/not_on_update_spec.rb +0 -19
- data/spec/models/post_with_status_spec.rb +0 -17
- data/spec/models/skipper_spec.rb +0 -46
- data/spec/models/thing_spec.rb +0 -11
- data/spec/models/version_spec.rb +0 -239
- data/spec/models/widget_spec.rb +0 -298
- data/spec/modules/paper_trail_spec.rb +0 -27
- data/spec/modules/version_concern_spec.rb +0 -32
- data/spec/modules/version_number_spec.rb +0 -44
- data/spec/paper_trail/config_spec.rb +0 -52
- data/spec/paper_trail_spec.rb +0 -66
- data/spec/rails_helper.rb +0 -34
- data/spec/requests/articles_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -95
- data/spec/support/alt_db_init.rb +0 -59
- data/test/custom_json_serializer.rb +0 -13
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -20
- data/test/dummy/app/controllers/articles_controller.rb +0 -17
- data/test/dummy/app/controllers/test_controller.rb +0 -5
- data/test/dummy/app/controllers/widgets_controller.rb +0 -31
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/models/animal.rb +0 -6
- data/test/dummy/app/models/article.rb +0 -16
- data/test/dummy/app/models/authorship.rb +0 -5
- data/test/dummy/app/models/book.rb +0 -9
- data/test/dummy/app/models/boolit.rb +0 -4
- data/test/dummy/app/models/callback_modifier.rb +0 -45
- data/test/dummy/app/models/cat.rb +0 -2
- data/test/dummy/app/models/chapter.rb +0 -9
- data/test/dummy/app/models/citation.rb +0 -5
- data/test/dummy/app/models/customer.rb +0 -4
- data/test/dummy/app/models/document.rb +0 -4
- data/test/dummy/app/models/dog.rb +0 -2
- data/test/dummy/app/models/editor.rb +0 -4
- data/test/dummy/app/models/editorship.rb +0 -5
- data/test/dummy/app/models/elephant.rb +0 -3
- data/test/dummy/app/models/fluxor.rb +0 -3
- data/test/dummy/app/models/foo_widget.rb +0 -2
- data/test/dummy/app/models/fruit.rb +0 -5
- data/test/dummy/app/models/gadget.rb +0 -3
- data/test/dummy/app/models/kitchen/banana.rb +0 -5
- data/test/dummy/app/models/legacy_widget.rb +0 -4
- data/test/dummy/app/models/line_item.rb +0 -4
- data/test/dummy/app/models/not_on_update.rb +0 -4
- data/test/dummy/app/models/order.rb +0 -5
- data/test/dummy/app/models/paragraph.rb +0 -5
- data/test/dummy/app/models/person.rb +0 -38
- data/test/dummy/app/models/post.rb +0 -3
- data/test/dummy/app/models/post_with_status.rb +0 -8
- data/test/dummy/app/models/protected_widget.rb +0 -3
- data/test/dummy/app/models/quotation.rb +0 -5
- data/test/dummy/app/models/section.rb +0 -6
- data/test/dummy/app/models/skipper.rb +0 -6
- data/test/dummy/app/models/song.rb +0 -32
- data/test/dummy/app/models/thing.rb +0 -3
- data/test/dummy/app/models/translation.rb +0 -4
- data/test/dummy/app/models/whatchamajigger.rb +0 -4
- data/test/dummy/app/models/widget.rb +0 -15
- data/test/dummy/app/models/wotsit.rb +0 -8
- data/test/dummy/app/versions/joined_version.rb +0 -5
- data/test/dummy/app/versions/json_version.rb +0 -3
- data/test/dummy/app/versions/kitchen/banana_version.rb +0 -5
- data/test/dummy/app/versions/post_version.rb +0 -3
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -69
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.mysql.yml +0 -19
- data/test/dummy/config/database.postgres.yml +0 -15
- data/test/dummy/config/database.sqlite.yml +0 -15
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -40
- data/test/dummy/config/environments/production.rb +0 -73
- data/test/dummy/config/environments/test.rb +0 -41
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -10
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/paper_trail.rb +0 -10
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +0 -287
- data/test/dummy/db/schema.rb +0 -246
- data/test/dummy/script/rails +0 -6
- data/test/functional/controller_test.rb +0 -91
- data/test/functional/enabled_for_controller_test.rb +0 -29
- data/test/functional/modular_sinatra_test.rb +0 -48
- data/test/functional/sinatra_test.rb +0 -49
- data/test/functional/thread_safety_test.rb +0 -48
- data/test/paper_trail_test.rb +0 -38
- data/test/test_helper.rb +0 -105
- data/test/time_travel_helper.rb +0 -15
- data/test/unit/associations_test.rb +0 -726
- data/test/unit/cleaner_test.rb +0 -182
- data/test/unit/inheritance_column_test.rb +0 -43
- data/test/unit/model_test.rb +0 -1373
- data/test/unit/protected_attrs_test.rb +0 -47
- data/test/unit/serializer_test.rb +0 -117
- data/test/unit/serializers/json_test.rb +0 -88
- data/test/unit/serializers/mixin_json_test.rb +0 -36
- data/test/unit/serializers/mixin_yaml_test.rb +0 -49
- data/test/unit/serializers/yaml_test.rb +0 -52
- data/test/unit/timestamp_test.rb +0 -43
- data/test/unit/version_test.rb +0 -119
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
describe PaperTrail, :type => :module, :versioning => true do
|
4
|
-
describe '#config' do
|
5
|
-
it { is_expected.to respond_to(:config) }
|
6
|
-
|
7
|
-
it "should allow for config values to be set" do
|
8
|
-
expect(subject.config.enabled).to eq(true)
|
9
|
-
subject.config.enabled = false
|
10
|
-
expect(subject.config.enabled).to eq(false)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should accept blocks and yield the config instance" do
|
14
|
-
expect(subject.config.enabled).to eq(true)
|
15
|
-
subject.config { |c| c.enabled = false }
|
16
|
-
expect(subject.config.enabled).to eq(false)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#configure' do
|
21
|
-
it { is_expected.to respond_to(:configure) }
|
22
|
-
|
23
|
-
it "should be an alias for the `config` method" do
|
24
|
-
expect(subject.method(:configure)).to eq(subject.method(:config))
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
describe PaperTrail::VersionConcern do
|
4
|
-
|
5
|
-
before(:all) { require 'support/alt_db_init' }
|
6
|
-
|
7
|
-
it 'allows included class to have different connections' do
|
8
|
-
expect(Foo::Version.connection).not_to eq(Bar::Version.connection)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'allows custom version class to share connection with superclass' do
|
12
|
-
expect(Foo::Version.connection).to eq(Foo::Document.connection)
|
13
|
-
expect(Bar::Version.connection).to eq(Bar::Document.connection)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'can be used with class_name option' do
|
17
|
-
expect(Foo::Document.version_class_name).to eq('Foo::Version')
|
18
|
-
expect(Bar::Document.version_class_name).to eq('Bar::Version')
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'persistence', :versioning => true do
|
22
|
-
before do
|
23
|
-
@foo_doc = Foo::Document.create!(:name => 'foobar')
|
24
|
-
@bar_doc = Bar::Document.create!(:name => 'raboof')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should store versions in the correct corresponding db location' do
|
28
|
-
expect(@foo_doc.versions.first).to be_instance_of(Foo::Version)
|
29
|
-
expect(@bar_doc.versions.first).to be_instance_of(Bar::Version)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe PaperTrail::VERSION do
|
4
|
-
|
5
|
-
describe "Constants" do
|
6
|
-
subject { PaperTrail::VERSION }
|
7
|
-
|
8
|
-
describe :MAJOR do
|
9
|
-
it { is_expected.to be_const_defined(:MAJOR) }
|
10
|
-
it { expect(subject::MAJOR).to be_a(Integer) }
|
11
|
-
end
|
12
|
-
describe :MINOR do
|
13
|
-
it { is_expected.to be_const_defined(:MINOR) }
|
14
|
-
it { expect(subject::MINOR).to be_a(Integer) }
|
15
|
-
end
|
16
|
-
describe :TINY do
|
17
|
-
it { is_expected.to be_const_defined(:TINY) }
|
18
|
-
it { expect(subject::TINY).to be_a(Integer) }
|
19
|
-
end
|
20
|
-
describe :PRE do
|
21
|
-
it { is_expected.to be_const_defined(:PRE) }
|
22
|
-
if PaperTrail::VERSION::PRE
|
23
|
-
it { expect(subject::PRE).to be_instance_of(String) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
describe :STRING do
|
27
|
-
it { is_expected.to be_const_defined(:STRING) }
|
28
|
-
it { expect(subject::STRING).to be_instance_of(String) }
|
29
|
-
|
30
|
-
it "should join the numbers into a period separated string" do
|
31
|
-
expect(subject::STRING).to eq(
|
32
|
-
[subject::MAJOR, subject::MINOR, subject::TINY, subject::PRE].compact.join('.'))
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
describe PaperTrail do
|
40
|
-
describe '#version' do
|
41
|
-
it { is_expected.to respond_to(:version) }
|
42
|
-
it { expect(subject.version).to eq(PaperTrail::VERSION::STRING) }
|
43
|
-
end
|
44
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
module PaperTrail
|
4
|
-
RSpec.describe Config do
|
5
|
-
describe ".instance" do
|
6
|
-
it "returns the singleton instance" do
|
7
|
-
expect { described_class.instance }.to_not raise_error
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe ".new" do
|
12
|
-
it "raises NoMethodError" do
|
13
|
-
expect { described_class.new }.to raise_error(NoMethodError)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#enabled" do
|
18
|
-
context "when paper_trail_enabled is true" do
|
19
|
-
it "returns true" do
|
20
|
-
store = double
|
21
|
-
allow(store).to receive(:fetch).
|
22
|
-
with(:paper_trail_enabled, true).
|
23
|
-
and_return(true)
|
24
|
-
allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
|
25
|
-
expect(described_class.instance.enabled).to eq(true)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "when paper_trail_enabled is false" do
|
30
|
-
it "returns false" do
|
31
|
-
store = double
|
32
|
-
allow(store).to receive(:fetch).
|
33
|
-
with(:paper_trail_enabled, true).
|
34
|
-
and_return(false)
|
35
|
-
allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
|
36
|
-
expect(described_class.instance.enabled).to eq(false)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "when paper_trail_enabled is nil" do
|
41
|
-
it "returns true" do
|
42
|
-
store = double
|
43
|
-
allow(store).to receive(:fetch).
|
44
|
-
with(:paper_trail_enabled, true).
|
45
|
-
and_return(nil)
|
46
|
-
allow(PaperTrail).to receive(:paper_trail_store).and_return(store)
|
47
|
-
expect(described_class.instance.enabled).to eq(true)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/spec/paper_trail_spec.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
describe "PaperTrail RSpec Helper" do
|
4
|
-
context 'default' do
|
5
|
-
it 'should have versioning off by default' do
|
6
|
-
expect(PaperTrail).not_to be_enabled
|
7
|
-
end
|
8
|
-
it 'should turn versioning on in a `with_versioning` block' do
|
9
|
-
expect(PaperTrail).not_to be_enabled
|
10
|
-
with_versioning do
|
11
|
-
expect(PaperTrail).to be_enabled
|
12
|
-
end
|
13
|
-
expect(PaperTrail).not_to be_enabled
|
14
|
-
end
|
15
|
-
|
16
|
-
context "error within `with_versioning` block" do
|
17
|
-
it "should revert the value of `PaperTrail.enabled?` to it's previous state" do
|
18
|
-
expect(PaperTrail).not_to be_enabled
|
19
|
-
expect { with_versioning { raise } }.to raise_error
|
20
|
-
expect(PaperTrail).not_to be_enabled
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context '`versioning: true`', :versioning => true do
|
26
|
-
it 'should have versioning on by default' do
|
27
|
-
expect(PaperTrail).to be_enabled
|
28
|
-
end
|
29
|
-
it 'should keep versioning on after a with_versioning block' do
|
30
|
-
expect(PaperTrail).to be_enabled
|
31
|
-
with_versioning do
|
32
|
-
expect(PaperTrail).to be_enabled
|
33
|
-
end
|
34
|
-
expect(PaperTrail).to be_enabled
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context '`with_versioning` block at class level' do
|
39
|
-
it { expect(PaperTrail).not_to be_enabled }
|
40
|
-
|
41
|
-
with_versioning do
|
42
|
-
it 'should have versioning on by default' do
|
43
|
-
expect(PaperTrail).to be_enabled
|
44
|
-
end
|
45
|
-
end
|
46
|
-
it 'should not leak the `enabled?` state into successive tests' do
|
47
|
-
expect(PaperTrail).not_to be_enabled
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe :whodunnit do
|
52
|
-
before(:all) { PaperTrail.whodunnit = 'foobar' }
|
53
|
-
|
54
|
-
it "should get set to `nil` by default" do
|
55
|
-
expect(PaperTrail.whodunnit).to be_nil
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe :controller_info do
|
60
|
-
before(:all) { ::PaperTrail.controller_info = {:foo => 'bar'} }
|
61
|
-
|
62
|
-
it "should get set to an empty hash before each test" do
|
63
|
-
expect(PaperTrail.controller_info).to eq({})
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/spec/rails_helper.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
ENV["RAILS_ENV"] ||= 'test'
|
3
|
-
ENV["DB"] ||= 'sqlite'
|
4
|
-
|
5
|
-
unless File.exists?(File.expand_path('../../test/dummy/config/database.yml', __FILE__))
|
6
|
-
warn "WARNING: No database.yml detected for the dummy app, please run `rake prepare` first"
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'spec_helper'
|
10
|
-
require File.expand_path('../../test/dummy/config/environment', __FILE__)
|
11
|
-
require 'rspec/rails'
|
12
|
-
require 'paper_trail/frameworks/rspec'
|
13
|
-
require 'shoulda/matchers'
|
14
|
-
require 'ffaker'
|
15
|
-
|
16
|
-
# prevent Test::Unit's AutoRunner from executing during RSpec's rake task
|
17
|
-
Test::Unit.run = true if defined?(Test::Unit) && Test::Unit.respond_to?(:run=)
|
18
|
-
|
19
|
-
# Checks for pending migrations before tests are run.
|
20
|
-
# If you are not using ActiveRecord, you can remove this line.
|
21
|
-
ActiveRecord::Migration.check_pending! if ActiveRecord::Migration.respond_to?(:check_pending!)
|
22
|
-
|
23
|
-
RSpec.configure do |config|
|
24
|
-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
25
|
-
|
26
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
27
|
-
# examples within a transaction, remove the following line or assign false
|
28
|
-
# instead of true.
|
29
|
-
config.use_transactional_fixtures = true
|
30
|
-
|
31
|
-
# The different available types are documented in the features, such as in
|
32
|
-
# https://relishapp.com/rspec/rspec-rails/docs
|
33
|
-
# config.infer_spec_type_from_file_location!
|
34
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
describe "Articles management", :type => :request, :order => :defined do
|
4
|
-
let(:valid_params) { { :article => { :title => 'Doh', :content => Faker::Lorem.sentence } } }
|
5
|
-
|
6
|
-
context "versioning disabled" do
|
7
|
-
specify { expect(PaperTrail).not_to be_enabled }
|
8
|
-
|
9
|
-
it "should not create a version" do
|
10
|
-
expect(PaperTrail).to be_enabled_for_controller
|
11
|
-
expect { post(articles_path, valid_params) }.to_not change(PaperTrail::Version, :count)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should not leak the state of the `PaperTrail.enabled_for_controller?` into the next test" do
|
15
|
-
expect(PaperTrail).to be_enabled_for_controller
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
with_versioning do
|
20
|
-
let(:article) { Article.last }
|
21
|
-
|
22
|
-
context "`current_user` method returns a `String`" do
|
23
|
-
it "should set that value as the `whodunnit`" do
|
24
|
-
expect { post articles_path, valid_params }.to change(PaperTrail::Version, :count).by(1)
|
25
|
-
expect(article.title).to eq('Doh')
|
26
|
-
expect(article.versions.last.whodunnit).to eq('foobar')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'pry-nav'
|
3
|
-
rescue LoadError
|
4
|
-
# It's OK, we don't include pry in e.g. gemfiles/3.0.gemfile
|
5
|
-
end
|
6
|
-
|
7
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
8
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
9
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
10
|
-
# file to always be loaded, without a need to explicitly require it in any files.
|
11
|
-
#
|
12
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
13
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
14
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
15
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
16
|
-
# a separate helper file that requires the additional dependencies and performs
|
17
|
-
# the additional setup, and require it from the spec files that actually need it.
|
18
|
-
#
|
19
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
20
|
-
# users commonly want.
|
21
|
-
#
|
22
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
-
RSpec.configure do |config|
|
24
|
-
# rspec-expectations config goes here. You can use an alternate
|
25
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
26
|
-
# assertions if you prefer.
|
27
|
-
config.expect_with :rspec do |expectations|
|
28
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
29
|
-
# and `failure_message` of custom matchers include text for helper methods
|
30
|
-
# defined using `chain`, e.g.:
|
31
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
32
|
-
# # => "be bigger than 2 and smaller than 4"
|
33
|
-
# ...rather than:
|
34
|
-
# # => "be bigger than 2"
|
35
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
36
|
-
end
|
37
|
-
|
38
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
39
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
40
|
-
config.mock_with :rspec do |mocks|
|
41
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
42
|
-
# a real object. This is generally recommended, and will default to
|
43
|
-
# `true` in RSpec 4.
|
44
|
-
mocks.verify_partial_doubles = true
|
45
|
-
end
|
46
|
-
|
47
|
-
# The settings below are suggested to provide a good initial experience
|
48
|
-
# with RSpec, but feel free to customize to your heart's content.
|
49
|
-
=begin
|
50
|
-
# These two settings work together to allow you to limit a spec run
|
51
|
-
# to individual examples or groups you care about by tagging them with
|
52
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
53
|
-
# get run.
|
54
|
-
config.filter_run :focus
|
55
|
-
config.run_all_when_everything_filtered = true
|
56
|
-
|
57
|
-
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
58
|
-
# For more details, see:
|
59
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
60
|
-
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
61
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
62
|
-
config.disable_monkey_patching!
|
63
|
-
|
64
|
-
# This setting enables warnings. It's recommended, but in some cases may
|
65
|
-
# be too noisy due to issues in dependencies.
|
66
|
-
config.warnings = true
|
67
|
-
|
68
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
69
|
-
# file, and it's useful to allow more verbose output when running an
|
70
|
-
# individual spec file.
|
71
|
-
if config.files_to_run.one?
|
72
|
-
# Use the documentation formatter for detailed output,
|
73
|
-
# unless a formatter has already been configured
|
74
|
-
# (e.g. via a command-line flag).
|
75
|
-
config.default_formatter = 'doc'
|
76
|
-
end
|
77
|
-
|
78
|
-
# Print the 10 slowest examples and example groups at the
|
79
|
-
# end of the spec run, to help surface which specs are running
|
80
|
-
# particularly slow.
|
81
|
-
config.profile_examples = 10
|
82
|
-
|
83
|
-
# Run specs in random order to surface order dependencies. If you find an
|
84
|
-
# order dependency and want to debug it, you can fix the order by providing
|
85
|
-
# the seed, which is printed after each run.
|
86
|
-
# --seed 1234
|
87
|
-
config.order = :random
|
88
|
-
|
89
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
90
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
91
|
-
# test failures related to randomization by passing the same `--seed` value
|
92
|
-
# as the one that triggered the failure.
|
93
|
-
Kernel.srand config.seed
|
94
|
-
=end
|
95
|
-
end
|
data/spec/support/alt_db_init.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
# This file copies the test database into locations for the `Foo` and `Bar` namespace,
|
2
|
-
# then defines those namespaces, then establishes the sqlite3 connection for the namespaces
|
3
|
-
# to simulate an application with multiple database connections.
|
4
|
-
|
5
|
-
#Load database yaml to use
|
6
|
-
configs = YAML.load_file("#{Rails.root}/config/database.yml")
|
7
|
-
|
8
|
-
#If we are testing with sqlite make it quick
|
9
|
-
db_directory = "#{Rails.root}/db"
|
10
|
-
# setup alternate databases
|
11
|
-
if ENV["DB"] == "sqlite"
|
12
|
-
if RUBY_VERSION >= '1.9'
|
13
|
-
FileUtils.cp "#{db_directory}/test.sqlite3", "#{db_directory}/test-foo.sqlite3"
|
14
|
-
FileUtils.cp "#{db_directory}/test.sqlite3", "#{db_directory}/test-bar.sqlite3"
|
15
|
-
else
|
16
|
-
require 'ftools'
|
17
|
-
File.cp "#{db_directory}/test.sqlite3", "#{db_directory}/test-foo.sqlite3"
|
18
|
-
File.cp "#{db_directory}/test.sqlite3", "#{db_directory}/test-bar.sqlite3"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Foo
|
23
|
-
class Base < ActiveRecord::Base
|
24
|
-
self.abstract_class = true
|
25
|
-
end
|
26
|
-
|
27
|
-
class Version < Base
|
28
|
-
include PaperTrail::VersionConcern
|
29
|
-
end
|
30
|
-
|
31
|
-
class Document < Base
|
32
|
-
has_paper_trail :class_name => 'Foo::Version'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Foo::Base.configurations = configs
|
37
|
-
Foo::Base.establish_connection(:foo)
|
38
|
-
ActiveRecord::Base.establish_connection(:foo)
|
39
|
-
ActiveRecord::Migrator.migrate File.expand_path("#{db_directory}/migrate/", __FILE__)
|
40
|
-
|
41
|
-
module Bar
|
42
|
-
class Base < ActiveRecord::Base
|
43
|
-
self.abstract_class = true
|
44
|
-
end
|
45
|
-
|
46
|
-
class Version < Base
|
47
|
-
include PaperTrail::VersionConcern
|
48
|
-
end
|
49
|
-
|
50
|
-
class Document < Base
|
51
|
-
has_paper_trail :class_name => 'Bar::Version'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
Bar::Base.configurations = configs
|
56
|
-
Bar::Base.establish_connection(:bar)
|
57
|
-
ActiveRecord::Base.establish_connection(:bar)
|
58
|
-
|
59
|
-
ActiveRecord::Migrator.migrate File.expand_path("#{db_directory}/migrate/", __FILE__)
|