Add latest added tracks list on the home page
This commit is contained in:
@@ -7,5 +7,12 @@ describe HomeController do
|
||||
get :index
|
||||
assigns[:playlists].should == [playlist]
|
||||
end
|
||||
|
||||
it 'assigns latest tracks as @tracks' do
|
||||
track1 = Factory.create(:track, :created_at => '2011-07-27 19:13:42')
|
||||
track2 = Factory.create(:track, :created_at => '2011-07-27 19:58:57')
|
||||
get :index
|
||||
assigns[:tracks].should == Track.latest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -56,4 +56,12 @@ describe Track do
|
||||
`rm -f #{Rails.root}/data/tracks/*`
|
||||
end
|
||||
end
|
||||
|
||||
describe '.latest' do
|
||||
it 'returns latest tracks in descending creation date order' do
|
||||
track1 = Factory.create(:track, :created_at => '2011-07-27 19:13:42')
|
||||
track2 = Factory.create(:track, :created_at => '2011-07-27 19:58:57')
|
||||
Track.latest.should == [track2, track1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -5,6 +5,9 @@ describe 'home/index.html.haml' do
|
||||
assign :playlists, [
|
||||
mock_model('Playlist', :name => 'Electro')
|
||||
]
|
||||
assign :tracks, [
|
||||
mock_model('Track', :name => 'Mega song')
|
||||
]
|
||||
end
|
||||
|
||||
it 'displays a list of playlists' do
|
||||
@@ -16,4 +19,9 @@ describe 'home/index.html.haml' do
|
||||
render
|
||||
rendered.should have_selector('a', :text => 'Add a track')
|
||||
end
|
||||
|
||||
it 'displays a list of tracks' do
|
||||
render
|
||||
rendered.should have_selector('ul>li', :text => 'Mega song')
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user