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'
|
||||
|
||||
gem 'rails', '3.0.9'
|
||||
gem 'rails', '3.1.0'
|
||||
|
||||
gem 'pg'
|
||||
|
||||
|
145
Gemfile.lock
145
Gemfile.lock
@ -1,96 +1,103 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.9)
|
||||
actionpack (= 3.0.9)
|
||||
mail (~> 2.2.19)
|
||||
actionpack (3.0.9)
|
||||
activemodel (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
builder (~> 2.1.2)
|
||||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.5.0)
|
||||
rack (~> 1.2.1)
|
||||
rack-mount (~> 0.6.14)
|
||||
rack-test (~> 0.5.7)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
builder (~> 2.1.2)
|
||||
i18n (~> 0.5.0)
|
||||
activerecord (3.0.9)
|
||||
activemodel (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
arel (~> 2.0.10)
|
||||
tzinfo (~> 0.3.23)
|
||||
activeresource (3.0.9)
|
||||
activemodel (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
activesupport (3.0.9)
|
||||
arel (2.0.10)
|
||||
bcrypt-ruby (2.1.4)
|
||||
builder (2.1.2)
|
||||
capybara (1.0.0)
|
||||
actionmailer (3.1.0)
|
||||
actionpack (= 3.1.0)
|
||||
mail (~> 2.3.0)
|
||||
actionpack (3.1.0)
|
||||
activemodel (= 3.1.0)
|
||||
activesupport (= 3.1.0)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
i18n (~> 0.6)
|
||||
rack (~> 1.3.2)
|
||||
rack-cache (~> 1.0.3)
|
||||
rack-mount (~> 0.8.2)
|
||||
rack-test (~> 0.6.1)
|
||||
sprockets (~> 2.0.0)
|
||||
activemodel (3.1.0)
|
||||
activesupport (= 3.1.0)
|
||||
bcrypt-ruby (~> 3.0.0)
|
||||
builder (~> 3.0.0)
|
||||
i18n (~> 0.6)
|
||||
activerecord (3.1.0)
|
||||
activemodel (= 3.1.0)
|
||||
activesupport (= 3.1.0)
|
||||
arel (~> 2.2.1)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.1.0)
|
||||
activemodel (= 3.1.0)
|
||||
activesupport (= 3.1.0)
|
||||
activesupport (3.1.0)
|
||||
multi_json (~> 1.0)
|
||||
arel (2.2.1)
|
||||
bcrypt-ruby (3.0.1)
|
||||
builder (3.0.0)
|
||||
capybara (1.1.1)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 0.2.0)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 0.1.4)
|
||||
childprocess (0.1.9)
|
||||
childprocess (0.2.2)
|
||||
ffi (~> 1.0.6)
|
||||
database_cleaner (0.6.7)
|
||||
diff-lcs (1.1.2)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
factory_girl (2.0.1)
|
||||
factory_girl_rails (1.1.0)
|
||||
factory_girl (~> 2.0.0)
|
||||
diff-lcs (1.1.3)
|
||||
erubis (2.7.0)
|
||||
factory_girl (2.1.0)
|
||||
factory_girl_rails (1.2.0)
|
||||
factory_girl (~> 2.1.0)
|
||||
railties (>= 3.0.0)
|
||||
ffi (1.0.9)
|
||||
guard (0.6.3)
|
||||
guard (0.7.0)
|
||||
thor (~> 0.14.6)
|
||||
guard-rspec (0.4.4)
|
||||
guard-rspec (0.4.5)
|
||||
guard (>= 0.4.0)
|
||||
guard-spork (0.2.1)
|
||||
guard (>= 0.2.2)
|
||||
spork (>= 0.8.4)
|
||||
haml (3.1.2)
|
||||
i18n (0.5.0)
|
||||
json_pure (1.5.3)
|
||||
mail (2.2.19)
|
||||
activesupport (>= 2.3.6)
|
||||
haml (3.1.3)
|
||||
hike (1.2.1)
|
||||
i18n (0.6.0)
|
||||
json_pure (1.6.0)
|
||||
mail (2.3.0)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.16)
|
||||
multi_json (1.0.3)
|
||||
nokogiri (1.5.0)
|
||||
pg (0.11.0)
|
||||
polyglot (0.3.1)
|
||||
rack (1.2.2)
|
||||
rack-mount (0.6.14)
|
||||
polyglot (0.3.2)
|
||||
rack (1.3.2)
|
||||
rack-cache (1.0.3)
|
||||
rack (>= 0.4)
|
||||
rack-mount (0.8.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (0.5.7)
|
||||
rack-ssl (1.3.2)
|
||||
rack
|
||||
rack-test (0.6.1)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.9)
|
||||
actionmailer (= 3.0.9)
|
||||
actionpack (= 3.0.9)
|
||||
activerecord (= 3.0.9)
|
||||
activeresource (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
rails (3.1.0)
|
||||
actionmailer (= 3.1.0)
|
||||
actionpack (= 3.1.0)
|
||||
activerecord (= 3.1.0)
|
||||
activeresource (= 3.1.0)
|
||||
activesupport (= 3.1.0)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.0.9)
|
||||
railties (3.0.9)
|
||||
actionpack (= 3.0.9)
|
||||
activesupport (= 3.0.9)
|
||||
railties (= 3.1.0)
|
||||
railties (3.1.0)
|
||||
actionpack (= 3.1.0)
|
||||
activesupport (= 3.1.0)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
thor (~> 0.14.4)
|
||||
thor (~> 0.14.6)
|
||||
rake (0.9.2)
|
||||
rb-inotify (0.8.6)
|
||||
ffi (>= 0.5.0)
|
||||
rdoc (3.8)
|
||||
rdoc (3.9.4)
|
||||
rspec (2.6.0)
|
||||
rspec-core (~> 2.6.0)
|
||||
rspec-expectations (~> 2.6.0)
|
||||
@ -105,14 +112,20 @@ GEM
|
||||
railties (~> 3.0)
|
||||
rspec (~> 2.6.0)
|
||||
rubyzip (0.9.4)
|
||||
selenium-webdriver (0.2.2)
|
||||
childprocess (>= 0.1.9)
|
||||
selenium-webdriver (2.6.0)
|
||||
childprocess (>= 0.2.1)
|
||||
ffi (>= 1.0.7)
|
||||
json_pure
|
||||
rubyzip
|
||||
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)
|
||||
treetop (1.4.9)
|
||||
tilt (1.3.3)
|
||||
treetop (1.4.10)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.29)
|
||||
xpath (0.1.4)
|
||||
@ -131,7 +144,7 @@ DEPENDENCIES
|
||||
guard-spork
|
||||
haml
|
||||
pg
|
||||
rails (= 3.0.9)
|
||||
rails (= 3.1.0)
|
||||
rb-inotify
|
||||
rspec-rails
|
||||
spork (~> 0.9.0.rc)
|
||||
|
@ -10,7 +10,7 @@ class TracksController < ApplicationController
|
||||
def create
|
||||
@track = Track.new(:name => params[:track][:name])
|
||||
if @track.save_with_file(
|
||||
params[:track][:file].tempfile,
|
||||
params[:track][:file],
|
||||
params[:track][:file].content_type
|
||||
)
|
||||
redirect_to @track
|
||||
@ -19,9 +19,8 @@ class TracksController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def stream
|
||||
def download
|
||||
track = Track.find params[:id]
|
||||
self.content_type = track.mime_type
|
||||
self.response_body = Streamer.new(track.filepath)
|
||||
send_file track.filepath, :type => track.mime_type
|
||||
end
|
||||
end
|
||||
|
@ -3,8 +3,6 @@
|
||||
%head
|
||||
%meta{'charset' => 'utf-8'}
|
||||
%title scube
|
||||
= stylesheet_link_tag :all
|
||||
= javascript_include_tag :defaults
|
||||
= csrf_meta_tag
|
||||
%body
|
||||
= yield
|
||||
|
@ -1,3 +1,3 @@
|
||||
%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
|
||||
|
@ -2,9 +2,12 @@ require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
|
||||
# If you have a Gemfile, require the gems listed there, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
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
|
||||
class Application < Rails::Application
|
||||
@ -13,7 +16,7 @@ module Scube
|
||||
# -- 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}/lib)
|
||||
# config.autoload_paths += %W(#{config.root}/lib)
|
||||
|
||||
# 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.
|
||||
@ -30,9 +33,6 @@ module Scube
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
# 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.
|
||||
config.encoding = "utf-8"
|
||||
|
||||
@ -41,5 +41,11 @@ module Scube
|
||||
|
||||
# BestStandardsSupport is setting this fucking X-UA-Compatible header...
|
||||
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
|
||||
|
@ -11,7 +11,6 @@ Scube::Application.configure do
|
||||
|
||||
# Show full error reports and disable caching
|
||||
config.consider_all_requests_local = true
|
||||
config.action_view.debug_rjs = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# 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
|
||||
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
|
||||
# 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
|
||||
config.cache_classes = true
|
||||
|
||||
@ -9,14 +8,27 @@ Scube::Application.configure do
|
||||
config.consider_all_requests_local = false
|
||||
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
|
||||
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:
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
||||
|
||||
# If you have no front-end server that supports something like X-Sendfile,
|
||||
# just comment this out and Rails will serve the files
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
@ -27,13 +39,12 @@ Scube::Application.configure do
|
||||
# Use a different cache store in production
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Disable Rails's static 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
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||
# 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
|
||||
# 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!
|
||||
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
|
||||
|
||||
# Show full error reports and disable caching
|
||||
@ -32,4 +36,7 @@ Scube::Application.configure do
|
||||
|
||||
# Print deprecation notices to the 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
|
||||
|
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.
|
||||
# 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:
|
||||
hello: "Hello world"
|
||||
|
@ -4,8 +4,9 @@ Scube::Application.routes.draw do
|
||||
resources :sessions, :only => [:new, :create]
|
||||
|
||||
resources :tracks do
|
||||
get 'stream', :on => :member
|
||||
get 'download', :on => :member
|
||||
end
|
||||
|
||||
resources :playlists
|
||||
|
||||
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
|
||||
|
||||
describe 'GET stream' do
|
||||
describe 'GET download' do
|
||||
let(:track) { Factory.create(:track) }
|
||||
|
||||
it 'streams the requested track' do
|
||||
get :stream, :id => track.id.to_s
|
||||
get :download, :id => track.id.to_s
|
||||
response.should be_success
|
||||
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
|
||||
get :stream, :id => track.id.to_s
|
||||
get :download, :id => track.id.to_s
|
||||
response.content_type.should == track.mime_type
|
||||
end
|
||||
end
|
||||
@ -42,10 +37,7 @@ describe TracksController do
|
||||
describe 'POST create' do
|
||||
let(:track) { mock_model(Track).as_null_object }
|
||||
let(:file) {
|
||||
file = mock(Rack::Test::UploadedFile)
|
||||
file.stub(:tempfile => File.new("#{Rails.root}/spec/fixtures/test.mp3"))
|
||||
file.stub(:content_type => 'audio/ogg')
|
||||
file
|
||||
fixture_file_upload("#{Rails.root}/spec/fixtures/test.mp3", 'audio/mpeg')
|
||||
}
|
||||
before { Track.stub(:new).and_return(track) }
|
||||
|
||||
@ -62,7 +54,7 @@ describe TracksController do
|
||||
|
||||
it 'saves the track with a file' do
|
||||
track.should_receive(:save_with_file).
|
||||
with(file.tempfile, 'audio/ogg')
|
||||
with(file, 'audio/mpeg')
|
||||
post :create, :track => { :file => file }
|
||||
end
|
||||
|
||||
|
@ -8,6 +8,10 @@ FactoryGirl.define do
|
||||
name 'Mega song'
|
||||
mime_type 'audio/ogg'
|
||||
sha256 '94a5486a69a7261da350c57f9e5a1eaa789e08752cfc56a1989976a6ad82f7a8'
|
||||
|
||||
after_create do |t|
|
||||
t.save_with_file(File.new("#{Rails.root}/spec/fixtures/test.mp3"), 'audio/mpeg')
|
||||
end
|
||||
end
|
||||
|
||||
factory :user do
|
||||
|
@ -34,7 +34,7 @@ feature 'Tracks' do
|
||||
|
||||
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]
|
||||
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
|
||||
class Engine
|
||||
[:DEFAULT_COST, :MIN_COST].each do |sym|
|
||||
remove_const sym
|
||||
const_set sym, 1
|
||||
end
|
||||
remove_const :DEFAULT_COST
|
||||
const_set :DEFAULT_COST, 4
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user