trackman 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,10 @@
1
1
  module Trackman
2
2
  module Path
3
3
  module Rails32Resolver
4
- include Resolver
4
+ include RailsResolver
5
5
 
6
+ alias old_rails_translate translate
7
+
6
8
  def translate url, parent_url
7
9
  root = working_dir.realpath
8
10
 
@@ -14,16 +16,20 @@ module Trackman
14
16
  begin
15
17
  path = sprockets.resolve path
16
18
  rescue Sprockets::FileNotFound => e
17
- Trackman::Utility::Debugger.trace "Could not find path: #{path}\n#{e.message}"
18
- return nil
19
+ Trackman::Utility::Debugger.trace "Sprocket did not find path: #{path}\n#{e.message}"
20
+ return old_rails_translate(url, parent_url)
19
21
  end
20
22
  path.relative_path_from(root).to_s
21
23
  end
22
24
 
25
+
23
26
  def prepare_for_sprocket path, parent_url, root
24
27
  folder = (root + Pathname.new(parent_url)).parent.realpath
25
28
  path = (folder + path).to_s
26
- path.slice! sprockets.paths.select{|p| path.include? p }.first
29
+
30
+ same_path = sprockets.paths.select{|p| path.include? p }.first
31
+ path.slice!(same_path) unless same_path.nil?
32
+
27
33
  path
28
34
  end
29
35
 
@@ -1,3 +1,3 @@
1
1
  module Trackman
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
@@ -19,5 +19,17 @@ describe Trackman::Path::Rails32Resolver do
19
19
 
20
20
  lambda { @test.translate 'some/path', 'path/to/my/parent' }.should_not raise_error
21
21
  end
22
+
23
+ it "can resolve public assets when sprocket cannot find anything" do
24
+ sprocket = double "SprocketEnvironment"
25
+ sprocket.stub(:paths).and_return([])
26
+ sprocket.stub(:resolve).and_raise Sprockets::FileNotFound
22
27
 
28
+ @test.stub(:sprockets).and_return(sprocket)
29
+
30
+ result = @test.translate 'favicon.ico', 'spec/fixtures/rails32/happy-path/public/503.html'
31
+
32
+ #I know path is not good but I think this is what we want to achieve
33
+ result.should == 'public/spec/fixtures/rails32/happy-path/public/favicon.ico'
34
+ end
23
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: