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