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/page_spec.rb
CHANGED
@@ -15,158 +15,307 @@ describe Kuhsaft::Page do
|
|
15
15
|
@page = Factory.create :page
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
child.parent.should eq(@page)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should have a list of root pages' do
|
39
|
-
root_page = Factory.create :page
|
40
|
-
root_page.childs << Factory.create(:page)
|
41
|
-
root_page.childs << Factory.create(:page)
|
42
|
-
Kuhsaft::Page.root_pages.should have_at_least(2).pages
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should increment it\'s position by 1' do
|
46
|
-
page = Factory.create :page
|
47
|
-
position = page.position
|
48
|
-
page.increment_position
|
49
|
-
page.position.should == (position + 1)
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should decrement it\'s position by 1' do
|
53
|
-
page = Factory.create :page
|
54
|
-
position = page.position
|
55
|
-
page.decrement_position
|
56
|
-
page.position.should == (position - 1)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should find the position of a page' do
|
60
|
-
page = Factory.create :page
|
61
|
-
position = page.position
|
62
|
-
Kuhsaft::Page.position_of(page.id).should == position
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should find the predecing sibling' do
|
66
|
-
page1 = Factory.create :page
|
67
|
-
page2 = Factory.create :page
|
68
|
-
page3 = Factory.create :page
|
69
|
-
page3.preceding_sibling.id.should == page2.id
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should find the succeeding sibling' do
|
73
|
-
page1 = Factory.create :page
|
74
|
-
page2 = Factory.create :page
|
75
|
-
page3 = Factory.create :page
|
76
|
-
page2.succeeding_sibling.id.should == page3.id
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should reposition before a page' do
|
80
|
-
page1 = Factory.create :page
|
81
|
-
page2 = Factory.create :page
|
82
|
-
page3 = Factory.create :page
|
83
|
-
page3.reposition page1.id
|
84
|
-
page3.preceding_sibling.id.should == page1.id
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should reposition before all siblings' do
|
88
|
-
page1 = Factory.create :page
|
89
|
-
page2 = Factory.create :page
|
90
|
-
page2.reposition nil
|
91
|
-
page2.position.should == 1
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'should save the translation when saved' do
|
95
|
-
@page.translation.title = 'some localized title'
|
96
|
-
@page.should_receive(:save_translation)
|
97
|
-
@page.save
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should have an url when saved' do
|
101
|
-
page = Factory.create :page
|
102
|
-
page.url.should == 'en/english-title'
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should have a link' do
|
106
|
-
page = Factory.create :page
|
107
|
-
page.link.should == '/en/english-title'
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should include the parents slug in its url' do
|
111
|
-
page = Factory.create :page
|
112
|
-
child = Factory.create :page
|
113
|
-
page.childs << child
|
114
|
-
page.save
|
115
|
-
child.url.should == 'en/english-title/english-title'
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should return the link of its first child when its empty' do
|
119
|
-
page = Factory.create :page
|
120
|
-
child = Factory.create :page
|
121
|
-
page.childs << child
|
122
|
-
page.translation.body = nil
|
123
|
-
page.save
|
124
|
-
page.link.should == child.link
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'should not modify the url when it\'s a redirect' do
|
128
|
-
page = Factory.create :page
|
129
|
-
page.translation.page_type = 'redirect'
|
130
|
-
page.translation.url = '/en/news'
|
131
|
-
page.save
|
132
|
-
page.link.should eq('/en/news')
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'should find its translated content by url' do
|
136
|
-
destroy_all_pages
|
137
|
-
page = Factory.create(:page)
|
138
|
-
Kuhsaft::Page.find_by_url(page.url).should eq(page)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'should provide an array of translation locales' do
|
142
|
-
Kuhsaft::Page.translation_locales.should be_a(Array)
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'should have :en as minimal translation locale' do
|
146
|
-
Kuhsaft::Page.translation_locales.include?(:en).should be_true
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'should have the current translation locale' do
|
150
|
-
Kuhsaft::Page.current_translation_locale = 'de'
|
151
|
-
Kuhsaft::Page.current_translation_locale.should be(:de)
|
18
|
+
describe 'associations' do
|
19
|
+
describe '#localized_pages' do
|
20
|
+
it 'should have localized_pages' do
|
21
|
+
@page.should respond_to(:localized_pages)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have at least 1 localized page' do
|
25
|
+
@page.localized_pages.should have_at_least(1).item
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#childs' do
|
30
|
+
it 'should have child pages' do
|
31
|
+
@page.childs << Factory.create(:page)
|
32
|
+
@page.childs.should have_at_least(1).page
|
33
|
+
end
|
34
|
+
end
|
152
35
|
end
|
153
36
|
|
154
|
-
|
155
|
-
|
156
|
-
|
37
|
+
describe 'class methods' do
|
38
|
+
describe '#root_pages' do
|
39
|
+
before { destroy_all_pages }
|
40
|
+
it 'should have a list of the toplevel pages' do
|
41
|
+
root_page = Factory.create :page
|
42
|
+
Kuhsaft::Page.root_pages.should have_at_least(1).page
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#position_of' do
|
47
|
+
it 'should find the position of a page' do
|
48
|
+
page = Factory.create :page
|
49
|
+
position = page.position
|
50
|
+
Kuhsaft::Page.position_of(page.id).should == position
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#find_by_url' do
|
55
|
+
before { destroy_all_pages }
|
56
|
+
it 'should find its translated content by url' do
|
57
|
+
page = Factory.create(:page)
|
58
|
+
Kuhsaft::Page.find_by_url(page.url).should eq(page)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#flat_tree' do
|
63
|
+
before { destroy_all_pages }
|
64
|
+
it 'should create an ordered, flat list of the page tree' do
|
65
|
+
tree = create_page_tree
|
66
|
+
Kuhsaft::Page.flat_tree.should eq(tree)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#published' do
|
71
|
+
before { destroy_all_pages }
|
72
|
+
it 'should get only published pages' do
|
73
|
+
p1, p2, p3 = 3.times.map { Factory.create :page }
|
74
|
+
p2.translation.update_attribute :published, Kuhsaft::PublishState::UNPUBLISHED
|
75
|
+
Kuhsaft::Page.published.should be_all { |p| p.published?.should be_true }
|
76
|
+
Kuhsaft::Page.published.length.should be(2)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#current_locale' do
|
81
|
+
before { destroy_all_pages }
|
82
|
+
it 'should only return pages with translations in the current locale' do
|
83
|
+
p1 = Factory.create :page
|
84
|
+
p1.translation.update_attribute :locale, :fr
|
85
|
+
p2 = Factory.create :page
|
86
|
+
p2.translation.update_attribute :locale, :fr
|
87
|
+
p3 = Factory.create :page
|
88
|
+
Kuhsaft::Page.current_translation_locale = :fr
|
89
|
+
Kuhsaft::Page.current_locale.should have(2).items
|
90
|
+
Kuhsaft::Page.current_translation_locale = :en
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe 'languages and locales' do
|
95
|
+
describe '#translation_locales' do
|
96
|
+
it 'should provide an array of translation locales' do
|
97
|
+
Kuhsaft::Page.translation_locales.should be_an_instance_of(Array)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should contain :en as minimal translation locale' do
|
101
|
+
Kuhsaft::Page.translation_locales.include?(:en).should be_true
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should contain only locale symbols' do
|
105
|
+
Kuhsaft::Page.translation_locales = ['de']
|
106
|
+
Kuhsaft::Page.translation_locales.should be_all { |l| l.should be_an_instance_of(Symbol)}
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#current_translation_locale' do
|
111
|
+
it 'should have the current translation locale' do
|
112
|
+
Kuhsaft::Page.current_translation_locale = 'de'
|
113
|
+
Kuhsaft::Page.current_translation_locale.should be(:de)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
157
117
|
end
|
158
118
|
|
159
|
-
|
160
|
-
|
119
|
+
describe 'instance methods' do
|
120
|
+
describe '#root?' do
|
121
|
+
it 'should return true for a page without a parent' do
|
122
|
+
Factory::create(:page).root?.should be_true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe '#without_self' do
|
127
|
+
it 'should return pages but not itself' do
|
128
|
+
10.times { Factory.create :page }
|
129
|
+
page = Kuhsaft::Page.first
|
130
|
+
page.without_self.should_not include(page)
|
131
|
+
end
|
132
|
+
after { destroy_all_pages }
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#nesting_name' do
|
136
|
+
before do
|
137
|
+
@p1, @p2, @p3 = create_page_tree
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'on the topmost level' do
|
141
|
+
it 'should have a label representing it\'s nesting depth without a leading dash' do
|
142
|
+
@p1.nesting_name.should eq('English Title 1')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'on the first level' do
|
147
|
+
it 'should have a label with one dash' do
|
148
|
+
@p2.nesting_name.should eq('- English Title 2')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'on the second level' do
|
153
|
+
it 'should have a label with two dashes' do
|
154
|
+
@p3.nesting_name.should eq('-- English Title 3')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe '#siblings' do
|
160
|
+
it 'should know it\'s siblings' do
|
161
|
+
Factory.create(:page).should respond_to(:siblings)
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should be a list of pages' do
|
165
|
+
Factory.create(:page).siblings.should be_all { |p| p.should be_an_instance_of(Kuhsaft::Page) }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe '#parent' do
|
170
|
+
before do
|
171
|
+
@page = Factory::create :page
|
172
|
+
@child = Factory::create :page
|
173
|
+
@page.childs << @child
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'should know it\'s parent page' do
|
177
|
+
@child.should respond_to(:parent)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should be a Kuhsaft::Page' do
|
181
|
+
@child.parent.should be_an_instance_of(Kuhsaft::Page)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#translation' do
|
186
|
+
it 'should have a translation' do
|
187
|
+
@page.should respond_to(:translation)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should return a Kuhsaft::LocalizedPage' do
|
191
|
+
@page.translation.should be_an_instance_of(Kuhsaft::LocalizedPage)
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'when saving the page' do
|
195
|
+
it 'should save the translation' do
|
196
|
+
@page.translation.title = 'some localized title'
|
197
|
+
@page.should_receive(:save_translation)
|
198
|
+
@page.save
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe '#page_part_type' do
|
204
|
+
it 'accepts a page_part_type to determine which page_part needs to be added' do
|
205
|
+
@page.should respond_to(:page_part_type)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe '#parent_pages' do
|
210
|
+
it 'should have parent_pages' do
|
211
|
+
@page.should respond_to(:parent_pages)
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should have a list of parent pages' do
|
215
|
+
@page.parent_pages.should be_instance_of(Array)
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should be ordered from top to bottom' do
|
219
|
+
@page.parent_pages.last.should be(@page)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe '#link' do
|
224
|
+
it 'should have a link' do
|
225
|
+
@page.should respond_to(:link)
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'when it has no content' do
|
229
|
+
it 'should return the link of it\'s first child' do
|
230
|
+
page = Factory.create :page
|
231
|
+
child = Factory.create :page
|
232
|
+
page.childs << child
|
233
|
+
page.translation.body = nil
|
234
|
+
page.save
|
235
|
+
page.link.should == child.link
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
161
239
|
end
|
162
240
|
|
163
|
-
|
164
|
-
|
241
|
+
describe 'custom ordering' do
|
242
|
+
describe '#increment_position' do
|
243
|
+
it 'should increment it\'s position by 1' do
|
244
|
+
page = Factory.create :page
|
245
|
+
position = page.position
|
246
|
+
page.increment_position
|
247
|
+
page.position.should == (position + 1)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
describe '#decrement_position' do
|
252
|
+
it 'should decrement it\'s position by 1' do
|
253
|
+
page = Factory.create :page
|
254
|
+
position = page.position
|
255
|
+
page.decrement_position
|
256
|
+
page.position.should == (position - 1)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe '#preceding_sibling' do
|
261
|
+
it 'should find the predecing sibling' do
|
262
|
+
page1 = Factory.create :page
|
263
|
+
page2 = Factory.create :page
|
264
|
+
page3 = Factory.create :page
|
265
|
+
page3.preceding_sibling.id.should == page2.id
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe '#succeeding_sibling' do
|
270
|
+
it 'should find the succeeding sibling' do
|
271
|
+
page1 = Factory.create :page
|
272
|
+
page2 = Factory.create :page
|
273
|
+
page3 = Factory.create :page
|
274
|
+
page2.succeeding_sibling.id.should == page3.id
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
describe '#reposition' do
|
279
|
+
it 'should reposition before a page, specified by id' do
|
280
|
+
page1 = Factory.create :page
|
281
|
+
page2 = Factory.create :page
|
282
|
+
page3 = Factory.create :page
|
283
|
+
page3.reposition page1.id
|
284
|
+
page3.preceding_sibling.id.should == page1.id
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should reposition before all siblings, specified by nil' do
|
288
|
+
page1 = Factory.create :page
|
289
|
+
page2 = Factory.create :page
|
290
|
+
page2.reposition nil
|
291
|
+
page2.position.should == 1
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe '#siblings' do
|
296
|
+
pending 'describe'
|
297
|
+
end
|
298
|
+
|
299
|
+
describe '#position_to_top' do
|
300
|
+
pending 'describe'
|
301
|
+
end
|
302
|
+
|
303
|
+
describe '#recount_siblings_position_from' do
|
304
|
+
pending 'describe'
|
305
|
+
end
|
306
|
+
|
307
|
+
describe '#reposition' do
|
308
|
+
pending 'describe'
|
309
|
+
end
|
310
|
+
|
311
|
+
describe '#set_position' do
|
312
|
+
pending
|
313
|
+
end
|
165
314
|
end
|
166
315
|
|
167
316
|
describe 'should delegate' do
|
168
|
-
it 'slug, title, keywords and description to the translation' do
|
169
|
-
[:slug, :title, :keywords, :description].each do |attr|
|
317
|
+
it 'slug, title, published, published?, page_type, fulltext, keywords, page_parts and description to the translation' do
|
318
|
+
[:slug, :title, :published, :published?, :page_type, :fulltext, :keywords, :page_parts, :description].each do |attr|
|
170
319
|
@page.send(attr).should eq(@page.translation.send(attr))
|
171
320
|
end
|
172
321
|
end
|
@@ -9,10 +9,6 @@ describe Kuhsaft::PublishState do
|
|
9
9
|
it 'should be UNPUBLISHED' do
|
10
10
|
@publish_state.value.should be(Kuhsaft::PublishState::UNPUBLISHED)
|
11
11
|
end
|
12
|
-
|
13
|
-
it 'should have a translated name' do
|
14
|
-
@publish_state.human_name.should eq(I18n.translate('unpublished'))
|
15
|
-
end
|
16
12
|
end
|
17
13
|
|
18
14
|
context 'published' do
|
@@ -23,10 +19,6 @@ describe Kuhsaft::PublishState do
|
|
23
19
|
it 'should be PUBLISHED' do
|
24
20
|
@publish_state.value.should be(Kuhsaft::PublishState::PUBLISHED)
|
25
21
|
end
|
26
|
-
|
27
|
-
it 'should have a translated name' do
|
28
|
-
@publish_state.human_name.should eq(I18n.translate('published'))
|
29
|
-
end
|
30
22
|
end
|
31
23
|
|
32
24
|
context 'published_at' do
|
@@ -37,9 +29,5 @@ describe Kuhsaft::PublishState do
|
|
37
29
|
it 'should be PUBLISHED_AT' do
|
38
30
|
@publish_state.value.should be(Kuhsaft::PublishState::PUBLISHED_AT)
|
39
31
|
end
|
40
|
-
|
41
|
-
it 'should have a translated name' do
|
42
|
-
@publish_state.human_name.should eq(I18n.translate('published_at'))
|
43
|
-
end
|
44
32
|
end
|
45
33
|
end
|