Remove controllers spec already tested elsewhere
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
describe 'API sign in' do
|
||||
let(:user) { FactoryGirl.create(:user) }
|
||||
include AcceptanceHelpers
|
||||
|
||||
let(:user) { create :user }
|
||||
|
||||
def do_create
|
||||
post api_sessions_path, format: :json, session: {
|
||||
@@ -11,17 +13,20 @@ describe 'API sign in' do
|
||||
it 'signs the user in with valid credentials' do
|
||||
do_create
|
||||
|
||||
expect(response).to be_success
|
||||
expect(JSON response.body).to include 'id'
|
||||
expect(json).to eq({
|
||||
id: user.id
|
||||
})
|
||||
end
|
||||
|
||||
[:email, :password].each do |attr|
|
||||
it "rejects authentication with invalid credentials (#{attr})" do
|
||||
allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID')
|
||||
do_create
|
||||
context "with invalid #{attr}" do
|
||||
it 'rejects authentication' do
|
||||
allow(user).to receive(attr).and_return(user.send(attr) + '_INVALID')
|
||||
do_create
|
||||
|
||||
expect(response).to be_not_found
|
||||
expect(response.body).to be_empty
|
||||
expect(response).to be_not_found
|
||||
expect(response.body).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -3,16 +3,27 @@ describe 'API playlists' do
|
||||
|
||||
before { api_sign_in }
|
||||
|
||||
it 'creates playlist' do
|
||||
playlist = FactoryGirl.attributes_for :playlist
|
||||
it 'lists playlists' do
|
||||
playlist = create :playlist
|
||||
get api_playlists_path, format: json
|
||||
|
||||
post_via_redirect api_playlists_path,
|
||||
expect(json).to match [
|
||||
a_hash_including(
|
||||
id: an_instance_of(Fixnum),
|
||||
name: playlist[:name]
|
||||
)
|
||||
]
|
||||
end
|
||||
|
||||
it 'creates playlist' do
|
||||
playlist = attributes_for :playlist
|
||||
post api_playlists_path,
|
||||
format: :json,
|
||||
playlist: playlist
|
||||
|
||||
json = JSON response.body
|
||||
|
||||
expect(json['id']).to be_a Fixnum
|
||||
expect(json['name']).to eq playlist[:name]
|
||||
expect(json).to match(
|
||||
id: an_instance_of(Fixnum),
|
||||
name: playlist[:name]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@@ -4,21 +4,20 @@ describe 'API tracks' do
|
||||
before { api_sign_in }
|
||||
|
||||
it 'lists tracks' do
|
||||
track_1 = FactoryGirl.create(:track_with_sound, name: 'Track 1')
|
||||
track_2 = FactoryGirl.create(:track, name: 'Track 2')
|
||||
|
||||
track_1 = create :track_with_sound, name: 'Track 1'
|
||||
track_2 = create :track, name: 'Track 2'
|
||||
get api_tracks_path, format: :json
|
||||
|
||||
expect(response.body).to eq [
|
||||
expect(json).to eq [
|
||||
{
|
||||
id: track_1.id,
|
||||
name: 'Track 1',
|
||||
sound_url: api_sound_url(track_1.sound)
|
||||
id: track_1.id,
|
||||
name: 'Track 1',
|
||||
sound_url: api_sound_url(track_1.sound)
|
||||
},
|
||||
{
|
||||
id: track_2.id,
|
||||
name: 'Track 2'
|
||||
id: track_2.id,
|
||||
name: 'Track 2'
|
||||
}
|
||||
].to_json
|
||||
]
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user