spec/models/user_spec.rb in recommendable-0.1.5 vs spec/models/user_spec.rb in recommendable-0.1.6

- old
+ new

@@ -4,10 +4,38 @@ # User and Bully are skeleton classes defined in the dummy application for # the sole purpose of running these tests. They're in spec/dummy/models/ but # really, there's nothing there of note. describe User do + describe "before_destroy filters" do + before :each do + Recommendable.redis.flushdb + @user1 = Factory(:user) + @user2 = Factory(:user) + @movie1 = Factory(:movie) + @movie2 = Factory(:movie) + end + + it "should no longer be involved in similarities or predictions" do + @user1.like @movie1 + @user1.like @movie2 + @user2.like @movie1 + + @user1.send :update_similarities + @user2.send :update_similarities + @user2.send :update_recommendations + + similarity_set = @user2.send :similarity_set + predictions_set = @user2.send :predictions_set_for, Movie + @user2.destroy + + @user1.similar_raters.wont_include @user2 + Recommendable.redis.get(similarity_set).must_be_nil + Recommendable.redis.get(predictions_set).must_be_nil + end + end + describe "that does not act_as_recommendable" do before :each do @user = Factory(:bully) @movie = Factory(:movie) end @@ -233,10 +261,10 @@ @frank.like(@movie2) @dave.send :update_similarities @dave.send :update_recommendations @dave.similar_raters.must_include @frank - @dave.recommendations_for(Movie).must_include @movie2 + @dave.recommended_movies.must_include @movie2 end it "should order similar users by similarity" do @dave.like(@movie1) @dave.like(@movie2)