Associate a user to his playlists
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :playlist do
|
||||
name 'Electro'
|
||||
association :user
|
||||
end
|
||||
|
||||
factory :track do
|
||||
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
||||
|
||||
describe Playlist do
|
||||
subject { playlist }
|
||||
let(:playlist) { Factory.build(:playlist) }
|
||||
let(:playlist) { Factory.build(:playlist) }
|
||||
|
||||
context 'with valid attributes' do
|
||||
it { should be_valid }
|
||||
@@ -15,4 +15,20 @@ describe Playlist do
|
||||
|
||||
it { should_not be_valid }
|
||||
end
|
||||
|
||||
context 'without user_id' do
|
||||
before do
|
||||
playlist.user = nil
|
||||
end
|
||||
|
||||
it { should_not be_valid }
|
||||
end
|
||||
|
||||
describe '#user' do
|
||||
it 'returns the user who created the playlist' do
|
||||
user = Factory.create(:user)
|
||||
playlist = user.playlists.build(Factory.attributes_for(:playlist))
|
||||
playlist.user.should == user
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user