kuhsaft 0.3.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +127 -77
- data/Rakefile +15 -10
- data/app/assets/javascripts/kuhsaft/application.js +2 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js +16 -4
- data/app/assets/javascripts/kuhsaft/cms/customizations.js +1 -0
- data/app/assets/stylesheets/kuhsaft/application.css.sass +4 -0
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +125 -0
- data/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +1 -0
- data/app/controllers/kuhsaft/application_controller.rb +5 -0
- data/app/controllers/kuhsaft/cms/admin_controller.rb +8 -10
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +35 -0
- data/app/controllers/kuhsaft/cms/pages_controller.rb +16 -19
- data/app/controllers/kuhsaft/pages_controller.rb +4 -10
- data/app/helpers/cms_helper.rb +3 -3
- data/app/helpers/kuhsaft/application_helper.rb +21 -0
- data/app/helpers/kuhsaft/cms/application_helper.rb +10 -0
- data/app/helpers/kuhsaft/cms/pages_helper.rb +14 -0
- data/app/helpers/pages_helper.rb +18 -21
- data/app/models/kuhsaft/accordion_brick.rb +16 -0
- data/app/models/kuhsaft/accordion_item_brick.rb +22 -0
- data/app/models/kuhsaft/brick.rb +85 -0
- data/app/models/kuhsaft/brick_type.rb +7 -0
- data/app/models/kuhsaft/cms.rb +7 -0
- data/app/models/kuhsaft/cms/admin.rb +20 -0
- data/app/models/kuhsaft/column_brick.rb +23 -0
- data/app/models/kuhsaft/image_brick.rb +19 -0
- data/app/models/kuhsaft/image_size.rb +52 -0
- data/app/models/kuhsaft/link_brick.rb +19 -0
- data/app/models/kuhsaft/page.rb +83 -101
- data/app/models/kuhsaft/partition.rb +18 -0
- data/app/models/kuhsaft/placeholder_brick.rb +11 -0
- data/app/models/kuhsaft/slider_brick.rb +16 -0
- data/app/models/kuhsaft/text_brick.rb +9 -0
- data/app/models/kuhsaft/two_column_brick.rb +50 -0
- data/app/models/kuhsaft/video_brick.rb +20 -0
- data/app/uploaders/kuhsaft/asset_uploader.rb +2 -2
- data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +63 -0
- data/app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml +3 -0
- data/app/{assets/stylesheets/kuhsaft/cms/base/partials/_forms.css.sass → views/kuhsaft/accordion_bricks/accordion_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/accordion_item_bricks/_accordion_item_brick.html.haml +8 -0
- data/app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +10 -0
- data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_empty_state.html.haml +5 -0
- data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +6 -0
- data/app/views/kuhsaft/cms/assets/index.html.haml +2 -2
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +38 -0
- data/app/views/kuhsaft/cms/bricks/_brick_list.html.haml +4 -0
- data/app/views/kuhsaft/cms/bricks/create.js.haml +1 -0
- data/app/views/kuhsaft/cms/bricks/destroy.js.haml +7 -0
- data/app/views/kuhsaft/cms/bricks/update.js.haml +2 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +17 -9
- data/app/views/kuhsaft/cms/pages/_form.html.haml +25 -60
- data/app/views/kuhsaft/cms/pages/edit.html.haml +14 -8
- data/app/views/kuhsaft/cms/pages/index.html.haml +8 -8
- data/app/views/kuhsaft/cms/pages/new.html.haml +1 -10
- data/app/views/kuhsaft/column_bricks/_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/{cms/page_parts/edit.html.haml → column_bricks/column_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +9 -0
- data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +10 -0
- data/app/views/kuhsaft/link_bricks/_link_brick.html.haml +3 -0
- data/app/views/kuhsaft/link_bricks/link_brick/_edit.html.haml +3 -0
- data/app/views/kuhsaft/pages/show.html.haml +5 -3
- data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +2 -0
- data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/slider_bricks/_slider_brick.html.haml +10 -0
- data/app/views/kuhsaft/{cms/page_parts/index.html.haml → slider_bricks/slider_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/text_bricks/_text_brick.html.haml +12 -0
- data/app/views/kuhsaft/text_bricks/text_brick/_edit.html.haml +2 -0
- data/app/views/kuhsaft/two_column_bricks/_two_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +9 -0
- data/app/views/kuhsaft/video_bricks/video_brick/_edit.html.haml +8 -0
- data/app/views/layouts/kuhsaft/cms/application.html.haml +20 -0
- data/config/initializers/devise.rb +231 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/locales/kuhsaft.en.yml +4 -1
- data/config/locales/models/kuhsaft/accordion_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/column_brick/de.yml +6 -0
- data/config/locales/models/kuhsaft/image_brick/de.yml +10 -0
- data/config/locales/models/kuhsaft/image_size/de.yml +13 -0
- data/config/locales/models/kuhsaft/link_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/page/de.yml +17 -0
- data/config/locales/models/kuhsaft/placeholder_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/slider_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/text_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/two_column_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/video_brick/de.yml +9 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/kuhsaft/cms/admin/de.yml +10 -0
- data/config/locales/views/kuhsaft/cms/bricks/de.yml +8 -0
- data/config/locales/views/kuhsaft/cms/pages/de.yml +9 -0
- data/config/locales/views/kuhsaft/cms/video_bricks/de.yml +7 -0
- data/config/locales/views/kuhsaft/text_brick/de.yml +6 -0
- data/config/locales/views/layouts/de.yml +6 -0
- data/config/routes.rb +10 -11
- data/db/migrate/01_create_kuhsaft_pages.rb +31 -0
- data/db/migrate/02_create_kuhsaft_bricks.rb +23 -0
- data/db/migrate/03_create_kuhsaft_brick_types.rb +12 -0
- data/db/migrate/04_create_kuhsaft_assets.rb +10 -0
- data/db/migrate/05_create_kuhsaft_cms_admins.rb +46 -0
- data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +7 -0
- data/db/seeds.rb +14 -0
- data/lib/generators/kuhsaft/translations/add_generator.rb +26 -0
- data/lib/kuhsaft.rb +8 -1
- data/lib/kuhsaft/brick_list.rb +71 -0
- data/lib/kuhsaft/engine.rb +17 -12
- data/lib/kuhsaft/partial_extractor.rb +21 -0
- data/lib/kuhsaft/translatable.rb +40 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/lib/tasks/kuhsaft_tasks.rake +10 -0
- data/lib/templates/kuhsaft/translations/add_translation.html.erb +13 -0
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +9 -3
- data/spec/dummy/app/assets/stylesheets/application.css +11 -5
- data/spec/dummy/app/controllers/application_controller.rb +0 -6
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/config/application.rb +24 -7
- data/spec/dummy/config/boot.rb +3 -2
- data/spec/dummy/config/database.yml +6 -3
- data/spec/dummy/config/environments/development.rb +8 -1
- data/spec/dummy/config/environments/production.rb +9 -2
- data/spec/dummy/config/environments/test.rb +4 -9
- data/spec/dummy/config/initializers/inflections.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/locales/en.yml +2 -2
- data/spec/dummy/config/routes.rb +2 -57
- data/spec/dummy/db/{migrate/.gitkeep → .gitkeep} +0 -0
- data/spec/dummy/public/500.html +0 -1
- data/spec/dummy/{lib/tasks → public/stylesheets}/.gitkeep +0 -0
- data/spec/factories.rb +11 -17
- data/spec/features/cms_auth_spec.rb +9 -0
- data/spec/features/cms_pages_spec.rb +23 -0
- data/spec/helpers/kuhsaft/cms/application_helper_spec.rb +25 -0
- data/spec/lib/brick_list_spec.rb +39 -0
- data/spec/lib/engine_spec.rb +25 -0
- data/spec/lib/translatable_spec.rb +85 -0
- data/spec/models/accordion_brick_spec.rb +32 -0
- data/spec/models/accordion_item_brick_spec.rb +50 -0
- data/spec/models/asset_spec.rb +25 -23
- data/spec/models/brick_spec.rb +110 -0
- data/spec/models/cms/admin_spec.rb +26 -0
- data/spec/models/column_brick_spec.rb +32 -0
- data/spec/models/image_brick_spec.rb +36 -0
- data/spec/models/image_size_spec.rb +36 -0
- data/spec/models/link_brick_spec.rb +45 -0
- data/spec/models/page_spec.rb +262 -281
- data/spec/models/placeholder_brick_spec.rb +40 -0
- data/spec/models/slider_brick_spec.rb +20 -0
- data/spec/models/text_brick_spec.rb +14 -0
- data/spec/models/two_column_brick_spec.rb +72 -0
- data/spec/models/video_brick_spec.rb +26 -0
- data/spec/spec_helper.rb +60 -51
- data/spec/support/kuhsaft_spec_helper.rb +4 -28
- data/spec/support/request_macros.rb +19 -0
- data/vendor/assets/javascripts/redactor.min.js +12 -0
- data/vendor/assets/stylesheets/redactor.css +692 -0
- metadata +402 -346
- data/.gitignore +0 -19
- data/.rspec +0 -2
- data/.rvmrc +0 -47
- data/CHANGELOG.md +0 -81
- data/Gemfile +0 -2
- data/Guardfile +0 -25
- data/LICENSE +0 -7
- data/app/assets/images/kuhsaft/add-child-page.png +0 -0
- data/app/assets/images/kuhsaft/closedhand.cur +0 -0
- data/app/assets/images/kuhsaft/delete.png +0 -0
- data/app/assets/images/kuhsaft/header-bg.jpg +0 -0
- data/app/assets/images/kuhsaft/module-nav-tab-bg.png +0 -0
- data/app/assets/images/kuhsaft/openhand.cur +0 -0
- data/app/assets/images/kuhsaft/page-edit-icon.png +0 -0
- data/app/assets/images/kuhsaft/page-new-icon.png +0 -0
- data/app/assets/images/kuhsaft/page-part-draggable-area.png +0 -0
- data/app/assets/images/kuhsaft/page-tree-breadcrumb-arrow.png +0 -0
- data/app/assets/images/kuhsaft/pages-breadcrumb-icon.png +0 -0
- data/app/assets/images/kuhsaft/tab-bg.png +0 -0
- data/app/assets/images/kuhsaft/toggle-arrow-closed.png +0 -0
- data/app/assets/images/kuhsaft/toggle-arrow-open.png +0 -0
- data/app/assets/images/kuhsaft/wrapper-bg.png +0 -0
- data/app/assets/javascripts/kuhsaft/cms/backend.js +0 -34
- data/app/assets/javascripts/kuhsaft/cms/jquery-ui-1.8.12.custom.min.js +0 -192
- data/app/assets/javascripts/kuhsaft/cms/jquery.elastic.source.js +0 -161
- data/app/assets/javascripts/kuhsaft/cms/jquery.min.js +0 -18
- data/app/assets/javascripts/kuhsaft/cms/jquery_ujs.js +0 -336
- data/app/assets/stylesheets/kuhsaft/cms/application.css +0 -6
- data/app/assets/stylesheets/kuhsaft/cms/base/base.css.sass +0 -9
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_assets.css.sass +0 -15
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_buttons.css.sass +0 -34
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_generic.css.sass +0 -342
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_simple_form.css.sass +0 -76
- data/app/controllers/kuhsaft/cms/page_parts_controller.rb +0 -34
- data/app/models/kuhsaft/localized_page.rb +0 -81
- data/app/models/kuhsaft/page_part.rb +0 -12
- data/app/models/kuhsaft/page_part/content.rb +0 -76
- data/app/models/kuhsaft/page_part/markdown.rb +0 -8
- data/app/views/kuhsaft/cms/page_parts/destroy.js.haml +0 -1
- data/app/views/kuhsaft/cms/page_parts/new.html.haml +0 -0
- data/app/views/kuhsaft/cms/page_parts/show.html.haml +0 -0
- data/app/views/kuhsaft/cms/page_parts/update.js.haml +0 -0
- data/app/views/kuhsaft/page_part/markdowns/_edit_markdown.html.haml +0 -1
- data/app/views/kuhsaft/page_part/markdowns/_show_markdown.html.haml +0 -1
- data/app/views/kuhsaft/pages/index.html.haml +0 -0
- data/app/views/layouts/kuhsaft/admin.html.haml +0 -35
- data/config/initializers/generators.rb +0 -7
- data/config/initializers/page_parts.rb +0 -17
- data/kuhsaft.gemspec +0 -39
- data/lib/generators/kuhsaft/install/assets_generator.rb +0 -12
- data/lib/generators/kuhsaft/install/migrations_generator.rb +0 -43
- data/lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb +0 -37
- data/lib/templates/kuhsaft/install/add_fulltext_to_localized_page.rb +0 -9
- data/lib/templates/kuhsaft/install/add_page_type_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/add_published_at_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/add_tags_to_page_part_contents.rb +0 -9
- data/lib/templates/kuhsaft/install/add_type_to_page_part_contents.rb +0 -9
- data/lib/templates/kuhsaft/install/add_url_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/create_assets.rb +0 -12
- data/lib/templates/kuhsaft/install/create_kuhsaft_localized_pages.rb +0 -19
- data/lib/templates/kuhsaft/install/create_kuhsaft_pages.rb +0 -14
- data/lib/templates/kuhsaft/install/create_page_part_contents.rb +0 -14
- data/spec/controllers/cms_assets_controller_spec.rb +0 -26
- data/spec/controllers/cms_pages_controller_spec.rb +0 -65
- data/spec/controllers/page_parts_controller_spec.rb +0 -60
- data/spec/controllers/pages_controller_spec.rb +0 -30
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/helpers/cms_helper_spec.rb +0 -22
- data/spec/helpers/pages_helper_spec.rb +0 -119
- data/spec/integration/navigation_spec.rb +0 -9
- data/spec/models/localized_page_spec.rb +0 -266
- data/spec/models/page_part_content_spec.rb +0 -95
- data/spec/models/page_part_spec.rb +0 -17
- data/spec/requests/cms_pages_spec.rb +0 -27
- data/spec/routing/assets_routing_spec.rb +0 -63
- data/spec/routing/page_part_routing_spec.rb +0 -70
- data/spec/routing/pages_routing_spec.rb +0 -74
@@ -1,266 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Kuhsaft::LocalizedPage do
|
4
|
-
before :each do
|
5
|
-
@page = Factory::create :page
|
6
|
-
@localized_page = @page.translation
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'associations' do
|
10
|
-
describe '#page_parts' do
|
11
|
-
it 'should have many page parts' do
|
12
|
-
@localized_page.should respond_to(:page_parts)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#page' do
|
17
|
-
it 'should belongs to a page' do
|
18
|
-
@localized_page.should respond_to(:page)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'instance methods' do
|
24
|
-
describe '#locale' do
|
25
|
-
it 'should have a locale' do
|
26
|
-
@localized_page.should respond_to(:locale)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should be a Symbol' do
|
30
|
-
@localized_page.locale.should be_an_instance_of(Symbol)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '#published?' do
|
35
|
-
it 'should know if it\'s published' do
|
36
|
-
@localized_page.should respond_to(:published?)
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when the published state is UNPUBLISHED' do
|
40
|
-
it 'should not be published' do
|
41
|
-
@localized_page.update_attribute :published, Kuhsaft::PublishState::UNPUBLISHED
|
42
|
-
@localized_page.published?.should be_false
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when a published_at date is set' do
|
46
|
-
it 'should not be published' do
|
47
|
-
@localized_page.update_attribute :published, Kuhsaft::PublishState::UNPUBLISHED
|
48
|
-
@localized_page.update_attribute :published_at, Time.now - 2.days
|
49
|
-
@localized_page.published?.should be_false
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'when the published state is PUBLISHED' do
|
55
|
-
it 'should be published' do
|
56
|
-
@localized_page.update_attribute :published, Kuhsaft::PublishState::PUBLISHED
|
57
|
-
@localized_page.published?.should be_true
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when the published_at date is set' do
|
61
|
-
it 'should be published' do
|
62
|
-
@localized_page.update_attribute :published, Kuhsaft::PublishState::PUBLISHED
|
63
|
-
@localized_page.update_attribute :published_at, Time.now + 2.days
|
64
|
-
@localized_page.published?.should be_true
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when the published state is PUBLISHED_AT' do
|
70
|
-
it 'should be published if the date is in the past' do
|
71
|
-
@localized_page.update_attribute :published, Kuhsaft::PublishState::PUBLISHED_AT
|
72
|
-
@localized_page.update_attribute :published_at, Time.now - 2.days
|
73
|
-
@localized_page.published?.should be_true
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should not be published if the date is in the future' do
|
77
|
-
@localized_page.update_attribute :published, Kuhsaft::PublishState::PUBLISHED_AT
|
78
|
-
@localized_page.update_attribute :published_at, Time.now + 2.days
|
79
|
-
@localized_page.published?.should be_false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#slug' do
|
85
|
-
it 'should have a slug' do
|
86
|
-
@localized_page.should respond_to(:slug)
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'when it is empty' do
|
90
|
-
it 'should be generated' do
|
91
|
-
@localized_page.should_receive(:create_slug)
|
92
|
-
@localized_page.save
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should use the title to generate the slug' do
|
96
|
-
@localized_page.slug.should eq(@localized_page.title.parameterize)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'when it is not empty' do
|
101
|
-
it 'should take the slug provided by the user' do
|
102
|
-
Factory.create(:localized_page, :slug => 'my-slug').slug.should == 'my-slug'
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe '#url' do
|
108
|
-
it 'should have an url' do
|
109
|
-
@localized_page.should respond_to(:url)
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'when saving the localized_page' do
|
113
|
-
context 'when it is a normal page' do
|
114
|
-
it 'should include the parents slug in its url' do
|
115
|
-
page = Kuhsaft::Page.new
|
116
|
-
page.localized_pages << Kuhsaft::LocalizedPage.new(:title => 'hi', :slug => 'parent-slug', :page_type => '', :locale => :en )
|
117
|
-
|
118
|
-
child = Kuhsaft::Page.new
|
119
|
-
child.localized_pages << Kuhsaft::LocalizedPage.new(:title => 'hi', :slug => 'child-slug', :page_type => '', :locale => :en)
|
120
|
-
|
121
|
-
page.childs << child
|
122
|
-
page.save
|
123
|
-
|
124
|
-
child.url.should == 'en/parent-slug/child-slug'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context 'when it is a navigation?' do
|
129
|
-
it 'the slug should be left out in the url' do
|
130
|
-
page = Kuhsaft::Page.new
|
131
|
-
page.localized_pages << Kuhsaft::LocalizedPage.new(:title => 'hi', :slug => 'parent-slug', :page_type => Kuhsaft::PageType::NAVIGATION, :locale => :en )
|
132
|
-
|
133
|
-
child = Kuhsaft::Page.new
|
134
|
-
child.localized_pages << Kuhsaft::LocalizedPage.new(:title => 'hi', :slug => 'child-slug', :page_type => '', :locale => :en)
|
135
|
-
|
136
|
-
page.childs << child
|
137
|
-
page.save
|
138
|
-
|
139
|
-
child.url.should == 'en/child-slug'
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context 'when it\'s a redirect?' do
|
144
|
-
it 'should not touch the url' do
|
145
|
-
page = Factory.create :page
|
146
|
-
page.translation.page_type = Kuhsaft::PageType::REDIRECT
|
147
|
-
page.translation.url = '/en/news'
|
148
|
-
page.save
|
149
|
-
page.link.should eq('/en/news')
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
describe '#page_type' do
|
156
|
-
it 'should have a page_type' do
|
157
|
-
@localized_page.should respond_to(:page_type)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
describe '#navigation?' do
|
162
|
-
it 'should be true if the page_type is PageType::NAVIGATION' do
|
163
|
-
@page.translation.page_type = Kuhsaft::PageType::NAVIGATION
|
164
|
-
@page.navigation?.should be_true
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe '#redirect?' do
|
169
|
-
it 'should be true if the page_type is PageType::REDIRECT' do
|
170
|
-
@page.translation.page_type = Kuhsaft::PageType::REDIRECT
|
171
|
-
@page.redirect?.should be_true
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe '#fulltext' do
|
176
|
-
before do
|
177
|
-
@page = Factory.create :page
|
178
|
-
@page.translation.keywords = 'key words'
|
179
|
-
@page.translation.description = 'descrip tion'
|
180
|
-
@page.translation.title = 'my title'
|
181
|
-
@page.translation.page_parts << Kuhsaft::PagePart::Markdown.new(:text => 'oh la la1')
|
182
|
-
@page.translation.page_parts << Kuhsaft::PagePart::Markdown.new(:text => 'oh la la2')
|
183
|
-
@page.translation.page_parts << Kuhsaft::PagePart::Markdown.new(:text => 'oh la la3')
|
184
|
-
@page.translation.page_parts << Kuhsaft::PagePart::Markdown.new(:text => nil)
|
185
|
-
@page.save
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'should have a fulltext' do
|
189
|
-
@localized_page.should respond_to(:fulltext)
|
190
|
-
end
|
191
|
-
|
192
|
-
context 'when saved' do
|
193
|
-
it 'should collect and assign the fulltext' do
|
194
|
-
@page.translation.should_receive(:collect_fulltext)
|
195
|
-
@page.save
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'should contain the title' do
|
199
|
-
@page.fulltext.should include('my title')
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'should contain the keywords' do
|
203
|
-
@page.fulltext.should include('key words')
|
204
|
-
end
|
205
|
-
|
206
|
-
it 'should contain the description' do
|
207
|
-
@page.fulltext.should include('descrip tion')
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should contain the page part content' do
|
211
|
-
@page.fulltext.should include('oh la la')
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'should convert all data to strings' do
|
215
|
-
expect { @page.translation.collect_fulltext }.to_not raise_error
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
describe 'validations' do
|
222
|
-
before do
|
223
|
-
@localized_page = Factory.create :localized_page
|
224
|
-
@localized_page.title = nil
|
225
|
-
@localized_page.slug = nil
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'should have a title' do
|
229
|
-
@localized_page.should have(1).error_on(:title)
|
230
|
-
end
|
231
|
-
|
232
|
-
it 'should have a slug' do
|
233
|
-
@localized_page.should have(1).error_on(:slug)
|
234
|
-
end
|
235
|
-
|
236
|
-
after do
|
237
|
-
@localized_page.destroy
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe 'class methods' do
|
242
|
-
describe 'search' do
|
243
|
-
before do
|
244
|
-
Factory.create :page
|
245
|
-
Factory.create :page
|
246
|
-
Factory.create :page
|
247
|
-
end
|
248
|
-
|
249
|
-
it 'should find any containing the search term' do
|
250
|
-
Kuhsaft::LocalizedPage.search('hi').should have_at_least(0).items
|
251
|
-
end
|
252
|
-
|
253
|
-
it 'should find with "English Title"' do
|
254
|
-
Kuhsaft::LocalizedPage.search('English Title').should have_at_least(1).item
|
255
|
-
end
|
256
|
-
|
257
|
-
it 'should only find results with the current locale' do
|
258
|
-
Kuhsaft::LocalizedPage.search('English Title').should be_all { |p| p.locale == Kuhsaft::Page.current_translation_locale }
|
259
|
-
end
|
260
|
-
|
261
|
-
it 'should only find published results' do
|
262
|
-
Kuhsaft::LocalizedPage.search('English Title').should be_all { |p| p.published? == true }
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'PagePart' do
|
4
|
-
describe 'Content' do
|
5
|
-
before do
|
6
|
-
@content = Kuhsaft::PagePart::Content.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'should belong to a LocalizedPage' do
|
10
|
-
@content.should respond_to(:localized_page)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should have a content to store serialized data' do
|
14
|
-
@content.should respond_to(:content)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should be orderable' do
|
18
|
-
@content.should respond_to(:position)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should have tags' do
|
22
|
-
@content.should respond_to(:tags)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should have a tag list' do
|
26
|
-
@content.should respond_to(:tag_list)
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'class' do
|
30
|
-
it 'should keep a list of the serializeable attributes' do
|
31
|
-
Kuhsaft::PagePart::Content.serializeable_attributes.should be_a(Array)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should return the position of a page_part' do
|
35
|
-
Kuhsaft::PagePart::Content.should respond_to(:position_of)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should keep a list of searchable attributes' do
|
39
|
-
Kuhsaft::PagePart::Content.searchable_attributes.should be_a(Array)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should have a list of page_part_types' do
|
43
|
-
Kuhsaft::PagePart::Content.page_part_types.should be_all { |p| p.superclass.should eq Kuhsaft::PagePart::Content }
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should have the Markdown PagePart by default' do
|
47
|
-
Kuhsaft::PagePart::Content.descendants.should include(Kuhsaft::PagePart::Markdown)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe 'Markdown' do
|
53
|
-
before do
|
54
|
-
@m = Kuhsaft::PagePart::Markdown.new
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'should have text' do
|
58
|
-
@m.should respond_to(:text)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should have searchable text' do
|
62
|
-
Kuhsaft::PagePart::Markdown.searchable_attributes.should include(:text)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should store text' do
|
66
|
-
@m.text = 'hi'
|
67
|
-
@m.text.should eq('hi')
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'should restore the serialized attributes when loaded' do
|
71
|
-
m = Kuhsaft::PagePart::Markdown.create(:text => 'hi')
|
72
|
-
m2 = Kuhsaft::PagePart::Markdown.find(m.id)
|
73
|
-
m2.text.should eq('hi')
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should set the initial position after save' do
|
77
|
-
@m2 = Kuhsaft::PagePart::Markdown.new
|
78
|
-
@m2.text = 'hi there'
|
79
|
-
@m2.should_receive(:set_position)
|
80
|
-
@m2.save
|
81
|
-
end
|
82
|
-
|
83
|
-
describe 'edit_partial_path' do
|
84
|
-
it 'should return kuhsaft/page_part/markdowns/edit_markdown' do
|
85
|
-
@m.edit_partial_path.should eq('kuhsaft/page_part/markdowns/edit_markdown')
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'show_partial_path' do
|
90
|
-
it 'should return kuhsaft/page_part/markdowns/show_markdown' do
|
91
|
-
@m.show_partial_path.should eq('kuhsaft/page_part/markdowns/show_markdown')
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Kuhsaft::PagePart do
|
4
|
-
context 'knows its page part types' do
|
5
|
-
it 'keeps known page parts as an array' do
|
6
|
-
Kuhsaft::PagePart.all.should be_a Array
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'references page part types as symbols' do
|
10
|
-
Kuhsaft::PagePart.all.should be_all { |p| p.should be_a Symbol }
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'can load the corresponding modules' do
|
14
|
-
lambda { Kuhsaft::PagePart.all.each { |p| p.to_s.camelize.constantize } }.should_not raise_error NameError
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Cms Pages Backend' do
|
4
|
-
|
5
|
-
context 'when creating a new root page' do
|
6
|
-
before do
|
7
|
-
visit cms_pages_path(:locale => :en)
|
8
|
-
click_link 'Create'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should display a blank page form' do
|
12
|
-
page.should have_selector(:new_kuhsaft_page)
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'when submitting the form' do
|
16
|
-
before do
|
17
|
-
fill_in 'kuhsaft_page_localized_pages_attributes_0_title', :with => 'My first page'
|
18
|
-
click_button 'Create Page'
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should create a new page' do
|
22
|
-
pending 'how wo we test this'
|
23
|
-
page.should have_content 'My first page'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'routing to Kuhsaft::cms::AssetsController' do
|
4
|
-
it 'routes /en/cms/assets to cms/assets#index' do
|
5
|
-
{ :get => '/en/cms/assets' }.should route_to(
|
6
|
-
:controller => 'kuhsaft/cms/assets',
|
7
|
-
:action => 'index',
|
8
|
-
:locale => 'en'
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'routes POST /en/cms/assets to cms/assets#create' do
|
13
|
-
{ :post => '/en/cms/assets' }.should route_to(
|
14
|
-
:controller => 'kuhsaft/cms/assets',
|
15
|
-
:action => 'create',
|
16
|
-
:locale => 'en'
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'routes PUT /en/cms/assets/:id to cms/assets#update' do
|
21
|
-
{ :put => '/en/cms/assets/1' }.should route_to(
|
22
|
-
:controller => 'kuhsaft/cms/assets',
|
23
|
-
:action => 'update',
|
24
|
-
:id => '1',
|
25
|
-
:locale => 'en'
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'routes DELETE /en/cms/assets/:id to cms/assets#destroy' do
|
30
|
-
{ :delete => '/en/cms/assets/1' }.should route_to(
|
31
|
-
:controller => 'kuhsaft/cms/assets',
|
32
|
-
:action => 'destroy',
|
33
|
-
:id => '1',
|
34
|
-
:locale => 'en'
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'routes /en/cms/assets/:id to cms/assets#show' do
|
39
|
-
{ :get => '/en/cms/assets/1' }.should route_to(
|
40
|
-
:controller => 'kuhsaft/cms/assets',
|
41
|
-
:action => 'show',
|
42
|
-
:id => '1',
|
43
|
-
:locale => 'en'
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'routes /en/cms/assets/new to cms/assets#new' do
|
48
|
-
{ :get => '/en/cms/assets/new' }.should route_to(
|
49
|
-
:controller => 'kuhsaft/cms/assets',
|
50
|
-
:action => 'new',
|
51
|
-
:locale => 'en'
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'routes /en/cms/assets/:id/edit to cms/assets#edit' do
|
56
|
-
{ :get => '/en/cms/assets/1/edit' }.should route_to(
|
57
|
-
:controller => 'kuhsaft/cms/assets',
|
58
|
-
:action => 'edit',
|
59
|
-
:id => '1',
|
60
|
-
:locale => 'en'
|
61
|
-
)
|
62
|
-
end
|
63
|
-
end
|