-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathtest_jammit_controller.rb
More file actions
51 lines (44 loc) · 1.51 KB
/
test_jammit_controller.rb
File metadata and controls
51 lines (44 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'test_helper'
require 'active_support'
require 'action_pack'
require 'action_controller'
require 'action_controller/base'
require 'action_controller/test_case'
require 'jammit/controller'
require 'jammit/routes'
require 'action_dispatch'
class JammitController
def self.controller_path
"jammit"
end
# Tests needs this defined otherwise it will call
# the parent ActionController::UrlFor#url_options
# That method doesn't work since it depends on
# Rail's boot process defining the routes
def url_options
{}
end
end
class JammitControllerTest < ActionController::TestCase
def setup
Jammit.load_configuration('test/config/assets.yml')
# Perform the routing setup that Rails needs to test the controller
@routes = ::ActionDispatch::Routing::RouteSet.new
@routes.draw do
get "/package/:package.:extension",
:to => 'jammit#package', :as => :jammit, :constraints => {
:extension => /.+/
}
end
end
def test_package_with_jst
get(:package, :package => 'jst_test', :extension => 'jst')
assert_equal( File.read("#{ASSET_ROOT}/fixtures/jammed/jst_test.js"), @response.body )
assert_match( /text\/javascript/, @response.headers['Content-Type'] )
end
def test_package_with_jst_mixed
get(:package, :package => 'js_test_with_templates', :extension => 'jst')
assert_equal( File.read("#{ASSET_ROOT}/fixtures/jammed/jst_test.js"), @response.body )
assert_match( /text\/javascript/, @response.headers['Content-Type'] )
end
end