kuhsaft 0.1.1 → 0.2.legacy
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -2
- data/LICENSE +7 -0
- data/README.md +70 -0
- data/Rakefile +1 -1
- data/app/controllers/kuhsaft/{admin → cms}/admin_controller.rb +2 -2
- data/app/controllers/kuhsaft/{admin → cms}/assets_controller.rb +5 -5
- data/app/controllers/kuhsaft/cms/page_parts_controller.rb +34 -0
- data/app/controllers/kuhsaft/{admin → cms}/pages_controller.rb +12 -11
- data/app/helpers/cms_helper.rb +5 -0
- data/app/helpers/pages_helper.rb +31 -12
- data/app/models/kuhsaft/asset.rb +18 -0
- data/app/models/kuhsaft/localized_page.rb +42 -16
- data/app/models/kuhsaft/page.rb +66 -66
- data/app/models/kuhsaft/page_part/content.rb +23 -2
- data/app/models/kuhsaft/publish_state.rb +2 -6
- data/app/stylesheets/kuhsaft/{admin → cms}/partials/_assets.sass +0 -0
- data/app/stylesheets/kuhsaft/cms/partials/_buttons.sass +13 -0
- data/app/stylesheets/kuhsaft/{admin/ie.sass → cms/partials/_forms.sass} +0 -0
- data/app/stylesheets/kuhsaft/cms/partials/_generic.sass +315 -0
- data/app/stylesheets/kuhsaft/cms/partials/_simple_form.sass +75 -0
- data/app/stylesheets/kuhsaft/{admin → cms}/screen.sass +2 -1
- data/app/uploaders/kuhsaft/asset_uploader.rb +1 -1
- data/app/views/kuhsaft/cms/assets/_form.html.haml +15 -0
- data/app/views/kuhsaft/cms/assets/_list.html.haml +11 -0
- data/app/views/kuhsaft/cms/assets/edit.html.haml +2 -0
- data/app/views/kuhsaft/cms/assets/index.html.haml +3 -0
- data/app/views/kuhsaft/cms/assets/new.html.haml +2 -0
- data/app/views/kuhsaft/cms/page_parts/destroy.js.haml +1 -0
- data/app/{stylesheets/kuhsaft/admin/print.sass → views/kuhsaft/cms/page_parts/edit.html.haml} +0 -0
- data/app/views/kuhsaft/{admin/pages/show.html.haml → cms/page_parts/index.html.haml} +0 -0
- 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/cms/pages/_branch.html.haml +11 -0
- data/app/views/kuhsaft/cms/pages/_form.html.haml +59 -0
- data/app/views/kuhsaft/cms/pages/edit.html.haml +11 -0
- data/app/views/kuhsaft/cms/pages/index.html.haml +8 -0
- data/app/views/kuhsaft/cms/pages/new.html.haml +6 -0
- data/app/views/kuhsaft/cms/pages/show.html.haml +0 -0
- data/app/views/kuhsaft/page_part/markdowns/_edit_markdown.html.haml +1 -0
- data/app/views/kuhsaft/page_part/markdowns/_show_markdown.html.haml +1 -0
- data/app/views/kuhsaft/pages/show.html.haml +3 -1
- data/app/views/layouts/kuhsaft/admin.html.haml +24 -14
- data/config/locales/kuhsaft.en.yml +28 -6
- data/config/routes.rb +7 -8
- data/kuhsaft.gemspec +3 -2
- data/lib/generators/kuhsaft/install/migrations_generator.rb +2 -0
- data/lib/kuhsaft.rb +3 -0
- data/lib/kuhsaft/engine.rb +1 -0
- data/lib/kuhsaft/orderable.rb +68 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb +37 -0
- data/lib/templates/kuhsaft/install/add_tags_to_page_part_contents.rb +9 -0
- data/public/images/kuhsaft/add-child-page.png +0 -0
- data/public/images/kuhsaft/delete.png +0 -0
- data/public/images/kuhsaft/header-bg.jpg +0 -0
- data/public/images/kuhsaft/module-nav-tab-bg.png +0 -0
- data/public/images/kuhsaft/page-edit-icon.png +0 -0
- data/public/images/kuhsaft/page-new-icon.png +0 -0
- data/public/images/kuhsaft/page-part-draggable-area.png +0 -0
- data/public/images/kuhsaft/page-tree-breadcrumb-arrow.png +0 -0
- data/public/images/kuhsaft/pages-breadcrumb-icon.png +0 -0
- data/public/images/kuhsaft/tab-bg.png +0 -0
- data/public/images/kuhsaft/toggle-arrow-closed.png +0 -0
- data/public/images/kuhsaft/toggle-arrow-open.png +0 -0
- data/public/images/kuhsaft/wrapper-bg.png +0 -0
- data/public/javascripts/kuhsaft/cms/application.js +31 -0
- data/public/javascripts/kuhsaft/{admin → cms}/jquery-1.4.4.js +0 -0
- data/public/javascripts/kuhsaft/{admin → cms}/jquery-ui-1.8.12.custom.min.js +0 -0
- data/public/javascripts/kuhsaft/{admin → cms}/rails.js +0 -0
- data/spec/controllers/{admin_assets_controller_spec.rb → cms_assets_controller_spec.rb} +5 -5
- data/spec/controllers/{admin_pages_controller_spec.rb → cms_pages_controller_spec.rb} +2 -2
- data/spec/controllers/page_parts_controller_spec.rb +60 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/config/locales/en.yml +1 -3
- data/spec/dummy/public/javascripts/kuhsaft/cms/application.js +31 -0
- data/spec/dummy/public/javascripts/kuhsaft/cms/jquery-1.4.4.js +7179 -0
- data/spec/dummy/public/javascripts/kuhsaft/cms/jquery-ui-1.8.12.custom.min.js +192 -0
- data/spec/dummy/public/javascripts/kuhsaft/cms/rails.js +157 -0
- data/spec/factories.rb +4 -2
- data/spec/helpers/pages_helper_spec.rb +93 -33
- data/spec/models/asset_spec.rb +18 -2
- data/spec/models/localized_page_spec.rb +225 -124
- data/spec/models/page_part_content_spec.rb +35 -4
- data/spec/models/page_spec.rb +292 -143
- data/spec/models/publish_state_spec.rb +0 -12
- data/spec/requests/cms_pages_spec.rb +27 -0
- data/spec/routing/assets_routing_spec.rb +37 -30
- data/spec/routing/page_part_routing_spec.rb +70 -0
- data/spec/routing/pages_routing_spec.rb +23 -23
- data/spec/support/kuhsaft_spec_helper.rb +3 -0
- metadata +107 -63
- data/README +0 -67
- data/app/stylesheets/kuhsaft/admin/partials/_buttons.sass +0 -216
- data/app/stylesheets/kuhsaft/admin/partials/_generic.sass +0 -48
- data/app/stylesheets/kuhsaft/admin/partials/_pages.sass +0 -46
- data/app/views/kuhsaft/admin/assets/_form.html.haml +0 -3
- data/app/views/kuhsaft/admin/assets/_list.html.haml +0 -11
- data/app/views/kuhsaft/admin/assets/edit.html.haml +0 -1
- data/app/views/kuhsaft/admin/assets/index.html.haml +0 -3
- data/app/views/kuhsaft/admin/assets/new.html.haml +0 -1
- data/app/views/kuhsaft/admin/kuhsaft/page_part/markdowns/_markdown.html.haml +0 -1
- data/app/views/kuhsaft/admin/pages/_branch.html.haml +0 -10
- data/app/views/kuhsaft/admin/pages/_form.html.haml +0 -22
- data/app/views/kuhsaft/admin/pages/edit.html.haml +0 -7
- data/app/views/kuhsaft/admin/pages/index.html.haml +0 -4
- data/app/views/kuhsaft/admin/pages/new.html.haml +0 -3
- data/config/initializers/compass.rb +0 -3
- data/public/images/css3buttons_backgrounds.png +0 -0
- data/public/images/css3buttons_icons.png +0 -0
- data/public/images/drag-handle.png +0 -0
- data/public/javascripts/kuhsaft/admin/application.js +0 -17
- data/spec/dummy/public/images/css3buttons_backgrounds.png +0 -0
- data/spec/dummy/public/images/css3buttons_icons.png +0 -0
- data/spec/dummy/public/images/drag-handle.png +0 -0
data/spec/models/asset_spec.rb
CHANGED
@@ -12,12 +12,28 @@ describe Kuhsaft::Asset do
|
|
12
12
|
Kuhsaft::AssetUploader.enable_processing = false
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should scale down to fit into a
|
16
|
-
@uploader.thumb.should have_dimensions(
|
15
|
+
it 'should scale down to fit into a 100x100 thumb' do
|
16
|
+
@uploader.thumb.should have_dimensions(100, 100)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should make the image readable only to the owner and not executable" do
|
20
20
|
pending 'how and where do we ensure permissions?'
|
21
21
|
@uploader.should have_permissions(0600)
|
22
22
|
end
|
23
|
+
|
24
|
+
describe '#file_type' do
|
25
|
+
it 'should have a file_type' do
|
26
|
+
@asset.should respond_to(:file_type)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should be symbolized' do
|
30
|
+
@asset.file_type.should be_a(Symbol)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#name' do
|
35
|
+
it 'should have a name' do
|
36
|
+
@asset.should respond_to(:name)
|
37
|
+
end
|
38
|
+
end
|
23
39
|
end
|
@@ -2,81 +2,219 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Kuhsaft::LocalizedPage do
|
4
4
|
before :each do
|
5
|
-
@
|
5
|
+
@page = Factory::create :page
|
6
|
+
@localized_page = @page.translation
|
6
7
|
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
it 'should not be published when set to false' do
|
21
|
-
@localized_page.update_attribute :published, false
|
22
|
-
@localized_page.published?.should be_false
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should not be published when set to 0' do
|
26
|
-
@localized_page.update_attribute :published, 0
|
27
|
-
@localized_page.published?.should be_false
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should belong to a page' do
|
31
|
-
@localized_page.page.should be_a(Kuhsaft::Page)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should create a slug when the slug is empty' do
|
35
|
-
@localized_page.should_receive(:create_slug)
|
36
|
-
@localized_page.save
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should generate the slug from the title' do
|
40
|
-
@localized_page.slug.should eq(@localized_page.title.parameterize)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should have page_parts' do
|
44
|
-
@localized_page.should respond_to(:page_parts)
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should not generate the slug if the user has set it' do
|
48
|
-
Factory.create(:localized_page, :slug => 'my-slug').slug.should == 'my-slug'
|
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
|
49
21
|
end
|
50
22
|
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
54
33
|
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
58
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
|
59
99
|
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
63
105
|
end
|
64
106
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
71
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
|
72
201
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
80
218
|
end
|
81
219
|
end
|
82
220
|
|
@@ -100,66 +238,29 @@ describe Kuhsaft::LocalizedPage do
|
|
100
238
|
end
|
101
239
|
end
|
102
240
|
|
103
|
-
describe '
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
@page.fulltext.should include('key words')
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should contain the description' do
|
130
|
-
@page.fulltext.should include('descrip tion')
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'should contain the page part content' do
|
134
|
-
@page.fulltext.should include('oh la la')
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'should convert all data to strings' do
|
138
|
-
expect { @page.translation.collect_fulltext }.to_not raise_error
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe 'search' do
|
143
|
-
before do
|
144
|
-
Factory.create :page
|
145
|
-
Factory.create :page
|
146
|
-
Factory.create :page
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'should find any containing the search term' do
|
150
|
-
Kuhsaft::LocalizedPage.search('hi').should have_at_least(0).items
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'should find with "English Title"' do
|
154
|
-
Kuhsaft::LocalizedPage.search('English Title').should have_at_least(1).item
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'should only find results with the current locale' do
|
158
|
-
Kuhsaft::LocalizedPage.search('English Title').should be_all { |p| p.locale == Kuhsaft::Page.current_translation_locale }
|
159
|
-
end
|
160
|
-
|
161
|
-
it 'should only find published results' do
|
162
|
-
Kuhsaft::LocalizedPage.search('English Title').should be_all { |p| p.published? == true }
|
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
|
163
264
|
end
|
164
265
|
end
|
165
266
|
end
|
@@ -14,11 +14,27 @@ describe 'PagePart' do
|
|
14
14
|
@content.should respond_to(:content)
|
15
15
|
end
|
16
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
|
+
|
17
29
|
context 'class' do
|
18
30
|
it 'should keep a list of the serializeable attributes' do
|
19
31
|
Kuhsaft::PagePart::Content.serializeable_attributes.should be_a(Array)
|
20
32
|
end
|
21
33
|
|
34
|
+
it 'should return the position of a page_part' do
|
35
|
+
Kuhsaft::PagePart::Content.should respond_to(:position_of)
|
36
|
+
end
|
37
|
+
|
22
38
|
it 'should keep a list of searchable attributes' do
|
23
39
|
Kuhsaft::PagePart::Content.searchable_attributes.should be_a(Array)
|
24
40
|
end
|
@@ -30,10 +46,6 @@ describe 'PagePart' do
|
|
30
46
|
it 'should have the Markdown PagePart by default' do
|
31
47
|
Kuhsaft::PagePart::Content.descendants.should include(Kuhsaft::PagePart::Markdown)
|
32
48
|
end
|
33
|
-
|
34
|
-
it 'should convert to_name' do
|
35
|
-
Kuhsaft::PagePart::Markdown.to_name.should eq('Markdown')
|
36
|
-
end
|
37
49
|
end
|
38
50
|
end
|
39
51
|
|
@@ -60,5 +72,24 @@ describe 'PagePart' do
|
|
60
72
|
m2 = Kuhsaft::PagePart::Markdown.find(m.id)
|
61
73
|
m2.text.should eq('hi')
|
62
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
|
63
94
|
end
|
64
95
|
end
|