From 686162e27059916b265540b569f2a4b7ba31292e Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Thu, 22 Sep 2011 19:56:20 +0000 Subject: [PATCH] Fix playlists controller specs for POST create action --- spec/controllers/playlists_controller_spec.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/controllers/playlists_controller_spec.rb b/spec/controllers/playlists_controller_spec.rb index 49c5799..f35db90 100644 --- a/spec/controllers/playlists_controller_spec.rb +++ b/spec/controllers/playlists_controller_spec.rb @@ -29,15 +29,19 @@ describe PlaylistsController do end describe 'POST create' do + def do_create + post :create, :playlist => Factory.attributes_for(:playlist) + end + context 'whith valid params' do - it 'creates a new playlist' do + it 'creates a new playlist for the current user' do expect { - post :create, :playlist => Factory.attributes_for(:playlist) - }.to change(Playlist, :count).by(1) + do_create + }.to change(controller.current_user.playlists, :count).by(1) end it 'redirects to the playlists index' do - post :create, :playlist => Factory.attributes_for(:playlist) + do_create response.should redirect_to(:action => 'index') end end @@ -46,12 +50,12 @@ describe PlaylistsController do before { Playlist.any_instance.stub(:save).and_return(false) } it 'assigns the playlist as @playlist' do - post :create, :playlist => {} + do_create assigns[:playlist].should be_a_new(Playlist) end it 'renders the new template' do - post :create, :playlist => {} + do_create response.should render_template('new') end end