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