Update to rails 3.1.0
* Bump rails version to 3.1.0 in Gemfile * Update config files * Fix bcrypt monkey patch for specs * Fix TracksController * Replace track streaming with track download * Remove assets from application layout
This commit is contained in:
parent
9a22c4bb94
commit
f49a5a3f67
2
Gemfile
2
Gemfile
@ -1,6 +1,6 @@
|
|||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
|
|
||||||
gem 'rails', '3.0.9'
|
gem 'rails', '3.1.0'
|
||||||
|
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
|
|
||||||
|
145
Gemfile.lock
145
Gemfile.lock
@ -1,96 +1,103 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
abstract (1.0.0)
|
actionmailer (3.1.0)
|
||||||
actionmailer (3.0.9)
|
actionpack (= 3.1.0)
|
||||||
actionpack (= 3.0.9)
|
mail (~> 2.3.0)
|
||||||
mail (~> 2.2.19)
|
actionpack (3.1.0)
|
||||||
actionpack (3.0.9)
|
activemodel (= 3.1.0)
|
||||||
activemodel (= 3.0.9)
|
activesupport (= 3.1.0)
|
||||||
activesupport (= 3.0.9)
|
builder (~> 3.0.0)
|
||||||
builder (~> 2.1.2)
|
erubis (~> 2.7.0)
|
||||||
erubis (~> 2.6.6)
|
i18n (~> 0.6)
|
||||||
i18n (~> 0.5.0)
|
rack (~> 1.3.2)
|
||||||
rack (~> 1.2.1)
|
rack-cache (~> 1.0.3)
|
||||||
rack-mount (~> 0.6.14)
|
rack-mount (~> 0.8.2)
|
||||||
rack-test (~> 0.5.7)
|
rack-test (~> 0.6.1)
|
||||||
tzinfo (~> 0.3.23)
|
sprockets (~> 2.0.0)
|
||||||
activemodel (3.0.9)
|
activemodel (3.1.0)
|
||||||
activesupport (= 3.0.9)
|
activesupport (= 3.1.0)
|
||||||
builder (~> 2.1.2)
|
bcrypt-ruby (~> 3.0.0)
|
||||||
i18n (~> 0.5.0)
|
builder (~> 3.0.0)
|
||||||
activerecord (3.0.9)
|
i18n (~> 0.6)
|
||||||
activemodel (= 3.0.9)
|
activerecord (3.1.0)
|
||||||
activesupport (= 3.0.9)
|
activemodel (= 3.1.0)
|
||||||
arel (~> 2.0.10)
|
activesupport (= 3.1.0)
|
||||||
tzinfo (~> 0.3.23)
|
arel (~> 2.2.1)
|
||||||
activeresource (3.0.9)
|
tzinfo (~> 0.3.29)
|
||||||
activemodel (= 3.0.9)
|
activeresource (3.1.0)
|
||||||
activesupport (= 3.0.9)
|
activemodel (= 3.1.0)
|
||||||
activesupport (3.0.9)
|
activesupport (= 3.1.0)
|
||||||
arel (2.0.10)
|
activesupport (3.1.0)
|
||||||
bcrypt-ruby (2.1.4)
|
multi_json (~> 1.0)
|
||||||
builder (2.1.2)
|
arel (2.2.1)
|
||||||
capybara (1.0.0)
|
bcrypt-ruby (3.0.1)
|
||||||
|
builder (3.0.0)
|
||||||
|
capybara (1.1.1)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
selenium-webdriver (~> 0.2.0)
|
selenium-webdriver (~> 2.0)
|
||||||
xpath (~> 0.1.4)
|
xpath (~> 0.1.4)
|
||||||
childprocess (0.1.9)
|
childprocess (0.2.2)
|
||||||
ffi (~> 1.0.6)
|
ffi (~> 1.0.6)
|
||||||
database_cleaner (0.6.7)
|
database_cleaner (0.6.7)
|
||||||
diff-lcs (1.1.2)
|
diff-lcs (1.1.3)
|
||||||
erubis (2.6.6)
|
erubis (2.7.0)
|
||||||
abstract (>= 1.0.0)
|
factory_girl (2.1.0)
|
||||||
factory_girl (2.0.1)
|
factory_girl_rails (1.2.0)
|
||||||
factory_girl_rails (1.1.0)
|
factory_girl (~> 2.1.0)
|
||||||
factory_girl (~> 2.0.0)
|
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
ffi (1.0.9)
|
ffi (1.0.9)
|
||||||
guard (0.6.3)
|
guard (0.7.0)
|
||||||
thor (~> 0.14.6)
|
thor (~> 0.14.6)
|
||||||
guard-rspec (0.4.4)
|
guard-rspec (0.4.5)
|
||||||
guard (>= 0.4.0)
|
guard (>= 0.4.0)
|
||||||
guard-spork (0.2.1)
|
guard-spork (0.2.1)
|
||||||
guard (>= 0.2.2)
|
guard (>= 0.2.2)
|
||||||
spork (>= 0.8.4)
|
spork (>= 0.8.4)
|
||||||
haml (3.1.2)
|
haml (3.1.3)
|
||||||
i18n (0.5.0)
|
hike (1.2.1)
|
||||||
json_pure (1.5.3)
|
i18n (0.6.0)
|
||||||
mail (2.2.19)
|
json_pure (1.6.0)
|
||||||
activesupport (>= 2.3.6)
|
mail (2.3.0)
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
mime-types (1.16)
|
mime-types (1.16)
|
||||||
|
multi_json (1.0.3)
|
||||||
nokogiri (1.5.0)
|
nokogiri (1.5.0)
|
||||||
pg (0.11.0)
|
pg (0.11.0)
|
||||||
polyglot (0.3.1)
|
polyglot (0.3.2)
|
||||||
rack (1.2.2)
|
rack (1.3.2)
|
||||||
rack-mount (0.6.14)
|
rack-cache (1.0.3)
|
||||||
|
rack (>= 0.4)
|
||||||
|
rack-mount (0.8.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (0.5.7)
|
rack-ssl (1.3.2)
|
||||||
|
rack
|
||||||
|
rack-test (0.6.1)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.0.9)
|
rails (3.1.0)
|
||||||
actionmailer (= 3.0.9)
|
actionmailer (= 3.1.0)
|
||||||
actionpack (= 3.0.9)
|
actionpack (= 3.1.0)
|
||||||
activerecord (= 3.0.9)
|
activerecord (= 3.1.0)
|
||||||
activeresource (= 3.0.9)
|
activeresource (= 3.1.0)
|
||||||
activesupport (= 3.0.9)
|
activesupport (= 3.1.0)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
railties (= 3.0.9)
|
railties (= 3.1.0)
|
||||||
railties (3.0.9)
|
railties (3.1.0)
|
||||||
actionpack (= 3.0.9)
|
actionpack (= 3.1.0)
|
||||||
activesupport (= 3.0.9)
|
activesupport (= 3.1.0)
|
||||||
|
rack-ssl (~> 1.3.2)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
rdoc (~> 3.4)
|
rdoc (~> 3.4)
|
||||||
thor (~> 0.14.4)
|
thor (~> 0.14.6)
|
||||||
rake (0.9.2)
|
rake (0.9.2)
|
||||||
rb-inotify (0.8.6)
|
rb-inotify (0.8.6)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
rdoc (3.8)
|
rdoc (3.9.4)
|
||||||
rspec (2.6.0)
|
rspec (2.6.0)
|
||||||
rspec-core (~> 2.6.0)
|
rspec-core (~> 2.6.0)
|
||||||
rspec-expectations (~> 2.6.0)
|
rspec-expectations (~> 2.6.0)
|
||||||
@ -105,14 +112,20 @@ GEM
|
|||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
rspec (~> 2.6.0)
|
rspec (~> 2.6.0)
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.4)
|
||||||
selenium-webdriver (0.2.2)
|
selenium-webdriver (2.6.0)
|
||||||
childprocess (>= 0.1.9)
|
childprocess (>= 0.2.1)
|
||||||
ffi (>= 1.0.7)
|
ffi (>= 1.0.7)
|
||||||
json_pure
|
json_pure
|
||||||
rubyzip
|
rubyzip
|
||||||
spork (0.9.0.rc9)
|
spork (0.9.0.rc9)
|
||||||
|
sprockets (2.0.0)
|
||||||
|
hike (~> 1.2)
|
||||||
|
rack (~> 1.0)
|
||||||
|
tilt (!= 1.3.0, ~> 1.1)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
treetop (1.4.9)
|
tilt (1.3.3)
|
||||||
|
treetop (1.4.10)
|
||||||
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.29)
|
tzinfo (0.3.29)
|
||||||
xpath (0.1.4)
|
xpath (0.1.4)
|
||||||
@ -131,7 +144,7 @@ DEPENDENCIES
|
|||||||
guard-spork
|
guard-spork
|
||||||
haml
|
haml
|
||||||
pg
|
pg
|
||||||
rails (= 3.0.9)
|
rails (= 3.1.0)
|
||||||
rb-inotify
|
rb-inotify
|
||||||
rspec-rails
|
rspec-rails
|
||||||
spork (~> 0.9.0.rc)
|
spork (~> 0.9.0.rc)
|
||||||
|
@ -10,7 +10,7 @@ class TracksController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@track = Track.new(:name => params[:track][:name])
|
@track = Track.new(:name => params[:track][:name])
|
||||||
if @track.save_with_file(
|
if @track.save_with_file(
|
||||||
params[:track][:file].tempfile,
|
params[:track][:file],
|
||||||
params[:track][:file].content_type
|
params[:track][:file].content_type
|
||||||
)
|
)
|
||||||
redirect_to @track
|
redirect_to @track
|
||||||
@ -19,9 +19,8 @@ class TracksController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def stream
|
def download
|
||||||
track = Track.find params[:id]
|
track = Track.find params[:id]
|
||||||
self.content_type = track.mime_type
|
send_file track.filepath, :type => track.mime_type
|
||||||
self.response_body = Streamer.new(track.filepath)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
%head
|
%head
|
||||||
%meta{'charset' => 'utf-8'}
|
%meta{'charset' => 'utf-8'}
|
||||||
%title scube
|
%title scube
|
||||||
= stylesheet_link_tag :all
|
|
||||||
= javascript_include_tag :defaults
|
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
%body
|
%body
|
||||||
= yield
|
= yield
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
%h1= @track.name
|
%h1= @track.name
|
||||||
%audio{:src => stream_track_path(@track), :controls => true, :autoplay => true}
|
%audio{:src => download_track_path(@track), :controls => true, :autoplay => true}
|
||||||
Your browser does not support the audio element
|
Your browser does not support the audio element
|
||||||
|
@ -2,9 +2,12 @@ require File.expand_path('../boot', __FILE__)
|
|||||||
|
|
||||||
require 'rails/all'
|
require 'rails/all'
|
||||||
|
|
||||||
# If you have a Gemfile, require the gems listed there, including any gems
|
if defined?(Bundler)
|
||||||
# you've limited to :test, :development, or :production.
|
# If you precompile assets before deploying to production, use this line
|
||||||
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
Bundler.require *Rails.groups(:assets => %w(development test))
|
||||||
|
# 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
|
||||||
@ -13,7 +16,7 @@ module Scube
|
|||||||
# -- 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.
|
# Custom directories with classes and modules you want to be autoloadable.
|
||||||
config.autoload_paths += %W(#{config.root}/lib)
|
# config.autoload_paths += %W(#{config.root}/lib)
|
||||||
|
|
||||||
# Only load the plugins named here, in the order given (default is alphabetical).
|
# 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.
|
# :all can be used as a placeholder for all plugins not explicitly named.
|
||||||
@ -30,9 +33,6 @@ module Scube
|
|||||||
# 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
|
||||||
|
|
||||||
# JavaScript files you want as :defaults (application.js is always included).
|
|
||||||
config.action_view.javascript_expansions[:defaults] = %w()
|
|
||||||
|
|
||||||
# Configure the default encoding used in templates for Ruby 1.9.
|
# Configure the default encoding used in templates for Ruby 1.9.
|
||||||
config.encoding = "utf-8"
|
config.encoding = "utf-8"
|
||||||
|
|
||||||
@ -41,5 +41,11 @@ module Scube
|
|||||||
|
|
||||||
# BestStandardsSupport is setting this fucking X-UA-Compatible header...
|
# BestStandardsSupport is setting this fucking X-UA-Compatible header...
|
||||||
config.middleware.delete ActionDispatch::BestStandardsSupport
|
config.middleware.delete ActionDispatch::BestStandardsSupport
|
||||||
|
|
||||||
|
# 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
|
||||||
|
@ -11,7 +11,6 @@ Scube::Application.configure do
|
|||||||
|
|
||||||
# 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_view.debug_rjs = 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
|
||||||
@ -22,5 +21,10 @@ Scube::Application.configure do
|
|||||||
|
|
||||||
# Only use best-standards-support built into browsers
|
# Only use best-standards-support built into browsers
|
||||||
config.action_dispatch.best_standards_support = :builtin
|
config.action_dispatch.best_standards_support = :builtin
|
||||||
end
|
|
||||||
|
|
||||||
|
# Do not compress assets
|
||||||
|
config.assets.compress = false
|
||||||
|
|
||||||
|
# Expands the lines which load the assets
|
||||||
|
config.assets.debug = true
|
||||||
|
end
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
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 production environment is meant for finished, "live" apps.
|
|
||||||
# Code is not reloaded between requests
|
# Code is not reloaded between requests
|
||||||
config.cache_classes = true
|
config.cache_classes = true
|
||||||
|
|
||||||
@ -9,14 +8,27 @@ Scube::Application.configure do
|
|||||||
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)
|
||||||
|
config.serve_static_assets = false
|
||||||
|
|
||||||
|
# Compress JavaScripts and CSS
|
||||||
|
config.assets.compress = true
|
||||||
|
|
||||||
|
# Don't fallback to assets pipeline if a precompiled asset is missed
|
||||||
|
config.assets.compile = false
|
||||||
|
|
||||||
|
# Generate digests for assets URLs
|
||||||
|
config.assets.digest = true
|
||||||
|
|
||||||
|
# Defaults to Rails.root.join("public/assets")
|
||||||
|
# config.assets.manifest = YOUR_PATH
|
||||||
|
|
||||||
# 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"
|
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
||||||
|
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||||
|
|
||||||
# For nginx:
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
# config.force_ssl = true
|
||||||
|
|
||||||
# If you have no front-end server that supports something like X-Sendfile,
|
|
||||||
# just comment this out and Rails will serve the files
|
|
||||||
|
|
||||||
# See everything in the log (default is :info)
|
# See everything in the log (default is :info)
|
||||||
# config.log_level = :debug
|
# config.log_level = :debug
|
||||||
@ -27,13 +39,12 @@ Scube::Application.configure do
|
|||||||
# 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
|
||||||
|
|
||||||
# Disable Rails's static asset server
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||||
# In production, Apache or nginx will already do this
|
|
||||||
config.serve_static_assets = false
|
|
||||||
|
|
||||||
# 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)
|
||||||
|
# config.assets.precompile += %w( search.js )
|
||||||
|
|
||||||
# Disable delivery errors, bad email addresses will be ignored
|
# Disable delivery errors, bad email addresses will be ignored
|
||||||
# config.action_mailer.raise_delivery_errors = false
|
# config.action_mailer.raise_delivery_errors = false
|
||||||
|
|
||||||
|
@ -7,7 +7,11 @@ 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
|
||||||
|
|
||||||
# Log error messages when you accidentally call methods on nil.
|
# Configure static asset server for tests with Cache-Control for performance
|
||||||
|
config.serve_static_assets = true
|
||||||
|
config.static_cache_control = "public, max-age=3600"
|
||||||
|
|
||||||
|
# Log error messages when you accidentally call methods on nil
|
||||||
config.whiny_nils = true
|
config.whiny_nils = true
|
||||||
|
|
||||||
# Show full error reports and disable caching
|
# Show full error reports and disable caching
|
||||||
@ -32,4 +36,7 @@ Scube::Application.configure do
|
|||||||
|
|
||||||
# Print deprecation notices to the stderr
|
# Print deprecation notices to the stderr
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
|
|
||||||
|
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
||||||
|
config.assets.allow_debugging = true
|
||||||
end
|
end
|
||||||
|
14
config/initializers/wrap_parameters.rb
Normal file
14
config/initializers/wrap_parameters.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
#
|
||||||
|
# This file contains settings for ActionController::ParamsWrapper which
|
||||||
|
# is enabled by default.
|
||||||
|
|
||||||
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||||
|
ActiveSupport.on_load(:action_controller) do
|
||||||
|
wrap_parameters :format => [:json]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Disable root element in JSON by default.
|
||||||
|
ActiveSupport.on_load(:active_record) do
|
||||||
|
self.include_root_in_json = false
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
# Sample localization file for English. Add more files in this directory for other locales.
|
# Sample localization file for English. Add more files in this directory for other locales.
|
||||||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||||
|
|
||||||
en:
|
en:
|
||||||
hello: "Hello world"
|
hello: "Hello world"
|
||||||
|
@ -4,8 +4,9 @@ Scube::Application.routes.draw do
|
|||||||
resources :sessions, :only => [:new, :create]
|
resources :sessions, :only => [:new, :create]
|
||||||
|
|
||||||
resources :tracks do
|
resources :tracks do
|
||||||
get 'stream', :on => :member
|
get 'download', :on => :member
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :playlists
|
resources :playlists
|
||||||
|
|
||||||
root :to => 'home#index'
|
root :to => 'home#index'
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
class Streamer
|
|
||||||
def initialize(file)
|
|
||||||
@file = file
|
|
||||||
end
|
|
||||||
|
|
||||||
def each
|
|
||||||
f = File.new(@file, 'r')
|
|
||||||
while data = f.read(4096) do
|
|
||||||
yield data
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -13,21 +13,16 @@ describe TracksController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET stream' do
|
describe 'GET download' do
|
||||||
let(:track) { Factory.create(:track) }
|
let(:track) { Factory.create(:track) }
|
||||||
|
|
||||||
it 'streams the requested track' do
|
it 'streams the requested track' do
|
||||||
get :stream, :id => track.id.to_s
|
get :download, :id => track.id.to_s
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a streamer instance' do
|
|
||||||
Streamer.should_receive(:new).with(track.filepath)
|
|
||||||
get :stream, :id => track.id.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns the track mime-type as content-type' do
|
it 'returns the track mime-type as content-type' do
|
||||||
get :stream, :id => track.id.to_s
|
get :download, :id => track.id.to_s
|
||||||
response.content_type.should == track.mime_type
|
response.content_type.should == track.mime_type
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -42,10 +37,7 @@ describe TracksController do
|
|||||||
describe 'POST create' do
|
describe 'POST create' do
|
||||||
let(:track) { mock_model(Track).as_null_object }
|
let(:track) { mock_model(Track).as_null_object }
|
||||||
let(:file) {
|
let(:file) {
|
||||||
file = mock(Rack::Test::UploadedFile)
|
fixture_file_upload("#{Rails.root}/spec/fixtures/test.mp3", 'audio/mpeg')
|
||||||
file.stub(:tempfile => File.new("#{Rails.root}/spec/fixtures/test.mp3"))
|
|
||||||
file.stub(:content_type => 'audio/ogg')
|
|
||||||
file
|
|
||||||
}
|
}
|
||||||
before { Track.stub(:new).and_return(track) }
|
before { Track.stub(:new).and_return(track) }
|
||||||
|
|
||||||
@ -62,7 +54,7 @@ describe TracksController do
|
|||||||
|
|
||||||
it 'saves the track with a file' do
|
it 'saves the track with a file' do
|
||||||
track.should_receive(:save_with_file).
|
track.should_receive(:save_with_file).
|
||||||
with(file.tempfile, 'audio/ogg')
|
with(file, 'audio/mpeg')
|
||||||
post :create, :track => { :file => file }
|
post :create, :track => { :file => file }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,6 +8,10 @@ FactoryGirl.define do
|
|||||||
name 'Mega song'
|
name 'Mega song'
|
||||||
mime_type 'audio/ogg'
|
mime_type 'audio/ogg'
|
||||||
sha256 '94a5486a69a7261da350c57f9e5a1eaa789e08752cfc56a1989976a6ad82f7a8'
|
sha256 '94a5486a69a7261da350c57f9e5a1eaa789e08752cfc56a1989976a6ad82f7a8'
|
||||||
|
|
||||||
|
after_create do |t|
|
||||||
|
t.save_with_file(File.new("#{Rails.root}/spec/fixtures/test.mp3"), 'audio/mpeg')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :user do
|
factory :user do
|
||||||
|
@ -34,7 +34,7 @@ feature 'Tracks' do
|
|||||||
|
|
||||||
visit track_path(track)
|
visit track_path(track)
|
||||||
|
|
||||||
page.should have_xpath "//audio[@src='#{stream_track_path(track)}']"
|
page.should have_xpath "//audio[@src='#{download_track_path(track)}']"
|
||||||
visit find('audio')[:src]
|
visit find('audio')[:src]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Streamer do
|
|
||||||
describe '#each' do
|
|
||||||
let(:stream) { Streamer.new("#{Rails.root}/spec/fixtures/test.mp3") }
|
|
||||||
|
|
||||||
it 'returns file content' do
|
|
||||||
chunks = ''
|
|
||||||
stream.each { |c| chunks << c }
|
|
||||||
chunks.should == File.read("#{Rails.root}/spec/fixtures/test.mp3")
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns content in multiple chunks' do
|
|
||||||
count = 0
|
|
||||||
stream.each { count += 1 }
|
|
||||||
count.should be >= 2
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -2,9 +2,7 @@ require 'bcrypt'
|
|||||||
|
|
||||||
module BCrypt
|
module BCrypt
|
||||||
class Engine
|
class Engine
|
||||||
[:DEFAULT_COST, :MIN_COST].each do |sym|
|
remove_const :DEFAULT_COST
|
||||||
remove_const sym
|
const_set :DEFAULT_COST, 4
|
||||||
const_set sym, 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user