requires_approval_rails_2 1.0.0 → 1.0.1

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.0.9"
7
- gem "activesupport", "~> 3.0.9"
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,19 +1,10 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activemodel (3.0.16)
5
- activesupport (= 3.0.16)
6
- builder (~> 2.1.2)
7
- i18n (~> 0.5.0)
8
- activerecord (3.0.16)
9
- activemodel (= 3.0.16)
10
- activesupport (= 3.0.16)
11
- arel (~> 2.0.10)
12
- tzinfo (~> 0.3.23)
13
- activesupport (3.0.16)
4
+ activerecord (2.3.12)
5
+ activesupport (= 2.3.12)
6
+ activesupport (2.3.12)
14
7
  archive-tar-minitar (0.5.2)
15
- arel (2.0.10)
16
- builder (2.1.2)
17
8
  columnize (0.3.6)
18
9
  diff-lcs (1.1.3)
19
10
  ffi (1.1.0)
@@ -29,7 +20,6 @@ GEM
29
20
  guard-spork (1.1.0)
30
21
  guard (>= 1.1)
31
22
  spork (>= 0.8.4)
32
- i18n (0.5.0)
33
23
  jeweler (1.8.4)
34
24
  bundler (~> 1.0)
35
25
  git (>= 1.2.5)
@@ -74,15 +64,14 @@ GEM
74
64
  spork (0.9.2)
75
65
  sqlite3 (1.3.6)
76
66
  thor (0.15.4)
77
- tzinfo (0.3.33)
78
67
  yard (0.8.2.1)
79
68
 
80
69
  PLATFORMS
81
70
  ruby
82
71
 
83
72
  DEPENDENCIES
84
- activerecord (~> 3.0.9)
85
- activesupport (~> 3.0.9)
73
+ activerecord (~> 2.3)
74
+ activesupport (~> 2.3)
86
75
  bundler
87
76
  guard-bundler
88
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.0
1
+ 1.0.1
@@ -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
 
@@ -79,7 +78,7 @@ module RequiresApproval
79
78
 
80
79
  # have any of our versions ever been approved?
81
80
  def has_approved_version?
82
- self.versions.where(:is_approved => true).count > 0
81
+ self.versions.count(:conditions => {:is_approved => true}) > 0
83
82
  end
84
83
 
85
84
  # have we already approved all outstanding changes?
@@ -219,11 +218,10 @@ module RequiresApproval
219
218
  :conditions => [
220
219
  "#{self.versions_table_name}.is_approved = ?", false
221
220
  ]
222
- end
223
221
 
224
- def unapproved
225
- includes(:latest_unapproved_version)
226
- .where("#{self.versions_table_name}.id IS NOT NULL")
222
+ self.set_up_scopes
223
+
224
+
227
225
  end
228
226
 
229
227
  # the class which our versions are
@@ -293,6 +291,15 @@ module RequiresApproval
293
291
  @versions_table_name = opts.delete(:versions_table_name)
294
292
  end
295
293
 
294
+ def set_up_scopes
295
+ self.named_scope(:unapproved, {
296
+ :include => [:latest_unapproved_version],
297
+ :conditions => [
298
+ "#{self.versions_table_name}.id IS NOT NULL"
299
+ ]
300
+ })
301
+ end
302
+
296
303
  def set_up_version_delegates
297
304
  self.fields_requiring_approval.each do |f|
298
305
  define_method("#{f}=") do |val|
@@ -302,12 +309,6 @@ module RequiresApproval
302
309
  end
303
310
  end
304
311
 
305
- def validates_approved_field(*args)
306
- self.versions_class.class_eval do
307
- validates(*args)
308
- end
309
- end
310
-
311
312
  # class name for our versions
312
313
  def versions_class_name
313
314
  @versions_class_name ||= "Version"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "requires_approval_rails_2"
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
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"]
12
- s.date = "2012-08-05"
12
+ s.date = "2012-08-06"
13
13
  s.description = "Gem to handle versioning and things that require approval"
14
14
  s.email = "dan.langevin@lifebooker.com"
15
15
  s.extra_rdoc_files = [
@@ -199,12 +199,13 @@ describe RequiresApproval do
199
199
 
200
200
  end
201
201
 
202
- context ".validates_approved_field" do
202
+ context "validation" do
203
203
 
204
204
  it "should delegate to the requires_approval field" do
205
205
  User.class_eval do
206
- validates_approved_field :first_name,
207
- :presence => true
206
+ self.versions_class.class_eval do
207
+ validates_presence_of :first_name
208
+ end
208
209
  end
209
210
 
210
211
  user = User.new
@@ -265,7 +266,8 @@ describe RequiresApproval do
265
266
  })
266
267
 
267
268
  # should create an approved version
268
- user.versions.where(:is_approved => true).count.should be > 0
269
+ count = user.versions.count(:conditions => {:is_approved => true})
270
+ count.should be > 0
269
271
 
270
272
  end
271
273
 
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.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-05 00:00:00.000000000 Z
12
+ date: 2012-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2169540880 !ruby/object:Gem::Requirement
16
+ requirement: &2164816540 !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: *2169540880
24
+ version_requirements: *2164816540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &2169540160 !ruby/object:Gem::Requirement
27
+ requirement: &2164815680 !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: *2169540160
35
+ version_requirements: *2164815680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2169539480 !ruby/object:Gem::Requirement
38
+ requirement: &2164814860 !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: *2169539480
46
+ version_requirements: *2164814860
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &2169539000 !ruby/object:Gem::Requirement
49
+ requirement: &2164813820 !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: *2169539000
57
+ version_requirements: *2164813820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-bundler
60
- requirement: &2169538300 !ruby/object:Gem::Requirement
60
+ requirement: &2164812360 !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: *2169538300
68
+ version_requirements: *2164812360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-spork
71
- requirement: &2169537620 !ruby/object:Gem::Requirement
71
+ requirement: &2164809020 !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: *2169537620
79
+ version_requirements: *2164809020
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &2169536920 !ruby/object:Gem::Requirement
82
+ requirement: &2164804700 !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: *2169536920
90
+ version_requirements: *2164804700
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: mocha
93
- requirement: &2169536380 !ruby/object:Gem::Requirement
93
+ requirement: &2164802980 !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: *2169536380
101
+ version_requirements: *2164802980
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &2169535740 !ruby/object:Gem::Requirement
104
+ requirement: &2164802080 !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: *2169535740
112
+ version_requirements: *2164802080
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &2169535060 !ruby/object:Gem::Requirement
115
+ requirement: &2164801020 !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: *2169535060
123
+ version_requirements: *2164801020
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: ruby-debug19
126
- requirement: &2169534300 !ruby/object:Gem::Requirement
126
+ requirement: &2164800460 !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: *2169534300
134
+ version_requirements: *2164800460
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: sqlite3
137
- requirement: &2169533780 !ruby/object:Gem::Requirement
137
+ requirement: &2164799940 !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: *2169533780
145
+ version_requirements: *2164799940
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: yard
148
- requirement: &2169533180 !ruby/object:Gem::Requirement
148
+ requirement: &2164799380 !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: *2169533180
156
+ version_requirements: *2164799380
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: 696855978375686757
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: