activerecord-userstamp 3.0.2 → 3.0.3

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 +103 -99
  5. data/Gemfile +3 -3
  6. data/LICENSE +21 -21
  7. data/README.md +189 -189
  8. data/Rakefile +17 -17
  9. data/activerecord-userstamp.gemspec +34 -34
  10. data/lib/active_record/userstamp.rb +30 -30
  11. data/lib/active_record/userstamp/configuration.rb +49 -49
  12. data/lib/active_record/userstamp/controller_additions.rb +50 -50
  13. data/lib/active_record/userstamp/migration_additions.rb +14 -14
  14. data/lib/active_record/userstamp/model_additions.rb +10 -10
  15. data/lib/active_record/userstamp/stampable.rb +123 -123
  16. data/lib/active_record/userstamp/stamper.rb +54 -54
  17. data/lib/active_record/userstamp/utilities.rb +55 -54
  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 +44 -44
  21. data/spec/controllers/users_controller_spec.rb +50 -50
  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 +36 -36
  28. data/spec/dummy/app/controllers/users_controller.rb +22 -22
  29. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  30. data/spec/dummy/app/models/comment.rb +5 -5
  31. data/spec/dummy/app/models/person.rb +3 -3
  32. data/spec/dummy/app/models/post.rb +14 -14
  33. data/spec/dummy/app/models/tag.rb +3 -0
  34. data/spec/dummy/app/models/user.rb +3 -3
  35. data/spec/dummy/app/views/layouts/application.html.erb +14 -14
  36. data/spec/dummy/bin/bundle +3 -3
  37. data/spec/dummy/bin/rails +4 -4
  38. data/spec/dummy/bin/rake +4 -4
  39. data/spec/dummy/bin/setup +29 -29
  40. data/spec/dummy/config.ru +4 -4
  41. data/spec/dummy/config/application.rb +30 -30
  42. data/spec/dummy/config/boot.rb +5 -5
  43. data/spec/dummy/config/database.yml +23 -23
  44. data/spec/dummy/config/environment.rb +5 -5
  45. data/spec/dummy/config/environments/development.rb +41 -41
  46. data/spec/dummy/config/environments/production.rb +79 -79
  47. data/spec/dummy/config/environments/test.rb +37 -37
  48. data/spec/dummy/config/initializers/assets.rb +11 -11
  49. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  50. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -3
  51. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  52. data/spec/dummy/config/initializers/inflections.rb +16 -16
  53. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  54. data/spec/dummy/config/initializers/session_store.rb +3 -3
  55. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  56. data/spec/dummy/config/locales/en.yml +23 -23
  57. data/spec/dummy/config/routes.rb +56 -56
  58. data/spec/dummy/config/secrets.yml +22 -22
  59. data/spec/dummy/db/schema.rb +54 -45
  60. data/spec/dummy/public/404.html +67 -67
  61. data/spec/dummy/public/422.html +67 -67
  62. data/spec/dummy/public/500.html +66 -66
  63. data/spec/lib/configuration_spec.rb +20 -20
  64. data/spec/lib/migration_spec.rb +71 -71
  65. data/spec/lib/stamper_spec.rb +66 -66
  66. data/spec/lib/stamping_spec.rb +250 -238
  67. data/spec/lib/userstamp_spec.rb +7 -7
  68. data/spec/rails_helper.rb +7 -7
  69. data/spec/spec_helper.rb +97 -97
  70. data/spec/support/database_helpers.rb +22 -22
  71. data/spec/support/with_temporary_table.rb +51 -51
  72. metadata +3 -2
@@ -1,6 +1,6 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -1,13 +1,13 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -1,15 +1,15 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -1,13 +1,13 @@
1
- class ApplicationController < ActionController::Base
2
- include ActiveRecord::Userstamp::ControllerAdditions
3
-
4
- # Prevent CSRF attacks by raising an exception.
5
- # For APIs, you may want to use :null_session instead.
6
- protect_from_forgery with: :exception
7
-
8
- protected
9
-
10
- def current_user
11
- User.find(session[:user_id])
12
- end
13
- end
1
+ class ApplicationController < ActionController::Base
2
+ include ActiveRecord::Userstamp::ControllerAdditions
3
+
4
+ # Prevent CSRF attacks by raising an exception.
5
+ # For APIs, you may want to use :null_session instead.
6
+ protect_from_forgery with: :exception
7
+
8
+ protected
9
+
10
+ def current_user
11
+ User.find(session[:user_id])
12
+ end
13
+ end
@@ -1,36 +1,36 @@
1
- class PostsController < ApplicationController
2
- def edit
3
- @post = Post.find(params[:id])
4
- render(inline: "<%= @post.title %>")
5
- end
6
-
7
- def update
8
- @post = Post.find(params[:id])
9
- @post.update_attributes(post_params)
10
- render(inline: "<%= @post.title %>")
11
- end
12
-
13
- def create
14
- fail
15
- end
16
-
17
- protected
18
-
19
- def current_user
20
- Person.find(session[:person_id])
21
- end
22
-
23
- def set_stamper
24
- Person.stamper = current_user
25
- end
26
-
27
- def reset_stamper
28
- Person.reset_stamper
29
- end
30
-
31
- private
32
-
33
- def post_params
34
- params.require(:post).permit(:title)
35
- end
36
- end
1
+ class PostsController < ApplicationController
2
+ def edit
3
+ @post = Post.find(params[:id])
4
+ render(inline: "<%= @post.title %>")
5
+ end
6
+
7
+ def update
8
+ @post = Post.find(params[:id])
9
+ @post.update_attributes(post_params)
10
+ render(inline: "<%= @post.title %>")
11
+ end
12
+
13
+ def create
14
+ fail
15
+ end
16
+
17
+ protected
18
+
19
+ def current_user
20
+ Person.find(session[:person_id])
21
+ end
22
+
23
+ def set_stamper
24
+ Person.stamper = current_user
25
+ end
26
+
27
+ def reset_stamper
28
+ Person.reset_stamper
29
+ end
30
+
31
+ private
32
+
33
+ def post_params
34
+ params.require(:post).permit(:title)
35
+ end
36
+ end
@@ -1,22 +1,22 @@
1
- class UsersController < ApplicationController
2
- def edit
3
- @user = User.find(params[:id])
4
- render(inline: "<%= @user.name %>")
5
- end
6
-
7
- def update
8
- @user = User.find(params[:id])
9
- @user.update_attributes(user_params)
10
- render(inline: "<%= @user.name %>")
11
- end
12
-
13
- def create
14
- fail
15
- end
16
-
17
- private
18
-
19
- def user_params
20
- params.require(:user).permit(:name)
21
- end
22
- end
1
+ class UsersController < ApplicationController
2
+ def edit
3
+ @user = User.find(params[:id])
4
+ render(inline: "<%= @user.name %>")
5
+ end
6
+
7
+ def update
8
+ @user = User.find(params[:id])
9
+ @user.update_attributes(user_params)
10
+ render(inline: "<%= @user.name %>")
11
+ end
12
+
13
+ def create
14
+ fail
15
+ end
16
+
17
+ private
18
+
19
+ def user_params
20
+ params.require(:user).permit(:name)
21
+ end
22
+ end
@@ -1,2 +1,2 @@
1
- module ApplicationHelper
2
- end
1
+ module ApplicationHelper
2
+ end
@@ -1,5 +1,5 @@
1
- # this class is only meant for compatability mode testing
2
- class Comment < ActiveRecord::Base
3
- stampable stamper_class_name: :person
4
- belongs_to :post
5
- end
1
+ # this class is only meant for compatability mode testing
2
+ class Comment < ActiveRecord::Base
3
+ stampable stamper_class_name: :person
4
+ belongs_to :post
5
+ end
@@ -1,3 +1,3 @@
1
- class Person < ActiveRecord::Base
2
- model_stamper
3
- end
1
+ class Person < ActiveRecord::Base
2
+ model_stamper
3
+ end
@@ -1,14 +1,14 @@
1
- class Post < ActiveRecord::Base
2
- stampable stamper_class_name: :person
3
- validates :creator, presence: true
4
- has_many :comments
5
-
6
- # override destroy to get soft delete like acts_as_paranoid style delete
7
- # Note: delete_all (used in helper) bypasses this and deletes all rows.
8
- def destroy
9
- run_callbacks :destroy do
10
- self.deleted_at = DateTime.now
11
- end
12
- end
13
-
14
- end
1
+ class Post < ActiveRecord::Base
2
+ stampable stamper_class_name: :person
3
+ validates :creator, presence: true
4
+ has_many :comments
5
+
6
+ # override destroy to get soft delete like acts_as_paranoid style delete
7
+ # Note: delete_all (used in helper) bypasses this and deletes all rows.
8
+ def destroy
9
+ run_callbacks :destroy do
10
+ self.deleted_at = DateTime.now
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,3 @@
1
+ class Tag < ActiveRecord::Base
2
+ has_and_belongs_to_many :posts
3
+ end
@@ -1,3 +1,3 @@
1
- class User < ActiveRecord::Base
2
- model_stamper
3
- end
1
+ class User < ActiveRecord::Base
2
+ model_stamper
3
+ end
@@ -1,14 +1,14 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env ruby.exe
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
1
+ #!/usr/bin/env ruby.exe
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby.exe
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
1
+ #!/usr/bin/env ruby.exe
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby.exe
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
1
+ #!/usr/bin/env ruby.exe
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -1,29 +1,29 @@
1
- #!/usr/bin/env ruby.exe
2
- require 'pathname'
3
-
4
- # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
-
7
- Dir.chdir APP_ROOT do
8
- # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
10
-
11
- puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
14
-
15
- # puts "\n== Copying sample files =="
16
- # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
18
- # end
19
-
20
- puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
22
-
23
- puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
26
-
27
- puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
29
- end
1
+ #!/usr/bin/env ruby.exe
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -1,4 +1,4 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -1,30 +1,30 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
- require "active_record/userstamp"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
-
25
- config.after_initialize do
26
- require_relative '../db/schema'
27
- end
28
- end
29
- end
30
-
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "active_record/userstamp"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+
22
+ # Do not swallow errors in after_commit/after_rollback callbacks.
23
+ config.active_record.raise_in_transactional_callbacks = true
24
+
25
+ config.after_initialize do
26
+ require_relative '../db/schema'
27
+ end
28
+ end
29
+ end
30
+