This repository was archived by the owner on Apr 24, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
refactoring_external_service Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,6 @@ def video_list
5151 def monthlyViews ( views , publishing_date )
5252 days_available = Date . today - Date . parse ( publishing_date )
5353 return views if days_available < 30
54- views * 365.0 / days_available / 12
54+ ( views * 365 / days_available / 12 ) . to_i
5555 end
5656end
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def test_when_views_unchanged_for_one_month
4646 expected = video_repo_response
4747 assert_equal ( expected [ 0 ] [ 'youtubeID' ] , actual [ 0 ] [ 'youtubeID' ] )
4848 assert_equal ( expected [ 0 ] [ 'views' ] , actual [ 0 ] [ 'views' ] )
49- assert_in_delta ( expected [ 0 ] [ 'monthlyViews' ] , actual [ 0 ] [ 'monthlyViews' ] , 0.1 )
49+ assert_equal ( expected [ 0 ] [ 'monthlyViews' ] , actual [ 0 ] [ 'monthlyViews' ] )
5050 end
5151
5252 def test_when_less_than_thirty_days_have_passed
@@ -87,7 +87,9 @@ def test_when_sixty_days_have_passed_since_publishing
8787 video_client : YoutubeVideoClientStub . new ( youtube_client_response )
8888 )
8989 actual = JSON . parse ( video_service . video_list )
90- assert_equal ( 10 , actual [ 0 ] [ 'views' ] )
91- assert_equal ( 5 , actual [ 0 ] [ 'monthlyViews' ] )
90+ assert_equal ( 10 , actual [ 0 ] [ 'views' ] , 'Total Views' )
91+ # I'm making another assumption here that fractional views don't really count for anything
92+ # So monthly views should always be integers.
93+ assert_equal ( 5 , actual [ 0 ] [ 'monthlyViews' ] , 'Monthly Views' )
9294 end
9395end
You can’t perform that action at this time.
0 commit comments