comfortable_mexican_sofa 1.6.14 → 1.6.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,7 +5,7 @@ ComfortableMexicanSofa is a powerful CMS Engine for your Rails 3 applications.
5
5
 
6
6
  Features
7
7
  --------
8
- * Simple integration with Rails 3.0 and 3.1 apps
8
+ * Simple integration with Rails 3 apps (with or without assets pipeline)
9
9
  * Build your application in Rails, not in CMS
10
10
  * Powerful page templating capability using [Tags](https://github.com/comfy/comfortable-mexican-sofa/wiki/Tags)
11
11
  * [Multiple Sites](https://github.com/comfy/comfortable-mexican-sofa/wiki/Sites) from a single installation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.14
1
+ 1.6.15
@@ -122,29 +122,35 @@
122
122
  #cms_body ul.list li .item .toggle.open a {
123
123
  background-image: url(/assets/comfortable_mexican_sofa/arrow_bottom.gif);
124
124
  }
125
- #cms_body ul.list li .item .icon {
125
+ #cms_body ul.list li .item .icon,
126
+ #cms_body table.formatted td .icon {
126
127
  float: left;
127
128
  width: 28px;
128
129
  height: 28px;
129
130
  background: url(/assets/comfortable_mexican_sofa/icon_regular.gif);
130
131
  }
131
- #cms_body ul.list li .item .icon.draft {
132
+ #cms_body ul.list li .item .icon.draft,
133
+ #cms_body table.formatted td .icon.draft {
132
134
  background: url(/assets/comfortable_mexican_sofa/icon_draft.gif);
133
135
  }
134
- #cms_body ul.list li .item .icon .dragger {
136
+ #cms_body ul.list li .item .icon .dragger,
137
+ #cms_body table.formatted td .icon .dragger {
135
138
  width: 28px;
136
139
  height: 28px;
137
140
  background: url(/assets/comfortable_mexican_sofa/icon_move.gif);
138
141
  cursor: move;
139
142
  display: none;
140
143
  }
141
- #cms_body ul.list li .item .icon:hover .dragger {
144
+ #cms_body ul.list li .item .icon:hover .dragger,
145
+ #cms_body table.formatted td .icon:hover .dragger {
142
146
  display: block;
143
147
  }
144
- #cms_body ul.list li .item .icon .dragger span {
148
+ #cms_body ul.list li .item .icon .dragger span,
149
+ #cms_body table.formatted td .icon .dragger span {
145
150
  display: none;
146
151
  }
147
- #cms_body ul.list li .item .label {
152
+ #cms_body ul.list li .item .label,
153
+ #cms_body table.formatted td .label {
148
154
  margin-left: 32px;
149
155
  font-size: 14px;
150
156
  font-weight: bold;
@@ -158,7 +164,8 @@
158
164
  text-transform: uppercase;
159
165
  color: #888;
160
166
  }
161
- #cms_body ul.list li .item .label .sublabel {
167
+ #cms_body ul.list li .item .label .sublabel,
168
+ #cms_body table.formatted td .label .sublabel {
162
169
  font-size: 10px;
163
170
  font-weight: normal;
164
171
  }
@@ -197,6 +204,12 @@
197
204
  #cms_body table.formatted tr:hover td {
198
205
  background-color: #fff
199
206
  }
207
+ #cms_body table.formatted tr td.action_links a {
208
+ opacity: 0.2;
209
+ }
210
+ #cms_body table.formatted tr:hover td.action_links a {
211
+ opacity: 1;
212
+ }
200
213
 
201
214
  /* -- Missing Translations ---------------------------------------------- */
202
215
  #cms_body .translation_missing {
@@ -54,7 +54,7 @@ protected
54
54
  I18n.locale = @cms_site.locale
55
55
  else
56
56
  I18n.locale = I18n.default_locale
57
- render :text => I18n.t('cms.content.site_not_found'), :status => 404
57
+ raise ActionController::RoutingError.new('Site Not Found')
58
58
  end
59
59
  end
60
60
 
@@ -66,7 +66,7 @@ protected
66
66
  if @cms_page = @cms_site.pages.published.find_by_full_path('/404')
67
67
  render_html(404)
68
68
  else
69
- render :text => I18n.t('cms.content.page_not_found'), :status => 404
69
+ raise ActionController::RoutingError.new('Page Not Found')
70
70
  end
71
71
  end
72
72
 
@@ -14,7 +14,7 @@ class Cms::Category < ActiveRecord::Base
14
14
  :presence => true
15
15
  validates :label,
16
16
  :presence => true,
17
- :uniqueness => { :scope => :categorized_type }
17
+ :uniqueness => { :scope => [:categorized_type, :site_id] }
18
18
  validates :categorized_type,
19
19
  :presence => true
20
20
 
@@ -24,4 +24,4 @@ class Cms::Category < ActiveRecord::Base
24
24
  where(:categorized_type => type)
25
25
  }
26
26
 
27
- end
27
+ end
@@ -49,7 +49,7 @@ class Cms::Layout < ActiveRecord::Base
49
49
  def self.app_layouts_for_select
50
50
  Dir.glob(File.expand_path('app/views/layouts/**/*.html.*', Rails.root)).collect do |filename|
51
51
  filename.gsub!("#{File.expand_path('app/views/layouts', Rails.root)}/", '')
52
- filename.split('/').last[0...1] == '_' ? nil : filename
52
+ filename.split('/').last[0...1] == '_' ? nil : filename.split('.').first
53
53
  end.compact.sort
54
54
  end
55
55
 
@@ -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.14"
8
+ s.version = "1.6.15"
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-02-24"
12
+ s.date = "2012-03-15"
13
13
  s.description = ""
14
14
  s.email = "oleg@theworkinggroup.ca"
15
15
  s.extra_rdoc_files = [
@@ -176,6 +176,7 @@ Gem::Specification.new do |s|
176
176
  "config/initializers/paperclip.rb",
177
177
  "config/locales/en.yml",
178
178
  "config/locales/es.yml",
179
+ "config/locales/ja.yml",
179
180
  "config/locales/pt-BR.yml",
180
181
  "config/locales/zh-CN.yml",
181
182
  "config/routes.rb",
@@ -224,6 +225,7 @@ Gem::Specification.new do |s|
224
225
  "lib/comfortable_mexican_sofa/tags/collection.rb",
225
226
  "lib/comfortable_mexican_sofa/tags/field_datetime.rb",
226
227
  "lib/comfortable_mexican_sofa/tags/field_integer.rb",
228
+ "lib/comfortable_mexican_sofa/tags/field_rich_text.rb",
227
229
  "lib/comfortable_mexican_sofa/tags/field_string.rb",
228
230
  "lib/comfortable_mexican_sofa/tags/field_text.rb",
229
231
  "lib/comfortable_mexican_sofa/tags/file.rb",
@@ -302,6 +304,7 @@ Gem::Specification.new do |s|
302
304
  "test/unit/tags/collection_test.rb",
303
305
  "test/unit/tags/field_datetime_test.rb",
304
306
  "test/unit/tags/field_integer_test.rb",
307
+ "test/unit/tags/field_rich_text_test.rb",
305
308
  "test/unit/tags/field_string_test.rb",
306
309
  "test/unit/tags/field_text_test.rb",
307
310
  "test/unit/tags/file_test.rb",
@@ -1,3 +1,3 @@
1
- Paperclip.options[:command_path] = case Rails.env
1
+ defined?(Paperclip) && Paperclip.options[:command_path] = case Rails.env
2
2
  when 'development', 'test' then '/usr/local/bin'
3
3
  end
@@ -221,4 +221,4 @@ es:
221
221
  image:
222
222
  insert: Insertar Imagen
223
223
  link:
224
- create: Create Link
224
+ create: Crear Link
@@ -0,0 +1,225 @@
1
+ # encoding: utf-8
2
+ ja:
3
+ # -- Models ---------------------------------------------------------------
4
+ attributes:
5
+ label: ラベル
6
+ slug: スラッグ
7
+ parent_id: 親
8
+ content: コンテンツ
9
+ activerecord:
10
+ models:
11
+ cms/site: サイト
12
+ cms/layout: レイアウト
13
+ cms/page: ページ
14
+ cms/snippet: スニペット
15
+ attributes:
16
+ cms/site:
17
+ hostname: ホスト名
18
+ path: パス
19
+ locale: 言語
20
+ is_mirrored: ミラーリング済み
21
+ cms/layout:
22
+ label: レイアウト名
23
+ app_layout: アプリケーションレイアウト
24
+ parent_id: 親レイアウト
25
+ css: スタイルシート
26
+ js: Javascript
27
+ cms/page:
28
+ label: ラベル
29
+ layout_id: レイアウト
30
+ slug: スラッグ
31
+ target_page_id: ページにリダイレクト
32
+ is_published: パブリッシュ済み
33
+
34
+ # -- Controllers ----------------------------------------------------------
35
+ cms:
36
+ base:
37
+ site_not_found: サイトが見つかりません
38
+ fixtures_enabled: CMS フィクスチャが有効です。 ここでの変更はすべて破棄されます。
39
+
40
+ sites:
41
+ created: サイトが作成されました
42
+ creation_failure: サイトの作成に失敗しました
43
+ updated: サイトが更新されました
44
+ update_failure: サイトの更新に失敗しました
45
+ deleted: サイトが削除されました
46
+ not_found: サイトが見つかりません
47
+
48
+ layouts:
49
+ created: レイアウトが作成されました
50
+ creation_failure: レイアウトの作成に失敗しました
51
+ updated: レイアウトが更新されました
52
+ update_failure: レイアウトの更新に失敗しました
53
+ deleted: レイアウトが削除されました
54
+ not_found: レイアウトが見つかりません
55
+
56
+ pages:
57
+ created: ページが作成されました
58
+ creation_failure: ページの作成に失敗しました
59
+ updated: ページが更新されました
60
+ update_failure: ページの更新に失敗しました
61
+ deleted: ページが削除されました
62
+ not_found: ページが見つかりません
63
+ layout_not_found: レイアウトが見つかりません。 レイアウトを作成してください。
64
+
65
+ snippets:
66
+ created: スニペットが作成されました
67
+ creation_failure: スニペットの作成に失敗しました
68
+ updated: スニペットが更新されました
69
+ update_failure: スニペットの更新に失敗しました
70
+ deleted: スニペットが削除されました
71
+ not_found: スニペットが見つかりません
72
+
73
+ revisions:
74
+ reverted: コンテンツが元に戻りました
75
+ record_not_found: レコードが見つかりません
76
+ not_found: リビジョンが見つかりません
77
+
78
+ files:
79
+ created: ファイルがアップロードされました
80
+ creation_failure: ファイルのアップロードに失敗しました
81
+ updated: ファイルが更新されました
82
+ update_failure: ファイルの更新に失敗しました
83
+ deleted: ファイルが削除されました
84
+ not_found: ファイルが見つかりません
85
+
86
+ content:
87
+ site_not_found: サイトが見つかりません
88
+ layout_not_found: レイアウトが見つかりません
89
+ page_not_found: ページが見つかりません
90
+
91
+ # -- Views ----------------------------------------------------------------
92
+ cms_admin:
93
+ base:
94
+ sites: サイト
95
+ layouts: レイアウト
96
+ pages: ページ
97
+ snippets: スニペット
98
+ files: ファイル
99
+
100
+ sites:
101
+ index:
102
+ title: サイト
103
+ new_link: 新規サイトを作成
104
+ select: サイトを選択
105
+ edit: 編集
106
+ delete: 削除
107
+ are_you_sure: このサイトを削除してもよろしいですか?
108
+ new:
109
+ title: 新規サイト
110
+ edit:
111
+ title: サイトを編集
112
+ form:
113
+ create: サイトを作成
114
+ update: サイトを更新
115
+
116
+ layouts:
117
+ index:
118
+ title: レイアウト
119
+ new_link: 新規レイアウトを作成
120
+ index_branch:
121
+ add_child_layout: 子レイアウトを追加
122
+ edit: 編集
123
+ delete: 削除
124
+ are_you_sure: よろしいですか?
125
+ new:
126
+ title: 新規レイアウト
127
+ edit:
128
+ title: レイアウトを編集
129
+ revision: リビジョン
130
+ form:
131
+ select_parent_layout: 親レイアウトを選択
132
+ select_app_layout: アプリケーションレイアウトを選択
133
+ create: レイアウトを作成
134
+ update: レイアウトを更新
135
+
136
+ pages:
137
+ index:
138
+ title: ページ
139
+ new_link: 新規ページを作成
140
+ index_branch:
141
+ toggle: 切り替え
142
+ add_child_page: 子ページを追加
143
+ edit: 編集
144
+ delete: 削除
145
+ are_you_sure: よろしいですか?
146
+ new:
147
+ title: 新規ページ
148
+ edit:
149
+ title: ページを編集
150
+ revision: リビジョン
151
+ form:
152
+ select_target_page: リダイレクトなし
153
+ preview: プレビュー
154
+ create: ページを作成
155
+ update: ページを更新
156
+ form_blocks:
157
+ no_tags: |-
158
+ レイアウトにはコンテンツタグが定義されていません。<br/>
159
+ コンテンツを編集してページまたはフィールドタグを含めてください。 例: <code>{{cms:page:content}}</code>
160
+
161
+ snippets:
162
+ index:
163
+ title: スニペット
164
+ new_link: 新規スニペットを作成
165
+ edit: 編集
166
+ delete: 削除
167
+ are_you_sure: よろしいですか?
168
+ new:
169
+ title: 新規スニペット
170
+ edit:
171
+ title: スニペットを編集
172
+ revision: リビジョン
173
+ form:
174
+ create: スニペットを作成
175
+ update: スニペットを更新
176
+
177
+ revisions:
178
+ show:
179
+ title: リビジョン
180
+ revision: リビジョン
181
+ full_path: フルパス
182
+ slug: スラッグ
183
+ update: このリビジョンに更新
184
+
185
+ files:
186
+ index:
187
+ title: ファイル
188
+ new_link: 新規ファイルをアップロード
189
+ edit: 編集
190
+ delete: 削除
191
+ are_you_sure: よろしいですか?
192
+ button: ファイルをアップロード
193
+ new:
194
+ title: 新規ファイル
195
+ edit:
196
+ title: ファイルを編集
197
+ form:
198
+ current_file: 現在のファイル
199
+ create: ファイルをアップロード
200
+ update: ファイルを更新
201
+ page_form:
202
+ are_you_sure: よろしいですか?
203
+ file:
204
+ are_you_sure: よろしいですか?
205
+
206
+ categories:
207
+ index:
208
+ label: カテゴリー
209
+ edit: 編集
210
+ done: 完了
211
+ all: すべて
212
+ add: 追加
213
+ show:
214
+ are_you_sure: よろしいですか?
215
+ edit:
216
+ save: 保存
217
+ form:
218
+ label: カテゴリー
219
+
220
+ dialogs:
221
+ image:
222
+ insert: 画像を挿入
223
+ link:
224
+ create: リンクを作成
225
+
data/config/routes.rb CHANGED
@@ -6,7 +6,7 @@ Rails.application.routes.draw do
6
6
  resources :pages do
7
7
  get :form_blocks, :on => :member
8
8
  get :toggle_branch, :on => :member
9
- put :reorder, :on => :collection
9
+ put :reorder, :on => :collection
10
10
  resources :revisions, :only => [:index, :show, :revert] do
11
11
  put :revert, :on => :member
12
12
  end
@@ -15,7 +15,7 @@ Rails.application.routes.draw do
15
15
  put :reorder, :on => :collection
16
16
  end
17
17
  resources :layouts do
18
- post :reorder, :on => :collection
18
+ put :reorder, :on => :collection
19
19
  resources :revisions, :only => [:index, :show, :revert] do
20
20
  put :revert, :on => :member
21
21
  end
@@ -82,7 +82,8 @@ class ComfortableMexicanSofa::Configuration
82
82
  'en' => 'English',
83
83
  'es' => 'Español',
84
84
  'pt-BR' => 'Português Brasileiro',
85
- 'zh-CN' => '简体中文'
85
+ 'zh-CN' => '简体中文',
86
+ 'ja' => '日本語'
86
87
  }
87
88
  @admin_locale = nil
88
89
  @database_config = nil
@@ -0,0 +1,17 @@
1
+ class ComfortableMexicanSofa::Tag::FieldRichText
2
+ include ComfortableMexicanSofa::Tag
3
+
4
+ def self.regex_tag_signature(identifier = nil)
5
+ identifier ||= /[\w\-]+/
6
+ /\{\{\s*cms:field:(#{identifier}):rich_text\s*?\}\}/
7
+ end
8
+
9
+ def content
10
+ block.content
11
+ end
12
+
13
+ def render
14
+ ''
15
+ end
16
+
17
+ end
@@ -77,6 +77,14 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase
77
77
  assert_select "textarea[name='page[blocks_attributes][0][content]'][class='code']"
78
78
  assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
79
79
  end
80
+
81
+ def test_get_new_with_rich_page_text
82
+ cms_layouts(:default).update_attribute(:content, '{{cms:field:test_label:rich_text}}')
83
+ get :new, :site_id => cms_sites(:default)
84
+ assert_response :success
85
+ assert_select "textarea[name='page[blocks_attributes][0][content]'][class='rich_text']"
86
+ assert_select "input[type='hidden'][name='page[blocks_attributes][0][identifier]'][value='test_label']"
87
+ end
80
88
 
81
89
  def test_get_new_with_page_datetime
82
90
  cms_layouts(:default).update_attribute(:content, '{{cms:page:test_label:datetime}}')
@@ -38,9 +38,9 @@ class CmsContentControllerTest < ActionController::TestCase
38
38
  end
39
39
 
40
40
  def test_render_page_not_found
41
- get :render_html, :cms_path => 'doesnotexist'
42
- assert_response 404
43
- assert_equal 'Page Not Found', response.body
41
+ assert_exception_raised ActionController::RoutingError, 'Page Not Found' do
42
+ get :render_html, :cms_path => 'doesnotexist'
43
+ end
44
44
  end
45
45
 
46
46
  def test_render_page_not_found_with_custom_404
@@ -66,9 +66,9 @@ class CmsContentControllerTest < ActionController::TestCase
66
66
  def test_render_page_with_no_site
67
67
  Cms::Site.destroy_all
68
68
 
69
- get :render_html, :cms_path => ''
70
- assert_response 404
71
- assert_equal 'Site Not Found', response.body
69
+ assert_exception_raised ActionController::RoutingError, 'Site Not Found' do
70
+ get :render_html, :cms_path => ''
71
+ end
72
72
  end
73
73
 
74
74
  def test_render_page_with_no_layout
@@ -90,8 +90,10 @@ class CmsContentControllerTest < ActionController::TestCase
90
90
  def test_render_page_unpublished
91
91
  page = cms_pages(:default)
92
92
  page.update_attribute(:is_published, false)
93
- get :render_html, :cms_path => ''
94
- assert_response 404
93
+
94
+ assert_exception_raised ActionController::RoutingError, 'Page Not Found' do
95
+ get :render_html, :cms_path => ''
96
+ end
95
97
  end
96
98
 
97
99
  def test_render_page_with_irb_disabled
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '~>3.0.11'
4
- gem 'active_link_to', '~>1.0.0'
5
- gem 'paperclip', '~>2.3.0'
3
+ gem 'rails', '3.0.12'
4
+ gem 'active_link_to', '1.0.0'
5
+ gem 'paperclip', '>=2.3.0'
6
6
 
7
7
  group :test do
8
8
  gem 'sqlite3'
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '~>3.1.3'
4
- gem 'active_link_to', '~>1.0.0'
5
- gem 'paperclip', '~>2.3.0'
3
+ gem 'rails', '3.1.4'
4
+ gem 'active_link_to', '1.0.0'
5
+ gem 'paperclip', '>=2.3.0'
6
6
 
7
7
  group :test do
8
8
  gem 'sqlite3'
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '~>3.2.0'
4
- gem 'active_link_to', '~>1.0.0'
5
- gem 'paperclip', '~>2.3.0'
3
+ gem 'rails', '3.2.2'
4
+ gem 'active_link_to', '1.0.0'
5
+ gem 'paperclip', '>=2.3.0'
6
6
 
7
7
  group :test do
8
8
  gem 'sqlite3'
@@ -11,8 +11,9 @@ class RoutingExtensionsTest < ActionDispatch::IntegrationTest
11
11
  ComfortableMexicanSofa.config.admin_route_prefix = 'custom-admin'
12
12
  Rails.application.reload_routes!
13
13
 
14
- http_auth :get, '/cms-admin/sites'
15
- assert_response 404
14
+ assert_exception_raised ActionController::RoutingError, 'Page Not Found' do
15
+ http_auth :get, '/cms-admin/sites'
16
+ end
16
17
 
17
18
  http_auth :get, '/custom-admin/sites'
18
19
  assert_response :success
@@ -31,8 +32,9 @@ class RoutingExtensionsTest < ActionDispatch::IntegrationTest
31
32
  ComfortableMexicanSofa.config.admin_route_prefix = ''
32
33
  Rails.application.reload_routes!
33
34
 
34
- http_auth :get, '/cms-admin'
35
- assert_response 404
35
+ assert_exception_raised ActionController::RoutingError, 'Page Not Found' do
36
+ http_auth :get, '/cms-admin'
37
+ end
36
38
  end
37
39
 
38
40
  def test_get_admin_with_all_routes_disabled
@@ -32,9 +32,14 @@ class SitesTest < ActionDispatch::IntegrationTest
32
32
  site_b = Cms::Site.create!(:identifier => 'site-b', :hostname => 'test.host', :path => 'path-b')
33
33
  site_c = Cms::Site.create!(:identifier => 'site-c', :hostname => 'test.host', :path => 'path-c/child')
34
34
 
35
+ [site_a, site_b, site_c].each do |site|
36
+ layout = site.layouts.create!(:identifier => 'test')
37
+ site.pages.create!(:label => 'index', :layout => layout)
38
+ site.pages.create!(:label => '404', :slug => '404', :layout => layout)
39
+ end
40
+
35
41
  %w(/ /path-a /path-a/child /path-c).each do |path|
36
42
  get path
37
- assert_response 404
38
43
  assert assigns(:cms_site), path
39
44
  assert_equal site_a, assigns(:cms_site)
40
45
  assert_equal path.gsub(/^\//, ''), @controller.params[:cms_path].to_s
@@ -42,7 +47,6 @@ class SitesTest < ActionDispatch::IntegrationTest
42
47
 
43
48
  %w(/path-b /path-b/child).each do |path|
44
49
  get path
45
- assert_response 404
46
50
  assert assigns(:cms_site), path
47
51
  assert_equal site_b, assigns(:cms_site)
48
52
  assert_equal path.gsub(/^\/path-b/, '').gsub(/^\//, ''), @controller.params[:cms_path].to_s
@@ -50,7 +54,6 @@ class SitesTest < ActionDispatch::IntegrationTest
50
54
 
51
55
  %w(/path-c/child /path-c/child/child).each do |path|
52
56
  get path
53
- assert_response 404
54
57
  assert assigns(:cms_site), path
55
58
  assert_equal site_c, assigns(:cms_site)
56
59
  assert_equal path.gsub(/^\/path-c\/child/, '').gsub(/^\//, ''), @controller.params[:cms_path].to_s
data/test/test_helper.rb CHANGED
@@ -45,18 +45,12 @@ class ActiveSupport::TestCase
45
45
  end
46
46
 
47
47
  # Example usage:
48
- # assert_has_errors_on( @record, [:field_1, :field_2] )
49
- # assert_has_errors_on( @record, {:field_1 => 'Message1', :field_2 => 'Message 2'} )
50
- def assert_has_errors_on(record, fields)
51
- fields = [fields].flatten unless fields.is_a?(Hash)
52
- fields.each do |field, message|
53
- assert record.errors.to_hash.has_key?(field.to_sym), "#{record.class.name} should error on invalid #{field}"
54
- if message && record.errors[field].is_a?(Array) && !message.is_a?(Array)
55
- assert_not_nil record.errors[field].index(message)
56
- elsif message
57
- assert_equal message, record.errors[field]
58
- end
59
- end
48
+ # assert_has_errors_on @record, :field_1, :field_2
49
+ def assert_has_errors_on(record, *fields)
50
+ unmatched = record.errors.keys - fields.flatten
51
+ assert unmatched.blank?, "#{record.class} has errors on '#{unmatched.join(', ')}'"
52
+ unmatched = fields.flatten - record.errors.keys
53
+ assert unmatched.blank?, "#{record.class} doesn't have errors on '#{unmatched.join(', ')}'"
60
54
  end
61
55
 
62
56
  # Example usage:
@@ -11,7 +11,7 @@ class CmsCategorizationTest < ActiveSupport::TestCase
11
11
  def test_validation
12
12
  category = Cms::Categorization.new
13
13
  assert category.invalid?
14
- assert_has_errors_on category, [:categorized_type, :categorized_id]
14
+ assert_has_errors_on category, :category_id, :categorized_type, :categorized_id
15
15
  end
16
16
 
17
17
  def test_creation
@@ -12,7 +12,7 @@ class CmsFileTest < ActiveSupport::TestCase
12
12
  assert_no_difference 'Cms::File.count' do
13
13
  file = Cms::File.create
14
14
  assert file.errors.present?
15
- assert_has_errors_on file, [:file_file_name]
15
+ assert_has_errors_on file, :site_id, :file_file_name, :file
16
16
  end
17
17
  end
18
18
 
@@ -55,7 +55,7 @@ class CmsLayoutTest < ActiveSupport::TestCase
55
55
  FileUtils.touch(File.expand_path('app/views/layouts/_partial.html.erb', Rails.root))
56
56
  FileUtils.touch(File.expand_path('app/views/layouts/not_a_layout.erb', Rails.root))
57
57
 
58
- assert_equal ['cms_admin.html.erb', 'cms_admin/nested.html.erb'], Cms::Layout.app_layouts_for_select
58
+ assert_equal ['cms_admin', 'cms_admin/nested'], Cms::Layout.app_layouts_for_select
59
59
 
60
60
  FileUtils.rm(File.expand_path('app/views/layouts/cms_admin/nested.html.erb', Rails.root))
61
61
  FileUtils.rm(File.expand_path('app/views/layouts/_partial.html.erb', Rails.root))
@@ -13,7 +13,7 @@ class CmsPageTest < ActiveSupport::TestCase
13
13
  page = Cms::Page.new
14
14
  page.save
15
15
  assert page.invalid?
16
- assert_has_errors_on page, [:layout, :slug, :label]
16
+ assert_has_errors_on page, :site_id, :layout, :slug, :label
17
17
  end
18
18
 
19
19
  def test_validation_of_parent_presence
@@ -12,7 +12,7 @@ class CmsSnippetTest < ActiveSupport::TestCase
12
12
  snippet = Cms::Snippet.new
13
13
  snippet.save
14
14
  assert snippet.invalid?
15
- assert_has_errors_on snippet, [:label, :identifier]
15
+ assert_has_errors_on snippet, :site_id, :label, :identifier
16
16
  end
17
17
 
18
18
  def test_label_assignment
@@ -0,0 +1,43 @@
1
+ require File.expand_path('../../test_helper', File.dirname(__FILE__))
2
+
3
+ class FieldRichTextTagTest < ActiveSupport::TestCase
4
+
5
+ def test_initialize_tag
6
+ assert tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag(
7
+ cms_pages(:default), '{{ cms:field:content:rich_text }}'
8
+ )
9
+ assert_equal 'content', tag.identifier
10
+ assert tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag(
11
+ cms_pages(:default), '{{cms:field:content:rich_text}}'
12
+ )
13
+ assert_equal 'content', tag.identifier
14
+ assert tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag(
15
+ cms_pages(:default), '{{cms:field:dash-content:rich_text}}'
16
+ )
17
+ assert_equal 'dash-content', tag.identifier
18
+ end
19
+
20
+ def test_initialize_tag_failure
21
+ [
22
+ '{{cms:field:content:not_rich_text}}',
23
+ '{{cms:field:content}}',
24
+ '{{cms:not_page:content}}',
25
+ '{not_a_tag}'
26
+ ].each do |tag_signature|
27
+ assert_nil ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag(
28
+ cms_pages(:default), tag_signature
29
+ )
30
+ end
31
+ end
32
+
33
+ def test_content_and_render
34
+ tag = ComfortableMexicanSofa::Tag::FieldRichText.initialize_tag(
35
+ cms_pages(:default), '{{cms:field:content:rich_text}}'
36
+ )
37
+ assert tag.block.content.blank?
38
+ tag.block.content = 'test_content'
39
+ assert_equal 'test_content', tag.content
40
+ assert_equal '', tag.render
41
+ end
42
+
43
+ end
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.14
4
+ version: 1.6.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-24 00:00:00.000000000Z
13
+ date: 2012-03-15 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &70275681873660 !ruby/object:Gem::Requirement
17
+ requirement: &70278706716960 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70275681873660
25
+ version_requirements: *70278706716960
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: active_link_to
28
- requirement: &70275681865720 !ruby/object:Gem::Requirement
28
+ requirement: &70278706693880 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70275681865720
36
+ version_requirements: *70278706693880
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: paperclip
39
- requirement: &70275681864260 !ruby/object:Gem::Requirement
39
+ requirement: &70278706687500 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 2.3.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70275681864260
47
+ version_requirements: *70278706687500
48
48
  description: ''
49
49
  email: oleg@theworkinggroup.ca
50
50
  executables: []
@@ -212,6 +212,7 @@ files:
212
212
  - config/initializers/paperclip.rb
213
213
  - config/locales/en.yml
214
214
  - config/locales/es.yml
215
+ - config/locales/ja.yml
215
216
  - config/locales/pt-BR.yml
216
217
  - config/locales/zh-CN.yml
217
218
  - config/routes.rb
@@ -260,6 +261,7 @@ files:
260
261
  - lib/comfortable_mexican_sofa/tags/collection.rb
261
262
  - lib/comfortable_mexican_sofa/tags/field_datetime.rb
262
263
  - lib/comfortable_mexican_sofa/tags/field_integer.rb
264
+ - lib/comfortable_mexican_sofa/tags/field_rich_text.rb
263
265
  - lib/comfortable_mexican_sofa/tags/field_string.rb
264
266
  - lib/comfortable_mexican_sofa/tags/field_text.rb
265
267
  - lib/comfortable_mexican_sofa/tags/file.rb
@@ -338,6 +340,7 @@ files:
338
340
  - test/unit/tags/collection_test.rb
339
341
  - test/unit/tags/field_datetime_test.rb
340
342
  - test/unit/tags/field_integer_test.rb
343
+ - test/unit/tags/field_rich_text_test.rb
341
344
  - test/unit/tags/field_string_test.rb
342
345
  - test/unit/tags/field_text_test.rb
343
346
  - test/unit/tags/file_test.rb
@@ -366,7 +369,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
366
369
  version: '0'
367
370
  segments:
368
371
  - 0
369
- hash: -4525357111478288434
372
+ hash: 4356669167521672038
370
373
  required_rubygems_version: !ruby/object:Gem::Requirement
371
374
  none: false
372
375
  requirements: