comfortable_mexican_sofa 1.8.4 → 1.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,9 +9,17 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController
9
9
  @files = @site.files.includes(:categories).for_category(params[:category]).order('cms_files.position')
10
10
 
11
11
  if params[:ajax]
12
- files = @files.images.collect do |file|
13
- { :thumb => file.file.url(:cms_thumb),
14
- :image => file.file.url }
12
+ if params[:not_images]
13
+ files = @files.not_images.collect do |file|
14
+ { :label => file.label,
15
+ :filename => file.file_file_name,
16
+ :url => file.file.url }
17
+ end
18
+ else
19
+ files = @files.images.collect do |file|
20
+ { :thumb => file.file.url(:cms_thumb),
21
+ :image => file.file.url }
22
+ end
15
23
  end
16
24
  render :json => files
17
25
  else
@@ -47,7 +55,7 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController
47
55
 
48
56
  if params[:ajax]
49
57
  view = render_to_string(:partial => 'cms_admin/files/file', :collection => @files, :layout => false)
50
- render :json => {:filelink => @file.file.url, :view => view.gsub("\n", '')}
58
+ render :json => {:filelink => @file.file.url, :filename => @file.file_file_name, :view => view.gsub("\n", '')}
51
59
  else
52
60
  flash[:success] = I18n.t('cms.files.created')
53
61
  redirect_to :action => :edit, :id => @file
@@ -106,7 +106,7 @@ protected
106
106
  @cms_site = @page.site
107
107
  @cms_layout = @page.layout
108
108
  @cms_page = @page
109
- render :inline => @page.content(true), :layout => layout
109
+ render :inline => @page.content(true), :layout => layout, :content_type => 'text/html'
110
110
  end
111
111
  end
112
112
  end
@@ -1,3 +1,3 @@
1
1
  module ComfortableMexicanSofa
2
- VERSION = "1.8.4"
2
+ VERSION = "1.8.5"
3
3
  end
@@ -41,7 +41,20 @@ class CmsAdmin::FilesControllerTest < ActionController::TestCase
41
41
  'image' => file.file.url
42
42
  }], r
43
43
  end
44
-
44
+
45
+ def test_get_index_as_ajax_with_no_images
46
+ file = cms_files(:default)
47
+ file.update_attribute(:file_content_type, 'text/plain')
48
+ get :index, :site_id => cms_sites(:default), :not_images => 1, :ajax => true
49
+ assert_response :success
50
+ r = JSON.parse(response.body)
51
+ assert_equal [{
52
+ 'label' => file.label,
53
+ 'filename' => file.file_file_name,
54
+ 'url' => file.file.url
55
+ }], r
56
+ end
57
+
45
58
  def test_get_new
46
59
  site = cms_sites(:default)
47
60
  get :new, :site_id => site
@@ -133,6 +146,7 @@ class CmsAdmin::FilesControllerTest < ActionController::TestCase
133
146
  file = Cms::File.last
134
147
  r = JSON.parse(response.body)
135
148
  assert_equal file.file.url, r['filelink']
149
+ assert_equal file.file_file_name, r['filename']
136
150
  assert_present r['view']
137
151
  end
138
152
  end
@@ -370,6 +370,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
370
370
  }
371
371
  assert_response :success
372
372
  assert_match /preview content/, response.body
373
+ assert_equal 'text/html', response.content_type
373
374
 
374
375
  assert_equal site, assigns(:cms_site)
375
376
  assert_equal layout, assigns(:cms_layout)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfortable_mexican_sofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4
4
+ version: 1.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-10 00:00:00.000000000 Z
13
+ date: 2013-09-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails