Merge branch 'rails4'

Upgrade all dependencies, then rails from 3.x to 4.0.
This commit is contained in:
Thibault Jouan 2014-04-01 10:07:56 +00:00
commit 92ac87c54e
49 changed files with 208 additions and 355 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/Gemfile-custom.rb /Gemfile-custom.rb
/Gemfile.lock
/config/database.yml /config/database.yml
/data/ /data/
/log/*.log /log/*.log

18
Gemfile
View File

@ -1,16 +1,18 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '~> 3.1' gem 'rails', '~> 4.0'
gem 'pg', '~> 0.11' gem 'pg', '~> 0.17'
gem 'haml', '~> 3.1' gem 'haml', '~> 4.0'
gem 'bcrypt-ruby', '~> 3.0' gem 'bcrypt', '~> 3.0'
gem 'rabl', '~> 0.6' gem 'rabl', '~> 0.6'
gem 'protected_attributes', '~> 1.0'
group :development, :test do group :development, :test do
gem 'rspec-rails', '~> 2.6' gem 'rspec-rails', '~> 2.6'
gem 'capybara', '~> 1.1' gem 'capybara', '~> 2.2'
gem 'factory_girl_rails', '~> 1.2' gem 'factory_girl_rails', '~> 4.4'
gem 'shoulda-matchers', '~> 1.0' gem 'shoulda-matchers', '~> 2.5'
end end
eval File.read('Gemfile-custom.rb') if File.exist?('Gemfile-custom.rb') eval File.read('Gemfile-custom.rb') if File.exist?('Gemfile-custom.rb')

View File

@ -1,151 +0,0 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.2)
actionpack (= 3.2.2)
mail (~> 2.4.0)
actionpack (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.2)
activesupport (= 3.2.2)
builder (~> 3.0.0)
activerecord (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.2)
activemodel (= 3.2.2)
activesupport (= 3.2.2)
activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.3.1)
ffi (~> 1.0.6)
diff-lcs (1.1.3)
erubis (2.7.0)
factory_girl (2.6.4)
activesupport (>= 2.3.9)
factory_girl_rails (1.7.0)
factory_girl (~> 2.6.0)
railties (>= 3.0.0)
ffi (1.0.11)
guard (0.10.0)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-rspec (0.6.0)
guard (>= 0.10.0)
guard-spork (0.5.2)
guard (>= 0.10.0)
spork (>= 0.8.4)
haml (3.1.4)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.6.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.1.0)
nokogiri (1.5.2)
pg (0.13.2)
polyglot (0.3.3)
rabl (0.6.1)
activesupport (>= 2.3.14)
multi_json (~> 1.1.0)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.2)
actionmailer (= 3.2.2)
actionpack (= 3.2.2)
activerecord (= 3.2.2)
activeresource (= 3.2.2)
activesupport (= 3.2.2)
bundler (~> 1.0)
railties (= 3.2.2)
railties (3.2.2)
actionpack (= 3.2.2)
activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.9.0)
rspec-core (~> 2.9.0)
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.9.0)
rubyzip (0.9.6.1)
selenium-webdriver (2.20.0)
childprocess (>= 0.2.5)
ffi (~> 1.0)
multi_json (~> 1.0)
rubyzip
shoulda-matchers (1.0.0)
spork (0.9.0)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.32)
xpath (0.1.4)
nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
bcrypt-ruby (~> 3.0)
capybara (~> 1.1)
factory_girl_rails (~> 1.2)
guard (~> 0.8)
guard-rspec (~> 0.4)
guard-spork (~> 0.2)
haml (~> 3.1)
pg (~> 0.11)
rabl (~> 0.6)
rails (~> 3.1)
rspec-rails (~> 2.6)
shoulda-matchers (~> 1.0)
spork (~> 0.9.0.rc)

View File

@ -3,6 +3,8 @@ require 'fileutils'
class Sound < ActiveRecord::Base class Sound < ActiveRecord::Base
belongs_to :track belongs_to :track
attr_accessible :file
validates_presence_of :sha256 validates_presence_of :sha256
validates_presence_of :mime_type validates_presence_of :mime_type

4
bin/bundle Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

5
bin/rails Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

5
bin/rake Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

View File

@ -2,12 +2,9 @@ require File.expand_path('../boot', __FILE__)
require 'rails/all' require 'rails/all'
if defined?(Bundler) # Require the gems listed in Gemfile, including any gems
# If you precompile assets before deploying to production, use this line # you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups(:assets => %w(development test))) Bundler.require(*Rails.groups)
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module Scube module Scube
class Application < Rails::Application class Application < Rails::Application
@ -15,16 +12,6 @@ module Scube
# Application configuration should go into files in config/initializers # Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)' # config.time_zone = 'Central Time (US & Canada)'
@ -32,31 +19,5 @@ module Scube
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # config.i18n.default_locale = :de
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# BestStandardsSupport is setting this fucking X-UA-Compatible header...
config.middleware.delete ActionDispatch::BestStandardsSupport
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
# config.active_record.whitelist_attributes = true
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
end end
end end

View File

@ -1,6 +1,4 @@
require 'rubygems'
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])

View File

@ -1,5 +1,5 @@
# Load the rails application # Load the Rails application.
require File.expand_path('../application', __FILE__) require File.expand_path('../application', __FILE__)
# Initialize the rails application # Initialize the Rails application.
Scube::Application.initialize! Scube::Application.initialize!

View File

@ -1,37 +1,29 @@
Scube::Application.configure do Scube::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development # every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
config.cache_classes = false config.cache_classes = false
# Log error messages when you accidentally call methods on nil. # Do not eager load code on boot.
config.whiny_nils = true config.eager_load = false
# Show full error reports and disable caching # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
# Don't care if the mailer can't send # Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
# Only use best-standards-support built into browsers # Raise an error on page load if there are pending migrations
config.action_dispatch.best_standards_support = :builtin config.active_record.migration_error = :page_load
# Raise exception on mass assignment protection for Active Record models # Debug mode disables concatenation and preprocessing of assets.
config.active_record.mass_assignment_sanitizer = :strict # This option may cause significant delays in view rendering with a large
# number of complex assets.
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true config.assets.debug = true
end end

View File

@ -1,67 +1,80 @@
Scube::Application.configure do Scube::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests # Code is not reloaded between requests.
config.cache_classes = true config.cache_classes = true
# Full error reports are disabled and caching is turned on # Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this) # Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false config.serve_static_assets = false
# Compress JavaScripts and CSS # Compress JavaScripts and CSS.
config.assets.compress = true config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Don't fallback to assets pipeline if a precompiled asset is missed # Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false config.assets.compile = false
# Generate digests for assets URLs # Generate digests for assets URLs.
config.assets.digest = true config.assets.digest = true
# Defaults to Rails.root.join("public/assets") # Version of your assets, change this if you want to expire all your assets.
# config.assets.manifest = YOUR_PATH config.assets.version = '1.0'
# Specifies the header that your server uses for sending files # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true # config.force_ssl = true
# See everything in the log (default is :info) # Set to :debug to see everything in the log.
# config.log_level = :debug config.log_level = :info
# Prepend all log lines with the following tags # Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ] # config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups # Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com" # config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js ) # config.assets.precompile += %w( search.js )
# Disable delivery errors, bad email addresses will be ignored # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found) # the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true config.i18n.fallbacks = true
# Send deprecation notices to registered listeners # Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works # Disable automatic flushing of the log to improve performance.
# with SQLite, MySQL, and PostgreSQL) # config.autoflush_log = false
# config.active_record.auto_explain_threshold_in_seconds = 0.5
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end end

View File

@ -1,5 +1,5 @@
Scube::Application.configure do Scube::Application.configure do
# Settings specified here will take precedence over those in config/application.rb # Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that # test suite. You never need to work with it otherwise. Remember that
@ -7,31 +7,30 @@ Scube::Application.configure do
# and recreated between test runs. Don't rely on the data there! # and recreated between test runs. Don't rely on the data there!
config.cache_classes = true config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance # Do not eager load code on boot. This avoids loading your whole application
config.serve_static_assets = true # just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600" config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil # Show full error reports and disable caching.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates # Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world. # Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the # The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
# Raise exception on mass assignment protection for Active Record models # Print deprecation notices to the stderr.
config.active_record.mass_assignment_sanitizer = :strict
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr
end end

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@ -1,16 +1,17 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format # Add new inflection rules using the following format. Inflections
# (all these examples are active by default): # are locale specific, and you may define rules for as many different
# ActiveSupport::Inflector.inflections do |inflect| # locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en' # inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1' # inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people' # inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep ) # inflect.uncountable %w( fish sheep )
# end # end
#
# These inflection rules are supported but not enabled by default: # These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections do |inflect| # ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful' # inflect.acronym 'RESTful'
# end # end

View File

@ -1,7 +1,12 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies. # Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid! # If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random, # Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks. # no regular words or you'll be exposed to dictionary attacks.
Scube::Application.config.secret_token = '1bc686843bfcf76e9ab8c057e11dbc14b9cec8574d4b189720223fc1faa18b4eadf98cb27fa8b4b224f373013ab3828c6874878a679b050c90ca839a5f731bfa' # You can use `rake secret` to generate a secure secret key.
# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
Scube::Application.config.secret_key_base = 'd0fb5028d03e9030435af05646555d948bbb65cef3910016c9dc34f5799a5bc6c8d41a248e02df21a27fef348eecc9dc5f9662dc277e0c17210a7cfc513200aa'

View File

@ -1,8 +1,3 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
#Scube::Application.config.session_store :cookie_store, :key => '_scube_session' Scube::Application.config.session_store :cookie_store, key: '_scube_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
Scube::Application.config.session_store :active_record_store

View File

@ -1,14 +1,14 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which # This file contains settings for ActionController::ParamsWrapper which
# is enabled by default. # is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end end
# Disable root element in JSON by default. # To enable root element in JSON for ActiveRecord objects.
ActiveSupport.on_load(:active_record) do ActiveSupport.on_load(:active_record) do
self.include_root_in_json = false self.include_root_in_json = true
end end

View File

@ -1,5 +1,23 @@
# Sample localization file for English. Add more files in this directory for other locales. # Files in the config/locales directory are used for internationalization
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. # and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en: en:
hello: "Hello world" hello: "Hello world"

View File

@ -1,6 +0,0 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'

View File

@ -9,7 +9,7 @@ describe API::ApplicationController do
context 'CORS: Cross-Origin Ressource Sharing' do context 'CORS: Cross-Origin Ressource Sharing' do
before do before do
request.env['Origin'] = 'http://origin.example/' request.headers['Origin'] = 'http://origin.example/'
end end
context 'preflight' do context 'preflight' do
@ -18,7 +18,7 @@ describe API::ApplicationController do
end end
def options(action) def options(action)
process action, nil, nil, nil, 'OPTIONS' process action, 'OPTIONS'
end end
it 'sets Access-Control-Allow-Methods header' do it 'sets Access-Control-Allow-Methods header' do
@ -43,8 +43,8 @@ describe API::ApplicationController do
it 'sets Access-Control-Allow-Origin header' do it 'sets Access-Control-Allow-Origin header' do
get :index get :index
response.headers['Access-Control-Allow-Origin'].should == response.headers['Access-Control-Allow-Origin']
request.env['Origin'] .should == request.headers['Origin']
end end
end end
end end

View File

@ -8,9 +8,11 @@ describe API::PlaylistsController do
end end
describe 'GET index' do describe 'GET index' do
render_views
before do before do
playlist_1 = Factory.create(:playlist, :name => 'Playlist 1') playlist_1 = FactoryGirl.create(:playlist, :name => 'Playlist 1')
playlist_2 = Factory.create(:playlist, :name => 'Playlist 2') playlist_2 = FactoryGirl.create(:playlist, :name => 'Playlist 2')
end end
def do_get def do_get
@ -35,7 +37,7 @@ describe API::PlaylistsController do
def do_create def do_create
post :create, post :create,
:format => :json, :format => :json,
:playlist => Factory.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

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe API::SessionsController do describe API::SessionsController do
describe 'POST create' do describe 'POST create' do
let(:user) { Factory.create(:user) } let(:user) { FactoryGirl.create(:user) }
def do_create def do_create
post :create, :format => :json, :session => { post :create, :format => :json, :session => {

View File

@ -8,9 +8,11 @@ describe API::TracksController do
end end
describe 'GET index' do describe 'GET index' do
render_views
before do before do
Factory.create(:track_with_sound) FactoryGirl.create(:track_with_sound)
Factory.create(:track_with_sound) FactoryGirl.create(:track_with_sound)
end end
def do_get def do_get

View File

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe ApplicationController do describe ApplicationController do
let(:user) { Factory.create(:user) } let(:user) { FactoryGirl.create(:user) }
describe '#current_user=' do describe '#current_user=' do
it 'stores the user id in the session as :user_id' do it 'stores the user id in the session as :user_id' do

View File

@ -9,14 +9,14 @@ describe HomeController do
describe 'GET index' do describe 'GET index' do
it 'assigns all playlists as @playlists' do it 'assigns all playlists as @playlists' do
playlist = Factory.create(:playlist) playlist = FactoryGirl.create(:playlist)
get :index get :index
assigns[:playlists].should == [playlist] assigns[:playlists].should == [playlist]
end end
it 'assigns latest tracks as @tracks' do it 'assigns latest tracks as @tracks' do
track1 = Factory.create(:track, :created_at => '2011-07-27 19:13:42') track1 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:13:42')
track2 = Factory.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

View File

@ -9,7 +9,7 @@ describe PlaylistsController do
describe 'GET index' do describe 'GET index' do
it 'assigns all playlists as @playlists' do it 'assigns all playlists as @playlists' do
playlist = Factory.create(:playlist) playlist = FactoryGirl.create(:playlist)
get :index get :index
assigns[:playlists].should == [playlist] assigns[:playlists].should == [playlist]
end end
@ -24,7 +24,7 @@ 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 = Factory.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
@ -32,7 +32,7 @@ describe PlaylistsController do
describe 'POST create' do describe 'POST create' do
def do_create def do_create
post :create, :playlist => Factory.attributes_for(:playlist) post :create, :playlist => FactoryGirl.attributes_for(:playlist)
end end
context 'whith valid params' do context 'whith valid params' do
@ -64,7 +64,7 @@ describe PlaylistsController do
end end
describe 'PUT update' do describe 'PUT update' do
let (:playlist) { Factory.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' }

View File

@ -8,7 +8,7 @@ describe SessionsController do
end end
describe 'POST create' do describe 'POST create' do
let(:user) { Factory.create(:user) } let(:user) { FactoryGirl.create(:user) }
def do_create def do_create
post :create, :session => { post :create, :session => {

View File

@ -8,7 +8,7 @@ describe SoundsController do
end end
describe 'GET show' do describe 'GET show' do
let(:sound) { Factory.create(:sound) } let(:sound) { FactoryGirl.create(:sound) }
def do_show def do_show
get :show, :id => sound.id get :show, :id => sound.id

View File

@ -9,7 +9,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 = Factory.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
@ -24,7 +24,7 @@ describe TracksController do
describe 'POST create new' do describe 'POST create new' do
def do_create def do_create
post :create, :track => Factory.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'

View File

@ -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 => Factory.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 => Factory.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 => Factory.attributes_for(:user) post :create, :user => FactoryGirl.attributes_for(:user)
response.should redirect_to(:root) response.should redirect_to(:root)
end end
end end

View File

@ -8,7 +8,7 @@ feature 'Home page' do
end end
scenario 'displays playlists' do scenario 'displays playlists' do
playlist = Factory.create(:playlist, :name => 'Electro') playlist = FactoryGirl.create(:playlist, :name => 'Electro')
visit root_path visit root_path
@ -16,11 +16,11 @@ feature 'Home page' do
end end
scenario 'displays last track added' do scenario 'displays last track added' do
Factory.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'
) )
Factory.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'
) )

View File

@ -8,8 +8,8 @@ feature 'Playlists' do
end end
scenario 'lists playlists' do scenario 'lists playlists' do
Factory.create(:playlist, :name => 'Electro') FactoryGirl.create(:playlist, :name => 'Electro')
Factory.create(:playlist, :name => 'Reggae') FactoryGirl.create(:playlist, :name => 'Reggae')
visit playlists_path visit playlists_path
@ -28,7 +28,7 @@ feature 'Playlists' do
end end
scenario 'edits playlist' do scenario 'edits playlist' do
Factory.create(:playlist, :name => 'Electro') FactoryGirl.create(:playlist, :name => 'Electro')
visit playlists_path visit playlists_path
click_link 'Electro' click_link 'Electro'

View File

@ -8,7 +8,7 @@ feature 'Tracks' do
end end
scenario 'shows track' do scenario 'shows track' do
track = Factory.create(:track, :name => 'Mega song') track = FactoryGirl.create(:track, :name => 'Mega song')
visit track_path(track) visit track_path(track)
@ -23,12 +23,12 @@ feature 'Tracks' do
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'
current_path.should == track_path(Track.find(:first)) current_path.should == track_path(Track.first)
page.should have_content('Mega song') page.should have_content('Mega song')
end end
scenario 'plays track' do scenario 'plays track' do
track = Factory.create(:track_with_sound) track = FactoryGirl.create(:track_with_sound)
visit track_path(track) visit track_path(track)

View File

@ -8,7 +8,7 @@ feature 'User sign in' do
end end
scenario 'signs the user in' do scenario 'signs the user in' do
user = Factory.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

View File

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
feature 'User sign up' do feature 'User sign up' do
let(:user) { Factory.build(:user) } let(:user) { FactoryGirl.build(:user) }
background do background do
visit new_user_path visit new_user_path

View File

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
feature 'API sign in' do feature 'API sign in' do
let(:user) { Factory.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 => {

View File

@ -3,7 +3,7 @@ require 'spec_helper'
feature 'API cross origin request' do feature 'API cross origin request' do
include UserIntegrationHelpers include UserIntegrationHelpers
let(:user) { Factory.create(:user) } let(:user) { FactoryGirl.create(:user) }
let(:origin) { 'http://origin.example/' } let(:origin) { 'http://origin.example/' }
background do background do
@ -14,9 +14,8 @@ feature 'API cross origin request' do
end end
scenario 'preflight request' do scenario 'preflight request' do
# FIXME: replace with a more stable/generic action @integration_session.send(
# FIXME: request without redirect :process,
request_via_redirect(
:options, :options,
api_playlists_path(:format => :json), api_playlists_path(:format => :json),
nil, nil,

View File

@ -8,7 +8,7 @@ feature 'API playlists' do
end end
scenario 'creates playlist' do scenario 'creates playlist' do
playlist = Factory.attributes_for :playlist playlist = FactoryGirl.attributes_for :playlist
post api_playlists_path, post api_playlists_path,
:format => :json, :format => :json,

View File

@ -8,8 +8,8 @@ feature 'API tracks' do
end end
scenario 'lists tracks' do scenario 'lists tracks' do
track_1 = Factory.create(:track_with_sound, :name => 'Track 1') track_1 = FactoryGirl.create(:track_with_sound, :name => 'Track 1')
track_2 = Factory.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

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe Playlist do describe Playlist do
subject { playlist } subject { playlist }
let(:playlist) { Factory.build(:playlist) } let(:playlist) { FactoryGirl.build(:playlist) }
it { should be_valid } it { should be_valid }
it { should belong_to :user } it { should belong_to :user }

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe Sound do describe Sound do
subject { sound } subject { sound }
let(:sound) { Factory.build(:sound) } let(:sound) { FactoryGirl.build(:sound) }
it { should be_valid } it { should be_valid }
it { should belong_to :track } it { should belong_to :track }
@ -20,7 +20,7 @@ describe Sound do
end end
describe '#file=' do describe '#file=' do
let (:file) { Factory.attributes_for(:sound)[:file] } let (:file) { FactoryGirl.attributes_for(:sound)[:file] }
it 'saves the file SHA256 digest' do it 'saves the file SHA256 digest' do
sound.sha256.should == Digest::SHA256.file(file.path).hexdigest sound.sha256.should == Digest::SHA256.file(file.path).hexdigest

View File

@ -2,8 +2,8 @@ require 'spec_helper'
describe Track do describe Track do
subject { track } subject { track }
let(:track) { Factory.build(:track) } let(:track) { FactoryGirl.build(:track) }
let(:file) { Factory.attributes_for(:track_with_sound)[:file] } let(:file) { FactoryGirl.attributes_for(:track_with_sound)[:file] }
it { should be_valid } it { should be_valid }
it { should have_many :sounds } it { should have_many :sounds }
@ -15,6 +15,8 @@ describe Track do
track.file = file track.file = file
end end
it { should be_valid }
it 'creates a sound for the track' do it 'creates a sound for the track' do
expect { expect {
track.save track.save
@ -24,7 +26,7 @@ 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 = mock('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
@ -34,7 +36,7 @@ describe Track do
describe '#sound' do describe '#sound' do
context 'with a sound' do context 'with a sound' do
before do before do
track.sounds << Factory.create(:sound) track.sounds << FactoryGirl.create(:sound)
end end
it 'returns a sound' do it 'returns a sound' do
@ -52,7 +54,7 @@ describe Track do
context 'with a sound' do context 'with a sound' do
before do before do
track.sounds << Factory.create(:sound) track.sounds << FactoryGirl.create(:sound)
end end
it 'returns true' do it 'returns true' do
@ -63,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 = Factory.create(:track, :created_at => '2011-07-27 19:13:42') track1 = FactoryGirl.create(:track, :created_at => '2011-07-27 19:13:42')
track2 = Factory.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

View File

@ -2,7 +2,7 @@ require 'spec_helper'
describe User do describe User do
subject { user } subject { user }
let(:user) { Factory.build(:user) } let(:user) { FactoryGirl.build(:user) }
it { should be_valid } it { should be_valid }
it { should have_many :playlists } it { should have_many :playlists }
@ -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) { Factory.create(:user, :email => 'unique@example.net') } let(:old_user) { FactoryGirl.create(:user, :email => 'unique@example.net') }
subject { Factory.build(:user, :email => old_user.email) } subject { FactoryGirl.build(:user, :email => old_user.email) }
it { should_not be_valid } it { should_not be_valid }

View File

@ -1,5 +1,5 @@
module UserControllerHelpers module UserControllerHelpers
def sign_in def sign_in
controller.current_user = Factory.create(:user) controller.current_user = FactoryGirl.create(:user)
end end
end end

View File

@ -1,6 +1,6 @@
module UserIntegrationHelpers module UserIntegrationHelpers
def sign_in def sign_in
user = Factory.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
@ -8,7 +8,7 @@ module UserIntegrationHelpers
end end
def api_sign_in def api_sign_in
user = Factory.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,

View File

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'tracks/show' do describe 'tracks/show' do
let(:track) { Factory.create(:track) } let(:track) { FactoryGirl.create(:track) }
before do before do
assign :track, track assign :track, track
@ -13,7 +13,7 @@ describe 'tracks/show' do
end end
context 'when track has a sound' do context 'when track has a sound' do
let(:track) { Factory.create(:track_with_sound) } let(:track) { FactoryGirl.create(:track_with_sound) }
it 'provides an audio stream for the track' do it 'provides an audio stream for the track' do
render render

View File

@ -48,8 +48,8 @@ describe 'users/new' do
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 = Factory.create(:user, :email => 'unique@example.net') user = FactoryGirl.create(:user, :email => 'unique@example.net')
new_user = Factory.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

View File