originator 3.0 → 3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG +8 -0
- data/Gemfile +9 -5
- data/Rakefile +14 -14
- data/VERSION +1 -1
- data/lib/migration_helper.rb +3 -1
- data/lib/stampable.rb +48 -39
- data/lib/stamper.rb +5 -5
- data/lib/userstamp.rb +28 -26
- data/originator.gemspec +8 -32
- data/test/compatibility_stamping_test.rb +6 -17
- data/test/controllers/posts_controller.rb +14 -14
- data/test/controllers/users_controller.rb +2 -2
- data/test/controllers/userstamp_controller.rb +5 -5
- data/test/helper.rb +25 -33
- data/test/models/comment.rb +3 -3
- data/test/models/foo.rb +1 -1
- data/test/models/person.rb +2 -1
- data/test/models/post.rb +6 -7
- data/test/models/user.rb +1 -1
- data/test/schema.rb +32 -33
- data/test/stamping_test.rb +15 -16
- data/test/userstamp_controller_test.rb +49 -49
- data/test/userstamp_test.rb +2 -2
- metadata +16 -43
- data/rdoc/classes/Ddb/Controller/Userstamp/InstanceMethods.html +0 -105
- data/rdoc/classes/Ddb/Controller/Userstamp.html +0 -125
- data/rdoc/classes/Ddb/Controller.html +0 -111
- data/rdoc/classes/Ddb/Userstamp/MigrationHelper/InstanceMethods.html +0 -142
- data/rdoc/classes/Ddb/Userstamp/MigrationHelper.html +0 -111
- data/rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html +0 -225
- data/rdoc/classes/Ddb/Userstamp/Stampable.html +0 -128
- data/rdoc/classes/Ddb/Userstamp/Stamper/ClassMethods.html +0 -142
- data/rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html +0 -207
- data/rdoc/classes/Ddb/Userstamp/Stamper.html +0 -112
- data/rdoc/classes/Ddb/Userstamp.html +0 -121
- data/rdoc/classes/Userstamp.html +0 -118
- data/rdoc/created.rid +0 -1
- data/rdoc/files/CHANGELOG.html +0 -137
- data/rdoc/files/LICENSE.html +0 -129
- data/rdoc/files/Readme_rdoc.html +0 -301
- data/rdoc/files/lib/migration_helper_rb.html +0 -101
- data/rdoc/files/lib/stampable_rb.html +0 -101
- data/rdoc/files/lib/stamper_rb.html +0 -101
- data/rdoc/files/lib/userstamp_rb.html +0 -110
- data/rdoc/fr_class_index.html +0 -38
- data/rdoc/fr_file_index.html +0 -33
- data/rdoc/fr_method_index.html +0 -33
- data/rdoc/index.html +0 -24
- data/rdoc/rdoc-style.css +0 -208
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 255e2766d89233e360a23010fb669e17b159caf6460ac74b86b6f0b509dfd921
|
|
4
|
+
data.tar.gz: 2e6172c95b4c0d462153e113add845c41d5da6710417cb94851ba03e7d4ac922
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed521be226d553afcf9c93d50ffbd8b498fbee4fdaaf673e7b5d7b271c092117b31b74b12ea77f348f1094a4b5243caf53cacd98768c7d0f98d31ced294dc200
|
|
7
|
+
data.tar.gz: 1218e9fb60f3eee0bcf60d8dbb0dc6c54414c7ebb58a9fb4c9b1cc32fe0a1737518a7398ec65de7738b0d7c0e86da3c8b6f172a3efec0a882cf280434f85c904
|
data/CHANGELOG
CHANGED
data/Gemfile
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
4
|
|
|
5
|
-
gem
|
|
6
|
-
gem
|
|
7
|
-
gem
|
|
8
|
-
gem
|
|
5
|
+
gem "rake"
|
|
6
|
+
gem "activesupport"
|
|
7
|
+
gem "sqlite3"
|
|
8
|
+
gem "test-unit"
|
|
9
|
+
gem "rails-controller-testing"
|
|
10
|
+
gem "rdoc"
|
|
11
|
+
|
|
12
|
+
gem "gem-release", "~> 2.2"
|
data/Rakefile
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env rake
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rake/testtask"
|
|
4
4
|
|
|
5
5
|
begin
|
|
6
|
-
require
|
|
6
|
+
require "rdoc/task"
|
|
7
7
|
rescue LoadError
|
|
8
|
-
require
|
|
9
|
-
require
|
|
8
|
+
require "rdoc/rdoc"
|
|
9
|
+
require "rake/rdoctask"
|
|
10
10
|
RDoc::Task = Rake::RDocTask
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
desc
|
|
13
|
+
desc "Default: run unit tests."
|
|
14
14
|
task :default => :test
|
|
15
15
|
|
|
16
|
-
desc
|
|
16
|
+
desc "Test the userstamp plugin."
|
|
17
17
|
Rake::TestTask.new(:test) do |t|
|
|
18
|
-
t.libs <<
|
|
19
|
-
t.pattern =
|
|
18
|
+
t.libs << "lib"
|
|
19
|
+
t.pattern = "test/**/*_test.rb"
|
|
20
20
|
t.verbose = true
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
desc
|
|
23
|
+
desc "Generate documentation for the userstamp plugin."
|
|
24
24
|
RDoc::Task.new(:rdoc) do |rdoc|
|
|
25
|
-
rdoc.rdoc_dir =
|
|
26
|
-
rdoc.title
|
|
27
|
-
rdoc.options <<
|
|
28
|
-
rdoc.rdoc_files.include(
|
|
29
|
-
rdoc.rdoc_files.include(
|
|
25
|
+
rdoc.rdoc_dir = "rdoc"
|
|
26
|
+
rdoc.title = "Userstamp"
|
|
27
|
+
rdoc.options << "--line-numbers" << "--inline-source"
|
|
28
|
+
rdoc.rdoc_files.include("Readme.rdoc", "CHANGELOG", "LICENSE")
|
|
29
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
|
30
30
|
end
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.2
|
data/lib/migration_helper.rb
CHANGED
|
@@ -16,4 +16,6 @@ module Ddb
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
ActiveSupport.on_load(:active_record) do
|
|
20
|
+
ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, Ddb::Userstamp::MigrationHelper)
|
|
21
|
+
end
|
data/lib/stampable.rb
CHANGED
|
@@ -26,26 +26,30 @@ module Ddb #:nodoc:
|
|
|
26
26
|
include InstanceMethods
|
|
27
27
|
|
|
28
28
|
# Should ActiveRecord record userstamps? Defaults to true.
|
|
29
|
-
class_attribute
|
|
29
|
+
class_attribute :record_userstamp
|
|
30
30
|
self.record_userstamp = true
|
|
31
31
|
|
|
32
32
|
# Which class is responsible for stamping? Defaults to :user.
|
|
33
|
-
class_attribute
|
|
33
|
+
class_attribute :stamper_class_name
|
|
34
34
|
|
|
35
35
|
# What column should be used for the creator stamp?
|
|
36
36
|
# Defaults to :creator_id when compatibility mode is off
|
|
37
37
|
# Defaults to :created_by when compatibility mode is on
|
|
38
|
-
class_attribute
|
|
38
|
+
class_attribute :creator_attribute
|
|
39
39
|
|
|
40
40
|
# What column should be used for the updater stamp?
|
|
41
41
|
# Defaults to :updater_id when compatibility mode is off
|
|
42
42
|
# Defaults to :updated_by when compatibility mode is on
|
|
43
|
-
class_attribute
|
|
43
|
+
class_attribute :updater_attribute
|
|
44
44
|
|
|
45
45
|
# What column should be used for the deleter stamp?
|
|
46
46
|
# Defaults to :deleter_id when compatibility mode is off
|
|
47
47
|
# Defaults to :deleted_by when compatibility mode is on
|
|
48
|
-
class_attribute
|
|
48
|
+
class_attribute :deleter_attribute
|
|
49
|
+
|
|
50
|
+
# Define if the belongs_to association should be optional or not
|
|
51
|
+
# Defaults to true to mantain the old behavior
|
|
52
|
+
class_attribute :userstamp_optional
|
|
49
53
|
end
|
|
50
54
|
end
|
|
51
55
|
|
|
@@ -59,7 +63,8 @@ module Ddb #:nodoc:
|
|
|
59
63
|
# :creator_attribute => :create_user,
|
|
60
64
|
# :updater_attribute => :update_user,
|
|
61
65
|
# :deleter_attribute => :delete_user
|
|
62
|
-
# :deleter => true
|
|
66
|
+
# :deleter => true,
|
|
67
|
+
# :optional => true
|
|
63
68
|
# end
|
|
64
69
|
#
|
|
65
70
|
# The method will automatically setup all the associations, and create <tt>before_save</tt>
|
|
@@ -68,30 +73,32 @@ module Ddb #:nodoc:
|
|
|
68
73
|
# acts_as_paranoid or you set the :deleter_attribute or set the :deleter option to true.
|
|
69
74
|
def stampable(options = {})
|
|
70
75
|
compatability = Ddb::Userstamp.compatibility_mode
|
|
71
|
-
defaults
|
|
76
|
+
defaults = {
|
|
72
77
|
:stamper_class_name => :user,
|
|
73
|
-
:creator_attribute
|
|
74
|
-
:updater_attribute
|
|
75
|
-
:deleter_attribute
|
|
76
|
-
:
|
|
78
|
+
:creator_attribute => (compatability ? :created_by : :creator_id),
|
|
79
|
+
:updater_attribute => (compatability ? :updated_by : :updater_id),
|
|
80
|
+
:deleter_attribute => (compatability ? :deleted_by : :deleter_id),
|
|
81
|
+
:optional => true,
|
|
82
|
+
:deleter => !!(options.has_key?(:deleter_attribute) or defined?(Caboose::Acts::Paranoid)),
|
|
77
83
|
}.merge(options)
|
|
78
84
|
|
|
79
85
|
self.stamper_class_name = defaults[:stamper_class_name].to_sym
|
|
80
|
-
self.creator_attribute
|
|
81
|
-
self.updater_attribute
|
|
82
|
-
self.deleter_attribute
|
|
86
|
+
self.creator_attribute = defaults[:creator_attribute].to_sym
|
|
87
|
+
self.updater_attribute = defaults[:updater_attribute].to_sym
|
|
88
|
+
self.deleter_attribute = defaults[:deleter_attribute].to_sym
|
|
89
|
+
self.userstamp_optional = !!defaults[:optional]
|
|
83
90
|
|
|
84
91
|
class_eval do
|
|
85
|
-
klass =
|
|
86
|
-
belongs_to :creator, :class_name => klass, :foreign_key => creator_attribute
|
|
87
|
-
belongs_to :updater, :class_name => klass, :foreign_key => updater_attribute
|
|
92
|
+
klass = stamper_class_name.to_s.camelize
|
|
93
|
+
belongs_to :creator, :class_name => klass, :foreign_key => creator_attribute, optional: userstamp_optional
|
|
94
|
+
belongs_to :updater, :class_name => klass, :foreign_key => updater_attribute, optional: userstamp_optional
|
|
88
95
|
|
|
89
96
|
before_validation :set_updater_attribute
|
|
90
97
|
before_validation :set_creator_attribute, :on => :create
|
|
91
98
|
|
|
92
99
|
if defaults[:deleter]
|
|
93
|
-
belongs_to :deleter, :class_name => klass, :foreign_key => deleter_attribute
|
|
94
|
-
before_destroy
|
|
100
|
+
belongs_to :deleter, :class_name => klass, :foreign_key => deleter_attribute, optional: userstamp_optional
|
|
101
|
+
before_destroy :set_deleter_attribute
|
|
95
102
|
end
|
|
96
103
|
end
|
|
97
104
|
end
|
|
@@ -118,35 +125,37 @@ module Ddb #:nodoc:
|
|
|
118
125
|
|
|
119
126
|
module InstanceMethods #:nodoc:
|
|
120
127
|
private
|
|
121
|
-
def has_stamper?
|
|
122
|
-
!self.class.stamper_class.nil? && !self.class.stamper_class.stamper.nil? rescue false
|
|
123
|
-
end
|
|
124
128
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
def has_stamper?
|
|
130
|
+
!self.class.stamper_class.nil? && !self.class.stamper_class.stamper.nil? rescue false
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def set_creator_attribute
|
|
134
|
+
return unless self.record_userstamp
|
|
135
|
+
if respond_to?(self.creator_attribute.to_sym) && has_stamper?
|
|
136
|
+
self.send("#{self.creator_attribute}=".to_sym, self.class.stamper_class.stamper)
|
|
130
137
|
end
|
|
138
|
+
end
|
|
131
139
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
end
|
|
140
|
+
def set_updater_attribute
|
|
141
|
+
return unless self.record_userstamp
|
|
142
|
+
if respond_to?(self.updater_attribute.to_sym) && has_stamper?
|
|
143
|
+
self.send("#{self.updater_attribute}=".to_sym, self.class.stamper_class.stamper)
|
|
137
144
|
end
|
|
145
|
+
end
|
|
138
146
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
end
|
|
147
|
+
def set_deleter_attribute
|
|
148
|
+
return unless self.record_userstamp
|
|
149
|
+
if respond_to?(self.deleter_attribute.to_sym) && has_stamper?
|
|
150
|
+
self.send("#{self.deleter_attribute}=".to_sym, self.class.stamper_class.stamper)
|
|
151
|
+
save
|
|
145
152
|
end
|
|
153
|
+
end
|
|
154
|
+
|
|
146
155
|
#end private
|
|
147
156
|
end
|
|
148
157
|
end
|
|
149
158
|
end
|
|
150
159
|
end
|
|
151
160
|
|
|
152
|
-
|
|
161
|
+
ActiveSupport.on_load(:active_record) { include Ddb::Userstamp::Stampable }
|
data/lib/stamper.rb
CHANGED
|
@@ -18,10 +18,10 @@ module Ddb #:nodoc:
|
|
|
18
18
|
# details on how to use this method.
|
|
19
19
|
def stamper=(object)
|
|
20
20
|
object_stamper = if object.is_a?(ActiveRecord::Base)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
object.send("#{object.class.primary_key}".to_sym)
|
|
22
|
+
else
|
|
23
|
+
object
|
|
24
|
+
end
|
|
25
25
|
|
|
26
26
|
Thread.current["#{self.to_s.downcase}_#{self.object_id}_stamper"] = object_stamper
|
|
27
27
|
end
|
|
@@ -40,4 +40,4 @@ module Ddb #:nodoc:
|
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
ActiveSupport.on_load(:active_record) { include Ddb::Userstamp::Stamper }
|
data/lib/userstamp.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
1
|
+
require "stamper"
|
|
2
|
+
require "stampable"
|
|
3
|
+
require "migration_helper"
|
|
4
4
|
|
|
5
5
|
module Userstamp
|
|
6
|
-
VERSION = File.read(
|
|
6
|
+
VERSION = File.read(File.join(File.dirname(__FILE__), "..", "VERSION")).strip
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
module Ddb
|
|
@@ -17,36 +17,38 @@ module Ddb
|
|
|
17
17
|
# specific implementation details.
|
|
18
18
|
module Userstamp
|
|
19
19
|
def self.included(base) # :nodoc:
|
|
20
|
-
base.send
|
|
21
|
-
base.before_action
|
|
22
|
-
base.after_action
|
|
20
|
+
base.send :include, InstanceMethods
|
|
21
|
+
base.before_action :set_stamper
|
|
22
|
+
base.after_action :reset_stamper
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
module InstanceMethods
|
|
26
26
|
private
|
|
27
|
-
# The <tt>set_stamper</tt> method as implemented here assumes a couple
|
|
28
|
-
# of things. First, that you are using a +User+ model as the stamper
|
|
29
|
-
# and second that your controller has a <tt>current_user</tt> method
|
|
30
|
-
# that contains the currently logged in stamper. If either of these
|
|
31
|
-
# are not the case in your application you will want to manually add
|
|
32
|
-
# your own implementation of this method to the private section of
|
|
33
|
-
# the controller where you are including the Userstamp module.
|
|
34
|
-
def set_stamper
|
|
35
|
-
User.stamper = self.current_user
|
|
36
|
-
end
|
|
37
27
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
# The <tt>set_stamper</tt> method as implemented here assumes a couple
|
|
29
|
+
# of things. First, that you are using a +User+ model as the stamper
|
|
30
|
+
# and second that your controller has a <tt>current_user</tt> method
|
|
31
|
+
# that contains the currently logged in stamper. If either of these
|
|
32
|
+
# are not the case in your application you will want to manually add
|
|
33
|
+
# your own implementation of this method to the private section of
|
|
34
|
+
# the controller where you are including the Userstamp module.
|
|
35
|
+
def set_stamper
|
|
36
|
+
User.stamper = self.current_user
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# The <tt>reset_stamper</tt> method as implemented here assumes that a
|
|
40
|
+
# +User+ model is being used as the stamper. If this is not the case then
|
|
41
|
+
# you will need to manually add your own implementation of this method to
|
|
42
|
+
# the private section of the controller where you are including the
|
|
43
|
+
# Userstamp module.
|
|
44
|
+
def reset_stamper
|
|
45
|
+
User.reset_stamper
|
|
46
|
+
end
|
|
47
|
+
|
|
46
48
|
#end private
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
ActiveSupport.on_load(:action_controller_base) { include Ddb::Controller }
|
data/originator.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = "originator"
|
|
5
|
-
s.version = File.read(File.join(File.dirname(__FILE__),
|
|
5
|
+
s.version = File.read(File.join(File.dirname(__FILE__), "VERSION")).strip
|
|
6
6
|
|
|
7
7
|
s.authors = ["DeLynn Berry", "Thomas von Deyen"]
|
|
8
8
|
s.homepage = "https://github.com/AlchemyCMS/originator"
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
14
14
|
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
|
-
"LICENSE"
|
|
16
|
+
"LICENSE",
|
|
17
17
|
]
|
|
18
18
|
s.files = [
|
|
19
19
|
"CHANGELOG",
|
|
@@ -27,31 +27,6 @@ Gem::Specification.new do |s|
|
|
|
27
27
|
"lib/stamper.rb",
|
|
28
28
|
"lib/userstamp.rb",
|
|
29
29
|
"originator.gemspec",
|
|
30
|
-
"rdoc/classes/Ddb/Controller.html",
|
|
31
|
-
"rdoc/classes/Ddb/Controller/Userstamp.html",
|
|
32
|
-
"rdoc/classes/Ddb/Controller/Userstamp/InstanceMethods.html",
|
|
33
|
-
"rdoc/classes/Ddb/Userstamp.html",
|
|
34
|
-
"rdoc/classes/Ddb/Userstamp/MigrationHelper.html",
|
|
35
|
-
"rdoc/classes/Ddb/Userstamp/MigrationHelper/InstanceMethods.html",
|
|
36
|
-
"rdoc/classes/Ddb/Userstamp/Stampable.html",
|
|
37
|
-
"rdoc/classes/Ddb/Userstamp/Stampable/ClassMethods.html",
|
|
38
|
-
"rdoc/classes/Ddb/Userstamp/Stamper.html",
|
|
39
|
-
"rdoc/classes/Ddb/Userstamp/Stamper/ClassMethods.html",
|
|
40
|
-
"rdoc/classes/Ddb/Userstamp/Stamper/InstanceMethods.html",
|
|
41
|
-
"rdoc/classes/Userstamp.html",
|
|
42
|
-
"rdoc/created.rid",
|
|
43
|
-
"rdoc/files/CHANGELOG.html",
|
|
44
|
-
"rdoc/files/LICENSE.html",
|
|
45
|
-
"rdoc/files/Readme_rdoc.html",
|
|
46
|
-
"rdoc/files/lib/migration_helper_rb.html",
|
|
47
|
-
"rdoc/files/lib/stampable_rb.html",
|
|
48
|
-
"rdoc/files/lib/stamper_rb.html",
|
|
49
|
-
"rdoc/files/lib/userstamp_rb.html",
|
|
50
|
-
"rdoc/fr_class_index.html",
|
|
51
|
-
"rdoc/fr_file_index.html",
|
|
52
|
-
"rdoc/fr_method_index.html",
|
|
53
|
-
"rdoc/index.html",
|
|
54
|
-
"rdoc/rdoc-style.css",
|
|
55
30
|
"test/compatibility_stamping_test.rb",
|
|
56
31
|
"test/controllers/posts_controller.rb",
|
|
57
32
|
"test/controllers/users_controller.rb",
|
|
@@ -65,18 +40,19 @@ Gem::Specification.new do |s|
|
|
|
65
40
|
"test/schema.rb",
|
|
66
41
|
"test/stamping_test.rb",
|
|
67
42
|
"test/userstamp_controller_test.rb",
|
|
68
|
-
"test/userstamp_test.rb"
|
|
43
|
+
"test/userstamp_test.rb",
|
|
69
44
|
]
|
|
70
45
|
s.require_paths = ["lib"]
|
|
71
46
|
s.rubygems_version = "1.8.11"
|
|
72
47
|
|
|
73
|
-
s.add_runtime_dependency
|
|
74
|
-
s.add_runtime_dependency
|
|
48
|
+
s.add_runtime_dependency "actionpack", ">= 4.0"
|
|
49
|
+
s.add_runtime_dependency "activerecord", ">= 4.0"
|
|
50
|
+
s.add_runtime_dependency "activesupport", ">= 4.0"
|
|
75
51
|
|
|
76
|
-
if s.respond_to? :specification_version
|
|
52
|
+
if s.respond_to? :specification_version
|
|
77
53
|
s.specification_version = 3
|
|
78
54
|
|
|
79
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new(
|
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.2.0")
|
|
80
56
|
else
|
|
81
57
|
end
|
|
82
58
|
else
|
|
@@ -1,23 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "helper"
|
|
2
2
|
|
|
3
|
-
class CompatibilityStampingTests < Test::Unit::TestCase
|
|
3
|
+
class CompatibilityStampingTests < Test::Unit::TestCase # :nodoc:
|
|
4
4
|
def setup
|
|
5
5
|
create_test_models
|
|
6
6
|
Ddb::Userstamp.compatibility_mode = true
|
|
7
|
-
|
|
7
|
+
require_relative "models/comment"
|
|
8
8
|
Comment.delete_all
|
|
9
|
-
@first_comment = Comment.create!(:comment =>
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test_comment_creation_with_stamped_integer
|
|
13
|
-
Person.stamper = @nicole.id
|
|
14
|
-
assert_equal @nicole.id, Person.stamper
|
|
15
|
-
|
|
16
|
-
comment = Comment.create(:comment => "Test Comment - 2")
|
|
17
|
-
assert_equal @nicole.id, comment.created_by
|
|
18
|
-
assert_equal @nicole.id, comment.updated_by
|
|
19
|
-
assert_equal @nicole, comment.creator
|
|
20
|
-
assert_equal @nicole, comment.updater
|
|
9
|
+
@first_comment = Comment.create!(:comment => "a comment", :post => @first_post)
|
|
21
10
|
end
|
|
22
11
|
|
|
23
12
|
def test_comment_creation_with_stamped_integer
|
|
@@ -40,7 +29,7 @@ class CompatibilityStampingTests < Test::Unit::TestCase # :nodoc:
|
|
|
40
29
|
assert_equal @delynn, comment.creator
|
|
41
30
|
assert_equal @delynn, comment.updater
|
|
42
31
|
end
|
|
43
|
-
|
|
32
|
+
|
|
44
33
|
def test_comment_updating_with_stamped_object
|
|
45
34
|
Person.stamper = @nicole
|
|
46
35
|
assert_equal @nicole.id, Person.stamper
|
|
@@ -66,4 +55,4 @@ class CompatibilityStampingTests < Test::Unit::TestCase # :nodoc:
|
|
|
66
55
|
assert_equal @delynn, @first_comment.creator
|
|
67
56
|
assert_equal @nicole, @first_comment.updater
|
|
68
57
|
end
|
|
69
|
-
end
|
|
58
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
class PostsController < UserstampController
|
|
2
2
|
def edit
|
|
3
3
|
@post = Post.find(params[:id])
|
|
4
|
-
render(:inline
|
|
4
|
+
render(:inline => "<%= @post.title %>")
|
|
5
5
|
end
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
def update
|
|
8
8
|
@post = Post.find(params[:id])
|
|
9
9
|
@post.update_attributes(params[:post])
|
|
@@ -11,16 +11,16 @@ class PostsController < UserstampController
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
protected
|
|
14
|
-
def current_user
|
|
15
|
-
Person.find(session[:person_id])
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def set_stamper
|
|
19
|
-
Person.stamper = self.current_user
|
|
20
|
-
end
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
def current_user
|
|
16
|
+
Person.find(session[:person_id])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def set_stamper
|
|
20
|
+
Person.stamper = self.current_user
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def reset_stamper
|
|
24
|
+
Person.reset_stamper
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class UsersController < UserstampController
|
|
2
2
|
def edit
|
|
3
3
|
@user = User.find(params[:id])
|
|
4
|
-
render(:inline
|
|
4
|
+
render(:inline => "<%= @user.name %>")
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def update
|
|
@@ -9,4 +9,4 @@ class UsersController < UserstampController
|
|
|
9
9
|
@user.update_attributes(params[:user])
|
|
10
10
|
render(:inline => "<%= @user.name %>")
|
|
11
11
|
end
|
|
12
|
-
end
|
|
12
|
+
end
|
data/test/helper.rb
CHANGED
|
@@ -1,43 +1,35 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "rubygems"
|
|
2
2
|
|
|
3
|
-
$LOAD_PATH.unshift(
|
|
3
|
+
$LOAD_PATH.unshift("lib")
|
|
4
4
|
|
|
5
5
|
# load normal stuff
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
6
|
+
require "active_support"
|
|
7
|
+
require "active_record"
|
|
8
|
+
require "action_controller"
|
|
9
|
+
require "originator"
|
|
10
10
|
|
|
11
11
|
# connect to db
|
|
12
12
|
ActiveRecord::Base.establish_connection({
|
|
13
13
|
:adapter => "sqlite3",
|
|
14
14
|
:database => ":memory:",
|
|
15
15
|
})
|
|
16
|
-
|
|
16
|
+
require_relative "schema"
|
|
17
17
|
|
|
18
18
|
# load test framework
|
|
19
|
-
require
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
require 'active_support/test_case'
|
|
25
|
-
require 'action_controller/test_case'
|
|
26
|
-
require 'action_controller/test_process'
|
|
27
|
-
require 'action_controller/integration'
|
|
19
|
+
require "test/unit"
|
|
20
|
+
require "active_support/test_case"
|
|
21
|
+
require "action_controller/test_case"
|
|
22
|
+
require "rails/controller/testing/test_process"
|
|
23
|
+
require "rails/controller/testing/integration"
|
|
28
24
|
|
|
29
25
|
# load test models/controllers
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
ActionController::Routing::Routes.draw do |map|
|
|
39
|
-
map.connect ':controller/:action/:id'
|
|
40
|
-
end
|
|
26
|
+
require_relative "controllers/userstamp_controller"
|
|
27
|
+
require_relative "controllers/users_controller"
|
|
28
|
+
require_relative "controllers/posts_controller"
|
|
29
|
+
require_relative "models/user"
|
|
30
|
+
require_relative "models/person"
|
|
31
|
+
require_relative "models/post"
|
|
32
|
+
require_relative "models/foo"
|
|
41
33
|
|
|
42
34
|
def reset_to_defaults
|
|
43
35
|
Ddb::Userstamp.compatibility_mode = false
|
|
@@ -49,13 +41,13 @@ def create_test_models
|
|
|
49
41
|
Person.delete_all
|
|
50
42
|
Post.delete_all
|
|
51
43
|
|
|
52
|
-
@zeus = User.create!(:name =>
|
|
53
|
-
@hera = User.create!(:name =>
|
|
44
|
+
@zeus = User.create!(:name => "Zeus")
|
|
45
|
+
@hera = User.create!(:name => "Hera")
|
|
54
46
|
User.stamper = @zeus.id
|
|
55
47
|
|
|
56
|
-
@delynn = Person.create!(:name =>
|
|
57
|
-
@nicole = Person.create!(:name =>
|
|
48
|
+
@delynn = Person.create!(:name => "Delynn")
|
|
49
|
+
@nicole = Person.create!(:name => "Nicole")
|
|
58
50
|
Person.stamper = @delynn.id
|
|
59
51
|
|
|
60
|
-
@first_post = Post.create!(:title =>
|
|
61
|
-
end
|
|
52
|
+
@first_post = Post.create!(:title => "a title")
|
|
53
|
+
end
|
data/test/models/comment.rb
CHANGED
data/test/models/foo.rb
CHANGED
data/test/models/person.rb
CHANGED