requires_approval_rails_2 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,8 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem "activerecord", "~> 3"
7
- gem "activesupport", "~> 3"
6
+ gem "activerecord", "~> 2.3"
7
+ gem "activesupport", "~> 2.3"
8
8
 
9
9
  # Add dependencies to develop your gem here.
10
10
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -1,42 +1,31 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.2.8)
5
- activesupport (= 3.2.8)
6
- builder (~> 3.0.0)
7
- activerecord (3.2.8)
8
- activemodel (= 3.2.8)
9
- activesupport (= 3.2.8)
10
- arel (~> 3.0.2)
11
- tzinfo (~> 0.3.29)
12
- activesupport (3.2.8)
13
- i18n (~> 0.6)
14
- multi_json (~> 1.0)
4
+ activerecord (2.3.12)
5
+ activesupport (= 2.3.12)
6
+ activesupport (2.3.12)
15
7
  archive-tar-minitar (0.5.2)
16
- arel (3.0.2)
17
- builder (3.0.0)
18
8
  columnize (0.3.6)
19
9
  diff-lcs (1.1.3)
20
- ffi (1.1.5)
10
+ ffi (1.1.0)
21
11
  git (1.2.5)
22
- guard (1.3.2)
12
+ guard (1.2.3)
23
13
  listen (>= 0.4.2)
24
14
  thor (>= 0.14.6)
25
15
  guard-bundler (1.0.0)
26
16
  bundler (~> 1.0)
27
17
  guard (~> 1.1)
28
- guard-rspec (1.2.1)
18
+ guard-rspec (1.2.0)
29
19
  guard (>= 1.1)
30
20
  guard-spork (1.1.0)
31
21
  guard (>= 1.1)
32
22
  spork (>= 0.8.4)
33
- i18n (0.6.0)
34
23
  jeweler (1.8.4)
35
24
  bundler (~> 1.0)
36
25
  git (>= 1.2.5)
37
26
  rake
38
27
  rdoc
39
- json (1.7.5)
28
+ json (1.7.4)
40
29
  linecache19 (0.5.12)
41
30
  ruby_core_source (>= 0.1.4)
42
31
  listen (0.4.7)
@@ -44,9 +33,8 @@ GEM
44
33
  rb-fsevent (~> 0.9.1)
45
34
  rb-inotify (~> 0.8.8)
46
35
  metaclass (0.0.1)
47
- mocha (0.12.3)
36
+ mocha (0.12.1)
48
37
  metaclass (~> 0.0.1)
49
- multi_json (1.3.6)
50
38
  rake (0.9.2.2)
51
39
  rb-fchange (0.0.5)
52
40
  ffi
@@ -60,9 +48,9 @@ GEM
60
48
  rspec-expectations (~> 2.11.0)
61
49
  rspec-mocks (~> 2.11.0)
62
50
  rspec-core (2.11.1)
63
- rspec-expectations (2.11.2)
51
+ rspec-expectations (2.11.1)
64
52
  diff-lcs (~> 1.1.3)
65
- rspec-mocks (2.11.2)
53
+ rspec-mocks (2.11.1)
66
54
  ruby-debug-base19 (0.11.25)
67
55
  columnize (>= 0.3.1)
68
56
  linecache19 (>= 0.5.11)
@@ -75,16 +63,15 @@ GEM
75
63
  archive-tar-minitar (>= 0.5.2)
76
64
  spork (0.9.2)
77
65
  sqlite3 (1.3.6)
78
- thor (0.16.0)
79
- tzinfo (0.3.33)
66
+ thor (0.15.4)
80
67
  yard (0.8.2.1)
81
68
 
82
69
  PLATFORMS
83
70
  ruby
84
71
 
85
72
  DEPENDENCIES
86
- activerecord (~> 3)
87
- activesupport (~> 3)
73
+ activerecord (~> 2.3)
74
+ activesupport (~> 2.3)
88
75
  bundler
89
76
  guard-bundler
90
77
  guard-rspec
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ require 'rake'
14
14
  require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "requires_approval"
17
+ gem.name = "requires_approval_rails_2"
18
18
  gem.homepage = "http://github.com/LifebookerInc/requires_approval"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Gem to handle versioning and things that require approval}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.5
1
+ 1.0.3
@@ -4,9 +4,8 @@ require 'errors'
4
4
 
5
5
  module RequiresApproval
6
6
 
7
- extend ActiveSupport::Concern
8
-
9
- included do |klass|
7
+
8
+ def self.included(klass)
10
9
  klass.send(:extend, ClassMethods)
11
10
  end
12
11
 
@@ -83,7 +82,7 @@ module RequiresApproval
83
82
 
84
83
  # have any of our versions ever been approved?
85
84
  def has_approved_version?
86
- self.versions.where(:is_approved => true).count > 0
85
+ self.versions.count(:conditions => {:is_approved => true}) > 0
87
86
  end
88
87
 
89
88
  # have we already approved all outstanding changes?
@@ -220,9 +219,8 @@ module RequiresApproval
220
219
 
221
220
  # create a blank version before create to handle if no
222
221
  # attributes were ever set
223
- self.before_validation(
224
- :latest_unapproved_version_with_nil_check,
225
- :on => :create
222
+ self.before_validation_on_create(
223
+ :latest_unapproved_version_with_nil_check
226
224
  )
227
225
 
228
226
  # create the versions class
@@ -238,11 +236,10 @@ module RequiresApproval
238
236
  :conditions => [
239
237
  "#{self.versions_table_name}.is_approved = ?", false
240
238
  ]
241
- end
242
239
 
243
- def unapproved
244
- includes(:latest_unapproved_version)
245
- .where("#{self.versions_table_name}.id IS NOT NULL")
240
+ self.set_up_scopes
241
+
242
+
246
243
  end
247
244
 
248
245
  # the class which our versions are
@@ -312,6 +309,15 @@ module RequiresApproval
312
309
  @versions_table_name = opts.delete(:versions_table_name)
313
310
  end
314
311
 
312
+ def set_up_scopes
313
+ self.named_scope(:unapproved, {
314
+ :include => [:latest_unapproved_version],
315
+ :conditions => [
316
+ "#{self.versions_table_name}.id IS NOT NULL"
317
+ ]
318
+ })
319
+ end
320
+
315
321
  def set_up_version_delegates
316
322
  self.fields_requiring_approval.each do |f|
317
323
  define_method("#{f}=") do |val|
@@ -331,12 +337,6 @@ module RequiresApproval
331
337
  end
332
338
  end
333
339
 
334
- def validates_approved_field(*args)
335
- self.versions_class.class_eval do
336
- validates(*args)
337
- end
338
- end
339
-
340
340
  # class name for our versions
341
341
  def versions_class_name
342
342
  @versions_class_name ||= "Version"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "requires_approval_rails_2"
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Langevin"]
@@ -235,12 +235,12 @@ describe RequiresApproval do
235
235
  user.reload
236
236
 
237
237
  user.latest_unapproved_version.should be nil
238
-
239
238
  user.update_attributes(
240
239
  :first_name => user.first_name,
241
240
  :last_name => user.last_name
242
241
  )
243
242
  user.reload
243
+
244
244
  user.latest_unapproved_version.should be nil
245
245
 
246
246
 
@@ -266,12 +266,13 @@ describe RequiresApproval do
266
266
 
267
267
  end
268
268
 
269
- context ".validates_approved_field" do
269
+ context "validation" do
270
270
 
271
271
  it "should delegate to the requires_approval field" do
272
272
  User.class_eval do
273
- validates_approved_field :first_name,
274
- :presence => true
273
+ self.versions_class.class_eval do
274
+ validates_presence_of :first_name
275
+ end
275
276
  end
276
277
 
277
278
  user = User.new
@@ -332,7 +333,8 @@ describe RequiresApproval do
332
333
  })
333
334
 
334
335
  # should create an approved version
335
- user.versions.where(:is_approved => true).count.should be > 0
336
+ count = user.versions.count(:conditions => {:is_approved => true})
337
+ count.should be > 0
336
338
 
337
339
  end
338
340
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: requires_approval_rails_2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2163753200 !ruby/object:Gem::Requirement
16
+ requirement: &2154973160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2163753200
24
+ version_requirements: *2154973160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &2163752640 !ruby/object:Gem::Requirement
27
+ requirement: &2154972680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2163752640
35
+ version_requirements: *2154972680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2163751920 !ruby/object:Gem::Requirement
38
+ requirement: &2154972200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2163751920
46
+ version_requirements: *2154972200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &2163751300 !ruby/object:Gem::Requirement
49
+ requirement: &2154971720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2163751300
57
+ version_requirements: *2154971720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-bundler
60
- requirement: &2163750660 !ruby/object:Gem::Requirement
60
+ requirement: &2154971240 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2163750660
68
+ version_requirements: *2154971240
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-spork
71
- requirement: &2163750040 !ruby/object:Gem::Requirement
71
+ requirement: &2154970760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2163750040
79
+ version_requirements: *2154970760
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &2163749420 !ruby/object:Gem::Requirement
82
+ requirement: &2154970280 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.8.3
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2163749420
90
+ version_requirements: *2154970280
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: mocha
93
- requirement: &2163748740 !ruby/object:Gem::Requirement
93
+ requirement: &2154986160 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2163748740
101
+ version_requirements: *2154986160
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &2163748060 !ruby/object:Gem::Requirement
104
+ requirement: &2154985680 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2163748060
112
+ version_requirements: *2154985680
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &2163747460 !ruby/object:Gem::Requirement
115
+ requirement: &2154985200 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2163747460
123
+ version_requirements: *2154985200
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: ruby-debug19
126
- requirement: &2163746760 !ruby/object:Gem::Requirement
126
+ requirement: &2154984720 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2163746760
134
+ version_requirements: *2154984720
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: sqlite3
137
- requirement: &2163746140 !ruby/object:Gem::Requirement
137
+ requirement: &2154984240 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2163746140
145
+ version_requirements: *2154984240
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: yard
148
- requirement: &2163745620 !ruby/object:Gem::Requirement
148
+ requirement: &2154983760 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,7 +153,7 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2163745620
156
+ version_requirements: *2154983760
157
157
  description: Gem to handle versioning and things that require approval
158
158
  email: dan.langevin@lifebooker.com
159
159
  executables: []
@@ -190,9 +190,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
190
  - - ! '>='
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
- segments:
194
- - 0
195
- hash: -2588660493545333348
196
193
  required_rubygems_version: !ruby/object:Gem::Requirement
197
194
  none: false
198
195
  requirements:
@@ -206,3 +203,4 @@ signing_key:
206
203
  specification_version: 3
207
204
  summary: Gem to handle versioning and things that require approval
208
205
  test_files: []
206
+ has_rdoc: