Commit 0e350c7caeed83aa50b9e7d4fc87bc0bdf53975a
1 parent
4d8f6b9d
Exists in
master
and in
28 other branches
[postgres-tests] Fixing scrap tests
Showing
1 changed file
with
18 additions
and
14 deletions
Show diff stats
test/unit/scrap_test.rb
1 | 1 | require File.join(File.dirname(__FILE__), '..', 'test_helper') |
2 | 2 | |
3 | 3 | class ScrapTest < ActiveSupport::TestCase |
4 | + | |
5 | + def setup | |
6 | + Person.delete_all | |
7 | + Scrap.delete_all | |
8 | + end | |
9 | + | |
4 | 10 | should "have the content" do |
5 | 11 | s = Scrap.new |
6 | 12 | s.valid? |
... | ... | @@ -98,7 +104,7 @@ class ScrapTest < ActiveSupport::TestCase |
98 | 104 | end |
99 | 105 | |
100 | 106 | should "create the leave_scrap action tracker verb on scrap creation of one user to community" do |
101 | - p = Person.first | |
107 | + p = fast_create(Person) | |
102 | 108 | c = fast_create(Community) |
103 | 109 | s = Scrap.new |
104 | 110 | s.sender= p |
... | ... | @@ -119,8 +125,8 @@ class ScrapTest < ActiveSupport::TestCase |
119 | 125 | p1 = fast_create(Person) |
120 | 126 | p2 = fast_create(Person) |
121 | 127 | p1.add_friend(p2) |
122 | - ActionTrackerNotification.destroy_all | |
123 | - Delayed::Job.destroy_all | |
128 | + ActionTrackerNotification.delete_all | |
129 | + Delayed::Job.delete_all | |
124 | 130 | s = Scrap.new |
125 | 131 | s.sender= p1 |
126 | 132 | s.receiver= p2 |
... | ... | @@ -134,11 +140,11 @@ class ScrapTest < ActiveSupport::TestCase |
134 | 140 | end |
135 | 141 | |
136 | 142 | should "notify leave_scrap action tracker verb to members of the communities and the community itself" do |
137 | - p = Person.first | |
143 | + p = fast_create(Person) | |
138 | 144 | c = fast_create(Community) |
139 | 145 | c.add_member(p) |
140 | - ActionTrackerNotification.destroy_all | |
141 | - Delayed::Job.destroy_all | |
146 | + ActionTrackerNotification.delete_all | |
147 | + Delayed::Job.delete_all | |
142 | 148 | s = Scrap.new |
143 | 149 | s.sender= p |
144 | 150 | s.receiver= c |
... | ... | @@ -152,25 +158,25 @@ class ScrapTest < ActiveSupport::TestCase |
152 | 158 | end |
153 | 159 | |
154 | 160 | should "create the leave_scrap_to_self action tracker verb on scrap creation of one user to itself" do |
155 | - p1 = Person.first | |
161 | + p = fast_create(Person) | |
156 | 162 | s = Scrap.new |
157 | - s.sender= p1 | |
158 | - s.receiver= p1 | |
163 | + s.sender= p | |
164 | + s.receiver= p | |
159 | 165 | s.content = 'some content' |
160 | 166 | s.save! |
161 | 167 | ta = ActionTracker::Record.last |
162 | 168 | assert_equal s.content, ta.params['content'] |
163 | 169 | assert_equal s.sender.name, ta.params['sender_name'] |
164 | 170 | assert_equal 'leave_scrap_to_self', ta.verb |
165 | - assert_equal p1, ta.user | |
171 | + assert_equal p, ta.user | |
166 | 172 | end |
167 | 173 | |
168 | 174 | should "notify leave_scrap_to_self action tracker verb to friends and itself" do |
169 | 175 | p1 = fast_create(Person) |
170 | 176 | p2 = fast_create(Person) |
171 | 177 | p1.add_friend(p2) |
172 | - ActionTrackerNotification.destroy_all | |
173 | - Delayed::Job.destroy_all | |
178 | + ActionTrackerNotification.delete_all | |
179 | + Delayed::Job.delete_all | |
174 | 180 | s = Scrap.new |
175 | 181 | s.sender= p1 |
176 | 182 | s.receiver= p1 |
... | ... | @@ -200,7 +206,6 @@ class ScrapTest < ActiveSupport::TestCase |
200 | 206 | end |
201 | 207 | |
202 | 208 | should "remove the replies is the root is removed" do |
203 | - Scrap.delete_all | |
204 | 209 | s = fast_create(Scrap) |
205 | 210 | s1 = fast_create(Scrap, :scrap_id => s.id) |
206 | 211 | s2 = fast_create(Scrap, :scrap_id => s.id) |
... | ... | @@ -211,7 +216,6 @@ class ScrapTest < ActiveSupport::TestCase |
211 | 216 | end |
212 | 217 | |
213 | 218 | should "update the scrap on reply creation" do |
214 | - Scrap.delete_all | |
215 | 219 | person = fast_create(Person) |
216 | 220 | s = fast_create(Scrap, :updated_at => DateTime.parse('2010-01-01')) |
217 | 221 | assert_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d') | ... | ... |