Add home page with playlists list and link to add a track

This commit is contained in:
Thibault Jouan 2011-07-27 19:34:59 +00:00
parent d452dde3ea
commit b39bc2d6da
9 changed files with 52 additions and 7 deletions

View File

@ -0,0 +1,5 @@
class HomeController < ApplicationController
def index
@playlists = Playlist.all
end
end

View File

@ -0,0 +1,4 @@
= link_to 'Add a track', new_track_path
%ul
- @playlists.each do |p|
%li= p.name

View File

@ -1,5 +1,4 @@
= link_to 'Create playlist', new_playlist_path
= link_to 'Add a track', new_track_path
%ul
- @playlists.each do |p|
%li

View File

@ -3,4 +3,6 @@ Scube::Application.routes.draw do
get 'stream', :on => :member
end
resources :playlists
root :to => 'home#index'
end

10
features/home.feature Normal file
View File

@ -0,0 +1,10 @@
Feature: Home
So that I can use scube efficiently
As a listener
I want to access the main features and valuable content from the homepage
Scenario: Playlist access
Given a playlist named "Electro"
When I am on the home page
Then I should see "Electro" within "ul>li"

View File

@ -10,7 +10,7 @@ Feature: Tracks
Then I should see "Mega song" within "h1"
Scenario: Create track
Given I am on the playlists page
Given I am on the home page
When I follow "Add a track"
And I fill in "Name" with "Mega song"
And I attach the file "features/fixtures/test.mp3" to "File"

View File

@ -0,0 +1,11 @@
require 'spec_helper'
describe HomeController do
describe 'GET index' do
it 'assigns all playlists as @playlists' do
playlist = Factory.create(:playlist)
get :index
assigns[:playlists].should == [playlist]
end
end
end

View File

@ -0,0 +1,19 @@
require 'spec_helper'
describe 'home/index.html.haml' do
before do
assign :playlists, [
mock_model('Playlist', :name => 'Electro')
]
end
it 'displays a list of playlists' do
render
rendered.should have_selector('ul>li', :text => 'Electro')
end
it 'displays a link to add a track' do
render
rendered.should have_selector('a', :text => 'Add a track')
end
end

View File

@ -21,9 +21,4 @@ describe 'playlists/index.html.haml' do
render
rendered.should have_selector('a', :text => 'Electro')
end
it 'displays a link to create a new track' do
render
rendered.should have_selector('a', :text => 'Add a track')
end
end