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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/paper_trail/install_generator.rb +91 -17
  3. data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb.erb +12 -0
  4. data/lib/generators/paper_trail/templates/{add_transaction_id_column_to_versions.rb → add_transaction_id_column_to_versions.rb.erb} +3 -1
  5. data/lib/generators/paper_trail/templates/create_version_associations.rb.erb +22 -0
  6. data/lib/generators/paper_trail/templates/{create_versions.rb → create_versions.rb.erb} +9 -7
  7. data/lib/paper_trail.rb +180 -148
  8. data/lib/paper_trail/attribute_serializers/README.md +10 -0
  9. data/lib/paper_trail/attribute_serializers/cast_attribute_serializer.rb +80 -0
  10. data/lib/paper_trail/attribute_serializers/legacy_active_record_shim.rb +48 -0
  11. data/lib/paper_trail/attribute_serializers/object_attribute.rb +39 -0
  12. data/lib/paper_trail/attribute_serializers/object_changes_attribute.rb +42 -0
  13. data/lib/paper_trail/cleaner.rb +16 -10
  14. data/lib/paper_trail/config.rb +28 -27
  15. data/lib/paper_trail/frameworks/active_record/models/paper_trail/version.rb +5 -1
  16. data/lib/paper_trail/frameworks/active_record/models/paper_trail/version_association.rb +6 -2
  17. data/lib/paper_trail/frameworks/cucumber.rb +1 -0
  18. data/lib/paper_trail/frameworks/rails.rb +2 -7
  19. data/lib/paper_trail/frameworks/rails/controller.rb +20 -18
  20. data/lib/paper_trail/frameworks/rails/engine.rb +6 -1
  21. data/lib/paper_trail/frameworks/rspec.rb +17 -6
  22. data/lib/paper_trail/frameworks/rspec/helpers.rb +3 -1
  23. data/lib/paper_trail/has_paper_trail.rb +25 -503
  24. data/lib/paper_trail/model_config.rb +207 -0
  25. data/lib/paper_trail/queries/versions/where_object.rb +60 -0
  26. data/lib/paper_trail/queries/versions/where_object_changes.rb +68 -0
  27. data/lib/paper_trail/record_history.rb +2 -12
  28. data/lib/paper_trail/record_trail.rb +573 -0
  29. data/lib/paper_trail/reifier.rb +164 -215
  30. data/lib/paper_trail/reifiers/belongs_to.rb +48 -0
  31. data/lib/paper_trail/reifiers/has_and_belongs_to_many.rb +50 -0
  32. data/lib/paper_trail/reifiers/has_many.rb +110 -0
  33. data/lib/paper_trail/reifiers/has_many_through.rb +90 -0
  34. data/lib/paper_trail/reifiers/has_one.rb +76 -0
  35. data/lib/paper_trail/serializers/json.rb +16 -7
  36. data/lib/paper_trail/serializers/yaml.rb +9 -13
  37. data/lib/paper_trail/version_association_concern.rb +3 -5
  38. data/lib/paper_trail/version_concern.rb +138 -111
  39. data/lib/paper_trail/version_number.rb +10 -9
  40. metadata +95 -327
  41. data/.gitignore +0 -22
  42. data/.rspec +0 -2
  43. data/.travis.yml +0 -41
  44. data/CHANGELOG.md +0 -362
  45. data/CONTRIBUTING.md +0 -84
  46. data/Gemfile +0 -2
  47. data/MIT-LICENSE +0 -20
  48. data/README.md +0 -1535
  49. data/Rakefile +0 -30
  50. data/doc/bug_report_template.rb +0 -65
  51. data/gemfiles/ar3.gemfile +0 -61
  52. data/lib/generators/paper_trail/templates/add_object_changes_to_versions.rb +0 -10
  53. data/lib/generators/paper_trail/templates/create_version_associations.rb +0 -17
  54. data/lib/paper_trail/attributes_serialization.rb +0 -89
  55. data/lib/paper_trail/frameworks/sinatra.rb +0 -38
  56. data/paper_trail.gemspec +0 -59
  57. data/spec/generators/install_generator_spec.rb +0 -67
  58. data/spec/models/animal_spec.rb +0 -36
  59. data/spec/models/boolit_spec.rb +0 -48
  60. data/spec/models/callback_modifier_spec.rb +0 -96
  61. data/spec/models/fluxor_spec.rb +0 -19
  62. data/spec/models/gadget_spec.rb +0 -70
  63. data/spec/models/joined_version_spec.rb +0 -47
  64. data/spec/models/json_version_spec.rb +0 -103
  65. data/spec/models/kitchen/banana_spec.rb +0 -14
  66. data/spec/models/not_on_update_spec.rb +0 -19
  67. data/spec/models/post_with_status_spec.rb +0 -17
  68. data/spec/models/skipper_spec.rb +0 -46
  69. data/spec/models/thing_spec.rb +0 -11
  70. data/spec/models/version_spec.rb +0 -239
  71. data/spec/models/widget_spec.rb +0 -298
  72. data/spec/modules/paper_trail_spec.rb +0 -27
  73. data/spec/modules/version_concern_spec.rb +0 -32
  74. data/spec/modules/version_number_spec.rb +0 -44
  75. data/spec/paper_trail/config_spec.rb +0 -52
  76. data/spec/paper_trail_spec.rb +0 -66
  77. data/spec/rails_helper.rb +0 -34
  78. data/spec/requests/articles_spec.rb +0 -30
  79. data/spec/spec_helper.rb +0 -95
  80. data/spec/support/alt_db_init.rb +0 -59
  81. data/test/custom_json_serializer.rb +0 -13
  82. data/test/dummy/Rakefile +0 -7
  83. data/test/dummy/app/controllers/application_controller.rb +0 -20
  84. data/test/dummy/app/controllers/articles_controller.rb +0 -17
  85. data/test/dummy/app/controllers/test_controller.rb +0 -5
  86. data/test/dummy/app/controllers/widgets_controller.rb +0 -31
  87. data/test/dummy/app/helpers/application_helper.rb +0 -2
  88. data/test/dummy/app/models/animal.rb +0 -6
  89. data/test/dummy/app/models/article.rb +0 -16
  90. data/test/dummy/app/models/authorship.rb +0 -5
  91. data/test/dummy/app/models/book.rb +0 -9
  92. data/test/dummy/app/models/boolit.rb +0 -4
  93. data/test/dummy/app/models/callback_modifier.rb +0 -45
  94. data/test/dummy/app/models/cat.rb +0 -2
  95. data/test/dummy/app/models/chapter.rb +0 -9
  96. data/test/dummy/app/models/citation.rb +0 -5
  97. data/test/dummy/app/models/customer.rb +0 -4
  98. data/test/dummy/app/models/document.rb +0 -4
  99. data/test/dummy/app/models/dog.rb +0 -2
  100. data/test/dummy/app/models/editor.rb +0 -4
  101. data/test/dummy/app/models/editorship.rb +0 -5
  102. data/test/dummy/app/models/elephant.rb +0 -3
  103. data/test/dummy/app/models/fluxor.rb +0 -3
  104. data/test/dummy/app/models/foo_widget.rb +0 -2
  105. data/test/dummy/app/models/fruit.rb +0 -5
  106. data/test/dummy/app/models/gadget.rb +0 -3
  107. data/test/dummy/app/models/kitchen/banana.rb +0 -5
  108. data/test/dummy/app/models/legacy_widget.rb +0 -4
  109. data/test/dummy/app/models/line_item.rb +0 -4
  110. data/test/dummy/app/models/not_on_update.rb +0 -4
  111. data/test/dummy/app/models/order.rb +0 -5
  112. data/test/dummy/app/models/paragraph.rb +0 -5
  113. data/test/dummy/app/models/person.rb +0 -38
  114. data/test/dummy/app/models/post.rb +0 -3
  115. data/test/dummy/app/models/post_with_status.rb +0 -8
  116. data/test/dummy/app/models/protected_widget.rb +0 -3
  117. data/test/dummy/app/models/quotation.rb +0 -5
  118. data/test/dummy/app/models/section.rb +0 -6
  119. data/test/dummy/app/models/skipper.rb +0 -6
  120. data/test/dummy/app/models/song.rb +0 -32
  121. data/test/dummy/app/models/thing.rb +0 -3
  122. data/test/dummy/app/models/translation.rb +0 -4
  123. data/test/dummy/app/models/whatchamajigger.rb +0 -4
  124. data/test/dummy/app/models/widget.rb +0 -15
  125. data/test/dummy/app/models/wotsit.rb +0 -8
  126. data/test/dummy/app/versions/joined_version.rb +0 -5
  127. data/test/dummy/app/versions/json_version.rb +0 -3
  128. data/test/dummy/app/versions/kitchen/banana_version.rb +0 -5
  129. data/test/dummy/app/versions/post_version.rb +0 -3
  130. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  131. data/test/dummy/config.ru +0 -4
  132. data/test/dummy/config/application.rb +0 -69
  133. data/test/dummy/config/boot.rb +0 -10
  134. data/test/dummy/config/database.mysql.yml +0 -19
  135. data/test/dummy/config/database.postgres.yml +0 -15
  136. data/test/dummy/config/database.sqlite.yml +0 -15
  137. data/test/dummy/config/environment.rb +0 -5
  138. data/test/dummy/config/environments/development.rb +0 -40
  139. data/test/dummy/config/environments/production.rb +0 -73
  140. data/test/dummy/config/environments/test.rb +0 -41
  141. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  142. data/test/dummy/config/initializers/inflections.rb +0 -10
  143. data/test/dummy/config/initializers/mime_types.rb +0 -5
  144. data/test/dummy/config/initializers/paper_trail.rb +0 -10
  145. data/test/dummy/config/initializers/secret_token.rb +0 -7
  146. data/test/dummy/config/initializers/session_store.rb +0 -8
  147. data/test/dummy/config/locales/en.yml +0 -5
  148. data/test/dummy/config/routes.rb +0 -4
  149. data/test/dummy/db/migrate/20110208155312_set_up_test_tables.rb +0 -287
  150. data/test/dummy/db/schema.rb +0 -246
  151. data/test/dummy/script/rails +0 -6
  152. data/test/functional/controller_test.rb +0 -91
  153. data/test/functional/enabled_for_controller_test.rb +0 -29
  154. data/test/functional/modular_sinatra_test.rb +0 -48
  155. data/test/functional/sinatra_test.rb +0 -49
  156. data/test/functional/thread_safety_test.rb +0 -48
  157. data/test/paper_trail_test.rb +0 -38
  158. data/test/test_helper.rb +0 -105
  159. data/test/time_travel_helper.rb +0 -15
  160. data/test/unit/associations_test.rb +0 -726
  161. data/test/unit/cleaner_test.rb +0 -182
  162. data/test/unit/inheritance_column_test.rb +0 -43
  163. data/test/unit/model_test.rb +0 -1373
  164. data/test/unit/protected_attrs_test.rb +0 -47
  165. data/test/unit/serializer_test.rb +0 -117
  166. data/test/unit/serializers/json_test.rb +0 -88
  167. data/test/unit/serializers/mixin_json_test.rb +0 -36
  168. data/test/unit/serializers/mixin_yaml_test.rb +0 -49
  169. data/test/unit/serializers/yaml_test.rb +0 -52
  170. data/test/unit/timestamp_test.rb +0 -43
  171. 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
@@ -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
@@ -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__)