Improve tracks CRUD

* Add index, edit and update action;
* Add _form partial;
* Add link to tracks/index in nav;
* Refactor specs.
This commit is contained in:
Thibault Jouan
2015-05-01 12:09:29 +00:00
parent e1c8a6038d
commit 5e1757aff9
9 changed files with 70 additions and 25 deletions

View File

@@ -4,22 +4,24 @@ feature 'Tracks CRUD' do
background { sign_in }
scenario 'shows track' do
track = FactoryGirl.create(:track, name: 'Mega song')
track = create_track
visit tracks_path
visit track_path(track)
click_link track[:name]
expect(page).to have_content 'Mega song'
expect(page).to have_content track[:name]
end
scenario 'creates track' do
visit root_path
scenario 'edits track' do
track = create_track
visit tracks_path
click_link 'Add a track'
fill_in 'Name', with: 'Mega song'
attach_file 'File', File.expand_path('spec/fixtures/test.mp3')
click_button 'Upload'
click_link track[:name]
click_link 'Edit'
fill_in 'Name', with: 'new track name'
click_button 'Save'
expect(current_path).to eq track_path Track.first
expect(page).to have_content 'Mega song'
expect(current_path).to eq tracks_path
expect(page).to have_content 'new track name'
end
end

View File

@@ -24,4 +24,13 @@ module AcceptanceHelpers
click_button 'Create'
playlist
end
def create_track
track = attributes_for :track
visit tracks_path
click_link 'Create track'
fill_in 'Name', with: track[:name]
click_button 'Upload'
track
end
end