Add home page with playlists list and link to add a track
This commit is contained in:
parent
d452dde3ea
commit
b39bc2d6da
5
app/controllers/home_controller.rb
Normal file
5
app/controllers/home_controller.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class HomeController < ApplicationController
|
||||
def index
|
||||
@playlists = Playlist.all
|
||||
end
|
||||
end
|
4
app/views/home/index.html.haml
Normal file
4
app/views/home/index.html.haml
Normal file
@ -0,0 +1,4 @@
|
||||
= link_to 'Add a track', new_track_path
|
||||
%ul
|
||||
- @playlists.each do |p|
|
||||
%li= p.name
|
@ -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
|
||||
|
@ -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
10
features/home.feature
Normal 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"
|
@ -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"
|
||||
|
11
spec/controllers/home_controller_spec.rb
Normal file
11
spec/controllers/home_controller_spec.rb
Normal 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
|
19
spec/views/home/index.html.haml_spec.rb
Normal file
19
spec/views/home/index.html.haml_spec.rb
Normal 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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user