has_moderated 1.0.alpha → 1.0.alpha2
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 +24 -26
- data/lib/has_moderated/associations/base.rb +7 -4
- data/lib/has_moderated/associations/collection.rb +1 -1
- data/lib/has_moderated/common.rb +0 -1
- data/lib/has_moderated/version.rb +1 -1
- data/test/dummy/Guardfile +30 -0
- data/test/dummy/log/test.log +18973 -0
- data/test/dummy/spec/models/task_spec.rb +23 -7
- data/test/dummy/spec/spec_helper.rb +60 -26
- metadata +6 -3
@@ -9,9 +9,9 @@ describe Task do
|
|
9
9
|
|
10
10
|
context "has_many association:" do
|
11
11
|
before do
|
12
|
-
Object.send(:remove_const, 'Task')
|
12
|
+
Object.send(:remove_const, 'Task') if defined? Task
|
13
13
|
load 'task.rb'
|
14
|
-
Object.send(:remove_const, 'Subtask')
|
14
|
+
Object.send(:remove_const, 'Subtask') if defined? Subtask
|
15
15
|
load 'subtask.rb'
|
16
16
|
# TODO: set very obscure options
|
17
17
|
Task.has_many :renamed_subtasks, :class_name => "Subtask"
|
@@ -128,16 +128,17 @@ describe Task do
|
|
128
128
|
load 'subtask.rb'
|
129
129
|
# TODO: set very obscure options
|
130
130
|
Task.has_and_belongs_to_many :renamed_subtasks, :class_name => "Subtask", :join_table => "tasks_jointable", :foreign_key => "m1_id", :association_foreign_key => "m2_id"
|
131
|
+
Subtask.has_and_belongs_to_many :renamed_tasks, :class_name => "Task", :join_table => "tasks_jointable", :foreign_key => "m2_id", :association_foreign_key => "m1_id"
|
131
132
|
Task.has_moderated_association :renamed_subtasks
|
132
133
|
end
|
133
134
|
|
134
|
-
it "creates and associates subtask
|
135
|
+
it "creates and associates a new subtask" do
|
135
136
|
task = Task.create! :title => "Task 1"
|
136
137
|
Moderation.count.should eq(0)
|
137
138
|
task.renamed_subtasks.create! :title => "Subtask 1"
|
138
|
-
|
139
|
-
task = Task.first
|
139
|
+
|
140
140
|
Subtask.count.should eq(0)
|
141
|
+
task = Task.first
|
141
142
|
task.renamed_subtasks.count.should eq(0)
|
142
143
|
|
143
144
|
Moderation.count.should eq(1)
|
@@ -147,6 +148,21 @@ describe Task do
|
|
147
148
|
subtask = Task.first.renamed_subtasks.first
|
148
149
|
subtask.title.should eq("Subtask 1")
|
149
150
|
end
|
151
|
+
|
152
|
+
it "associates an existing subtask" do
|
153
|
+
task = Task.create! :title => "Task 1"
|
154
|
+
Subtask.create! :title => "Subtask 1"
|
155
|
+
Task.first.renamed_subtasks.count.should eq(0)
|
156
|
+
Moderation.count.should eq(0)
|
157
|
+
task.renamed_subtasks << Subtask.first
|
158
|
+
|
159
|
+
Moderation.count.should eq(1)
|
160
|
+
Moderation.last.accept
|
161
|
+
Moderation.count.should eq(0)
|
162
|
+
|
163
|
+
subtask = Task.first.renamed_subtasks.first
|
164
|
+
subtask.title.should eq("Subtask 1")
|
165
|
+
end
|
150
166
|
end
|
151
167
|
|
152
168
|
#
|
@@ -258,7 +274,6 @@ describe Task do
|
|
258
274
|
Moderation.count.should eq(0)
|
259
275
|
task.renamed_subtask = Subtask.new :title => "Subtask 1"
|
260
276
|
task.save
|
261
|
-
debugger
|
262
277
|
|
263
278
|
task = Task.first
|
264
279
|
task.renamed_subtask.should be_nil
|
@@ -289,7 +304,7 @@ describe Task do
|
|
289
304
|
subtask.title.should eq("Subtask 1")
|
290
305
|
end
|
291
306
|
|
292
|
-
it "set subtask to nil" do
|
307
|
+
it "set subtask to nil (delete)" do
|
293
308
|
task = Task.create! :title => "Task 1"
|
294
309
|
task.renamed_subtask = Subtask.new :title => "Subtask 1"
|
295
310
|
task.save
|
@@ -331,6 +346,7 @@ describe Task do
|
|
331
346
|
Task.first.title.should eq("Task 1")
|
332
347
|
end
|
333
348
|
|
349
|
+
# TODO: test all associations on create
|
334
350
|
it "moderates assoc on create" do
|
335
351
|
task = Task.new :title => "Task 1"
|
336
352
|
task.renamed_subtasks.build :title => "Subtask 1"
|
@@ -1,31 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spork'
|
3
|
+
#uncomment the following line to use spork with the debugger
|
4
|
+
#require 'spork/ext/ruby-debug'
|
5
5
|
|
6
|
-
|
7
|
-
# in
|
8
|
-
|
6
|
+
Spork.prefork do
|
7
|
+
# Loading more in this block will cause your tests to run faster. However,
|
8
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
9
|
+
# need to restart spork for it take effect.
|
10
|
+
|
11
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
12
|
+
ENV["RAILS_ENV"] ||= 'test'
|
13
|
+
require File.expand_path("../../config/environment", __FILE__)
|
14
|
+
require 'rspec/rails'
|
9
15
|
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
14
|
-
#
|
15
|
-
# config.mock_with :mocha
|
16
|
-
# config.mock_with :flexmock
|
17
|
-
# config.mock_with :rr
|
18
|
-
config.mock_with :rspec
|
16
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
17
|
+
# in spec/support/ and its subdirectories.
|
18
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.mock_with :rspec
|
22
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
23
|
+
config.use_transactional_fixtures = true
|
24
|
+
|
25
|
+
# Exclude broken tests
|
26
|
+
config.filter_run_excluding :broken => true
|
27
|
+
config.filter_run :focus => true
|
28
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
29
|
+
config.run_all_when_everything_filtered = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Spork.each_run do
|
34
|
+
# This code will be run each time you run your specs.
|
22
35
|
|
23
|
-
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
24
|
-
# examples within a transaction, remove the following line or assign false
|
25
|
-
# instead of true.
|
26
|
-
config.use_transactional_fixtures = true
|
27
|
-
|
28
|
-
# Exclude broken tests
|
29
|
-
config.filter_run_excluding :broken => true
|
30
|
-
#config.filter_run :focus => true
|
31
36
|
end
|
37
|
+
|
38
|
+
# --- Instructions ---
|
39
|
+
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
|
40
|
+
# block.
|
41
|
+
#
|
42
|
+
# The Spork.prefork block is run only once when the spork server is started.
|
43
|
+
# You typically want to place most of your (slow) initializer code in here, in
|
44
|
+
# particular, require'ing any 3rd-party gems that you don't normally modify
|
45
|
+
# during development.
|
46
|
+
#
|
47
|
+
# The Spork.each_run block is run each time you run your specs. In case you
|
48
|
+
# need to load files that tend to change during development, require them here.
|
49
|
+
# With Rails, your application modules are loaded automatically, so sometimes
|
50
|
+
# this block can remain empty.
|
51
|
+
#
|
52
|
+
# Note: You can modify files loaded *from* the Spork.each_run block without
|
53
|
+
# restarting the spork server. However, this file itself will not be reloaded,
|
54
|
+
# so if you change any of the code inside the each_run block, you still need to
|
55
|
+
# restart the server. In general, if you have non-trivial code in this file,
|
56
|
+
# it's advisable to move it into a separate file so you can easily edit it
|
57
|
+
# without restarting spork. (For example, with RSpec, you could move
|
58
|
+
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
|
59
|
+
# spec/support/* files are require'd from inside the each_run block.)
|
60
|
+
#
|
61
|
+
# Any code that is left outside the two blocks will be run during preforking
|
62
|
+
# *and* during each_run -- that's probably not what you want.
|
63
|
+
#
|
64
|
+
# These instructions should self-destruct in 10 seconds. If they don't, feel
|
65
|
+
# free to delete them.
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_moderated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -3702664264
|
5
5
|
prerelease: 4
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- alpha
|
10
|
-
|
10
|
+
- 2
|
11
|
+
version: 1.0.alpha2
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Jan Berdajs
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2012-05-
|
19
|
+
date: 2012-05-20 00:00:00 Z
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
prerelease: false
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- test/dummy/db/migrate/20120515175621_remove_photo_relateds.rb
|
132
133
|
- test/dummy/db/schema.rb
|
133
134
|
- test/dummy/db/test.sqlite3
|
135
|
+
- test/dummy/Guardfile
|
134
136
|
- test/dummy/log/development.log
|
135
137
|
- test/dummy/log/test.log
|
136
138
|
- test/dummy/public/404.html
|
@@ -245,6 +247,7 @@ test_files:
|
|
245
247
|
- test/dummy/db/migrate/20120515175621_remove_photo_relateds.rb
|
246
248
|
- test/dummy/db/schema.rb
|
247
249
|
- test/dummy/db/test.sqlite3
|
250
|
+
- test/dummy/Guardfile
|
248
251
|
- test/dummy/log/development.log
|
249
252
|
- test/dummy/log/test.log
|
250
253
|
- test/dummy/public/404.html
|