kuhsaft 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +7 -0
- data/app/controllers/kuhsaft/pages_controller.rb +9 -1
- data/app/views/kuhsaft/cms/pages/new.html.haml +4 -0
- data/config/locales/kuhsaft.en.yml +3 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +10 -3
- data/spec/dummy/app/helpers/application_helper.rb +9 -0
- data/spec/helpers/application_helper_spec.rb +22 -0
- metadata +6 -4
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@
|
|
6
6
|
|
7
7
|
- fix README on how to integrate devise (rails31) ([@effkay][])
|
8
8
|
|
9
|
+
## 0.2.4 - August 29, 2011
|
10
|
+
|
11
|
+
### Improvements
|
12
|
+
|
13
|
+
- handle 404s with an ActionController::RoutingError, controllers can optionally implement a `handle_404` method to change behavior ([@manufaktor][])
|
14
|
+
- Backend now shows the hierarchy breadcrumb when creating a new page ([@manufaktor][])
|
15
|
+
|
9
16
|
### New features
|
10
17
|
|
11
18
|
## 0.2.3 - August 19, 2011
|
@@ -6,7 +6,15 @@ module Kuhsaft
|
|
6
6
|
|
7
7
|
def show
|
8
8
|
@page = Kuhsaft::Page.find_by_url(params[:url])
|
9
|
-
|
9
|
+
if @page.present?
|
10
|
+
respond_with @page
|
11
|
+
else
|
12
|
+
if respond_to?(:handle_404)
|
13
|
+
handle_404
|
14
|
+
else
|
15
|
+
raise ActionController::RoutingError.new('Not Found')
|
16
|
+
end
|
17
|
+
end
|
10
18
|
end
|
11
19
|
|
12
20
|
private
|
@@ -2,5 +2,9 @@
|
|
2
2
|
- Kuhsaft::Page.translation_locales.each do |locale|
|
3
3
|
%li{ :class => (:current if params[:locale] == locale.to_s) }= link_to locale.to_s, new_cms_page_path(:locale => locale)
|
4
4
|
|
5
|
+
.page-tree-breadcrumb
|
6
|
+
- available_parent_pages.each do |parent_page|
|
7
|
+
= link_to((parent_page[:title].presence || parent_page.title), parent_page[:link].presence || edit_cms_page_path(parent_page))
|
8
|
+
|
5
9
|
.box-container
|
6
10
|
= render :partial => 'form', :locals => { :url => cms_pages_path, :page_title => t('.new') }
|
@@ -1,4 +1,5 @@
|
|
1
1
|
en:
|
2
|
+
404: '404, Page not found'
|
2
3
|
layouts:
|
3
4
|
kuhsaft:
|
4
5
|
admin:
|
@@ -13,8 +14,10 @@ en:
|
|
13
14
|
create: 'Create new page'
|
14
15
|
new:
|
15
16
|
new: 'Creating new page'
|
17
|
+
pages: 'Pages'
|
16
18
|
edit:
|
17
19
|
edit_html: 'Editing page: <span>%{title}</span>'
|
20
|
+
pages: 'Pages'
|
18
21
|
branch:
|
19
22
|
add: 'Add page'
|
20
23
|
create: 'Create new page'
|
data/lib/kuhsaft/version.rb
CHANGED
@@ -5,8 +5,8 @@ describe Kuhsaft::PagesController do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
set_lang :en
|
8
|
-
# create page with slug=english-title
|
9
|
-
@page = Factory
|
8
|
+
# create page with slug=english-title-1
|
9
|
+
@page = Factory(:page)
|
10
10
|
end
|
11
11
|
|
12
12
|
after do
|
@@ -16,8 +16,15 @@ describe Kuhsaft::PagesController do
|
|
16
16
|
|
17
17
|
describe 'should render successfully' do
|
18
18
|
it '#show' do
|
19
|
-
get :show, :locale => 'en', :url => '
|
19
|
+
get :show, :locale => 'en', :url => 'english-title-1'
|
20
|
+
response.response_code.should eq(200)
|
20
21
|
response.should be_success
|
21
22
|
end
|
22
23
|
end
|
24
|
+
|
25
|
+
describe 'should render 404' do
|
26
|
+
it 'should raise RoutingError by default' do
|
27
|
+
expect{ get :show, :locale => 'en', :url => '/i-dont-know' }.to raise_error(ActionController::RoutingError)
|
28
|
+
end
|
29
|
+
end
|
23
30
|
end
|
@@ -1,2 +1,11 @@
|
|
1
1
|
module ApplicationHelper
|
2
|
+
def available_parent_pages
|
3
|
+
pages = []
|
4
|
+
pages << { :title => t('kuhsaft.cms.pages.new.pages'), :link => cms_pages_path(:locale => :en) }
|
5
|
+
if params[:parent_id].present?
|
6
|
+
parent_page = Kuhsaft::Page.find(params[:parent_id])
|
7
|
+
pages += parent_page.parent_pages
|
8
|
+
end
|
9
|
+
pages << { :title => t('kuhsaft.cms.pages.new.new_page'), :link => '#' }
|
10
|
+
end
|
2
11
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApplicationHelper do
|
4
|
+
context 'when the user creates a toplevel page' do
|
5
|
+
describe '#available_parent_pages' do
|
6
|
+
it 'should return the 2 pages' do
|
7
|
+
helper.available_parent_pages.should have(2).pages
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#available_parent_pages' do
|
13
|
+
before do
|
14
|
+
page1, page2, page3 = create_page_tree
|
15
|
+
helper.stub!(:params).and_return(:parent_id => page3.id)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should return the parent pages' do
|
19
|
+
helper.available_parent_pages.should have_at_least(3).pages
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuhsaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Immanuel H\xC3\xA4ussermann"
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-08-
|
20
|
+
date: 2011-08-29 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rspec-rails
|
@@ -412,6 +412,7 @@ files:
|
|
412
412
|
- spec/dummy/public/stylesheets/.gitkeep
|
413
413
|
- spec/dummy/script/rails
|
414
414
|
- spec/factories.rb
|
415
|
+
- spec/helpers/application_helper_spec.rb
|
415
416
|
- spec/helpers/pages_helper_spec.rb
|
416
417
|
- spec/integration/navigation_spec.rb
|
417
418
|
- spec/kuhsaft_spec.rb
|
@@ -493,6 +494,7 @@ test_files:
|
|
493
494
|
- spec/dummy/public/stylesheets/.gitkeep
|
494
495
|
- spec/dummy/script/rails
|
495
496
|
- spec/factories.rb
|
497
|
+
- spec/helpers/application_helper_spec.rb
|
496
498
|
- spec/helpers/pages_helper_spec.rb
|
497
499
|
- spec/integration/navigation_spec.rb
|
498
500
|
- spec/kuhsaft_spec.rb
|