Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed rspec error.

  • Loading branch information...
commit 07490171e1efca7bd1b459652b0b65d46957ce89 1 parent e24b1a9
@saberma saberma authored
View
2  app/models/shop.rb
@@ -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
View
10 config/initializers/add_method_to_ruby.rb
@@ -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
View
8 spec/controllers/admin/assets_controller_spec.rb
@@ -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
View
8 spec/controllers/admin/themes_controller_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.