Skip to content

Instantly share code, notes, and snippets.

@DGaffney
Created January 20, 2011 20:38
Show Gist options
  • Save DGaffney/788605 to your computer and use it in GitHub Desktop.
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....
#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