Permalink
Browse files

Move Rails dependency down to 3.0

  • Loading branch information...
1 parent 93bba17 commit f98b4d472c2c3fb9971743b6fbbf7e039a77089e @airhorns committed May 5, 2012
Showing with 38 additions and 6 deletions.
  1. +1 −1 Gemfile
  2. +4 −0 lib/sprockets/rails/railtie.rb
  3. +1 −1 sprockets-rails.gemspec
  4. +28 −0 test/abstract_unit.rb
  5. +4 −4 test/assets_debugging_test.rb
View
@@ -3,7 +3,7 @@ source "http://rubygems.org"
# Specify your gem's dependencies in sprockets-rails.gemspec
gemspec
-gem "rails", :git => "git://github.com/rails/rails"
+gem "rails"
gem "uglifier", :require => false
gem "mocha"
gem "jquery-rails"
@@ -20,6 +20,7 @@ class Railtie < ::Rails::Railtie
next unless config.assets.enabled
require 'sprockets'
+ FileUtils.mkdir_p('tmp/cache/assets')
app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
env.version = ::Rails.env + "-#{config.assets.version}"
@@ -43,6 +44,9 @@ class Railtie < ::Rails::Railtie
config.assets.digests = YAML.load_file(path)
end
+ config.assets.paths.unshift(*config.paths.vendor.assets.existent_directories)
+ config.assets.paths.unshift(*config.paths.app.assets.existent_directories)
+
ActiveSupport.on_load(:action_view) do
include ::Sprockets::Rails::Helpers::RailsHelper
app.assets.context_class.instance_eval do
View
@@ -15,5 +15,5 @@ Gem::Specification.new do |s|
s.test_files = Dir["test/**/*"]
s.add_runtime_dependency "sprockets", "~> 2.4.1"
- s.add_runtime_dependency "railties", ">= 4.0.0.beta", '< 5.0'
+ s.add_runtime_dependency "railties", "~> 3.0.0"
end
View
@@ -74,8 +74,36 @@ def build_app(options = {})
end
add_to_config 'config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"; config.session_store :cookie_store, :key => "_myapp_session"; config.active_support.deprecation = :log'
+
+ add_to_env_config 'production', <<-RUBY
+
+ config.assets.enabled = true
+
+ # 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
+ RUBY
+
+ add_to_env_config 'development', <<-RUBY
+
+ config.assets.enabled = true
+
+ # Do not compress assets.
+ config.assets.compress = false
+
+ config.assets.compile = true
+
+ # Expands the lines which load the assets.
+ config.assets.debug = true
+ RUBY
end
+
def teardown_app
ENV['RAILS_ENV'] = @prev_rails_env if @prev_rails_env
end
@@ -45,8 +45,8 @@ class ::PostsController < ActionController::Base ; end
# the debug_assets params isn't used if compile is off
get '/posts?debug_assets=true'
- assert_match(/<script src="\/assets\/application-([0-z]+)\.js"><\/script>/, last_response.body)
- assert_no_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js"><\/script>/, last_response.body)
+ assert_match(/<script src="\/assets\/application-([0-z]+)\.js" type=\"text\/javascript\"><\/script>/, last_response.body)
+ assert_no_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js" type=\"text\/javascript\"><\/script>/, last_response.body)
end
test "assets aren't concatened when compile is true is on and debug_assets params is true" do
@@ -58,8 +58,8 @@ class ::PostsController < ActionController::Base ; end
class ::PostsController < ActionController::Base ; end
get '/posts?debug_assets=true'
- assert_match(/<script src="\/assets\/application-([0-z]+)\.js\?body=1"><\/script>/, last_response.body)
- assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1"><\/script>/, last_response.body)
+ assert_match(/<script src="\/assets\/application-([0-z]+)\.js\?body=1" type=\"text\/javascript\"><\/script>/, last_response.body)
+ assert_match(/<script src="\/assets\/xmlhr-([0-z]+)\.js\?body=1" type=\"text\/javascript\"><\/script>/, last_response.body)
end
end
end

0 comments on commit f98b4d4

Please sign in to comment.