comfortable_mexican_sofa 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE +20 -0
- data/README.rdoc +55 -0
- data/Rakefile +88 -0
- data/VERSION +1 -0
- data/app/controllers/cms_admin/attachments_controller.rb +55 -0
- data/app/controllers/cms_admin/base_controller.rb +25 -0
- data/app/controllers/cms_admin/categories_controller.rb +69 -0
- data/app/controllers/cms_admin/layouts_controller.rb +71 -0
- data/app/controllers/cms_admin/pages_controller.rb +79 -0
- data/app/controllers/cms_admin/sections_controller.rb +17 -0
- data/app/controllers/cms_admin/snippets_controller.rb +58 -0
- data/app/controllers/cms_common/render_page.rb +47 -0
- data/app/controllers/cms_content_controller.rb +30 -0
- data/app/helpers/cms_helper.rb +12 -0
- data/app/models/cms_attachment.rb +17 -0
- data/app/models/cms_attachment_categorization.rb +5 -0
- data/app/models/cms_block.rb +15 -0
- data/app/models/cms_category.rb +36 -0
- data/app/models/cms_layout.rb +102 -0
- data/app/models/cms_page.rb +125 -0
- data/app/models/cms_page_categorization.rb +6 -0
- data/app/models/cms_snippet.rb +15 -0
- data/app/views/cms_admin/attachments/_details.html.haml +27 -0
- data/app/views/cms_admin/attachments/_form.html.haml +24 -0
- data/app/views/cms_admin/attachments/edit.html.haml +10 -0
- data/app/views/cms_admin/attachments/index.html.haml +36 -0
- data/app/views/cms_admin/attachments/new.html.haml +8 -0
- data/app/views/cms_admin/categories/_category.html.haml +21 -0
- data/app/views/cms_admin/categories/_category_subform.html.haml +12 -0
- data/app/views/cms_admin/categories/_form.html.haml +18 -0
- data/app/views/cms_admin/categories/_new.html.haml +7 -0
- data/app/views/cms_admin/categories/_toggle_link.html.haml +9 -0
- data/app/views/cms_admin/categories/_tree_branch.html.haml +36 -0
- data/app/views/cms_admin/categories/children.js.rjs +10 -0
- data/app/views/cms_admin/categories/create.js.rjs +9 -0
- data/app/views/cms_admin/categories/edit.html.haml +10 -0
- data/app/views/cms_admin/categories/index.html.haml +7 -0
- data/app/views/cms_admin/categories/new.html.haml +8 -0
- data/app/views/cms_admin/categories/show.html.haml +17 -0
- data/app/views/cms_admin/layouts/_details.html.haml +6 -0
- data/app/views/cms_admin/layouts/_form.html.haml +19 -0
- data/app/views/cms_admin/layouts/_toggle_link.html.haml +9 -0
- data/app/views/cms_admin/layouts/_tree_branch.html.haml +39 -0
- data/app/views/cms_admin/layouts/children.js.rjs +10 -0
- data/app/views/cms_admin/layouts/edit.html.haml +10 -0
- data/app/views/cms_admin/layouts/index.html.haml +7 -0
- data/app/views/cms_admin/layouts/new.html.haml +8 -0
- data/app/views/cms_admin/pages/_details.html.haml +25 -0
- data/app/views/cms_admin/pages/_form.html.haml +45 -0
- data/app/views/cms_admin/pages/_form_blocks.html.haml +48 -0
- data/app/views/cms_admin/pages/_toggle_link.html.haml +10 -0
- data/app/views/cms_admin/pages/_tree_branch.html.haml +41 -0
- data/app/views/cms_admin/pages/children.js.rjs +10 -0
- data/app/views/cms_admin/pages/edit.html.haml +11 -0
- data/app/views/cms_admin/pages/form_blocks.js.rjs +1 -0
- data/app/views/cms_admin/pages/index.html.haml +6 -0
- data/app/views/cms_admin/pages/new.html.haml +9 -0
- data/app/views/cms_admin/sections/show.html.haml +23 -0
- data/app/views/cms_admin/snippets/_form.html.haml +10 -0
- data/app/views/cms_admin/snippets/edit.html.haml +10 -0
- data/app/views/cms_admin/snippets/index.html.haml +26 -0
- data/app/views/cms_admin/snippets/new.html.haml +8 -0
- data/app/views/cms_content/show.xml.rxml +27 -0
- data/app/views/cms_content/sitemap.xml.rxml +16 -0
- data/app/views/layouts/cms_admin.html.haml +44 -0
- data/comfortable_mexican_sofa.gemspec +254 -0
- data/config/cms_routes.rb +25 -0
- data/generators/cms/cms_generator.rb +55 -0
- data/generators/cms/templates/README +32 -0
- data/generators/cms/templates/images/arrow_bottom.gif +0 -0
- data/generators/cms/templates/images/arrow_right.gif +0 -0
- data/generators/cms/templates/images/icon_attachment.gif +0 -0
- data/generators/cms/templates/images/icon_category.gif +0 -0
- data/generators/cms/templates/images/icon_draft.gif +0 -0
- data/generators/cms/templates/images/icon_layout.gif +0 -0
- data/generators/cms/templates/images/icon_move.gif +0 -0
- data/generators/cms/templates/images/icon_regular.gif +0 -0
- data/generators/cms/templates/images/icon_snippet.gif +0 -0
- data/generators/cms/templates/images/logo.png +0 -0
- data/generators/cms/templates/initializers/cms.rb +14 -0
- data/generators/cms/templates/initializers/paperclip.rb +14 -0
- data/generators/cms/templates/javascripts/codemirror_init.js +16 -0
- data/generators/cms/templates/javascripts/mce_init.js +17 -0
- data/generators/cms/templates/javascripts/utilities.js +27 -0
- data/generators/cms/templates/migrations/create_cms.rb +113 -0
- data/generators/cms/templates/stylesheets/cms_master.sass +414 -0
- data/init.rb +1 -0
- data/lib/comfortable_mexican_sofa.rb +46 -0
- data/lib/comfortable_mexican_sofa/acts_as_categorized.rb +87 -0
- data/lib/comfortable_mexican_sofa/acts_as_published.rb +60 -0
- data/lib/comfortable_mexican_sofa/cms_acts_as_tree.rb +108 -0
- data/lib/comfortable_mexican_sofa/cms_rails_extensions.rb +12 -0
- data/lib/comfortable_mexican_sofa/cms_tag.rb +109 -0
- data/lib/comfortable_mexican_sofa/cms_tags/attachment.rb +3 -0
- data/lib/comfortable_mexican_sofa/cms_tags/block.rb +117 -0
- data/lib/comfortable_mexican_sofa/cms_tags/helper.rb +3 -0
- data/lib/comfortable_mexican_sofa/cms_tags/page_block.rb +119 -0
- data/lib/comfortable_mexican_sofa/cms_tags/partial.rb +19 -0
- data/lib/comfortable_mexican_sofa/cms_tags/snippet.rb +19 -0
- data/rails/init.rb +1 -0
- data/test/fixtures/cms_attachment_categorizations.yml +7 -0
- data/test/fixtures/cms_attachments.yml +6 -0
- data/test/fixtures/cms_blocks.yml +38 -0
- data/test/fixtures/cms_categories.yml +19 -0
- data/test/fixtures/cms_layouts.yml +41 -0
- data/test/fixtures/cms_page_categorizations.yml +15 -0
- data/test/fixtures/cms_pages.yml +38 -0
- data/test/fixtures/cms_snippets.yml +7 -0
- data/test/fixtures/files/upload_file.txt +1 -0
- data/test/functional/cms_admin/attachments_controller_test.rb +63 -0
- data/test/functional/cms_admin/categories_controller_test.rb +86 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +77 -0
- data/test/functional/cms_admin/pages_controller_test.rb +153 -0
- data/test/functional/cms_admin/sections_controller_test.rb +9 -0
- data/test/functional/cms_admin/snippets_controller_test.rb +63 -0
- data/test/functional/cms_content_controller_test.rb +52 -0
- data/test/models/cms_attachment_test.rb +16 -0
- data/test/models/cms_block_test.rb +11 -0
- data/test/models/cms_categorization_test.rb +39 -0
- data/test/models/cms_category_test.rb +71 -0
- data/test/models/cms_layout_test.rb +44 -0
- data/test/models/cms_page_test.rb +55 -0
- data/test/models/cms_snippet_test.rb +16 -0
- data/test/models/cms_tag_test.rb +70 -0
- data/test/rails_root/README +243 -0
- data/test/rails_root/Rakefile +10 -0
- data/test/rails_root/app/controllers/application_controller.rb +10 -0
- data/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails_root/app/views/cms/under-development.html.haml +1 -0
- data/test/rails_root/app/views/complex_page/_example.html.erb +1 -0
- data/test/rails_root/config/boot.rb +110 -0
- data/test/rails_root/config/database.yml +22 -0
- data/test/rails_root/config/environment.rb +48 -0
- data/test/rails_root/config/environments/development.rb +17 -0
- data/test/rails_root/config/environments/production.rb +28 -0
- data/test/rails_root/config/environments/test.rb +28 -0
- data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/new_rails_defaults.rb +19 -0
- data/test/rails_root/config/initializers/session_store.rb +15 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +43 -0
- data/test/rails_root/doc/README_FOR_APP +2 -0
- data/test/rails_root/public/404.html +30 -0
- data/test/rails_root/public/422.html +30 -0
- data/test/rails_root/public/500.html +30 -0
- data/test/rails_root/public/favicon.ico +0 -0
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/index.html +275 -0
- data/test/rails_root/public/javascripts/application.js +2 -0
- data/test/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails_root/public/javascripts/dragdrop.js +973 -0
- data/test/rails_root/public/javascripts/effects.js +1128 -0
- data/test/rails_root/public/javascripts/prototype.js +4320 -0
- data/test/rails_root/public/robots.txt +5 -0
- data/test/rails_root/public/stylesheets/sass/cms_master.sass +414 -0
- data/test/rails_root/script/about +4 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/script/dbconsole +3 -0
- data/test/rails_root/script/destroy +3 -0
- data/test/rails_root/script/generate +3 -0
- data/test/rails_root/script/performance/benchmarker +3 -0
- data/test/rails_root/script/performance/profiler +3 -0
- data/test/rails_root/script/plugin +3 -0
- data/test/rails_root/script/runner +3 -0
- data/test/rails_root/script/server +3 -0
- data/test/test_helper.rb +17 -0
- metadata +303 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
class CmsTag::PageBlock < CmsTag::Tag
|
2
|
+
|
3
|
+
FORMAT = {
|
4
|
+
:text => {
|
5
|
+
:db_column => :content_text,
|
6
|
+
:description => '',
|
7
|
+
:form_output => lambda { |tag|
|
8
|
+
tag.view.text_area_tag "cms_page[blocks][#{tag.label}][content_text]", tag.content,
|
9
|
+
:rows => 20
|
10
|
+
}
|
11
|
+
},
|
12
|
+
:rich_text => {
|
13
|
+
:db_column => :content_text,
|
14
|
+
:description => '',
|
15
|
+
:form_output => lambda { |tag|
|
16
|
+
tag.view.text_area_tag "cms_page[blocks][#{tag.label}][content_text]", tag.content,
|
17
|
+
:rows => 20,
|
18
|
+
:class => 'mceEditor'
|
19
|
+
}
|
20
|
+
},
|
21
|
+
:code => {
|
22
|
+
:db_column => :content_text,
|
23
|
+
:description => '',
|
24
|
+
:form_output => lambda { |tag|
|
25
|
+
tag.view.content_tag :div, :class => 'codemirror' do
|
26
|
+
tag.view.text_area_tag "cms_page[blocks][#{tag.label}][content_text]", tag.content,
|
27
|
+
:rows => 20,
|
28
|
+
:class => 'codeTextArea'
|
29
|
+
end
|
30
|
+
}
|
31
|
+
},
|
32
|
+
:string => {
|
33
|
+
:db_column => :content_string,
|
34
|
+
:description => '',
|
35
|
+
:form_output => lambda { |tag|
|
36
|
+
tag.view.text_field_tag "cms_page[blocks][#{tag.label}][content_string]", tag.content
|
37
|
+
}
|
38
|
+
},
|
39
|
+
:integer => {
|
40
|
+
:db_column => :content_integer,
|
41
|
+
:description => '',
|
42
|
+
:form_output => lambda { |tag|
|
43
|
+
tag.view.text_field_tag "cms_page[blocks][#{tag.label}][content_integer]", tag.content
|
44
|
+
}
|
45
|
+
},
|
46
|
+
:boolean => {
|
47
|
+
:db_column => :content_boolean,
|
48
|
+
:description => '',
|
49
|
+
:form_output => lambda { |tag|
|
50
|
+
tag.view.check_box_tag "cms_page[blocks][#{tag.label}][content_boolean]", tag.content
|
51
|
+
}
|
52
|
+
},
|
53
|
+
:date => {
|
54
|
+
:db_column => :content_datetime,
|
55
|
+
:description => '',
|
56
|
+
:form_output => lambda { |tag|
|
57
|
+
tag.view.fields_for "cms_page[blocks][#{tag.label}]" do |field|
|
58
|
+
field.date_select :content_datetime, :default => tag.content
|
59
|
+
end
|
60
|
+
}
|
61
|
+
},
|
62
|
+
:time => {
|
63
|
+
:db_column => :content_datetime,
|
64
|
+
:description => '',
|
65
|
+
:form_output => lambda { |tag|
|
66
|
+
tag.view.fields_for "cms_page[blocks][#{tag.label}]" do |field|
|
67
|
+
field.datetime_select :content_datetime, :default => tag.content
|
68
|
+
end
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
attr_accessor :format
|
74
|
+
|
75
|
+
def self.regex
|
76
|
+
/\{\{\s*?(cms_page_block:.*?)\s*?\}\}/
|
77
|
+
end
|
78
|
+
|
79
|
+
def regex
|
80
|
+
/\{\{\s*?cms_page_block:#{Regexp.escape(label)}.*?\s*?\}\}/
|
81
|
+
end
|
82
|
+
|
83
|
+
# this shold be the most important tag to render, but let's leave space
|
84
|
+
# for some unforseen cases
|
85
|
+
def self.render_priority
|
86
|
+
1
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.has_form?
|
90
|
+
true
|
91
|
+
end
|
92
|
+
|
93
|
+
def assign_accessors
|
94
|
+
tokens = self.tag_signature.split(':')
|
95
|
+
self.label = tokens[1]
|
96
|
+
self.format = tokens[2]
|
97
|
+
end
|
98
|
+
|
99
|
+
def form_label
|
100
|
+
view.label_tag label.titleize
|
101
|
+
end
|
102
|
+
|
103
|
+
def form_input
|
104
|
+
if FORMAT.has_key? self.format.to_sym
|
105
|
+
FORMAT[self.format.to_sym][:form_output].call(self)
|
106
|
+
else
|
107
|
+
'Unknown tag format'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def content
|
112
|
+
page && page.cms_block_content(self.label, FORMAT[self.format.to_sym][:db_column])
|
113
|
+
end
|
114
|
+
|
115
|
+
def render
|
116
|
+
content.to_s
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CmsTag::Partial < CmsTag::Tag
|
2
|
+
|
3
|
+
def self.regex
|
4
|
+
/\{\{\s*?(cms_partial:.*?)\s*?\}\}/
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.render_priority
|
8
|
+
3
|
9
|
+
end
|
10
|
+
|
11
|
+
def regex
|
12
|
+
/\{\{\s*?cms_partial:#{Regexp.escape(label)}.*?\s*?\}\}/
|
13
|
+
end
|
14
|
+
|
15
|
+
def content
|
16
|
+
"<%= render :partial => '#{self.label}' %>"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CmsTag::Snippet < CmsTag::Tag
|
2
|
+
|
3
|
+
def self.regex
|
4
|
+
/\{\{\s*?(cms_snippet:.*?)\s*?\}\}/
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.render_priority
|
8
|
+
2
|
9
|
+
end
|
10
|
+
|
11
|
+
def regex
|
12
|
+
/\{\{\s*?cms_snippet:#{Regexp.escape(label)}.*?\s*?\}\}/
|
13
|
+
end
|
14
|
+
|
15
|
+
def render
|
16
|
+
CmsSnippet.content_for(label)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'comfortable_mexican_sofa'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
default_block_header:
|
2
|
+
cms_page: default
|
3
|
+
label: header
|
4
|
+
content_string: /block:header/
|
5
|
+
|
6
|
+
default_page_block_default:
|
7
|
+
cms_page: default
|
8
|
+
label: default
|
9
|
+
content_text: /page_block:default/
|
10
|
+
|
11
|
+
default_page_block_footer:
|
12
|
+
cms_page: default
|
13
|
+
label: footer
|
14
|
+
content_text: /page_block:footer/
|
15
|
+
|
16
|
+
complex_page_block_header:
|
17
|
+
cms_page: complex
|
18
|
+
label: header
|
19
|
+
content_string: /block:header/
|
20
|
+
|
21
|
+
complex_page_block_left_column:
|
22
|
+
cms_page: complex
|
23
|
+
label: left_column
|
24
|
+
content_text: |-
|
25
|
+
/page_block:left_column/ {{ cms_snippet:complex_snippet }}
|
26
|
+
|
27
|
+
complex_page_block_right_column:
|
28
|
+
cms_page: complex
|
29
|
+
label: right_column
|
30
|
+
content_text: |-
|
31
|
+
/page_block:right_column/ {{ cms_partial:complex_page/example }}
|
32
|
+
|
33
|
+
complex_page_block_footer:
|
34
|
+
cms_page: complex
|
35
|
+
label: footer
|
36
|
+
content_text: /page_block:footer/
|
37
|
+
|
38
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
category_1: &category
|
2
|
+
label: Category 1
|
3
|
+
slug: category_1
|
4
|
+
parent_id:
|
5
|
+
description: Some Category Description
|
6
|
+
|
7
|
+
category_2:
|
8
|
+
label: Category 2
|
9
|
+
slug: category_2
|
10
|
+
|
11
|
+
category_2_1:
|
12
|
+
label: Category 2.1
|
13
|
+
slug: category_2_1
|
14
|
+
parent: category_2
|
15
|
+
|
16
|
+
category_2_2:
|
17
|
+
label: Category 2.2
|
18
|
+
slug: category_2_2
|
19
|
+
parent: category_2
|
@@ -0,0 +1,41 @@
|
|
1
|
+
default:
|
2
|
+
label: Default Layout
|
3
|
+
parent:
|
4
|
+
children_count: 1
|
5
|
+
position: 0
|
6
|
+
is_extendable: 1
|
7
|
+
content: |-
|
8
|
+
{{ cms_block:header:string }}{{ cms_page_block:default:text }}{{ cms_page_block:footer:text }}
|
9
|
+
|
10
|
+
nested:
|
11
|
+
label: Nested Layout
|
12
|
+
parent: default
|
13
|
+
content: |-
|
14
|
+
{{ cms_page_block:left_column:text }}{{ cms_page_block:right_column:text }}{{ cms_snippet:complex_snippet }}
|
15
|
+
|
16
|
+
identical_tags:
|
17
|
+
label: Layout with identical tags
|
18
|
+
content: |-
|
19
|
+
This is a layout that has tags that share same signature
|
20
|
+
Techincally we need to report that there's only one tag
|
21
|
+
We don't really care how many times it's mentioned
|
22
|
+
{{ cms_block:my_block_1:text }}
|
23
|
+
{{ cms_block:my_block_1:string }}
|
24
|
+
and another set
|
25
|
+
{{ cms_block:my_block_2:integer }}
|
26
|
+
{{ cms_block:my_block_2:string }}
|
27
|
+
and a proper, singular one
|
28
|
+
{{ cms_block:my_block_3:boolean}}
|
29
|
+
|
30
|
+
all_included_tags:
|
31
|
+
label: Layout with all tags
|
32
|
+
content: |-
|
33
|
+
Block: {{ cms_block:test_block:string }}
|
34
|
+
PageBlock: {{ cms_page_block:test_page_block:string }}
|
35
|
+
Snippet: {{ cms_snippet:test_snippet }}
|
36
|
+
Partial: {{ cms_partial:content/test_partial }}
|
37
|
+
Attachment: {{ cms_attachment:test_attachment }}
|
38
|
+
Helper: {{ cms_helper:test_helper }}
|
39
|
+
Fake: {{ cms_fake:not_real:whatever }}
|
40
|
+
|
41
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
page_category_1:
|
2
|
+
cms_page: default
|
3
|
+
cms_category: category_2
|
4
|
+
|
5
|
+
page_category_2:
|
6
|
+
cms_page: default
|
7
|
+
cms_category: category_2_1
|
8
|
+
|
9
|
+
page_category_3:
|
10
|
+
cms_page: default
|
11
|
+
cms_category: category_2_2
|
12
|
+
|
13
|
+
page_category_4:
|
14
|
+
cms_page: complex
|
15
|
+
cms_category: category_2
|
@@ -0,0 +1,38 @@
|
|
1
|
+
default: &page
|
2
|
+
label: Home Page
|
3
|
+
cms_layout: default
|
4
|
+
parent:
|
5
|
+
slug:
|
6
|
+
full_path: ''
|
7
|
+
children_count: 1
|
8
|
+
position: 0
|
9
|
+
published_at: <%= 10.days.ago %>
|
10
|
+
unpublished_at:
|
11
|
+
is_section: 0
|
12
|
+
|
13
|
+
complex:
|
14
|
+
<<: *page
|
15
|
+
parent: default
|
16
|
+
label: Complex Page
|
17
|
+
cms_layout: nested
|
18
|
+
slug: complex-page
|
19
|
+
full_path: 'complex-page'
|
20
|
+
is_section: 1
|
21
|
+
|
22
|
+
unpublished:
|
23
|
+
<<: *page
|
24
|
+
parent: default
|
25
|
+
label: Unpublished Page
|
26
|
+
cms_layout: default
|
27
|
+
slug: unpublished
|
28
|
+
full_path: 'unpublished'
|
29
|
+
published_at: <%= 10.days.from_now %>
|
30
|
+
|
31
|
+
under_development:
|
32
|
+
<<: *page
|
33
|
+
parent: default
|
34
|
+
label: Page under development
|
35
|
+
slug: 'under-development'
|
36
|
+
full_path: 'under-development'
|
37
|
+
|
38
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
This is a file
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CmsAdmin::AttachmentsControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
http_auth
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_index
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert assigns(:cms_attachments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_get_new
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_get_edit
|
21
|
+
get :edit, :id => cms_attachments(:default)
|
22
|
+
assert_response :success
|
23
|
+
assert assigns(:cms_attachment)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create
|
27
|
+
assert_difference 'CmsAttachment.count', 1 do
|
28
|
+
post :create, :cms_attachment => {
|
29
|
+
:label => 'Test File',
|
30
|
+
:description => 'This is a file',
|
31
|
+
:file => fixture_file_upload('files/upload_file.txt', 'text/plain')
|
32
|
+
}
|
33
|
+
assert_response :redirect
|
34
|
+
assert_redirected_to :action => :edit
|
35
|
+
assert_equal 'Attachment created', flash[:notice]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_update
|
40
|
+
attachment = cms_attachments(:default)
|
41
|
+
put :update, :id => attachment, :cms_attachment => {
|
42
|
+
:label => 'New Label',
|
43
|
+
:description => 'New Description'
|
44
|
+
}
|
45
|
+
attachment.reload
|
46
|
+
assert_equal 'New Label', attachment.label
|
47
|
+
assert_equal 'New Description', attachment.description
|
48
|
+
|
49
|
+
assert_response :redirect
|
50
|
+
assert_redirected_to :action => :edit
|
51
|
+
assert_equal 'Attachment updated', flash[:notice]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_destroy
|
55
|
+
assert_difference 'CmsAttachment.count', -1 do
|
56
|
+
delete :destroy, :id => cms_attachments(:default)
|
57
|
+
assert_response :redirect
|
58
|
+
assert_redirected_to :action => :index
|
59
|
+
assert_equal 'Attachment removed', flash[:notice]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CmsAdmin::CategoriesControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
http_auth
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_get_index
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert assigns(:cms_categories)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_get_new
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_get_show
|
21
|
+
get :show, :id => cms_categories(:category_2)
|
22
|
+
assert_response :success
|
23
|
+
assert assigns(:cms_category)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_get_edit
|
27
|
+
get :edit, :id => cms_categories(:category_1)
|
28
|
+
assert_response :success
|
29
|
+
assert assigns(:cms_category)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_create
|
33
|
+
assert_difference 'CmsCategory.count', 1 do
|
34
|
+
post :create, :cms_category => {
|
35
|
+
:label => 'Category 1',
|
36
|
+
:description => 'This is a category',
|
37
|
+
}
|
38
|
+
end
|
39
|
+
assert_redirected_to :action => :edit
|
40
|
+
assert_equal 'Category created', flash[:notice]
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_create_fail
|
44
|
+
assert_no_difference 'CmsCategory.count' do
|
45
|
+
post :create, :cms_category => {
|
46
|
+
:label => '',
|
47
|
+
:description => 'This is a category',
|
48
|
+
}
|
49
|
+
end
|
50
|
+
assert_response :success
|
51
|
+
assert_template 'new'
|
52
|
+
assert assigns(:cms_category).errors.on(:label)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_update
|
56
|
+
category = cms_categories(:category_1)
|
57
|
+
put :update, :id => category, :cms_category => {
|
58
|
+
:label => 'Category 2',
|
59
|
+
:description => 'New Description'
|
60
|
+
}
|
61
|
+
assert_redirected_to :action => :edit
|
62
|
+
category.reload
|
63
|
+
assert_equal 'Category 2', category.label
|
64
|
+
assert_equal 'New Description', category.description
|
65
|
+
assert_equal 'Category updated', flash[:notice]
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_update_fail
|
69
|
+
category = cms_categories(:category_1)
|
70
|
+
put :update, :id => category, :cms_category => {
|
71
|
+
:label => '',
|
72
|
+
:description => 'New Description'
|
73
|
+
}
|
74
|
+
assert_response :success
|
75
|
+
assert_template 'edit'
|
76
|
+
assert assigns(:cms_category).errors.on(:label)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_destroy
|
80
|
+
assert_difference 'CmsCategory.count', -1 do
|
81
|
+
delete :destroy, :id => cms_categories(:category_1)
|
82
|
+
assert_redirected_to cms_admin_categories_path
|
83
|
+
assert_equal 'Category deleted', flash[:notice]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|