has_moderated 0.0.34 → 1.0.alpha
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.
- data/README.rdoc +17 -0
- data/lib/generators/has_moderated/install/templates/migration.rb +4 -3
- data/lib/has_moderated/adapters/active_record.rb +109 -0
- data/lib/has_moderated/adapters/proxy.rb +23 -0
- data/lib/has_moderated/associations/base.rb +157 -0
- data/lib/has_moderated/associations/collection.rb +123 -0
- data/lib/has_moderated/associations/has_many.rb +15 -0
- data/lib/has_moderated/associations/has_one.rb +58 -0
- data/lib/has_moderated/carrier_wave.rb +3 -3
- data/lib/has_moderated/common.rb +62 -113
- data/lib/has_moderated/moderated_attributes.rb +24 -11
- data/lib/has_moderated/moderated_create.rb +22 -14
- data/lib/has_moderated/moderated_destroy.rb +11 -10
- data/lib/has_moderated/moderation_model.rb +6 -200
- data/lib/has_moderated/user_hooks.rb +3 -2
- data/lib/has_moderated/version.rb +1 -1
- data/lib/has_moderated.rb +15 -7
- data/test/dummy/app/models/moderation.rb +0 -0
- data/test/dummy/app/models/subtask.rb +0 -1
- data/test/dummy/app/models/task.rb +0 -13
- data/test/dummy/app/models/task_connection.rb +4 -0
- data/test/dummy/db/migrate/20120515155730_create_moderations2.rb +20 -0
- data/test/dummy/db/migrate/20120515174306_prepare_for_new_tests.rb +36 -0
- data/test/dummy/db/migrate/20120515175621_remove_photo_relateds.rb +8 -0
- data/test/dummy/db/schema.rb +17 -96
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +35 -0
- data/test/dummy/log/test.log +81290 -0
- data/test/dummy/spec/models/task_spec.rb +414 -247
- data/test/dummy/spec/spec_helper.rb +4 -0
- metadata +26 -57
- data/lib/has_moderated/moderated_associations.rb +0 -69
- data/test/dummy/app/models/habtm_name_test.rb +0 -3
- data/test/dummy/app/models/hjoin_test.rb +0 -3
- data/test/dummy/app/models/hmany_fk_test.rb +0 -3
- data/test/dummy/app/models/hmanythrough_join.rb +0 -4
- data/test/dummy/app/models/hmanythrough_test.rb +0 -4
- data/test/dummy/app/models/hone_as_test.rb +0 -3
- data/test/dummy/app/models/hone_test.rb +0 -3
- data/test/dummy/app/models/hook_test.rb +0 -9
- data/test/dummy/app/models/photo.rb +0 -8
- data/test/dummy/app/models/photo_holder.rb +0 -4
- data/test/dummy/app/models/photo_related.rb +0 -3
- data/test/dummy/app/models/task_all.rb +0 -4
- data/test/dummy/app/models/task_photo.rb +0 -5
- data/test/dummy/spec/models/habtm_name_test_spec.rb +0 -22
- data/test/dummy/spec/models/hjoin_test_spec.rb +0 -54
- data/test/dummy/spec/models/hmany_fk_test_spec.rb +0 -36
- data/test/dummy/spec/models/hmanythrough_test_spec.rb +0 -99
- data/test/dummy/spec/models/hone_as_test_spec.rb +0 -36
- data/test/dummy/spec/models/hone_test_spec.rb +0 -36
- data/test/dummy/spec/models/hooks_spec.rb +0 -30
- data/test/dummy/spec/models/photo_holder_spec.rb +0 -21
- data/test/dummy/spec/models/photo_spec.rb +0 -69
- data/test/dummy/spec/models/task_photo_spec.rb +0 -25
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: has_moderated
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: -1851332122
|
|
5
|
+
prerelease: 4
|
|
6
6
|
segments:
|
|
7
|
+
- 1
|
|
7
8
|
- 0
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
version: 0.0.34
|
|
9
|
+
- alpha
|
|
10
|
+
version: 1.0.alpha
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jan Berdajs
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-
|
|
18
|
+
date: 2012-05-15 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
prerelease: false
|
|
@@ -61,9 +61,14 @@ files:
|
|
|
61
61
|
- lib/generators/has_moderated/install/templates/migration.rb
|
|
62
62
|
- lib/generators/has_moderated/install/templates/moderation.rb
|
|
63
63
|
- lib/generators/USAGE
|
|
64
|
+
- lib/has_moderated/adapters/active_record.rb
|
|
65
|
+
- lib/has_moderated/adapters/proxy.rb
|
|
66
|
+
- lib/has_moderated/associations/base.rb
|
|
67
|
+
- lib/has_moderated/associations/collection.rb
|
|
68
|
+
- lib/has_moderated/associations/has_many.rb
|
|
69
|
+
- lib/has_moderated/associations/has_one.rb
|
|
64
70
|
- lib/has_moderated/carrier_wave.rb
|
|
65
71
|
- lib/has_moderated/common.rb
|
|
66
|
-
- lib/has_moderated/moderated_associations.rb
|
|
67
72
|
- lib/has_moderated/moderated_attributes.rb
|
|
68
73
|
- lib/has_moderated/moderated_create.rb
|
|
69
74
|
- lib/has_moderated/moderated_destroy.rb
|
|
@@ -79,22 +84,10 @@ files:
|
|
|
79
84
|
- test/dummy/app/assets/stylesheets/application.css
|
|
80
85
|
- test/dummy/app/controllers/application_controller.rb
|
|
81
86
|
- test/dummy/app/helpers/application_helper.rb
|
|
82
|
-
- test/dummy/app/models/habtm_name_test.rb
|
|
83
|
-
- test/dummy/app/models/hjoin_test.rb
|
|
84
|
-
- test/dummy/app/models/hmany_fk_test.rb
|
|
85
|
-
- test/dummy/app/models/hmanythrough_join.rb
|
|
86
|
-
- test/dummy/app/models/hmanythrough_test.rb
|
|
87
|
-
- test/dummy/app/models/hone_as_test.rb
|
|
88
|
-
- test/dummy/app/models/hone_test.rb
|
|
89
|
-
- test/dummy/app/models/hook_test.rb
|
|
90
87
|
- test/dummy/app/models/moderation.rb
|
|
91
|
-
- test/dummy/app/models/photo.rb
|
|
92
|
-
- test/dummy/app/models/photo_holder.rb
|
|
93
|
-
- test/dummy/app/models/photo_related.rb
|
|
94
88
|
- test/dummy/app/models/subtask.rb
|
|
95
89
|
- test/dummy/app/models/task.rb
|
|
96
|
-
- test/dummy/app/models/
|
|
97
|
-
- test/dummy/app/models/task_photo.rb
|
|
90
|
+
- test/dummy/app/models/task_connection.rb
|
|
98
91
|
- test/dummy/app/uploaders/generic_uploader.rb
|
|
99
92
|
- test/dummy/app/views/layouts/application.html.erb
|
|
100
93
|
- test/dummy/config/application.rb
|
|
@@ -133,6 +126,9 @@ files:
|
|
|
133
126
|
- test/dummy/db/migrate/20111018174319_create_hmany_fk_tests.rb
|
|
134
127
|
- test/dummy/db/migrate/20111018180207_create_habtm_name_tests.rb
|
|
135
128
|
- test/dummy/db/migrate/20120209045206_create_photo_relateds.rb
|
|
129
|
+
- test/dummy/db/migrate/20120515155730_create_moderations2.rb
|
|
130
|
+
- test/dummy/db/migrate/20120515174306_prepare_for_new_tests.rb
|
|
131
|
+
- test/dummy/db/migrate/20120515175621_remove_photo_relateds.rb
|
|
136
132
|
- test/dummy/db/schema.rb
|
|
137
133
|
- test/dummy/db/test.sqlite3
|
|
138
134
|
- test/dummy/log/development.log
|
|
@@ -159,16 +155,6 @@ files:
|
|
|
159
155
|
- test/dummy/spec/factories/photos.rb
|
|
160
156
|
- test/dummy/spec/factories/task_alls.rb
|
|
161
157
|
- test/dummy/spec/factories/task_photos.rb
|
|
162
|
-
- test/dummy/spec/models/habtm_name_test_spec.rb
|
|
163
|
-
- test/dummy/spec/models/hjoin_test_spec.rb
|
|
164
|
-
- test/dummy/spec/models/hmany_fk_test_spec.rb
|
|
165
|
-
- test/dummy/spec/models/hmanythrough_test_spec.rb
|
|
166
|
-
- test/dummy/spec/models/hone_as_test_spec.rb
|
|
167
|
-
- test/dummy/spec/models/hone_test_spec.rb
|
|
168
|
-
- test/dummy/spec/models/hooks_spec.rb
|
|
169
|
-
- test/dummy/spec/models/photo_holder_spec.rb
|
|
170
|
-
- test/dummy/spec/models/photo_spec.rb
|
|
171
|
-
- test/dummy/spec/models/task_photo_spec.rb
|
|
172
158
|
- test/dummy/spec/models/task_spec.rb
|
|
173
159
|
- test/dummy/spec/spec_helper.rb
|
|
174
160
|
- test/dummy/spec/support/photos.rb
|
|
@@ -192,12 +178,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
192
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
179
|
none: false
|
|
194
180
|
requirements:
|
|
195
|
-
- - "
|
|
181
|
+
- - ">"
|
|
196
182
|
- !ruby/object:Gem::Version
|
|
197
|
-
hash:
|
|
183
|
+
hash: 25
|
|
198
184
|
segments:
|
|
199
|
-
-
|
|
200
|
-
|
|
185
|
+
- 1
|
|
186
|
+
- 3
|
|
187
|
+
- 1
|
|
188
|
+
version: 1.3.1
|
|
201
189
|
requirements: []
|
|
202
190
|
|
|
203
191
|
rubyforge_project:
|
|
@@ -210,22 +198,10 @@ test_files:
|
|
|
210
198
|
- test/dummy/app/assets/stylesheets/application.css
|
|
211
199
|
- test/dummy/app/controllers/application_controller.rb
|
|
212
200
|
- test/dummy/app/helpers/application_helper.rb
|
|
213
|
-
- test/dummy/app/models/habtm_name_test.rb
|
|
214
|
-
- test/dummy/app/models/hjoin_test.rb
|
|
215
|
-
- test/dummy/app/models/hmany_fk_test.rb
|
|
216
|
-
- test/dummy/app/models/hmanythrough_join.rb
|
|
217
|
-
- test/dummy/app/models/hmanythrough_test.rb
|
|
218
|
-
- test/dummy/app/models/hone_as_test.rb
|
|
219
|
-
- test/dummy/app/models/hone_test.rb
|
|
220
|
-
- test/dummy/app/models/hook_test.rb
|
|
221
201
|
- test/dummy/app/models/moderation.rb
|
|
222
|
-
- test/dummy/app/models/photo.rb
|
|
223
|
-
- test/dummy/app/models/photo_holder.rb
|
|
224
|
-
- test/dummy/app/models/photo_related.rb
|
|
225
202
|
- test/dummy/app/models/subtask.rb
|
|
226
203
|
- test/dummy/app/models/task.rb
|
|
227
|
-
- test/dummy/app/models/
|
|
228
|
-
- test/dummy/app/models/task_photo.rb
|
|
204
|
+
- test/dummy/app/models/task_connection.rb
|
|
229
205
|
- test/dummy/app/uploaders/generic_uploader.rb
|
|
230
206
|
- test/dummy/app/views/layouts/application.html.erb
|
|
231
207
|
- test/dummy/config/application.rb
|
|
@@ -264,6 +240,9 @@ test_files:
|
|
|
264
240
|
- test/dummy/db/migrate/20111018174319_create_hmany_fk_tests.rb
|
|
265
241
|
- test/dummy/db/migrate/20111018180207_create_habtm_name_tests.rb
|
|
266
242
|
- test/dummy/db/migrate/20120209045206_create_photo_relateds.rb
|
|
243
|
+
- test/dummy/db/migrate/20120515155730_create_moderations2.rb
|
|
244
|
+
- test/dummy/db/migrate/20120515174306_prepare_for_new_tests.rb
|
|
245
|
+
- test/dummy/db/migrate/20120515175621_remove_photo_relateds.rb
|
|
267
246
|
- test/dummy/db/schema.rb
|
|
268
247
|
- test/dummy/db/test.sqlite3
|
|
269
248
|
- test/dummy/log/development.log
|
|
@@ -290,16 +269,6 @@ test_files:
|
|
|
290
269
|
- test/dummy/spec/factories/photos.rb
|
|
291
270
|
- test/dummy/spec/factories/task_alls.rb
|
|
292
271
|
- test/dummy/spec/factories/task_photos.rb
|
|
293
|
-
- test/dummy/spec/models/habtm_name_test_spec.rb
|
|
294
|
-
- test/dummy/spec/models/hjoin_test_spec.rb
|
|
295
|
-
- test/dummy/spec/models/hmany_fk_test_spec.rb
|
|
296
|
-
- test/dummy/spec/models/hmanythrough_test_spec.rb
|
|
297
|
-
- test/dummy/spec/models/hone_as_test_spec.rb
|
|
298
|
-
- test/dummy/spec/models/hone_test_spec.rb
|
|
299
|
-
- test/dummy/spec/models/hooks_spec.rb
|
|
300
|
-
- test/dummy/spec/models/photo_holder_spec.rb
|
|
301
|
-
- test/dummy/spec/models/photo_spec.rb
|
|
302
|
-
- test/dummy/spec/models/task_photo_spec.rb
|
|
303
272
|
- test/dummy/spec/models/task_spec.rb
|
|
304
273
|
- test/dummy/spec/spec_helper.rb
|
|
305
274
|
- test/dummy/spec/support/photos.rb
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
module HasModerated
|
|
2
|
-
module ModeratedAssociations
|
|
3
|
-
module ClassMethods
|
|
4
|
-
def has_moderated_association *args
|
|
5
|
-
assocs = []
|
|
6
|
-
|
|
7
|
-
unless args.blank?
|
|
8
|
-
if args == [:all]
|
|
9
|
-
assocs = self.reflections.keys.reject do |r|
|
|
10
|
-
r == :moderations
|
|
11
|
-
end
|
|
12
|
-
else
|
|
13
|
-
assocs = args
|
|
14
|
-
assocs = [assocs] unless assocs.respond_to?("[]")
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
#TODO: should add to some class var and clean duplicates
|
|
19
|
-
|
|
20
|
-
after_initialize do
|
|
21
|
-
assocs.each do |assoc_name|
|
|
22
|
-
assoc = self.association(assoc_name)
|
|
23
|
-
if assoc.reflection.collection?
|
|
24
|
-
def assoc.add_to_target_with_moderation record
|
|
25
|
-
if !owner.new_record? && !owner.has_moderated_updating
|
|
26
|
-
#TODO: add moderation
|
|
27
|
-
owner.add_associations_moderated(self.reflection.name => [record])
|
|
28
|
-
record
|
|
29
|
-
else
|
|
30
|
-
add_to_target_without_moderation record
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
def assoc.delete_records_with_moderation(records, method) # method comes from :dependent => :destroy
|
|
34
|
-
if !owner.new_record? && !owner.has_moderated_updating
|
|
35
|
-
#todo only care for records which are already in database
|
|
36
|
-
record_ids = records.map(&:id)
|
|
37
|
-
owner.delete_associations_moderated(self.reflection.name => record_ids)
|
|
38
|
-
else
|
|
39
|
-
delete_records_without_moderation(records, method)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
assoc.class_eval do
|
|
43
|
-
alias_method_chain :add_to_target, :moderation
|
|
44
|
-
alias_method_chain :delete_records, :moderation
|
|
45
|
-
end
|
|
46
|
-
else
|
|
47
|
-
def assoc.replace_with_moderation(record, save = true)
|
|
48
|
-
if !owner.new_record? && !owner.has_moderated_updating
|
|
49
|
-
#TODO: add moderation
|
|
50
|
-
owner.add_associations_moderated(self.reflection.name => [record])
|
|
51
|
-
record
|
|
52
|
-
else
|
|
53
|
-
replace_without_moderation record
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
assoc.class_eval do
|
|
57
|
-
alias_method_chain :replace, :moderation
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
module InstanceMethods
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HabtmNameTest do
|
|
4
|
-
it "moderates assoc on update" do
|
|
5
|
-
t = Task.new :title => "Test"
|
|
6
|
-
t.save
|
|
7
|
-
|
|
8
|
-
Task.count.should eq(0)
|
|
9
|
-
|
|
10
|
-
Moderation.last.accept
|
|
11
|
-
|
|
12
|
-
t = Task.first
|
|
13
|
-
t.habtms.create! :title => "HJoin"
|
|
14
|
-
HabtmNameTest.count.should eq(0)
|
|
15
|
-
|
|
16
|
-
Moderation.last.accept
|
|
17
|
-
HabtmNameTest.count.should eq(1)
|
|
18
|
-
|
|
19
|
-
Task.first.habtms.count.should eq(1)
|
|
20
|
-
Task.first.habtms.first.title.should eq("HJoin")
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HjoinTest do
|
|
4
|
-
it "moderates assoc on create" do
|
|
5
|
-
t = Task.new :title => "Test"
|
|
6
|
-
t.hjoin_tests.build :title => "HJoin"
|
|
7
|
-
t.save
|
|
8
|
-
|
|
9
|
-
HjoinTest.count.should eq(0)
|
|
10
|
-
Task.count.should eq(0)
|
|
11
|
-
|
|
12
|
-
Moderation.last.accept
|
|
13
|
-
|
|
14
|
-
Task.first.hjoin_tests.count.should eq(1)
|
|
15
|
-
Task.first.hjoin_tests.first.title.should eq("HJoin")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "moderates assoc on update" do
|
|
19
|
-
t = Task.new :title => "Test"
|
|
20
|
-
t.save
|
|
21
|
-
|
|
22
|
-
Task.count.should eq(0)
|
|
23
|
-
|
|
24
|
-
Moderation.last.accept
|
|
25
|
-
|
|
26
|
-
t = Task.first
|
|
27
|
-
t.hjoin_tests.create! :title => "HJoin"
|
|
28
|
-
HjoinTest.count.should eq(0)
|
|
29
|
-
|
|
30
|
-
Moderation.last.accept
|
|
31
|
-
HjoinTest.count.should eq(1)
|
|
32
|
-
|
|
33
|
-
Task.first.hjoin_tests.count.should eq(1)
|
|
34
|
-
Task.first.hjoin_tests.first.title.should eq("HJoin")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "moderates assoc to existing" do
|
|
38
|
-
t = Task.new :title => "Test"
|
|
39
|
-
t.save
|
|
40
|
-
Moderation.last.accept
|
|
41
|
-
|
|
42
|
-
hjt = HjoinTest.create! :title => "Existing"
|
|
43
|
-
HjoinTest.count.should eq(1)
|
|
44
|
-
|
|
45
|
-
t = Task.first
|
|
46
|
-
t.hjoin_tests << hjt
|
|
47
|
-
Task.first.hjoin_tests.count.should eq(0)
|
|
48
|
-
|
|
49
|
-
Moderation.last.accept
|
|
50
|
-
|
|
51
|
-
Task.first.hjoin_tests.count.should eq(1)
|
|
52
|
-
Task.first.hjoin_tests.first.title.should eq("Existing")
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HmanyFkTest do
|
|
4
|
-
it "moderates assoc on create" do
|
|
5
|
-
t = Task.new :title => "Test"
|
|
6
|
-
t.lalas.build :title => "HJoin"
|
|
7
|
-
t.save
|
|
8
|
-
|
|
9
|
-
HmanyFkTest.count.should eq(0)
|
|
10
|
-
Task.count.should eq(0)
|
|
11
|
-
|
|
12
|
-
Moderation.last.accept
|
|
13
|
-
|
|
14
|
-
Task.first.lalas.count.should eq(1)
|
|
15
|
-
Task.first.lalas.first.title.should eq("HJoin")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "moderates assoc on update" do
|
|
19
|
-
t = Task.new :title => "Test"
|
|
20
|
-
t.save
|
|
21
|
-
|
|
22
|
-
Task.count.should eq(0)
|
|
23
|
-
|
|
24
|
-
Moderation.last.accept
|
|
25
|
-
|
|
26
|
-
t = Task.first
|
|
27
|
-
t.lalas.create! :title => "HJoin"
|
|
28
|
-
HmanyFkTest.count.should eq(0)
|
|
29
|
-
|
|
30
|
-
Moderation.last.accept
|
|
31
|
-
HmanyFkTest.count.should eq(1)
|
|
32
|
-
|
|
33
|
-
Task.first.lalas.count.should eq(1)
|
|
34
|
-
Task.first.lalas.first.title.should eq("HJoin")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HmanythroughTest do
|
|
4
|
-
it "moderates assoc on create" do
|
|
5
|
-
t = Task.new :title => "Test"
|
|
6
|
-
t.hmanythrough_test.build :title => "HJoin"
|
|
7
|
-
t.save
|
|
8
|
-
|
|
9
|
-
HmanythroughTest.count.should eq(0)
|
|
10
|
-
Task.count.should eq(0)
|
|
11
|
-
|
|
12
|
-
Moderation.last.accept
|
|
13
|
-
|
|
14
|
-
Task.first.hmanythrough_test.count.should eq(1)
|
|
15
|
-
Task.first.hmanythrough_test.first.title.should eq("HJoin")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "moderates assoc on update" do
|
|
19
|
-
t = Task.new :title => "Test"
|
|
20
|
-
t.save
|
|
21
|
-
|
|
22
|
-
Task.count.should eq(0)
|
|
23
|
-
|
|
24
|
-
Moderation.last.accept
|
|
25
|
-
|
|
26
|
-
t = Task.first
|
|
27
|
-
t.hmanythrough_test.create! :title => "HJoin"
|
|
28
|
-
HmanythroughTest.count.should eq(0)
|
|
29
|
-
|
|
30
|
-
Moderation.last.accept
|
|
31
|
-
HmanythroughTest.count.should eq(1)
|
|
32
|
-
|
|
33
|
-
Task.first.hmanythrough_test.count.should eq(1)
|
|
34
|
-
Task.first.hmanythrough_test.first.title.should eq("HJoin")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "moderates assoc on update (through model)" do
|
|
38
|
-
t = Task.new :title => "Test"
|
|
39
|
-
t.save
|
|
40
|
-
|
|
41
|
-
Task.count.should eq(0)
|
|
42
|
-
|
|
43
|
-
Moderation.last.accept
|
|
44
|
-
|
|
45
|
-
t = Task.first
|
|
46
|
-
j = HmanythroughJoin.new :exdata => "Data"
|
|
47
|
-
j.hmanythrough_test = HmanythroughTest.new :title => "Hello"
|
|
48
|
-
t.hmanythrough_join << j
|
|
49
|
-
t.save
|
|
50
|
-
HmanythroughTest.count.should eq(0)
|
|
51
|
-
|
|
52
|
-
Moderation.last.accept
|
|
53
|
-
HmanythroughTest.count.should eq(1)
|
|
54
|
-
|
|
55
|
-
Task.first.hmanythrough_test.count.should eq(1)
|
|
56
|
-
Task.first.hmanythrough_test.first.title.should eq("Hello")
|
|
57
|
-
Task.first.hmanythrough_test.first.hmanythrough_join.first.exdata.should eq("Data")
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "moderates assoc on update (through model) 2" do
|
|
61
|
-
pending("need to figure this out, hook will trigger when calling build already")
|
|
62
|
-
t = Task.new :title => "Test"
|
|
63
|
-
t.save
|
|
64
|
-
|
|
65
|
-
Task.count.should eq(0)
|
|
66
|
-
|
|
67
|
-
Moderation.last.accept
|
|
68
|
-
|
|
69
|
-
t = Task.first
|
|
70
|
-
j = t.hmanythrough_join.build :exdata => "Data"
|
|
71
|
-
j.hmanythrough_test = HmanythroughTest.new :title => "Hello"
|
|
72
|
-
t.save
|
|
73
|
-
HmanythroughTest.count.should eq(0)
|
|
74
|
-
|
|
75
|
-
raise Moderation.last.to_yaml
|
|
76
|
-
Moderation.last.accept
|
|
77
|
-
HmanythroughTest.count.should eq(1)
|
|
78
|
-
|
|
79
|
-
Task.first.hmanythrough_test.count.should eq(1)
|
|
80
|
-
Task.first.hmanythrough_test.first.title.should eq("Hello")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "moderates assoc extra data on create" do
|
|
84
|
-
t = Task.new :title => "Test"
|
|
85
|
-
j = t.hmanythrough_join.build :exdata => "Data"
|
|
86
|
-
j.hmanythrough_test = HmanythroughTest.new :title => "Hello"
|
|
87
|
-
t.save
|
|
88
|
-
|
|
89
|
-
HmanythroughTest.count.should eq(0)
|
|
90
|
-
Task.count.should eq(0)
|
|
91
|
-
|
|
92
|
-
Moderation.last.accept
|
|
93
|
-
HmanythroughTest.count.should eq(1)
|
|
94
|
-
|
|
95
|
-
Task.first.hmanythrough_test.count.should eq(1)
|
|
96
|
-
Task.first.hmanythrough_test.first.title.should eq("Hello")
|
|
97
|
-
Task.first.hmanythrough_test.first.hmanythrough_join.first.exdata.should eq("Data")
|
|
98
|
-
end
|
|
99
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HoneAsTest do
|
|
4
|
-
it "moderates assoc on create" do
|
|
5
|
-
t = Task.new :title => "Test"
|
|
6
|
-
t.hone_as_test = HoneAsTest.new :title => "Hone"
|
|
7
|
-
t.save
|
|
8
|
-
|
|
9
|
-
HoneAsTest.count.should eq(0)
|
|
10
|
-
Task.count.should eq(0)
|
|
11
|
-
|
|
12
|
-
Moderation.last.accept
|
|
13
|
-
HoneAsTest.count.should eq(1)
|
|
14
|
-
|
|
15
|
-
Task.first.hone_as_test.title.should eq("Hone")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "moderates assoc on update" do
|
|
19
|
-
t = Task.new :title => "Test"
|
|
20
|
-
t.save
|
|
21
|
-
|
|
22
|
-
Task.count.should eq(0)
|
|
23
|
-
|
|
24
|
-
Moderation.last.accept
|
|
25
|
-
|
|
26
|
-
t = Task.first
|
|
27
|
-
t.association(:hone_as_test).build :title => "Hone"
|
|
28
|
-
t.save
|
|
29
|
-
HoneAsTest.count.should eq(0)
|
|
30
|
-
|
|
31
|
-
Moderation.last.accept
|
|
32
|
-
HoneAsTest.count.should eq(1)
|
|
33
|
-
|
|
34
|
-
Task.first.hone_as_test.title.should eq("Hone")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HoneTest do
|
|
4
|
-
it "moderates assoc on create" do
|
|
5
|
-
t = Task.new :title => "Test"
|
|
6
|
-
t.hone_test = HoneTest.new :title => "Hone"
|
|
7
|
-
t.save
|
|
8
|
-
|
|
9
|
-
HoneTest.count.should eq(0)
|
|
10
|
-
Task.count.should eq(0)
|
|
11
|
-
|
|
12
|
-
Moderation.last.accept
|
|
13
|
-
HoneTest.count.should eq(1)
|
|
14
|
-
|
|
15
|
-
Task.first.hone_test.title.should eq("Hone")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "moderates assoc on update" do
|
|
19
|
-
t = Task.new :title => "Test"
|
|
20
|
-
t.save
|
|
21
|
-
|
|
22
|
-
Task.count.should eq(0)
|
|
23
|
-
|
|
24
|
-
Moderation.last.accept
|
|
25
|
-
|
|
26
|
-
t = Task.first
|
|
27
|
-
t.association(:hone_test).build :title => "Hone"
|
|
28
|
-
t.save
|
|
29
|
-
HoneTest.count.should eq(0)
|
|
30
|
-
|
|
31
|
-
Moderation.last.accept
|
|
32
|
-
HoneTest.count.should eq(1)
|
|
33
|
-
|
|
34
|
-
Task.first.hone_test.title.should eq("Hone")
|
|
35
|
-
end
|
|
36
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe HookTest do
|
|
4
|
-
it "should trigger on creating hook when creating a moderation (create moderation)" do
|
|
5
|
-
HookTest.create!(:title => "TEST")
|
|
6
|
-
val = Moderation.last.attr_value
|
|
7
|
-
val = val[0, 4]
|
|
8
|
-
val.should eq("TEST") # this behavior is defined by the HookTest model
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should trigger on creating hook when creating a moderation (attribute change moderation)" do
|
|
12
|
-
HookTest.create!(:title => "") # use blank title because of our hook, so moderation is valid
|
|
13
|
-
Moderation.last.accept
|
|
14
|
-
|
|
15
|
-
HookTest.first.update_attributes :title => "TEST"
|
|
16
|
-
|
|
17
|
-
val = Moderation.last.attr_value
|
|
18
|
-
val = val[0, 4]
|
|
19
|
-
val.should eq("TEST") # this behavior is defined by the HookTest model
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# control test
|
|
23
|
-
it "should not have these testing spaces for other models" do
|
|
24
|
-
Task.create!(:title => "TEST")
|
|
25
|
-
|
|
26
|
-
val = Moderation.last.attr_value
|
|
27
|
-
val = val[0, 4]
|
|
28
|
-
val.should_not eq("TEST")
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe PhotoHolder do
|
|
4
|
-
before(:each) do
|
|
5
|
-
FileUtils.rm_rf(TEMPDIR) # remove temp dir
|
|
6
|
-
FileUtils.rm_rf(File.expand_path("../../../public/uploads", __FILE__)) # remove uploads dir
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "should upload photo" do
|
|
10
|
-
photo = PhotoHolder.create!(:photos_attributes => { 0 => {:photo => carrierwave_test_photo}})
|
|
11
|
-
|
|
12
|
-
Photo.count.should eq(0)
|
|
13
|
-
tmpEmpty?.should be_false
|
|
14
|
-
Moderation.last.accept
|
|
15
|
-
tmpEmpty?.should be_true
|
|
16
|
-
|
|
17
|
-
Photo.count.should eq(1)
|
|
18
|
-
photo = Photo.first
|
|
19
|
-
assert_photo_uploaded(photo.photo)
|
|
20
|
-
end
|
|
21
|
-
end
|