Skip to content

Commit

Permalink
Merge e280c48 into 3ad40ef
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalzbank committed May 28, 2013
2 parents 3ad40ef + e280c48 commit 15e4bdf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/premailer/rails/css_loaders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def request_and_unzip(file)
::Rails.configuration.assets.prefix.sub(/^\//, ''),
::Rails.configuration.assets.digests[file]
].join('/')
response = Kernel.open(url)
response = Kernel.open(url) rescue return

begin
Zlib::GzipReader.new(response).read
Expand Down
26 changes: 26 additions & 0 deletions spec/lib/css_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,32 @@ def css_for_doc(doc)
).should == 'content of base.css'
end
end

context 'when asset can not be found and it is not in the digest' do
before {
Kernel.stubs(:open).raises(Errno::ENOENT)
Rails.application.assets.stubs(:find_asset).returns(nil)
Rails.configuration.stubs(:action_controller).returns(
stub(:asset_host => 'http://example.com')
)
Rails.configuration.stubs(:assets).returns(
stub(
:enabled => true,
:prefix => '/assets',
:digests => { }
)
)
}

it 'should request the static file' do
File.expects(:read) \
.with('RAILS_ROOT/public/stylesheets/base.css') \
.returns('content of base.css')

load_css('/stylesheets/base.css') \
.should == 'content of base.css'
end
end
end

context 'when static stylesheets are used' do
Expand Down

0 comments on commit 15e4bdf

Please sign in to comment.