activerecord-userstamp 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -5
  3. data/.rspec +2 -2
  4. data/CHANGELOG.md +80 -0
  5. data/Gemfile +3 -3
  6. data/LICENSE +21 -21
  7. data/README.md +188 -220
  8. data/Rakefile +17 -17
  9. data/activerecord-userstamp.gemspec +34 -34
  10. data/lib/active_record/userstamp.rb +30 -14
  11. data/lib/active_record/userstamp/configuration.rb +49 -0
  12. data/lib/active_record/userstamp/controller_additions.rb +38 -41
  13. data/lib/active_record/userstamp/migration_additions.rb +14 -16
  14. data/lib/active_record/userstamp/model_additions.rb +10 -3
  15. data/lib/active_record/userstamp/stampable.rb +121 -174
  16. data/lib/active_record/userstamp/stamper.rb +47 -39
  17. data/lib/active_record/userstamp/utilities.rb +18 -0
  18. data/lib/active_record/userstamp/version.rb +4 -4
  19. data/lib/activerecord/userstamp.rb +1 -1
  20. data/spec/controllers/posts_controller_spec.rb +46 -46
  21. data/spec/controllers/users_controller_spec.rb +41 -41
  22. data/spec/dummy/README.rdoc +28 -28
  23. data/spec/dummy/Rakefile +6 -6
  24. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  25. data/spec/dummy/app/assets/stylesheets/application.css +15 -15
  26. data/spec/dummy/app/controllers/application_controller.rb +13 -13
  27. data/spec/dummy/app/controllers/posts_controller.rb +32 -32
  28. data/spec/dummy/app/controllers/users_controller.rb +18 -18
  29. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  30. data/spec/dummy/app/models/comment.rb +5 -6
  31. data/spec/dummy/app/models/person.rb +3 -4
  32. data/spec/dummy/app/models/post.rb +14 -13
  33. data/spec/dummy/app/models/user.rb +3 -4
  34. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  35. data/spec/dummy/bin/bundle +3 -3
  36. data/spec/dummy/bin/rails +4 -4
  37. data/spec/dummy/bin/rake +4 -4
  38. data/spec/dummy/bin/setup +29 -29
  39. data/spec/dummy/config.ru +4 -4
  40. data/spec/dummy/config/application.rb +30 -30
  41. data/spec/dummy/config/boot.rb +5 -5
  42. data/spec/dummy/config/database.yml +23 -25
  43. data/spec/dummy/config/environment.rb +5 -5
  44. data/spec/dummy/config/environments/development.rb +41 -41
  45. data/spec/dummy/config/environments/production.rb +79 -79
  46. data/spec/dummy/config/environments/test.rb +37 -37
  47. data/spec/dummy/config/initializers/assets.rb +11 -11
  48. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  49. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -3
  50. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  51. data/spec/dummy/config/initializers/inflections.rb +16 -16
  52. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  53. data/spec/dummy/config/initializers/session_store.rb +3 -3
  54. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  55. data/spec/dummy/config/locales/en.yml +23 -23
  56. data/spec/dummy/config/routes.rb +56 -56
  57. data/spec/dummy/config/secrets.yml +22 -22
  58. data/spec/dummy/db/schema.rb +45 -55
  59. data/spec/dummy/public/404.html +67 -67
  60. data/spec/dummy/public/422.html +67 -67
  61. data/spec/dummy/public/500.html +66 -66
  62. data/spec/lib/configuration_spec.rb +20 -0
  63. data/spec/lib/migration_spec.rb +55 -12
  64. data/spec/lib/stamping_spec.rb +210 -170
  65. data/spec/lib/userstamp_spec.rb +7 -7
  66. data/spec/rails_helper.rb +7 -7
  67. data/spec/spec_helper.rb +97 -97
  68. data/spec/support/database_helpers.rb +20 -22
  69. metadata +6 -5
  70. data/CHANGELOG +0 -26
  71. data/spec/dummy/app/models/foo.rb +0 -3
  72. data/spec/lib/compatibility_stamping_spec.rb +0 -69
@@ -1,7 +1,7 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe ActiveRecord::Userstamp do
4
- it 'has a VERSION' do
5
- expect(ActiveRecord::Userstamp::VERSION).to match(/^\d+\.\d+\.\d+$/)
6
- end
7
- end
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe ActiveRecord::Userstamp do
4
+ it 'has a VERSION' do
5
+ expect(ActiveRecord::Userstamp::VERSION).to match(/^\d+\.\d+\.\d+$/)
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- ENV['RAILS_ENV'] ||= 'test'
2
- require 'spec_helper'
3
-
4
- require File.expand_path('dummy/config/environment.rb', __dir__)
5
- require 'rspec/rails'
6
-
7
- Dir[__dir__ + '/support/**/*'].each { |f| require f if File.file?(f) }
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require 'spec_helper'
3
+
4
+ require File.expand_path('dummy/config/environment.rb', __dir__)
5
+ require 'rspec/rails'
6
+
7
+ Dir[__dir__ + '/support/**/*'].each { |f| require f if File.file?(f) }
@@ -1,97 +1,97 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause
4
- # this file to always be loaded, without a need to explicitly require it in any
5
- # files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need
13
- # it.
14
- #
15
- # The `.rspec` file also contains a few flags that are not defaults but that
16
- # users commonly want.
17
- #
18
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
- require 'bundler/setup'
20
- Bundler.setup
21
-
22
- require 'coverage_helper'
23
-
24
- RSpec.configure do |config|
25
- # rspec-expectations config goes here. You can use an alternate
26
- # assertion/expectation library such as wrong or the stdlib/minitest
27
- # assertions if you prefer.
28
- config.expect_with :rspec do |expectations|
29
- # This option will default to `true` in RSpec 4. It makes the `description`
30
- # and `failure_message` of custom matchers include text for helper methods
31
- # defined using `chain`, e.g.:
32
- # be_bigger_than(2).and_smaller_than(4).description
33
- # # => "be bigger than 2 and smaller than 4"
34
- # ...rather than:
35
- # # => "be bigger than 2"
36
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
- end
38
-
39
- # rspec-mocks config goes here. You can use an alternate test double
40
- # library (such as bogus or mocha) by changing the `mock_with` option here.
41
- config.mock_with :rspec do |mocks|
42
- # Prevents you from mocking or stubbing a method that does not exist on
43
- # a real object. This is generally recommended, and will default to
44
- # `true` in RSpec 4.
45
- mocks.verify_partial_doubles = true
46
- end
47
-
48
- # These two settings work together to allow you to limit a spec run
49
- # to individual examples or groups you care about by tagging them with
50
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
- # get run.
52
- config.filter_run :focus
53
- config.run_all_when_everything_filtered = true
54
-
55
- # Allows RSpec to persist some state between runs in order to support
56
- # the `--only-failures` and `--next-failure` CLI options. We recommend
57
- # you configure your source control system to ignore this file.
58
- config.example_status_persistence_file_path = "spec/examples.txt"
59
-
60
- # Limits the available syntax to the non-monkey patched syntax that is
61
- # recommended. For more details, see:
62
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
65
- config.disable_monkey_patching!
66
-
67
- # This setting enables warnings. It's recommended, but in some cases may
68
- # be too noisy due to issues in dependencies.
69
- config.warnings = true
70
-
71
- # Many RSpec users commonly either run the entire suite or an individual
72
- # file, and it's useful to allow more verbose output when running an
73
- # individual spec file.
74
- if config.files_to_run.one?
75
- # Use the documentation formatter for detailed output,
76
- # unless a formatter has already been configured
77
- # (e.g. via a command-line flag).
78
- config.default_formatter = 'doc'
79
- end
80
-
81
- # Print the 10 slowest examples and example groups at the
82
- # end of the spec run, to help surface which specs are running
83
- # particularly slow.
84
- config.profile_examples = 10
85
-
86
- # Run specs in random order to surface order dependencies. If you find an
87
- # order dependency and want to debug it, you can fix the order by providing
88
- # the seed, which is printed after each run.
89
- # --seed 1234
90
- config.order = :random
91
-
92
- # Seed global randomization in this process using the `--seed` CLI option.
93
- # Setting this allows you to use `--seed` to deterministically reproduce
94
- # test failures related to randomization by passing the same `--seed` value
95
- # as the one that triggered the failure.
96
- Kernel.srand config.seed
97
- end
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ require 'bundler/setup'
20
+ Bundler.setup
21
+
22
+ require 'coverage_helper'
23
+
24
+ RSpec.configure do |config|
25
+ # rspec-expectations config goes here. You can use an alternate
26
+ # assertion/expectation library such as wrong or the stdlib/minitest
27
+ # assertions if you prefer.
28
+ config.expect_with :rspec do |expectations|
29
+ # This option will default to `true` in RSpec 4. It makes the `description`
30
+ # and `failure_message` of custom matchers include text for helper methods
31
+ # defined using `chain`, e.g.:
32
+ # be_bigger_than(2).and_smaller_than(4).description
33
+ # # => "be bigger than 2 and smaller than 4"
34
+ # ...rather than:
35
+ # # => "be bigger than 2"
36
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
+ end
38
+
39
+ # rspec-mocks config goes here. You can use an alternate test double
40
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
41
+ config.mock_with :rspec do |mocks|
42
+ # Prevents you from mocking or stubbing a method that does not exist on
43
+ # a real object. This is generally recommended, and will default to
44
+ # `true` in RSpec 4.
45
+ mocks.verify_partial_doubles = true
46
+ end
47
+
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Allows RSpec to persist some state between runs in order to support
56
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
57
+ # you configure your source control system to ignore this file.
58
+ config.example_status_persistence_file_path = "spec/examples.txt"
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ end
@@ -1,22 +1,20 @@
1
- def reset_to_defaults
2
- ActiveRecord::Userstamp.compatibility_mode = false
3
- create_test_models
4
- end
5
-
6
- def create_test_models
7
- User.delete_all
8
- Person.delete_all
9
- Post.delete_all
10
- Comment.delete_all
11
- Foo.delete_all
12
-
13
- @zeus = User.create!(:name => 'Zeus')
14
- @hera = User.create!(:name => 'Hera')
15
- User.stamper = @zeus.id
16
-
17
- @delynn = Person.create!(:name => 'Delynn')
18
- @nicole = Person.create!(:name => 'Nicole')
19
- Person.stamper = @delynn.id
20
-
21
- @first_post = Post.create!(:title => 'a title')
22
- end
1
+ def reset_to_defaults
2
+ create_test_models
3
+ end
4
+
5
+ def create_test_models
6
+ User.delete_all
7
+ Person.delete_all
8
+ Post.delete_all
9
+ Comment.delete_all
10
+
11
+ @zeus = User.create!(name: 'Zeus')
12
+ @hera = User.create!(name: 'Hera')
13
+ User.stamper = @zeus.id
14
+
15
+ @delynn = Person.create!(name: 'Delynn')
16
+ @nicole = Person.create!(name: 'Nicole')
17
+ Person.stamper = @delynn.id
18
+
19
+ @first_post = Post.create!(title: 'a title')
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-userstamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Low
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -176,18 +176,20 @@ files:
176
176
  - ".gitignore"
177
177
  - ".rspec"
178
178
  - ".travis.yml"
179
- - CHANGELOG
179
+ - CHANGELOG.md
180
180
  - Gemfile
181
181
  - LICENSE
182
182
  - README.md
183
183
  - Rakefile
184
184
  - activerecord-userstamp.gemspec
185
185
  - lib/active_record/userstamp.rb
186
+ - lib/active_record/userstamp/configuration.rb
186
187
  - lib/active_record/userstamp/controller_additions.rb
187
188
  - lib/active_record/userstamp/migration_additions.rb
188
189
  - lib/active_record/userstamp/model_additions.rb
189
190
  - lib/active_record/userstamp/stampable.rb
190
191
  - lib/active_record/userstamp/stamper.rb
192
+ - lib/active_record/userstamp/utilities.rb
191
193
  - lib/active_record/userstamp/version.rb
192
194
  - lib/activerecord/userstamp.rb
193
195
  - spec/controllers/posts_controller_spec.rb
@@ -206,7 +208,6 @@ files:
206
208
  - spec/dummy/app/mailers/.keep
207
209
  - spec/dummy/app/models/comment.rb
208
210
  - spec/dummy/app/models/concerns/.keep
209
- - spec/dummy/app/models/foo.rb
210
211
  - spec/dummy/app/models/person.rb
211
212
  - spec/dummy/app/models/post.rb
212
213
  - spec/dummy/app/models/user.rb
@@ -241,7 +242,7 @@ files:
241
242
  - spec/dummy/public/422.html
242
243
  - spec/dummy/public/500.html
243
244
  - spec/dummy/public/favicon.ico
244
- - spec/lib/compatibility_stamping_spec.rb
245
+ - spec/lib/configuration_spec.rb
245
246
  - spec/lib/migration_spec.rb
246
247
  - spec/lib/stamping_spec.rb
247
248
  - spec/lib/userstamp_spec.rb
data/CHANGELOG DELETED
@@ -1,26 +0,0 @@
1
- 2.0 (2-17-2008)
2
- * [Ben Wyrosdick] - Added a migration helper that gives migration scripts a <tt>userstamps</tt>
3
- method.
4
- * [Marshall Roch] - Stamping can be temporarily turned off using the 'without_stamps' class
5
- method.
6
- Example:
7
- Post.without_stamps do
8
- post = Post.find(params[:id])
9
- post.update_attributes(params[:post])
10
- post.save
11
- end
12
-
13
- * Models that should receive updates made by 'stampers' now use the acts_as_stampable class
14
- method. This sets up the belongs_to relationships and also injects private methods for use by
15
- the individual callback filter methods.
16
-
17
- * Models that are responsible for updating now use the acts_as_stamper class method. This
18
- injects the stamper= and stamper methods that are thread safe and should be updated per
19
- request by a controller.
20
-
21
- * The Userstamp module is now meant to be included with one of your project's controllers (the
22
- Application Controller is recommended). It creates a before filter called 'set_stampers' that
23
- is responsible for setting all the current Stampers.
24
-
25
- 1.0 (01-18-2006)
26
- * Initial Release
@@ -1,3 +0,0 @@
1
- class Foo < ActiveRecord::Base
2
- stampable :deleter_attribute => :deleter_id
3
- end
@@ -1,69 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe 'Compatibility Stamping', type: :model do
4
- before do
5
- create_test_models
6
- ActiveRecord::Userstamp.compatibility_mode = true
7
- Comment.delete_all
8
- @first_comment = Comment.create!(:comment => 'a comment', :post => @first_post)
9
- end
10
-
11
- context 'when creating an object' do
12
- context 'when the stamper is an ID' do
13
- it 'sets the correct stamper' do
14
- Person.stamper = @nicole.id
15
- expect(Person.stamper).to eq(@nicole.id)
16
-
17
- comment = Comment.create(:comment => "Test Comment - 2")
18
- expect(comment.created_by).to eq(@nicole.id)
19
- expect(comment.updated_by).to eq(@nicole.id)
20
- expect(comment.creator).to eq(@nicole)
21
- expect(comment.updater).to eq(@nicole)
22
- end
23
- end
24
-
25
- context 'when the stamper is an object' do
26
- it 'sets the correct stamper' do
27
- expect(Person.stamper).to eq(@delynn.id)
28
-
29
- comment = Comment.create(:comment => "Test Comment")
30
- expect(comment.created_by).to eq(@delynn.id)
31
- expect(comment.updated_by).to eq(@delynn.id)
32
- expect(comment.creator).to eq(@delynn)
33
- expect(comment.updater).to eq(@delynn)
34
- end
35
- end
36
- end
37
-
38
- context 'when updating an object' do
39
- context 'when the stamper is an object' do
40
- it 'sets the correct creator and updater' do
41
- Person.stamper = @nicole
42
- expect(Person.stamper).to eq(@nicole.id)
43
-
44
- @first_comment.comment << " - Updated"
45
- @first_comment.save
46
- @first_comment.reload
47
- expect(@first_comment.created_by).to eq(@delynn.id)
48
- expect(@first_comment.updated_by).to eq(@nicole.id)
49
- expect(@first_comment.creator).to eq(@delynn)
50
- expect(@first_comment.updater).to eq(@nicole)
51
- end
52
- end
53
-
54
- context 'when the stamper is an ID' do
55
- it 'sets the correct creator and updater' do
56
- Person.stamper = @nicole.id
57
- expect(Person.stamper).to eq(@nicole.id)
58
-
59
- @first_comment.comment << " - Updated"
60
- @first_comment.save
61
- @first_comment.reload
62
- expect(@first_comment.created_by).to eq(@delynn.id)
63
- expect(@first_comment.updated_by).to eq(@nicole.id)
64
- expect(@first_comment.creator).to eq(@delynn)
65
- expect(@first_comment.updater).to eq(@nicole)
66
- end
67
- end
68
- end
69
- end