Permalink
Browse files

fixed rspec error.

  • Loading branch information...
1 parent e24b1a9 commit 07490171e1efca7bd1b459652b0b65d46957ce89 @saberma saberma committed Feb 2, 2012
View
@@ -81,7 +81,7 @@ def plan_unlimited?
end
def storage # 已占用的容量(如要支持windows可修改为循环获取目录大小)
- Rails.cache.fetch(self.storage_cache_key, expires_in: 5.minutes) do
+ smart_fetch(self.storage_cache_key, expires_in: 5.minutes) do
`du -sm #{self.path} | awk '{print $1}'`.to_i # 以M为单位
end
end
@@ -20,6 +20,16 @@ def as_json(options={})
Carmen.default_locale = :cn
+# 修正:DEPRECATION WARNING: Setting :expires_in on read has been deprecated in favor of setting it on write
+def smart_fetch(name, options = {}, &blk)
+ in_cache = Rails.cache.fetch(name)
+ return in_cache if in_cache
+ if block_given?
+ val = yield
+ Rails.cache.write(name, val, options)
+ return val
+ end
+end
#增加subdomain属性
#rails 3.1默认支持subdomain和domain
@@ -32,13 +32,10 @@
let(:file_path) { Rails.root.join('spec', 'factories', 'data', 'themes') }
- before do
- post :upload, key: 'assets/product.jpg', theme_id: theme.id, id: 0, qqfile: Rack::Test::UploadedFile.new(File.join(file_path, 'product.jpg'))
- end
-
describe 'ie' do # 支持ie浏览器上传
it 'should be success' do
+ post :upload, key: 'assets/product.jpg', theme_id: theme.id, id: 0, qqfile: Rack::Test::UploadedFile.new(File.join(file_path, 'product.jpg'))
response.should be_success
response.content_type.should eql 'text/html' # context_type不为'text/html'时,ie会将json作为文件下载
end
@@ -51,7 +48,10 @@
before { Rails.cache.write(shop.storage_cache_key, 101) }
+ after { Rails.cache.delete(shop.storage_cache_key) }
+
it 'should be fail' do
+ post :upload, key: 'assets/product.jpg', theme_id: theme.id, id: 0, qqfile: Rack::Test::UploadedFile.new(File.join(file_path, 'product.jpg'))
JSON(response.body)['storage_full'].should be_true
end
@@ -37,7 +37,7 @@
shop.themes.install theme_dark # 原主题会置为[未发布]状态
end
- it 'should be duplicate' do
+ it 'should be success' do
expect do
put :duplicate, id: theme.id
JSON(response.body)['shop_theme']['role'].should eql 'unpublished'
@@ -50,6 +50,8 @@
before { Rails.cache.write(shop.storage_cache_key, 101) }
+ after { Rails.cache.delete(shop.storage_cache_key) }
+
it 'should be fail' do
put :duplicate, id: theme.id
JSON(response.body)['storage_full'].should eql true
@@ -127,6 +129,8 @@
before { Rails.cache.write(shop.storage_cache_key, 101) }
+ after { Rails.cache.delete(shop.storage_cache_key) }
+
it 'should be fail' do
raw_attach_file File.join(zip_path, 'woodland-missing-templates-index.zip')
post :upload, qqfile: 'woodland.zip'
@@ -169,6 +173,8 @@
before { Rails.cache.write(shop.storage_cache_key, 101) }
+ after { Rails.cache.delete(shop.storage_cache_key) }
+
it 'should be fail' do
post :install, handle: theme_slate.handle, style_handle: theme_slate.style_handle
JSON(response.body)['error'].should_not be_blank

0 comments on commit 0749017

Please sign in to comment.