comfortable_mexican_sofa 1.6.19 → 1.6.20

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.19
1
+ 1.6.20
@@ -27,7 +27,9 @@ class CmsAdmin::BaseController < ApplicationController
27
27
  protected
28
28
 
29
29
  def load_admin_site
30
- unless (@site = Cms::Site.find_by_id(params[:site_id]) || Cms::Site.first)
30
+ if @site = Cms::Site.find_by_id(params[:site_id] || session[:site_id]) || Cms::Site.first
31
+ session[:site_id] = @site.id
32
+ else
31
33
  I18n.locale = ComfortableMexicanSofa.config.admin_locale || I18n.default_locale
32
34
  flash[:error] = I18n.t('cms.base.site_not_found')
33
35
  return redirect_to(new_cms_admin_site_path)
@@ -8,6 +8,7 @@ class CmsAdmin::SitesController < CmsAdmin::BaseController
8
8
 
9
9
  def index
10
10
  return redirect_to :action => :new if Cms::Site.count == 0
11
+ @site = Cms::Site.find_by_id(session[:site_id])
11
12
  @sites = Cms::Site.all
12
13
  end
13
14
 
@@ -4,6 +4,9 @@ class Cms::Block < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'cms_blocks'
6
6
 
7
+ attr_accessible :identifier,
8
+ :content
9
+
7
10
  # -- Relationships --------------------------------------------------------
8
11
  belongs_to :page
9
12
  has_many :files,
@@ -4,6 +4,8 @@ class Cms::Categorization < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'cms_categorizations'
6
6
 
7
+ attr_accessible :categorized
8
+
7
9
  # -- Relationships --------------------------------------------------------
8
10
  belongs_to :category
9
11
  belongs_to :categorized,
@@ -4,6 +4,9 @@ class Cms::Category < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'cms_categories'
6
6
 
7
+ attr_accessible :label,
8
+ :categorized_type
9
+
7
10
  # -- Relationships --------------------------------------------------------
8
11
  belongs_to :site
9
12
  has_many :categorizations,
@@ -10,6 +10,12 @@ class Cms::File < ActiveRecord::Base
10
10
 
11
11
  attr_accessor :dimensions
12
12
 
13
+ attr_accessible :site, :site_id,
14
+ :file,
15
+ :dimentions,
16
+ :label,
17
+ :description
18
+
13
19
  # -- AR Extensions --------------------------------------------------------
14
20
  has_attached_file :file, ComfortableMexicanSofa.config.upload_file_options.merge(
15
21
  # dimensions accessor needs to be set before file assignment for this to work
@@ -8,6 +8,14 @@ class Cms::Layout < ActiveRecord::Base
8
8
  cms_is_mirrored
9
9
  cms_has_revisions_for :content, :css, :js
10
10
 
11
+ attr_accessible :label,
12
+ :identifier,
13
+ :content,
14
+ :css,
15
+ :js,
16
+ :parent, :parent_id,
17
+ :app_layout
18
+
11
19
  # -- Relationships --------------------------------------------------------
12
20
  belongs_to :site
13
21
  has_many :pages, :dependent => :nullify
@@ -5,6 +5,12 @@ class Cms::Page < ActiveRecord::Base
5
5
 
6
6
  self.table_name = 'cms_pages'
7
7
 
8
+ attr_accessible :layout, :layout_id,
9
+ :label,
10
+ :slug,
11
+ :parent, :parent_id,
12
+ :blocks_attributes
13
+
8
14
  cms_acts_as_tree :counter_cache => :children_count
9
15
  cms_is_categorized
10
16
  cms_is_mirrored
@@ -25,12 +31,12 @@ class Cms::Page < ActiveRecord::Base
25
31
  # -- Callbacks ------------------------------------------------------------
26
32
  before_validation :assigns_label,
27
33
  :assign_parent
28
- after_validation :escape_slug
29
- before_create :assign_position
30
- before_save :assign_full_path,
31
- :set_cached_content
32
- after_save :sync_child_pages
33
- after_find :unescape_slug_and_path
34
+ after_validation :escape_slug
35
+ before_create :assign_position
36
+ before_save :assign_full_path,
37
+ :set_cached_content
38
+ after_save :sync_child_pages
39
+ after_find :unescape_slug_and_path
34
40
 
35
41
  # -- Validations ----------------------------------------------------------
36
42
  validates :site_id,
@@ -178,8 +184,8 @@ protected
178
184
 
179
185
  # Unescape the slug and full path back into their original forms unless they're nonexistent
180
186
  def unescape_slug_and_path
181
- self.slug = CGI::unescape(self.slug) unless self.slug.nil?
182
- self.full_path = CGI::unescape(self.full_path) unless self.full_path.nil?
187
+ self.slug = CGI::unescape(self.slug) unless self.slug.nil?
188
+ self.full_path = CGI::unescape(self.full_path) unless self.full_path.nil?
183
189
  end
184
190
 
185
191
  end
@@ -6,6 +6,8 @@ class Cms::Revision < ActiveRecord::Base
6
6
 
7
7
  serialize :data
8
8
 
9
+ attr_accessible :data
10
+
9
11
  # -- Relationships --------------------------------------------------------
10
12
  belongs_to :record, :polymorphic => true
11
13
 
@@ -4,6 +4,13 @@ class Cms::Site < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'cms_sites'
6
6
 
7
+ attr_accessible :identifier,
8
+ :label,
9
+ :hostname,
10
+ :path,
11
+ :locale,
12
+ :is_mirrored
13
+
7
14
  # -- Relationships --------------------------------------------------------
8
15
  has_many :layouts, :dependent => :delete_all
9
16
  has_many :pages, :dependent => :delete_all
@@ -8,6 +8,10 @@ class Cms::Snippet < ActiveRecord::Base
8
8
  cms_is_mirrored
9
9
  cms_has_revisions_for :content
10
10
 
11
+ attr_accessible :identifier,
12
+ :label,
13
+ :content
14
+
11
15
  # -- Relationships --------------------------------------------------------
12
16
  belongs_to :site
13
17
 
@@ -12,7 +12,7 @@
12
12
  <div class='details'>
13
13
  <input type='text' value='<%= file.file.url %>'/>
14
14
  <div class='file_type'><%= file.file_content_type %></div>
15
- <div class='file_size'><%= number_to_human_size(file.file_file_size) %></div>
15
+ <div class='file_size'><%= number_to_human_size(file.file_file_size, :locale => :en) %></div>
16
16
  </div>
17
17
  </div>
18
18
  </div>
@@ -1,6 +1,6 @@
1
1
  <ul class='nav'>
2
2
  <li><%= active_link_to t('cms_admin.base.sites'), cms_admin_sites_path, :active => :exclusive %></li>
3
- <% if @site && params[:controller] != 'cms_admin/sites' %>
3
+ <% if @site && !@site.new_record? %>
4
4
  <li><%= active_link_to t('cms_admin.base.layouts'), cms_admin_site_layouts_path(@site) %></li>
5
5
  <li><%= active_link_to t('cms_admin.base.pages'), cms_admin_site_pages_path(@site) %></li>
6
6
  <li><%= active_link_to t('cms_admin.base.snippets'), cms_admin_site_snippets_path(@site) %></li>
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "comfortable_mexican_sofa"
8
- s.version = "1.6.19"
8
+ s.version = "1.6.20"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov", "The Working Group Inc"]
12
- s.date = "2012-05-24"
12
+ s.date = "2012-05-28"
13
13
  s.description = ""
14
14
  s.email = "oleg@theworkinggroup.ca"
15
15
  s.extra_rdoc_files = [
@@ -41,8 +41,16 @@ module ComfortableMexicanSofa
41
41
  # Configure sensitive parameters which will be filtered from the log file.
42
42
  config.filter_parameters += [:password]
43
43
 
44
+ # Enforce whitelist mode for mass assignment.
45
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
46
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
47
+ # parameters by using an attr_accessible or attr_protected declaration.
48
+ if config.active_record.respond_to?(:whitelist_attributes)
49
+ config.active_record.whitelist_attributes = true
50
+ end
51
+
44
52
  # Enable the asset pipeline
45
- if Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1
53
+ if config.respond_to?(:assets)
46
54
  config.assets.enabled = true
47
55
  end
48
56
 
@@ -50,7 +50,7 @@ module ComfortableMexicanSofa::IsMirrored
50
50
  :slug => self.slug,
51
51
  :label => self.slug.blank?? self.label : m.label,
52
52
  :parent_id => site.pages.find_by_full_path(self.parent.try(:full_path)).try(:id),
53
- :layout => site.layouts.find_by_identifier(self.layout.identifier)
53
+ :layout => site.layouts.find_by_identifier(self.layout.try(:identifier))
54
54
  }
55
55
  m
56
56
  when Cms::Snippet
@@ -62,7 +62,11 @@ module ComfortableMexicanSofa::IsMirrored
62
62
  end
63
63
 
64
64
  mirror.is_mirrored = true
65
- mirror.save!
65
+ begin
66
+ mirror.save!
67
+ rescue ActiveRecord::RecordInvalid
68
+ logger.detailed_error($!)
69
+ end
66
70
  end
67
71
  end
68
72
 
@@ -89,7 +89,7 @@ module ComfortableMexicanSofa::Fixtures
89
89
  Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path|
90
90
  slug = path.split('/').last
91
91
  page = if parent
92
- parent.children.find_by_slug(slug) || parent.children.new(:slug => slug, :site => site)
92
+ parent.children.find_by_slug(slug) || site.pages.new(:parent => parent, :slug => slug)
93
93
  else
94
94
  site.pages.root || site.pages.new(:slug => slug)
95
95
  end
@@ -8,7 +8,7 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
8
8
  assert assigns(:pages)
9
9
  assert_template :index
10
10
  end
11
-
11
+
12
12
  def test_get_index_with_no_pages
13
13
  Cms::Page.delete_all
14
14
  get :index, :site_id => cms_sites(:default)
@@ -214,6 +214,13 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
214
214
  assert assigns(:page).layout
215
215
  end
216
216
 
217
+ def test_get_edit_with_non_english_locale
218
+ site = cms_sites(:default)
219
+ site.update_attribute(:locale, 'es')
220
+ get :edit, :site_id => site, :id => cms_pages(:default)
221
+ assert_response :success
222
+ end
223
+
217
224
  def test_creation
218
225
  assert_difference 'Cms::Page.count' do
219
226
  assert_difference 'Cms::Block.count', 2 do
@@ -67,8 +67,10 @@ class CmsAdmin::SitesControllerTest < ActionController::TestCase
67
67
  def test_update
68
68
  site = cms_sites(:default)
69
69
  put :update, :id => site, :site => {
70
- :label => 'New Site',
71
- :hostname => 'new.site.local'
70
+ :label => 'New Site',
71
+ :hostname => 'new.site.local',
72
+ :locale => 'es',
73
+ :is_mirrored => '1'
72
74
  }
73
75
  assert_response :redirect
74
76
  assert_redirected_to :action => :edit, :id => site
@@ -76,6 +78,8 @@ class CmsAdmin::SitesControllerTest < ActionController::TestCase
76
78
  site.reload
77
79
  assert_equal 'New Site', site.label
78
80
  assert_equal 'new.site.local', site.hostname
81
+ assert_equal 'es', site.locale
82
+ assert site.is_mirrored?
79
83
  end
80
84
 
81
85
  def test_update_failure
@@ -16,8 +16,7 @@ class CmsBlockTest < ActiveSupport::TestCase
16
16
 
17
17
  def test_creation_via_page_nested_attributes
18
18
  assert_difference ['Cms::Page.count', 'Cms::Block.count'] do
19
- page = Cms::Page.create!(
20
- :site => cms_sites(:default),
19
+ page = cms_sites(:default).pages.create!(
21
20
  :layout => cms_layouts(:default),
22
21
  :label => 'test page',
23
22
  :slug => 'test_page',
@@ -38,8 +37,7 @@ class CmsBlockTest < ActiveSupport::TestCase
38
37
 
39
38
  def test_creation_via_page_nested_attributes_as_hash
40
39
  assert_difference ['Cms::Page.count', 'Cms::Block.count'] do
41
- page = Cms::Page.create!(
42
- :site => cms_sites(:default),
40
+ page = cms_sites(:default).pages.create!(
43
41
  :layout => cms_layouts(:default),
44
42
  :label => 'test page',
45
43
  :slug => 'test_page',
@@ -60,8 +58,7 @@ class CmsBlockTest < ActiveSupport::TestCase
60
58
 
61
59
  def test_creation_via_page_nested_attributes_as_hash_with_duplicates
62
60
  assert_difference ['Cms::Page.count', 'Cms::Block.count'] do
63
- page = Cms::Page.create!(
64
- :site => cms_sites(:default),
61
+ page = cms_sites(:default).pages.create!(
65
62
  :layout => cms_layouts(:default),
66
63
  :label => 'test page',
67
64
  :slug => 'test_page',
@@ -90,8 +87,7 @@ class CmsBlockTest < ActiveSupport::TestCase
90
87
 
91
88
  page = nil
92
89
  assert_difference ['Cms::Page.count', 'Cms::Block.count', 'Cms::File.count'] do
93
- page = Cms::Page.create!(
94
- :site => cms_sites(:default),
90
+ page = cms_sites(:default).pages.create!(
95
91
  :layout => layout,
96
92
  :label => 'test page',
97
93
  :slug => 'test_page',
@@ -134,8 +130,7 @@ class CmsBlockTest < ActiveSupport::TestCase
134
130
  page = nil
135
131
  assert_difference ['Cms::Page.count', 'Cms::Block.count'] do
136
132
  assert_difference 'Cms::File.count', 2 do
137
- page = Cms::Page.create!(
138
- :site => cms_sites(:default),
133
+ page = cms_sites(:default).pages.create!(
139
134
  :layout => layout,
140
135
  :label => 'test page',
141
136
  :slug => 'test_page',
@@ -177,8 +172,7 @@ class CmsBlockTest < ActiveSupport::TestCase
177
172
 
178
173
  assert_difference 'Cms::Page.count' do
179
174
  assert_difference 'Cms::Block.count', 3 do
180
- page = Cms::Page.create!(
181
- :site => cms_sites(:default),
175
+ page = cms_sites(:default).pages.create!(
182
176
  :layout => layout,
183
177
  :label => 'test page',
184
178
  :slug => 'test_page',
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.6.19
4
+ version: 1.6.20
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: 2012-05-24 00:00:00.000000000 Z
13
+ date: 2012-05-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -384,7 +384,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
384
384
  version: '0'
385
385
  segments:
386
386
  - 0
387
- hash: 1154446217690371427
387
+ hash: 3514363953654359561
388
388
  required_rubygems_version: !ruby/object:Gem::Requirement
389
389
  none: false
390
390
  requirements: