Commit 2140347ff544fc132b764be5d6feefd1459a1440
1 parent
59b7885c
Exists in
staging
and in
42 other branches
Added tests
Showing
1 changed file
with
37 additions
and
1 deletions
Show diff stats
test/unit/community_test.rb
| ... | ... | @@ -341,5 +341,41 @@ class CommunityTest < ActiveSupport::TestCase |
| 341 | 341 | assert_equal false, community.receives_scrap_notification? |
| 342 | 342 | end |
| 343 | 343 | |
| 344 | - should 'return tracked_actions and scraps as activities' | |
| 344 | + should 'return scraps as activities' do | |
| 345 | + person = fast_create(Person) | |
| 346 | + community = fast_create(Community) | |
| 347 | + | |
| 348 | + scrap = Scrap.create!(defaults_for_scrap(:sender => person, :receiver => community, :content => 'A scrap')) | |
| 349 | + activity = ActionTracker::Record.last | |
| 350 | + | |
| 351 | + assert_equal 'An article about free software', activity.get_name.last | |
| 352 | + assert_equal [scrap,activity], person.activities.map { |a| a.klass.constantize.find(a.id) } | |
| 353 | + end | |
| 354 | + | |
| 355 | + should 'return tracked_actions as activities' do | |
| 356 | + person = fast_create(Person) | |
| 357 | + another_person = fast_create(Person) | |
| 358 | + | |
| 359 | + scrap = Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => person, :content => 'A scrap')) | |
| 360 | + UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once | |
| 361 | + TinyMceArticle.create!(:profile => person, :name => 'An article about free software') | |
| 362 | + activity = ActionTracker::Record.last | |
| 363 | + | |
| 364 | + assert_equal 'An article about free software', activity.get_name.last | |
| 365 | + assert_equal [scrap,activity], person.activities.map { |a| a.klass.constantize.find(a.id) } | |
| 366 | + end | |
| 367 | + | |
| 368 | + should 'return articles published on communities as activities' do | |
| 369 | + person = fast_create(Person) | |
| 370 | + another_person = fast_create(Person) | |
| 371 | + | |
| 372 | + scrap = Scrap.create!(defaults_for_scrap(:sender => another_person, :receiver => person, :content => 'A scrap')) | |
| 373 | + UserStampSweeper.any_instance.expects(:current_user).returns(person).at_least_once | |
| 374 | + TinyMceArticle.create!(:profile => person, :name => 'An article about free software') | |
| 375 | + activity = ActionTracker::Record.last | |
| 376 | + | |
| 377 | + assert_equal 'An article about free software', activity.get_name.last | |
| 378 | + assert_equal [scrap,activity], person.activities.map { |a| a.klass.constantize.find(a.id) } | |
| 379 | + end | |
| 380 | + | |
| 345 | 381 | end | ... | ... |