test/services/recommender_test.rb in meducation_sdk-1.6.5 vs test/services/recommender_test.rb in meducation_sdk-1.6.6

- old
+ new

@@ -92,10 +92,11 @@ Net::HTTP.expects(:get_response).returns(mock(body: json)) MediaFile.expects(:where).with({id: [item.id, item2.id]}).returns([item, item2]) good_resources = mock MediaFile.expects(:where).with('rating > 2').returns(@per_result) + @per_result.expects(:where).with(safe_for_email: true).returns(@per_result) items = Recommender.new(item, limit: limit).recommend assert_equal [item, item2, item3], items end def test_should_limit_correctly @@ -111,27 +112,28 @@ @per_result.expects(:per).with(5).returns(@per_result) @per_result.stubs(to_a: [item3]) Net::HTTP.expects(:get_response).raises(StandardError) MeducationSDK.config.logger.expects(:error).with("!!Recommender Error!!") MeducationSDK.config.logger.expects(:error).with("StandardError") - MediaFile.stubs(:where).with('rating > 2').returns(@per_result) + MediaFile.expects(:where).with('rating > 2').returns(@per_result) Recommender.new(item).recommend end def test_should_get_good_resources_if_error_from_recommender @per_result.expects(:per).with(5).returns(@per_result) @per_result.stubs(to_a: [item3]) Net::HTTP.expects(:get_response).raises(StandardError) - MediaFile.stubs(:where).with('rating > 2').returns(@per_result) + MediaFile.expects(:where).with('rating > 2').returns(@per_result) items = Recommender.new(item).recommend assert_equal [item3], items end def test_should_get_good_resources_if_error_from_recommender @per_result.expects(:per).with(5).returns(@per_result) @per_result.stubs(to_a: [item3]) Net::HTTP.expects(:get_response).raises(StandardError) - MediaFile.stubs(:where).with('rating > 2').returns(@per_result) + MediaFile.expects(:where).with('rating > 2').returns(@per_result) + @per_result.expects(:where).with(safe_for_email: true).returns(@per_result) items = Recommender.new(item).recommend assert_equal [item3], items end def test_should_catch_an_exception_and_render_backup_recommendations