has_moderated 0.0.2 → 0.0.3

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.
@@ -0,0 +1,8 @@
1
+ # Read about factories at http://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :task_all do
5
+ title "MyString"
6
+ value "MyString"
7
+ end
8
+ end
@@ -112,4 +112,68 @@ describe Task do
112
112
  Moderation.last.accept
113
113
  Task.last.desc.should eq("Hollywood Hills")
114
114
  end
115
+
116
+ it "remembers associations to existing records" do
117
+ subtask = Subtask.create! :title => "Bye Bye"
118
+ Subtask.count.should eq(1)
119
+
120
+ t = Task.new :title => "Hollywood Hills"
121
+ t.subtasks << subtask
122
+ t.save
123
+
124
+ Task.count.should eq(0)
125
+ Subtask.first.task.should be_nil
126
+
127
+ Moderation.last.accept
128
+ Subtask.first.task.should_not be_nil
129
+ t = Task.first
130
+ t.subtasks.count.should eq(1)
131
+ t.subtasks.first.title.should eq("Bye Bye")
132
+ end
133
+
134
+ it "accepts :all for has_moderated_create's :with_associations option" do
135
+ t = TaskAll.new :title => "Bye Bye"
136
+ t.subtasks.build :title => "Hollywood Hills"
137
+ t.save
138
+
139
+ TaskAll.count.should eq(0)
140
+ Subtask.count.should eq(0)
141
+
142
+ Moderation.last.accept
143
+
144
+ TaskAll.count.should eq(1)
145
+ Subtask.count.should eq(1)
146
+ TaskAll.first.title.should eq("Bye Bye")
147
+ TaskAll.first.subtasks.first.title.should eq("Hollywood Hills")
148
+ end
149
+
150
+ it "ignores associations to existing records that were deleted" do
151
+ subtask = Subtask.create! :title => "Bye Bye"
152
+ Subtask.count.should eq(1)
153
+
154
+ t = Task.new :title => "Hollywood Hills"
155
+ t.subtasks << subtask
156
+ t.save
157
+
158
+ Task.count.should eq(0)
159
+ Subtask.delete_all
160
+ Subtask.count.should eq(0)
161
+
162
+ Moderation.last.accept
163
+ Task.first.subtasks.count.should eq(0)
164
+ Subtask.count.should eq(0)
165
+ end
166
+
167
+ it "moderates destroy" do
168
+ Task.create! :title => "Bye Bye"
169
+ Moderation.last.accept
170
+
171
+ Task.count.should eq(1)
172
+
173
+ Task.first.destroy
174
+ Task.count.should eq(1)
175
+
176
+ Moderation.last.accept
177
+ Task.count.should eq(0)
178
+ end
115
179
  end
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
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: 2011-09-01 00:00:00 +02:00
18
+ date: 2011-09-08 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -88,20 +88,24 @@ files:
88
88
  - test/dummy/script/rails
89
89
  - test/dummy/db/schema.rb
90
90
  - test/dummy/db/development.sqlite3
91
+ - test/dummy/db/migrate/20110908025410_create_task_alls.rb
91
92
  - test/dummy/db/migrate/20110901013228_create_subtasks.rb
92
93
  - test/dummy/db/migrate/20110901013205_create_tasks.rb
94
+ - test/dummy/db/migrate/20110908025606_add_task_all_id_to_subtasks.rb
93
95
  - test/dummy/db/migrate/20110901013618_create_moderations.rb
94
96
  - test/dummy/db/test.sqlite3
95
97
  - test/dummy/app/helpers/application_helper.rb
96
98
  - test/dummy/app/models/task.rb
97
99
  - test/dummy/app/models/moderation.rb
98
100
  - test/dummy/app/models/subtask.rb
101
+ - test/dummy/app/models/task_all.rb
99
102
  - test/dummy/app/assets/stylesheets/application.css
100
103
  - test/dummy/app/assets/javascripts/application.js
101
104
  - test/dummy/app/controllers/application_controller.rb
102
105
  - test/dummy/app/views/layouts/application.html.erb
103
106
  - test/dummy/spec/models/task_spec.rb
104
107
  - test/dummy/spec/spec_helper.rb
108
+ - test/dummy/spec/factories/task_alls.rb
105
109
  - test/dummy/config.ru
106
110
  - test/dummy/Rakefile
107
111
  - test/dummy/public/500.html
@@ -163,20 +167,24 @@ test_files:
163
167
  - test/dummy/script/rails
164
168
  - test/dummy/db/schema.rb
165
169
  - test/dummy/db/development.sqlite3
170
+ - test/dummy/db/migrate/20110908025410_create_task_alls.rb
166
171
  - test/dummy/db/migrate/20110901013228_create_subtasks.rb
167
172
  - test/dummy/db/migrate/20110901013205_create_tasks.rb
173
+ - test/dummy/db/migrate/20110908025606_add_task_all_id_to_subtasks.rb
168
174
  - test/dummy/db/migrate/20110901013618_create_moderations.rb
169
175
  - test/dummy/db/test.sqlite3
170
176
  - test/dummy/app/helpers/application_helper.rb
171
177
  - test/dummy/app/models/task.rb
172
178
  - test/dummy/app/models/moderation.rb
173
179
  - test/dummy/app/models/subtask.rb
180
+ - test/dummy/app/models/task_all.rb
174
181
  - test/dummy/app/assets/stylesheets/application.css
175
182
  - test/dummy/app/assets/javascripts/application.js
176
183
  - test/dummy/app/controllers/application_controller.rb
177
184
  - test/dummy/app/views/layouts/application.html.erb
178
185
  - test/dummy/spec/models/task_spec.rb
179
186
  - test/dummy/spec/spec_helper.rb
187
+ - test/dummy/spec/factories/task_alls.rb
180
188
  - test/dummy/config.ru
181
189
  - test/dummy/Rakefile
182
190
  - test/dummy/public/500.html