Commit 0e350c7caeed83aa50b9e7d4fc87bc0bdf53975a

Authored by Rodrigo Souto
1 parent 4d8f6b9d

[postgres-tests] Fixing scrap tests

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