Created
January 20, 2011 20:38
-
-
Save DGaffney/788605 to your computer and use it in GitHub Desktop.
This is done in various files (click_tag_test,favorite_tag_test,etc...) and could be more dry....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Basically, across five different files, we have: | |
| #Model here is one of these: [Click,Favorite,Friendship,Reply,Retweet] | |
| test "create should record model tags" do | |
| ad, user = ads(:sample), users(:sample) | |
| assert_kind_of Fitness, ALGORITHM.calculate_fitness_for(ad, user) | |
| assert some_crap | |
| assert_difference('ModelTag.count'){ Model.create!(models(:sample).attributes) } | |
| end | |
| test "create should not record model tags if no common tags" do | |
| ad, user = ads(:sample), users(:sample) | |
| ad.tags = [] | |
| ad.save(false) | |
| assert some_crap | |
| assert_no_difference('ModelTag.count'){ Model.create!(models(:sample).attributes) } | |
| end | |
| #you could pass in the model like that, and call it by either model.to_s or model.classify.constantize (depending on how its set up) | |
| #but the real issue is the models(:sample) bit, where i'm not sure how to call that "models" bit dynamically to make this work. | |
| #a send seems incorrect, because it is a method of an object, whereas this is a global local variable? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment