Commit b36352d352f7d2693952d35160e3e3bc301ac6e8
1 parent
04ed091f
Exists in
master
and in
29 other branches
Fix tests to work with `mail` 2.5
creating a mail intance crashes it there is no valid recipient; so we change places to use create_user.person instead of fast_create(Person) to make sure the user person instances have a valid email address.
Showing
3 changed files
with
24 additions
and
24 deletions
Show diff stats
test/unit/person_test.rb
... | ... | @@ -1198,8 +1198,8 @@ class PersonTest < ActiveSupport::TestCase |
1198 | 1198 | |
1199 | 1199 | should 'return tracked_actions and scraps as activities' do |
1200 | 1200 | ActionTracker::Record.destroy_all |
1201 | - person = fast_create(Person) | |
1202 | - another_person = fast_create(Person) | |
1201 | + person = create_user.person | |
1202 | + another_person = create_user.person | |
1203 | 1203 | |
1204 | 1204 | UserStampSweeper.any_instance.stubs(:current_user).returns(another_person) |
1205 | 1205 | scrap = create(Scrap, defaults_for_scrap(:sender => another_person, :receiver => person, :content => 'A scrap')) | ... | ... |
test/unit/scrap_notifier_test.rb
... | ... | @@ -57,10 +57,10 @@ class ScrapNotifierTest < ActiveSupport::TestCase |
57 | 57 | |
58 | 58 | should 'not deliver mail if is a reply on a community' do |
59 | 59 | community = fast_create(Community) |
60 | - person = fast_create(Person) | |
60 | + person = create_user.person | |
61 | 61 | scrap = fast_create(Scrap, :receiver_id => community.id, :sender_id => @sender.id) |
62 | 62 | assert_no_difference 'ActionMailer::Base.deliveries.size' do |
63 | - Scrap.create!(:sender_id => person, :receiver_id => @sender.id, :scrap_id => scrap.id, :content => 'Hi myself!') | |
63 | + Scrap.create!(:sender_id => person.id, :receiver_id => @sender.id, :scrap_id => scrap.id, :content => 'Hi myself!') | |
64 | 64 | end |
65 | 65 | end |
66 | 66 | ... | ... |
test/unit/scrap_test.rb
... | ... | @@ -42,7 +42,7 @@ class ScrapTest < ActiveSupport::TestCase |
42 | 42 | end |
43 | 43 | |
44 | 44 | should "be associated to Person as sender" do |
45 | - person = fast_create(Person) | |
45 | + person = create_user.person | |
46 | 46 | s = Scrap.new |
47 | 47 | assert_nothing_raised do |
48 | 48 | s.sender = person |
... | ... | @@ -50,7 +50,7 @@ class ScrapTest < ActiveSupport::TestCase |
50 | 50 | end |
51 | 51 | |
52 | 52 | should "be associated to Person as receiver" do |
53 | - person = fast_create(Person) | |
53 | + person = create_user.person | |
54 | 54 | s = Scrap.new |
55 | 55 | assert_nothing_raised do |
56 | 56 | s.receiver = person |
... | ... | @@ -66,7 +66,7 @@ class ScrapTest < ActiveSupport::TestCase |
66 | 66 | end |
67 | 67 | |
68 | 68 | should "collect all scraps sent and received of a person" do |
69 | - person = fast_create(Person) | |
69 | + person = create_user.person | |
70 | 70 | s1 = fast_create(Scrap, :sender_id => person.id) |
71 | 71 | assert_equal [s1], Scrap.all_scraps(person) |
72 | 72 | s2 = fast_create(Scrap, :sender_id => person.id) |
... | ... | @@ -77,7 +77,7 @@ class ScrapTest < ActiveSupport::TestCase |
77 | 77 | |
78 | 78 | should "collect all scraps sent and received of a community" do |
79 | 79 | community = fast_create(Community) |
80 | - person = fast_create(Person) | |
80 | + person = create_user.person | |
81 | 81 | s1 = fast_create(Scrap, :sender_id => person.id) |
82 | 82 | assert_equal [], Scrap.all_scraps(community) |
83 | 83 | s2 = fast_create(Scrap, :receiver_id => community.id, :sender_id => person.id) |
... | ... | @@ -87,8 +87,8 @@ class ScrapTest < ActiveSupport::TestCase |
87 | 87 | end |
88 | 88 | |
89 | 89 | should "create the leave_scrap action tracker verb on scrap creation of one user to another" do |
90 | - p1 = fast_create(Person) | |
91 | - p2 = fast_create(Person) | |
90 | + p1 = create_user.person | |
91 | + p2 = create_user.person | |
92 | 92 | s = Scrap.new |
93 | 93 | s.sender= p1 |
94 | 94 | s.receiver= p2 |
... | ... | @@ -104,7 +104,7 @@ class ScrapTest < ActiveSupport::TestCase |
104 | 104 | end |
105 | 105 | |
106 | 106 | should "create the leave_scrap action tracker verb on scrap creation of one user to community" do |
107 | - p = fast_create(Person) | |
107 | + p = create_user.person | |
108 | 108 | c = fast_create(Community) |
109 | 109 | s = Scrap.new |
110 | 110 | s.sender= p |
... | ... | @@ -122,8 +122,8 @@ class ScrapTest < ActiveSupport::TestCase |
122 | 122 | end |
123 | 123 | |
124 | 124 | should "notify leave_scrap action tracker verb to friends and itself" do |
125 | - p1 = fast_create(Person) | |
126 | - p2 = fast_create(Person) | |
125 | + p1 = create_user.person | |
126 | + p2 = create_user.person | |
127 | 127 | p1.add_friend(p2) |
128 | 128 | ActionTrackerNotification.delete_all |
129 | 129 | Delayed::Job.delete_all |
... | ... | @@ -140,7 +140,7 @@ class ScrapTest < ActiveSupport::TestCase |
140 | 140 | end |
141 | 141 | |
142 | 142 | should "notify leave_scrap action tracker verb to members of the communities and the community itself" do |
143 | - p = fast_create(Person) | |
143 | + p = create_user.person | |
144 | 144 | c = fast_create(Community) |
145 | 145 | c.add_member(p) |
146 | 146 | ActionTrackerNotification.delete_all |
... | ... | @@ -158,7 +158,7 @@ class ScrapTest < ActiveSupport::TestCase |
158 | 158 | end |
159 | 159 | |
160 | 160 | should "create the leave_scrap_to_self action tracker verb on scrap creation of one user to itself" do |
161 | - p = fast_create(Person) | |
161 | + p = create_user.person | |
162 | 162 | s = Scrap.new |
163 | 163 | s.sender= p |
164 | 164 | s.receiver= p |
... | ... | @@ -172,8 +172,8 @@ class ScrapTest < ActiveSupport::TestCase |
172 | 172 | end |
173 | 173 | |
174 | 174 | should "notify leave_scrap_to_self action tracker verb to friends and itself" do |
175 | - p1 = fast_create(Person) | |
176 | - p2 = fast_create(Person) | |
175 | + p1 = create_user.person | |
176 | + p2 = create_user.person | |
177 | 177 | p1.add_friend(p2) |
178 | 178 | ActionTrackerNotification.delete_all |
179 | 179 | Delayed::Job.delete_all |
... | ... | @@ -216,7 +216,7 @@ class ScrapTest < ActiveSupport::TestCase |
216 | 216 | end |
217 | 217 | |
218 | 218 | should "update the scrap on reply creation" do |
219 | - person = fast_create(Person) | |
219 | + person = create_user.person | |
220 | 220 | s = fast_create(Scrap, :updated_at => DateTime.parse('2010-01-01')) |
221 | 221 | assert_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d') |
222 | 222 | DateTime.stubs(:now).returns(DateTime.parse('2010-09-07')) |
... | ... | @@ -242,20 +242,20 @@ class ScrapTest < ActiveSupport::TestCase |
242 | 242 | end |
243 | 243 | |
244 | 244 | should 'strip all html tags' do |
245 | - s, r = fast_create(Person), fast_create(Person) | |
245 | + s, r = create_user.person, create_user.person | |
246 | 246 | s = build Scrap, :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" |
247 | 247 | assert_equal "Test Rails", s.strip_all_html_tags |
248 | 248 | end |
249 | 249 | |
250 | 250 | should 'strip html before save' do |
251 | - s, r = fast_create(Person), fast_create(Person) | |
251 | + s, r = create_user.person, create_user.person | |
252 | 252 | s = build Scrap, :sender => s, :receiver => r, :content => "<p>Test <b>Rails</b></p>" |
253 | 253 | s.save! |
254 | 254 | assert_equal "Test Rails", s.reload.content |
255 | 255 | end |
256 | 256 | |
257 | 257 | should 'strip html before validate' do |
258 | - s, r = fast_create(Person), fast_create(Person) | |
258 | + s, r = create_user.person, create_user.person | |
259 | 259 | s = build Scrap, :sender => s, :receiver => r, :content => "<p><b></b></p>" |
260 | 260 | assert !s.valid? |
261 | 261 | s.content = "<p>Test</p>" |
... | ... | @@ -272,7 +272,7 @@ class ScrapTest < ActiveSupport::TestCase |
272 | 272 | end |
273 | 273 | |
274 | 274 | should 'scrap wall url be the root scrap receiver url if it is a reply' do |
275 | - p1, p2 = fast_create(Person), fast_create(Person) | |
275 | + p1, p2 = create_user.person, create_user.person | |
276 | 276 | r = create Scrap, :sender => p1, :receiver => p2, :content => "Hello!" |
277 | 277 | s = build Scrap, :sender => p2, :receiver => p1, :content => "Hi!" |
278 | 278 | r.replies << s; s.reload |
... | ... | @@ -280,13 +280,13 @@ class ScrapTest < ActiveSupport::TestCase |
280 | 280 | end |
281 | 281 | |
282 | 282 | should 'scrap wall url be the scrap receiver url if it is not a reply' do |
283 | - p1, p2 = fast_create(Person), fast_create(Person) | |
283 | + p1, p2 = create_user.person, create_user.person | |
284 | 284 | s = create Scrap, :sender => p1, :receiver => p2, :content => "Hello!" |
285 | 285 | assert_equal s.scrap_wall_url, s.receiver.wall_url |
286 | 286 | end |
287 | 287 | |
288 | 288 | should 'create activity with reply_scrap_on_self when top_root scrap receiver is the same as sender' do |
289 | - s, r = fast_create(Person), fast_create(Person) | |
289 | + s, r = create_user.person, create_user.person | |
290 | 290 | root = fast_create(Scrap, :sender_id => s.id, :receiver_id => r.id) |
291 | 291 | assert_difference 'ActionTracker::Record.count', 1 do |
292 | 292 | reply = create(Scrap, :sender => r, :receiver => s, :scrap_id => root.id, :content => 'sample') | ... | ... |