Use ruby 2.x hash syntax
This commit is contained in:
parent
712e9501a2
commit
da96c4814a
@ -1,4 +1,4 @@
|
|||||||
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
|
guard 'spork', rspec_env: { RAILS_ENV: 'test' } do
|
||||||
watch('config/application.rb')
|
watch('config/application.rb')
|
||||||
watch('config/environment.rb')
|
watch('config/environment.rb')
|
||||||
watch('config/routes.rb')
|
watch('config/routes.rb')
|
||||||
@ -8,7 +8,7 @@ guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
|
|||||||
watch(%r{^spec/support/.+\.rb$})
|
watch(%r{^spec/support/.+\.rb$})
|
||||||
end
|
end
|
||||||
|
|
||||||
guard 'rspec', :cmd => 'bundle exec rspec --drb -f doc' do
|
guard 'rspec', cmd: 'bundle exec rspec --drb -f doc' do
|
||||||
watch(%r{^spec/.+_spec\.rb$})
|
watch(%r{^spec/.+_spec\.rb$})
|
||||||
|
|
||||||
watch('spec/spec_helper.rb') { 'spec' }
|
watch('spec/spec_helper.rb') { 'spec' }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class API::ApplicationController < ApplicationController
|
class API::ApplicationController < ApplicationController
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_filter :verify_authenticity_token
|
||||||
skip_before_filter :authenticate!, :only => [:cor_preflight]
|
skip_before_filter :authenticate!, only: [:cor_preflight]
|
||||||
|
|
||||||
before_filter :cor_filter
|
before_filter :cor_filter
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
class API::SessionsController < API::ApplicationController
|
class API::SessionsController < API::ApplicationController
|
||||||
skip_before_filter :authenticate!, :only => [:create]
|
skip_before_filter :authenticate!, only: [:create]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
user = User.find_by_email(params[:session][:email])
|
user = User.find_by_email(params[:session][:email])
|
||||||
|
|
||||||
if ! user.try(:authenticate?, params[:session][:password])
|
if ! user.try(:authenticate?, params[:session][:password])
|
||||||
return render :json => '', :status => :not_found
|
return render json: '', status: :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
@user = user
|
@user = user
|
||||||
|
@ -2,6 +2,6 @@ class API::SoundsController < API::ApplicationController
|
|||||||
# FIXME: add some tests!
|
# FIXME: add some tests!
|
||||||
def show
|
def show
|
||||||
sound = Sound.find params[:id]
|
sound = Sound.find params[:id]
|
||||||
send_file sound.path, :type => sound.mime_type
|
send_file sound.path, type: sound.mime_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,9 +10,9 @@ class PlaylistsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@playlist = current_user.playlists.build(params[:playlist])
|
@playlist = current_user.playlists.build(params[:playlist])
|
||||||
if @playlist.save
|
if @playlist.save
|
||||||
redirect_to :action => 'index'
|
redirect_to action: 'index'
|
||||||
else
|
else
|
||||||
render :action => 'new'
|
render action: 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -23,9 +23,9 @@ class PlaylistsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
@playlist = Playlist.find(params[:id])
|
@playlist = Playlist.find(params[:id])
|
||||||
if @playlist.update_attributes params[:playlist]
|
if @playlist.update_attributes params[:playlist]
|
||||||
redirect_to :action => 'index'
|
redirect_to action: 'index'
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render action: 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class SessionsController < ApplicationController
|
class SessionsController < ApplicationController
|
||||||
skip_before_filter :authenticate!, :only => [:new, :create]
|
skip_before_filter :authenticate!, only: [:new, :create]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
user = User.find_by_email(params[:session][:email])
|
user = User.find_by_email(params[:session][:email])
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
class SoundsController < ApplicationController
|
class SoundsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
sound = Sound.find params[:id]
|
sound = Sound.find params[:id]
|
||||||
send_file sound.path, :type => sound.mime_type
|
send_file sound.path, type: sound.mime_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
skip_before_filter :authenticate!, :only => [:new, :create]
|
skip_before_filter :authenticate!, only: [:new, :create]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@user = User.new
|
@user = User.new
|
||||||
|
@ -6,7 +6,7 @@ class Track < ActiveRecord::Base
|
|||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
|
|
||||||
def file=(file)
|
def file=(file)
|
||||||
sounds.build({:file => file})
|
sounds.build(file: file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sound
|
def sound
|
||||||
|
@ -9,11 +9,11 @@ class User < ActiveRecord::Base
|
|||||||
has_many :playlists
|
has_many :playlists
|
||||||
|
|
||||||
validates :email,
|
validates :email,
|
||||||
:presence => true,
|
presence: true,
|
||||||
:uniqueness => true
|
uniqueness: true
|
||||||
validates :password,
|
validates :password,
|
||||||
:presence => true,
|
presence: true,
|
||||||
:confirmation => true
|
confirmation: true
|
||||||
validates_presence_of :password_hash
|
validates_presence_of :password_hash
|
||||||
|
|
||||||
def password=(plain_password)
|
def password=(plain_password)
|
||||||
|
@ -3,4 +3,4 @@ collection @tracks
|
|||||||
attribute :id
|
attribute :id
|
||||||
attribute :name
|
attribute :name
|
||||||
|
|
||||||
node(:sound_url, :if => ->(t) { t.sound? }) { |t| api_sound_url t.sound }
|
node(:sound_url, if: ->(t) { t.sound? }) { |t| api_sound_url t.sound }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
!!!
|
!!!
|
||||||
%html
|
%html
|
||||||
%head
|
%head
|
||||||
%meta{:charset => 'utf-8'}
|
%meta{charset: 'utf-8'}
|
||||||
%title scube
|
%title scube
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
%body
|
%body
|
||||||
|
@ -1 +1 @@
|
|||||||
= render 'form', :submit_text => 'Save'
|
= render 'form', submit_text: 'Save'
|
||||||
|
@ -1 +1 @@
|
|||||||
= render 'form', :submit_text => 'Create'
|
= render 'form', submit_text: 'Create'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
= form_for(:session, :url => sessions_path) do |f|
|
= form_for(:session, url: sessions_path) do |f|
|
||||||
%table
|
%table
|
||||||
%tbody
|
%tbody
|
||||||
%tr
|
%tr
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
= form_for @track, :html => { :multipart => true } do |t|
|
= form_for @track, html: { multipart: true } do |t|
|
||||||
%table
|
%table
|
||||||
%tbody
|
%tbody
|
||||||
%tr
|
%tr
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%h1= @track.name
|
%h1= @track.name
|
||||||
|
|
||||||
- if @track.sound?
|
- if @track.sound?
|
||||||
%audio{:src => sound_path(@track.sound), :controls => true, :autoplay => true}
|
%audio{src: sound_path(@track.sound), controls: true, autoplay: true}
|
||||||
Your browser does not support the audio element
|
Your browser does not support the audio element
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
= form_for(@user, :url => users_path) do |f|
|
= form_for(@user, url: users_path) do |f|
|
||||||
- if @user.errors.any?
|
- if @user.errors.any?
|
||||||
%ul
|
%ul
|
||||||
- @user.errors.full_messages.each do |m|
|
- @user.errors.full_messages.each do |m|
|
||||||
|
@ -12,5 +12,5 @@ Rabl.configure do |config|
|
|||||||
# config.include_plist_root = true
|
# config.include_plist_root = true
|
||||||
# config.include_xml_root = false
|
# config.include_xml_root = false
|
||||||
# config.enable_json_callbacks = false
|
# config.enable_json_callbacks = false
|
||||||
# config.xml_options = { :dasherize => true, :skip_types => false }
|
# config.xml_options = { dasherize: true, skip_types: false }
|
||||||
end
|
end
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
Scube::Application.routes.draw do
|
Scube::Application.routes.draw do
|
||||||
namespace :api do
|
namespace :api do
|
||||||
resources :sounds, :only => [:show]
|
resources :sounds, only: [:show]
|
||||||
resources :tracks, :only => [:index]
|
resources :tracks, only: [:index]
|
||||||
resources :playlists, :only => [:index, :create]
|
resources :playlists, only: [:index, :create]
|
||||||
resources :sessions, :only => [:create]
|
resources :sessions, only: [:create]
|
||||||
|
|
||||||
match '*all' => 'application#cor_preflight', :via => :options
|
match '*all' => 'application#cor_preflight', via: :options
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :sounds, :only => [:show]
|
resources :sounds, only: [:show]
|
||||||
|
|
||||||
resources :users, :only => [:new, :create]
|
resources :users, only: [:new, :create]
|
||||||
|
|
||||||
resources :sessions, :only => [:new, :create]
|
resources :sessions, only: [:new, :create]
|
||||||
|
|
||||||
resources :tracks do
|
resources :tracks do
|
||||||
get 'download', :on => :member
|
get 'download', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :playlists
|
resources :playlists
|
||||||
|
|
||||||
root :to => 'home#index'
|
root to: 'home#index'
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ class InitialSchema < ActiveRecord::Migration
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table :sessions do |t|
|
create_table :sessions do |t|
|
||||||
t.string :session_id, :null => false
|
t.string :session_id, null: false
|
||||||
t.text :data
|
t.text :data
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
@ -31,7 +31,7 @@ class InitialSchema < ActiveRecord::Migration
|
|||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index :users, :email, :unique => true
|
add_index :users, :email, unique: true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ describe API::PlaylistsController do
|
|||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
playlist_1 = FactoryGirl.create(:playlist, :name => 'Playlist 1')
|
playlist_1 = FactoryGirl.create(:playlist, name: 'Playlist 1')
|
||||||
playlist_2 = FactoryGirl.create(:playlist, :name => 'Playlist 2')
|
playlist_2 = FactoryGirl.create(:playlist, name: 'Playlist 2')
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_get
|
def do_get
|
||||||
get :index, :format => :json
|
get :index, format: :json
|
||||||
JSON response.body
|
JSON response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -36,8 +36,8 @@ describe API::PlaylistsController do
|
|||||||
describe 'POST create' do
|
describe 'POST create' do
|
||||||
def do_create
|
def do_create
|
||||||
post :create,
|
post :create,
|
||||||
:format => :json,
|
format: :json,
|
||||||
:playlist => FactoryGirl.attributes_for(:playlist)
|
playlist: FactoryGirl.attributes_for(:playlist)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a new playlist for the current user' do
|
it 'creates a new playlist for the current user' do
|
||||||
|
@ -5,9 +5,9 @@ describe API::SessionsController do
|
|||||||
let(:user) { FactoryGirl.create(:user) }
|
let(:user) { FactoryGirl.create(:user) }
|
||||||
|
|
||||||
def do_create
|
def do_create
|
||||||
post :create, :format => :json, :session => {
|
post :create, format: :json, session: {
|
||||||
:email => user.email,
|
email: user.email,
|
||||||
:password => user.password
|
password: user.password
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ describe API::TracksController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def do_get
|
def do_get
|
||||||
get :index, :format => :json
|
get :index, format: :json
|
||||||
JSON response.body
|
JSON response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ describe HomeController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'assigns latest tracks as @tracks' do
|
it 'assigns latest tracks as @tracks' do
|
||||||
track1 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:13:42')
|
track1 = FactoryGirl.create(:track, created_at: '2011-07-27 19:13:42')
|
||||||
track2 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:58:57')
|
track2 = FactoryGirl.create(:track, created_at: '2011-07-27 19:58:57')
|
||||||
get :index
|
get :index
|
||||||
assigns[:tracks].should == Track.latest
|
assigns[:tracks].should == Track.latest
|
||||||
end
|
end
|
||||||
|
@ -25,14 +25,14 @@ describe PlaylistsController do
|
|||||||
describe 'GET edit' do
|
describe 'GET edit' do
|
||||||
it 'assigns the requested playlist as @playlist' do
|
it 'assigns the requested playlist as @playlist' do
|
||||||
playlist = FactoryGirl.create(:playlist)
|
playlist = FactoryGirl.create(:playlist)
|
||||||
get :edit, :id => playlist.id.to_s
|
get :edit, id: playlist.id.to_s
|
||||||
assigns[:playlist].should == playlist
|
assigns[:playlist].should == playlist
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST create' do
|
describe 'POST create' do
|
||||||
def do_create
|
def do_create
|
||||||
post :create, :playlist => FactoryGirl.attributes_for(:playlist)
|
post :create, playlist: FactoryGirl.attributes_for(:playlist)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'whith valid params' do
|
context 'whith valid params' do
|
||||||
@ -44,7 +44,7 @@ describe PlaylistsController do
|
|||||||
|
|
||||||
it 'redirects to the playlists index' do
|
it 'redirects to the playlists index' do
|
||||||
do_create
|
do_create
|
||||||
response.should redirect_to(:action => 'index')
|
response.should redirect_to(action: 'index')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,19 +67,19 @@ describe PlaylistsController do
|
|||||||
let (:playlist) { FactoryGirl.create(:playlist) }
|
let (:playlist) { FactoryGirl.create(:playlist) }
|
||||||
|
|
||||||
def do_update
|
def do_update
|
||||||
put :update, :id => playlist.id.to_s, :playlist => { :name => 'Rock' }
|
put :update, id: playlist.id.to_s, playlist: { name: 'Rock' }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'whith valid params' do
|
context 'whith valid params' do
|
||||||
it 'updates the playlist' do
|
it 'updates the playlist' do
|
||||||
Playlist.any_instance.should_receive(:update_attributes).
|
Playlist.any_instance.should_receive(:update_attributes)
|
||||||
with({'name' => 'Rock'})
|
.with({'name' => 'Rock'})
|
||||||
do_update
|
do_update
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the playlists index' do
|
it 'redirects to the playlists index' do
|
||||||
do_update
|
do_update
|
||||||
response.should redirect_to(:action => 'index')
|
response.should redirect_to(action: 'index')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ describe SessionsController do
|
|||||||
let(:user) { FactoryGirl.create(:user) }
|
let(:user) { FactoryGirl.create(:user) }
|
||||||
|
|
||||||
def do_create
|
def do_create
|
||||||
post :create, :session => {
|
post :create, session: {
|
||||||
:email => user.email,
|
email: user.email,
|
||||||
:password => user.password
|
password: user.password
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ describe SoundsController do
|
|||||||
let(:sound) { FactoryGirl.create(:sound) }
|
let(:sound) { FactoryGirl.create(:sound) }
|
||||||
|
|
||||||
def do_show
|
def do_show
|
||||||
get :show, :id => sound.id
|
get :show, id: sound.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the sound file content as the response body' do
|
it 'sets the sound file content as the response body' do
|
||||||
do_show
|
do_show
|
||||||
response.body.should == File.read(sound.path, :encoding => 'BINARY')
|
response.body.should == File.read(sound.path, encoding: 'BINARY')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets the sound mime-type as the response content-type' do
|
it 'sets the sound mime-type as the response content-type' do
|
||||||
|
@ -10,7 +10,7 @@ describe TracksController do
|
|||||||
describe 'GET show' do
|
describe 'GET show' do
|
||||||
it 'assigns the requested track as @track' do
|
it 'assigns the requested track as @track' do
|
||||||
track = FactoryGirl.create(:track)
|
track = FactoryGirl.create(:track)
|
||||||
get :show, :id => track.id.to_s
|
get :show, id: track.id.to_s
|
||||||
assigns[:track].should == track
|
assigns[:track].should == track
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -24,8 +24,8 @@ describe TracksController do
|
|||||||
|
|
||||||
describe 'POST create new' do
|
describe 'POST create new' do
|
||||||
def do_create
|
def do_create
|
||||||
post :create, :track => FactoryGirl.attributes_for(:track).merge({
|
post :create, track: FactoryGirl.attributes_for(:track).merge({
|
||||||
:file => fixture_file_upload(
|
file: fixture_file_upload(
|
||||||
"#{Rails.root}/spec/fixtures/test.mp3",
|
"#{Rails.root}/spec/fixtures/test.mp3",
|
||||||
'audio/mpeg'
|
'audio/mpeg'
|
||||||
)
|
)
|
||||||
|
@ -12,17 +12,17 @@ describe UsersController do
|
|||||||
context 'whith valid params' do
|
context 'whith valid params' do
|
||||||
it 'creates a new user' do
|
it 'creates a new user' do
|
||||||
expect {
|
expect {
|
||||||
post :create, :user => FactoryGirl.attributes_for(:user)
|
post :create, user: FactoryGirl.attributes_for(:user)
|
||||||
}.to change(User, :count).by(1)
|
}.to change(User, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'signs the user in' do
|
it 'signs the user in' do
|
||||||
post :create, :user => FactoryGirl.attributes_for(:user)
|
post :create, user: FactoryGirl.attributes_for(:user)
|
||||||
controller.current_user.should_not be_nil
|
controller.current_user.should_not be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'redirects to the home page' do
|
it 'redirects to the home page' do
|
||||||
post :create, :user => FactoryGirl.attributes_for(:user)
|
post :create, user: FactoryGirl.attributes_for(:user)
|
||||||
response.should redirect_to(:root)
|
response.should redirect_to(:root)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -31,12 +31,12 @@ describe UsersController do
|
|||||||
before { User.any_instance.stub(:save).and_return(false) }
|
before { User.any_instance.stub(:save).and_return(false) }
|
||||||
|
|
||||||
it 'assigns the user as @user' do
|
it 'assigns the user as @user' do
|
||||||
post :create, :user => {}
|
post :create, user: {}
|
||||||
assigns[:user].should be_a_new(User)
|
assigns[:user].should be_a_new(User)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders the new template' do
|
it 'renders the new template' do
|
||||||
post :create, :user => {}
|
post :create, user: {}
|
||||||
response.should render_template('new')
|
response.should render_template('new')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
def build_sound_file
|
def build_sound_file
|
||||||
file = File.new("#{Rails.root}/spec/fixtures/test.mp3")
|
file = File.new("#{Rails.root}/spec/fixtures/test.mp3")
|
||||||
file.stub(:content_type => 'audio/mpeg')
|
file.stub(content_type: 'audio/mpeg')
|
||||||
file
|
file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ feature 'Home page' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'displays playlists' do
|
scenario 'displays playlists' do
|
||||||
playlist = FactoryGirl.create(:playlist, :name => 'Electro')
|
playlist = FactoryGirl.create(:playlist, name: 'Electro')
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
@ -17,12 +17,12 @@ feature 'Home page' do
|
|||||||
|
|
||||||
scenario 'displays last track added' do
|
scenario 'displays last track added' do
|
||||||
FactoryGirl.create(:track,
|
FactoryGirl.create(:track,
|
||||||
:name => 'Mega song 1',
|
name: 'Mega song 1',
|
||||||
:created_at => '2011-07-27 19:13:42'
|
created_at: '2011-07-27 19:13:42'
|
||||||
)
|
)
|
||||||
FactoryGirl.create(:track,
|
FactoryGirl.create(:track,
|
||||||
:name => 'Mega song 2',
|
name: 'Mega song 2',
|
||||||
:created_at => '2011-07-27 19:58:57'
|
created_at: '2011-07-27 19:58:57'
|
||||||
)
|
)
|
||||||
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
@ -8,8 +8,8 @@ feature 'Playlists' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'lists playlists' do
|
scenario 'lists playlists' do
|
||||||
FactoryGirl.create(:playlist, :name => 'Electro')
|
FactoryGirl.create(:playlist, name: 'Electro')
|
||||||
FactoryGirl.create(:playlist, :name => 'Reggae')
|
FactoryGirl.create(:playlist, name: 'Reggae')
|
||||||
|
|
||||||
visit playlists_path
|
visit playlists_path
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ feature 'Playlists' do
|
|||||||
visit playlists_path
|
visit playlists_path
|
||||||
|
|
||||||
click_link 'Create playlist'
|
click_link 'Create playlist'
|
||||||
fill_in 'Name', :with => 'Electro'
|
fill_in 'Name', with: 'Electro'
|
||||||
click_button 'Create'
|
click_button 'Create'
|
||||||
|
|
||||||
current_path.should == playlists_path
|
current_path.should == playlists_path
|
||||||
@ -28,11 +28,11 @@ feature 'Playlists' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'edits playlist' do
|
scenario 'edits playlist' do
|
||||||
FactoryGirl.create(:playlist, :name => 'Electro')
|
FactoryGirl.create(:playlist, name: 'Electro')
|
||||||
visit playlists_path
|
visit playlists_path
|
||||||
|
|
||||||
click_link 'Electro'
|
click_link 'Electro'
|
||||||
fill_in 'Name', :with => 'Rock'
|
fill_in 'Name', with: 'Rock'
|
||||||
click_button 'Save'
|
click_button 'Save'
|
||||||
|
|
||||||
current_path.should == playlists_path
|
current_path.should == playlists_path
|
||||||
|
@ -8,7 +8,7 @@ feature 'Tracks' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'shows track' do
|
scenario 'shows track' do
|
||||||
track = FactoryGirl.create(:track, :name => 'Mega song')
|
track = FactoryGirl.create(:track, name: 'Mega song')
|
||||||
|
|
||||||
visit track_path(track)
|
visit track_path(track)
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ feature 'Tracks' do
|
|||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
click_link 'Add a track'
|
click_link 'Add a track'
|
||||||
fill_in 'Name', :with => 'Mega song'
|
fill_in 'Name', with: 'Mega song'
|
||||||
attach_file 'File', File.expand_path('spec/fixtures/test.mp3')
|
attach_file 'File', File.expand_path('spec/fixtures/test.mp3')
|
||||||
click_button 'Upload'
|
click_button 'Upload'
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ feature 'User sign in' do
|
|||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
|
|
||||||
visit new_session_path
|
visit new_session_path
|
||||||
fill_in 'Email', :with => user.email
|
fill_in 'Email', with: user.email
|
||||||
fill_in 'Password', :with => user.password
|
fill_in 'Password', with: user.password
|
||||||
click_button 'Sign in'
|
click_button 'Sign in'
|
||||||
|
|
||||||
current_path.should == root_path
|
current_path.should == root_path
|
||||||
|
@ -5,9 +5,9 @@ feature 'User sign up' do
|
|||||||
|
|
||||||
background do
|
background do
|
||||||
visit new_user_path
|
visit new_user_path
|
||||||
fill_in 'Email', :with => user.email
|
fill_in 'Email', with: user.email
|
||||||
fill_in 'Password', :with => user.password
|
fill_in 'Password', with: user.password
|
||||||
fill_in 'Password confirmation', :with => user.password
|
fill_in 'Password confirmation', with: user.password
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'creates the user' do
|
scenario 'creates the user' do
|
||||||
|
@ -4,9 +4,9 @@ feature 'API sign in' do
|
|||||||
let(:user) { FactoryGirl.create(:user) }
|
let(:user) { FactoryGirl.create(:user) }
|
||||||
|
|
||||||
def do_create
|
def do_create
|
||||||
post api_sessions_path, :format => :json, :session => {
|
post api_sessions_path, format: :json, session: {
|
||||||
:email => user.email,
|
email: user.email,
|
||||||
:password => user.password
|
password: user.password
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ feature 'API cross origin request' do
|
|||||||
let(:origin) { 'http://origin.example/' }
|
let(:origin) { 'http://origin.example/' }
|
||||||
|
|
||||||
background do
|
background do
|
||||||
post sessions_path, :session => {
|
post sessions_path, session: {
|
||||||
:email => user.email,
|
email: user.email,
|
||||||
:password => user.password
|
password: user.password
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ feature 'API cross origin request' do
|
|||||||
@integration_session.send(
|
@integration_session.send(
|
||||||
:process,
|
:process,
|
||||||
:options,
|
:options,
|
||||||
api_playlists_path(:format => :json),
|
api_playlists_path(format: :json),
|
||||||
nil,
|
nil,
|
||||||
{ 'Origin' => origin }
|
{ 'Origin' => origin }
|
||||||
)
|
)
|
||||||
@ -32,7 +32,7 @@ feature 'API cross origin request' do
|
|||||||
|
|
||||||
scenario 'basic request' do
|
scenario 'basic request' do
|
||||||
# FIXME: replace with a more stable/generic action
|
# FIXME: replace with a more stable/generic action
|
||||||
get api_playlists_path(:format => :json), nil, {
|
get api_playlists_path(format: :json), nil, {
|
||||||
'Origin' => origin
|
'Origin' => origin
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ feature 'API cross origin request' do
|
|||||||
|
|
||||||
scenario 'request without origin' do
|
scenario 'request without origin' do
|
||||||
# FIXME: replace with a more stable/generic action
|
# FIXME: replace with a more stable/generic action
|
||||||
get api_playlists_path(:format => :json)
|
get api_playlists_path(format: :json)
|
||||||
|
|
||||||
response.headers['Access-Control-Allow-Origin'].should == ''
|
response.headers['Access-Control-Allow-Origin'].should == ''
|
||||||
end
|
end
|
||||||
|
@ -11,8 +11,8 @@ feature 'API playlists' do
|
|||||||
playlist = FactoryGirl.attributes_for :playlist
|
playlist = FactoryGirl.attributes_for :playlist
|
||||||
|
|
||||||
post api_playlists_path,
|
post api_playlists_path,
|
||||||
:format => :json,
|
format: :json,
|
||||||
:playlist => playlist
|
playlist: playlist
|
||||||
|
|
||||||
json = JSON response.body
|
json = JSON response.body
|
||||||
|
|
||||||
|
@ -8,20 +8,20 @@ feature 'API tracks' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'lists tracks' do
|
scenario 'lists tracks' do
|
||||||
track_1 = FactoryGirl.create(:track_with_sound, :name => 'Track 1')
|
track_1 = FactoryGirl.create(:track_with_sound, name: 'Track 1')
|
||||||
track_2 = FactoryGirl.create(:track, :name => 'Track 2')
|
track_2 = FactoryGirl.create(:track, name: 'Track 2')
|
||||||
|
|
||||||
get api_tracks_path, :format => :json
|
get api_tracks_path, format: :json
|
||||||
|
|
||||||
response.body.should == [
|
response.body.should == [
|
||||||
{
|
{
|
||||||
:id => track_1.id,
|
id: track_1.id,
|
||||||
:name => 'Track 1',
|
name: 'Track 1',
|
||||||
:sound_url => api_sound_url(track_1.sound)
|
sound_url: api_sound_url(track_1.sound)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:id => track_2.id,
|
id: track_2.id,
|
||||||
:name => 'Track 2'
|
name: 'Track 2'
|
||||||
}
|
}
|
||||||
].to_json
|
].to_json
|
||||||
end
|
end
|
||||||
|
@ -27,8 +27,8 @@ describe Track do
|
|||||||
describe '#file=' do
|
describe '#file=' do
|
||||||
it 'builds a new related sound with the file' do
|
it 'builds a new related sound with the file' do
|
||||||
sounds = double 'sounds association proxy'
|
sounds = double 'sounds association proxy'
|
||||||
track.stub(:sounds => sounds)
|
track.stub(sounds: sounds)
|
||||||
sounds.should_receive(:build).with({:file => file})
|
sounds.should_receive(:build).with({file: file})
|
||||||
track.file = file
|
track.file = file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -65,8 +65,8 @@ describe Track do
|
|||||||
|
|
||||||
describe '.latest' do
|
describe '.latest' do
|
||||||
it 'returns latest tracks in descending creation date order' do
|
it 'returns latest tracks in descending creation date order' do
|
||||||
track1 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:13:42')
|
track1 = FactoryGirl.create(:track, created_at: '2011-07-27 19:13:42')
|
||||||
track2 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:58:57')
|
track2 = FactoryGirl.create(:track, created_at: '2011-07-27 19:58:57')
|
||||||
Track.latest.should == [track2, track1]
|
Track.latest.should == [track2, track1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,8 +12,8 @@ describe User do
|
|||||||
it { should_not allow_mass_assignment_of :password_hash }
|
it { should_not allow_mass_assignment_of :password_hash }
|
||||||
|
|
||||||
context 'when a user with the same email address already exists' do
|
context 'when a user with the same email address already exists' do
|
||||||
let(:old_user) { FactoryGirl.create(:user, :email => 'unique@example.net') }
|
let(:old_user) { FactoryGirl.create(:user, email: 'unique@example.net') }
|
||||||
subject { FactoryGirl.build(:user, :email => old_user.email) }
|
subject { FactoryGirl.build(:user, email: old_user.email) }
|
||||||
|
|
||||||
it { should_not be_valid }
|
it { should_not be_valid }
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ require 'spec_helper'
|
|||||||
|
|
||||||
describe '/api OPTIONS requests routing' do
|
describe '/api OPTIONS requests routing' do
|
||||||
it 'routes to API::ApplicationController#cor_preflight' do
|
it 'routes to API::ApplicationController#cor_preflight' do
|
||||||
{ :options => '/api/some_route' }.should route_to(
|
{ options: '/api/some_route' }.should route_to(
|
||||||
:controller => 'api/application',
|
controller: 'api/application',
|
||||||
:action => 'cor_preflight',
|
action: 'cor_preflight',
|
||||||
:all => 'some_route'
|
all: 'some_route'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,17 +2,17 @@ module UserIntegrationHelpers
|
|||||||
def sign_in
|
def sign_in
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
visit new_session_path
|
visit new_session_path
|
||||||
fill_in 'Email', :with => user.email
|
fill_in 'Email', with: user.email
|
||||||
fill_in 'Password', :with => user.password
|
fill_in 'Password', with: user.password
|
||||||
click_button('Sign in')
|
click_button('Sign in')
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_sign_in
|
def api_sign_in
|
||||||
user = FactoryGirl.create :user
|
user = FactoryGirl.create :user
|
||||||
|
|
||||||
post api_sessions_path, :format => :json, :session => {
|
post api_sessions_path, format: :json, session: {
|
||||||
:email => user.email,
|
email: user.email,
|
||||||
:password => user.password
|
password: user.password
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,25 +3,25 @@ require 'spec_helper'
|
|||||||
describe 'home/index' do
|
describe 'home/index' do
|
||||||
before do
|
before do
|
||||||
assign :playlists, [
|
assign :playlists, [
|
||||||
mock_model(Playlist, :name => 'Electro')
|
mock_model(Playlist, name: 'Electro')
|
||||||
]
|
]
|
||||||
assign :tracks, [
|
assign :tracks, [
|
||||||
mock_model(Track, :name => 'Mega song')
|
mock_model(Track, name: 'Mega song')
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays a list of playlists' do
|
it 'displays a list of playlists' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('ul>li', :text => 'Electro')
|
rendered.should have_selector('ul>li', text: 'Electro')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays a link to add a track' do
|
it 'displays a link to add a track' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('a', :text => 'Add a track')
|
rendered.should have_selector('a', text: 'Add a track')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays a list of tracks' do
|
it 'displays a list of tracks' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('ul>li', :text => 'Mega song')
|
rendered.should have_selector('ul>li', text: 'Mega song')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,11 +16,11 @@ describe 'playlists/edit' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a text field with a label for the playlists name' do
|
it 'renders a text field with a label for the playlists name' do
|
||||||
playlist.stub(:name => 'Electro')
|
playlist.stub(name: 'Electro')
|
||||||
render
|
render
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
"input[type=text][name='playlist[name]'][value=Electro]"
|
"input[type=text][name='playlist[name]'][value=Electro]"
|
||||||
)
|
)
|
||||||
rendered.should have_selector("label[for=playlist_name]", :text => 'Name')
|
rendered.should have_selector("label[for=playlist_name]", text: 'Name')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,22 +3,22 @@ require 'spec_helper'
|
|||||||
describe 'playlists/index' do
|
describe 'playlists/index' do
|
||||||
before do
|
before do
|
||||||
assign :playlists, [
|
assign :playlists, [
|
||||||
mock_model(Playlist, :name => 'Electro')
|
mock_model(Playlist, name: 'Electro')
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays a list of playlists' do
|
it 'displays a list of playlists' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('ul>li', :text => 'Electro')
|
rendered.should have_selector('ul>li', text: 'Electro')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays a link to create a new playlist' do
|
it 'displays a link to create a new playlist' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('a', :text => 'Create playlist')
|
rendered.should have_selector('a', text: 'Create playlist')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays playlists as links' do
|
it 'displays playlists as links' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('a', :text => 'Electro')
|
rendered.should have_selector('a', text: 'Electro')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,11 +18,11 @@ describe 'playlists/new' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a text field with a label for the playlists name' do
|
it 'renders a text field with a label for the playlists name' do
|
||||||
playlist.stub(:name => 'Electro')
|
playlist.stub(name: 'Electro')
|
||||||
render
|
render
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
"input[type=text][name='playlist[name]'][value=Electro]"
|
"input[type=text][name='playlist[name]'][value=Electro]"
|
||||||
)
|
)
|
||||||
rendered.should have_selector("label[for=playlist_name]", :text => 'Name')
|
rendered.should have_selector("label[for=playlist_name]", text: 'Name')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ describe 'sessions/new' do
|
|||||||
it 'renders a text field with a label for the mail address' do
|
it 'renders a text field with a label for the mail address' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector("input[type=text][name='session[email]']")
|
rendered.should have_selector("input[type=text][name='session[email]']")
|
||||||
rendered.should have_selector('label[for=session_email]', :text => 'Email')
|
rendered.should have_selector('label[for=session_email]', text: 'Email')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a password field with a label for the password' do
|
it 'renders a password field with a label for the password' do
|
||||||
@ -21,7 +21,7 @@ describe 'sessions/new' do
|
|||||||
"input[type=password][name='session[password]']"
|
"input[type=password][name='session[password]']"
|
||||||
)
|
)
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
'label[for=session_password]', :text => 'Password'
|
'label[for=session_password]', text: 'Password'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ describe 'sessions/new' do
|
|||||||
render
|
render
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
"a[href='#{new_user_path}']",
|
"a[href='#{new_user_path}']",
|
||||||
:text => 'Sign up'
|
text: 'Sign up'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,18 +16,18 @@ describe 'tracks/new' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a text field with a label for the playlists name' do
|
it 'renders a text field with a label for the playlists name' do
|
||||||
track.stub(:name => 'Mega song')
|
track.stub(name: 'Mega song')
|
||||||
render
|
render
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
"input[type=text][name='track[name]'][value='Mega song']"
|
"input[type=text][name='track[name]'][value='Mega song']"
|
||||||
)
|
)
|
||||||
rendered.should have_selector('label[for=track_name]', :text => 'Name')
|
rendered.should have_selector('label[for=track_name]', text: 'Name')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a file field with a label for the tracks file' do
|
it 'renders a file field with a label for the tracks file' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector("form[enctype='multipart/form-data']")
|
rendered.should have_selector("form[enctype='multipart/form-data']")
|
||||||
rendered.should have_selector("input[type=file][name='track[file]']")
|
rendered.should have_selector("input[type=file][name='track[file]']")
|
||||||
rendered.should have_selector('label[for=track_file]', :text => 'File')
|
rendered.should have_selector('label[for=track_file]', text: 'File')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,7 @@ describe 'tracks/show' do
|
|||||||
|
|
||||||
it 'displays the name of the track' do
|
it 'displays the name of the track' do
|
||||||
render
|
render
|
||||||
rendered.should have_selector('h1', :text => 'Mega song')
|
rendered.should have_selector('h1', text: 'Mega song')
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when track has a sound' do
|
context 'when track has a sound' do
|
||||||
@ -34,7 +34,7 @@ describe 'tracks/show' do
|
|||||||
render
|
render
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
'audio',
|
'audio',
|
||||||
:text => 'Your browser does not support the audio element'
|
text: 'Your browser does not support the audio element'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ describe 'users/new' do
|
|||||||
"input[type=text][name='user[email]']"
|
"input[type=text][name='user[email]']"
|
||||||
)
|
)
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
'label[for=user_email]', :text => 'Email'
|
'label[for=user_email]', text: 'Email'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ describe 'users/new' do
|
|||||||
"input[type=password][name='user[password]']"
|
"input[type=password][name='user[password]']"
|
||||||
)
|
)
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
'label[for=user_password]', :text => 'Password'
|
'label[for=user_password]', text: 'Password'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -42,14 +42,14 @@ describe 'users/new' do
|
|||||||
)
|
)
|
||||||
rendered.should have_selector(
|
rendered.should have_selector(
|
||||||
'label[for=user_password_confirmation]',
|
'label[for=user_password_confirmation]',
|
||||||
:text => 'Password confirmation'
|
text: 'Password confirmation'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the user has some validation errors' do
|
context 'when the user has some validation errors' do
|
||||||
it 'on the email address uniqueness' do
|
it 'on the email address uniqueness' do
|
||||||
user = FactoryGirl.create(:user, :email => 'unique@example.net')
|
user = FactoryGirl.create(:user, email: 'unique@example.net')
|
||||||
new_user = FactoryGirl.build(:user, :email => user.email)
|
new_user = FactoryGirl.build(:user, email: user.email)
|
||||||
new_user.save
|
new_user.save
|
||||||
assign :user, new_user
|
assign :user, new_user
|
||||||
render
|
render
|
||||||
|
Loading…
x
Reference in New Issue
Block a user