kuhsaft 2.2.6 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -0
- data/Rakefile +6 -5
- data/app/assets/javascripts/ckeditor/plugins/adv_link/LICENSE.txt +674 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/README.md +62 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/anchor.js.coffee +81 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/link.js.coffee +1353 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/images/anchor.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/images/hidpi/anchor.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/de.js +68 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/en.js +68 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/plugin.js.coffee +282 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js.coffee.erb +42 -4
- data/app/assets/stylesheets/kuhsaft/application.css.sass +0 -3
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +26 -11
- data/app/controllers/kuhsaft/api/pages_controller.rb +14 -0
- data/app/controllers/kuhsaft/cms/admin_controller.rb +1 -1
- data/app/controllers/kuhsaft/cms/assets_controller.rb +7 -7
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +15 -4
- data/app/controllers/kuhsaft/cms/pages_controller.rb +8 -15
- data/app/controllers/kuhsaft/pages_controller.rb +16 -6
- data/app/controllers/kuhsaft/sitemaps_controller.rb +13 -0
- data/app/helpers/cms_helper.rb +4 -4
- data/app/helpers/kuhsaft/admin_helper.rb +0 -1
- data/app/helpers/kuhsaft/cms/admin_helper.rb +1 -2
- data/app/helpers/kuhsaft/cms/pages_helper.rb +2 -7
- data/app/helpers/pages_helper.rb +8 -37
- data/app/helpers/sitemaps_helper.rb +12 -0
- data/app/models/kuhsaft/accordion_item_brick.rb +1 -1
- data/app/models/kuhsaft/anchor_brick.rb +1 -1
- data/app/models/kuhsaft/asset.rb +26 -23
- data/app/models/kuhsaft/asset_brick.rb +2 -1
- data/app/models/kuhsaft/brick.rb +38 -16
- data/app/models/kuhsaft/brick_type.rb +2 -2
- data/app/models/kuhsaft/brick_type_filter.rb +0 -2
- data/app/models/kuhsaft/column_brick.rb +0 -1
- data/app/models/kuhsaft/image_brick.rb +2 -2
- data/app/models/kuhsaft/image_size.rb +0 -1
- data/app/models/kuhsaft/link_brick.rb +1 -1
- data/app/models/kuhsaft/page.rb +111 -107
- data/app/models/kuhsaft/page_type.rb +1 -1
- data/app/models/kuhsaft/partition.rb +12 -12
- data/app/models/kuhsaft/placeholder_brick.rb +8 -0
- data/app/models/kuhsaft/publish_state.rb +9 -10
- data/app/models/kuhsaft/slider_brick.rb +0 -2
- data/app/models/kuhsaft/text_brick.rb +1 -1
- data/app/models/kuhsaft/two_column_brick.rb +0 -1
- data/app/models/kuhsaft/video_brick.rb +1 -2
- data/app/uploaders/kuhsaft/asset_brick_asset_uploader.rb +39 -38
- data/app/uploaders/kuhsaft/asset_uploader.rb +43 -43
- data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +7 -34
- data/app/views/kuhsaft/asset_bricks/asset_brick/_edit.html.haml +3 -2
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +2 -2
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +17 -10
- data/app/views/kuhsaft/cms/bricks/_new.html.haml +34 -0
- data/app/views/kuhsaft/cms/bricks/create.js.haml +6 -0
- data/app/views/kuhsaft/cms/bricks/destroy.js.haml +4 -0
- data/app/views/kuhsaft/cms/bricks/new.js.haml +11 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +2 -2
- data/app/views/kuhsaft/cms/pages/_form.html.haml +29 -18
- data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +9 -7
- data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +3 -0
- data/app/views/kuhsaft/pages/show.html.haml +1 -9
- data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +1 -1
- data/app/views/kuhsaft/sitemaps/index.xml.haml +9 -0
- data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +4 -4
- data/app/views/layouts/kuhsaft/cms/application.html.haml +4 -3
- data/config/initializers/simple_form.rb +4 -4
- data/config/initializers/simple_form_bootstrap.rb +14 -14
- data/config/locales/de.yml +203 -0
- data/config/locales/en.yml +282 -0
- data/config/locales/kuhsaft.de.yml +14 -0
- data/config/locales/kuhsaft.en.yml +60 -0
- data/config/locales/models/kuhsaft/image_brick/de.yml +1 -0
- data/config/locales/models/kuhsaft/image_brick/en.yml +16 -0
- data/config/locales/models/kuhsaft/text_brick/de.yml +3 -0
- data/config/locales/models/kuhsaft/text_brick/en.yml +16 -0
- data/config/locales/models/kuhsaft/video_brick/en.yml +15 -0
- data/config/locales/views/kuhsaft/cms/pages/de.yml +3 -0
- data/config/locales/views/kuhsaft/cms/video_bricks/de.yml +1 -1
- data/config/routes.rb +18 -9
- data/db/migrate/10_add_redirect_url_to_kuhsaft_pages.rb +1 -1
- data/db/migrate/11_update_url_and_redirect_url_value.rb +4 -4
- data/db/migrate/13_add_page_title_to_pages.rb +1 -1
- data/db/migrate/15_add_alt_text_to_bricks.rb +5 -0
- data/db/migrate/16_update_default_value_for_page_type.rb +9 -0
- data/db/migrate/17_set_page_type_to_content_for_empty_fields.rb +7 -0
- data/lib/generators/kuhsaft/assets/install_generator.rb +1 -2
- data/lib/generators/kuhsaft/translations/add_generator.rb +19 -4
- data/lib/kuhsaft.rb +1 -0
- data/lib/kuhsaft/brick_list.rb +6 -8
- data/lib/kuhsaft/engine.rb +5 -1
- data/lib/kuhsaft/orderable.rb +22 -19
- data/lib/kuhsaft/partial_extractor.rb +1 -1
- data/lib/kuhsaft/searchable.rb +8 -11
- data/lib/kuhsaft/translatable.rb +35 -19
- data/lib/kuhsaft/version.rb +1 -1
- data/lib/tasks/kuhsaft_tasks.rake +12 -0
- data/lib/templates/kuhsaft/assets/ck-config.js.coffee +7 -0
- data/lib/templates/kuhsaft/translations/add_translation.html.erb +4 -10
- data/spec/controllers/kuhsaft/api/pages_controller_spec.rb +70 -0
- data/spec/controllers/kuhsaft/pages_controller_spec.rb +18 -14
- data/spec/controllers/kuhsaft/sitemaps_controller_spec.rb +13 -0
- data/spec/dummy/app/assets/javascripts/kuhsaft/cms/ck-config.js.coffee +7 -0
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/database.yml +1 -1
- data/spec/factories.rb +3 -3
- data/spec/features/cms_pages_spec.rb +13 -13
- data/spec/features/search_spec.rb +16 -18
- data/spec/helpers/kuhsaft/cms/pages_helper_spec.rb +2 -1
- data/spec/kuhsaft_spec.rb +1 -1
- data/spec/lib/brick_list_spec.rb +1 -1
- data/spec/lib/page_tree_spec.rb +10 -6
- data/spec/lib/searchable_spec.rb +4 -4
- data/spec/lib/translatable_spec.rb +114 -44
- data/spec/models/anchor_brick_spec.rb +1 -1
- data/spec/models/asset_spec.rb +1 -1
- data/spec/models/brick_spec.rb +1 -1
- data/spec/models/page_spec.rb +48 -37
- data/spec/models/publish_state_spec.rb +9 -9
- data/spec/spec_helper.rb +43 -21
- data/spec/support/kuhsaft_spec_helper.rb +2 -2
- data/spec/support/write_expectation.rb +57 -0
- data/spec/views/kuhsaft/sitemaps/index.xml.haml_spec.rb +67 -0
- metadata +119 -4
data/lib/kuhsaft/version.rb
CHANGED
@@ -8,3 +8,15 @@ namespace :kuhsaft do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
Rake::Task['db:seed'].enhance ['kuhsaft:db:seed']
|
11
|
+
|
12
|
+
desc "Create nondigest versions of all ckeditor digest assets"
|
13
|
+
task "assets:precompile" do
|
14
|
+
fingerprint = /\-[0-9a-f]{32}\./
|
15
|
+
for file in Dir["public/assets/kuhsaft/cms/ck-config*"]
|
16
|
+
next unless file =~ fingerprint
|
17
|
+
nondigest = file.sub fingerprint, '.'
|
18
|
+
if !File.exist?(nondigest) or File.mtime(file) > File.mtime(nondigest)
|
19
|
+
FileUtils.cp file, nondigest, verbose: true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
CKEDITOR.editorConfig = (config) ->
|
2
2
|
config.language = "de"
|
3
|
+
config.extraAllowedContent = 'iframe[*]'
|
3
4
|
config.removeButtons = "Anchor,Underline,Strike,Subscript,Superscript"
|
4
5
|
config.format_tags = "p;h1;h2;h3;h4;pre"
|
5
6
|
config.toolbar = [["Format"],
|
@@ -9,6 +10,12 @@ CKEDITOR.editorConfig = (config) ->
|
|
9
10
|
["Source", "-", "ShowBlocks", "-", "About"],
|
10
11
|
["Maximize"]]
|
11
12
|
|
13
|
+
config.linkShowAdvancedTab = false
|
14
|
+
config.linkShowTargetTab = false
|
15
|
+
|
16
|
+
config.removePlugins = 'link'
|
17
|
+
config.extraPlugins = 'adv_link'
|
18
|
+
|
12
19
|
true
|
13
20
|
|
14
21
|
# FULL OPTIONS:
|
@@ -1,14 +1,8 @@
|
|
1
|
-
class Add<%=
|
1
|
+
class Add<%= formatted_locale.classify %>Translation < ActiveRecord::Migration
|
2
2
|
|
3
3
|
def change
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
add_column :kuhsaft_pages, :description_<%= get_locale %>, :text
|
8
|
-
add_column :kuhsaft_pages, :body_<%= get_locale %>, :text
|
9
|
-
add_column :kuhsaft_pages, :url_<%= get_locale %>, :text
|
10
|
-
add_column :kuhsaft_pages, :redirect_url_<%= get_locale %>, :text
|
11
|
-
add_column :kuhsaft_pages, :fulltext_<%= get_locale %>, :text
|
4
|
+
<%- translated_columns.each do |column_hash| %>
|
5
|
+
add_column :kuhsaft_pages, "<%= get_attribute(column_hash).to_s %>", :<%= get_type(column_hash).to_sym %>
|
6
|
+
<%- end %>
|
12
7
|
end
|
13
|
-
|
14
8
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::Api::PagesController do
|
4
|
+
describe '#index' do
|
5
|
+
before do
|
6
|
+
@pages = []
|
7
|
+
@pages << @page1 = create(:page, published: true, title_de: 'foobar de',
|
8
|
+
url_de: 'de/foobar-de', title_en: 'foobar en', url_en: 'en/foobar-en')
|
9
|
+
@pages << @page2 = create(:page, published: true, title_de: 'barfoo de',
|
10
|
+
url_de: 'de/barfoo-de', title_en: 'barfoo en', url_en: 'en/barfoo-en')
|
11
|
+
@pages << @unpublished = create(:page, published: false, title_de: 'unpublished de',
|
12
|
+
url_de: 'de/unpublished-de', title_en: 'unpublished en',
|
13
|
+
url_en: 'en/unpublished-en')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'gets only published pages' do
|
17
|
+
I18n.with_locale :de do
|
18
|
+
get :index, use_route: :kuhsaft
|
19
|
+
expect(JSON.parse(response.body)).to eq([@page1, @page2].as_json)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'gets specific translated pages for each locale' do
|
24
|
+
I18n.with_locale :de do
|
25
|
+
@pages << @only_german = create(:page, published: true, title: 'foobar de', url: 'de/foobar-de')
|
26
|
+
get :index, use_route: :kuhsaft
|
27
|
+
expect(JSON.parse(response.body)).to eq([@page1, @page2, @only_german].as_json)
|
28
|
+
end
|
29
|
+
|
30
|
+
I18n.with_locale :en do
|
31
|
+
get :index, use_route: :kuhsaft
|
32
|
+
expect(JSON.parse(response.body)).to eq([@page1, @page2].as_json)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'expected json format of a page' do
|
38
|
+
before do
|
39
|
+
@pages = []
|
40
|
+
@pages << @page1 = create(:page, published: true, title_de: 'foobar de',
|
41
|
+
url_de: 'de/foobar-de', title_en: 'foobar en', url_en: 'en/foobar-en')
|
42
|
+
@pages << @page2 = create(:page, published: true, title_de: 'barfoo de',
|
43
|
+
url_de: 'de/barfoo-de', title_en: 'barfoo en', url_en: 'en/barfoo-en')
|
44
|
+
|
45
|
+
I18n.with_locale :de do
|
46
|
+
get :index, use_route: :kuhsaft
|
47
|
+
@json = JSON.parse(response.body)
|
48
|
+
@page_hash = @json.first
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'contains the title' do
|
53
|
+
I18n.with_locale :de do
|
54
|
+
expect(@page_hash['title']).to eq(@page1.title)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'contains the url with page ID' do
|
59
|
+
I18n.with_locale :de do
|
60
|
+
expect(@page_hash['url']).to eq('/pages/' + @page1.id.to_s)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'does not contain the slug' do
|
65
|
+
I18n.with_locale :de do
|
66
|
+
expect(@page_hash['slug']).to eq(nil)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -6,15 +6,15 @@ describe Kuhsaft::PagesController do
|
|
6
6
|
describe '#index' do
|
7
7
|
before do
|
8
8
|
@pages = [
|
9
|
-
create(:page, :
|
10
|
-
create(:page, :
|
9
|
+
create(:page, published: true, fulltext_de: 'foobar'),
|
10
|
+
create(:page, published: true, fulltext_de: 'barfoo')
|
11
11
|
]
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'with search parameter' do
|
15
15
|
it 'assigns the search results' do
|
16
16
|
I18n.with_locale :de do
|
17
|
-
get(:index,
|
17
|
+
get(:index, use_route: :kuhsaft, search: 'foobar')
|
18
18
|
end
|
19
19
|
assigns(:pages).should eq([@pages.first])
|
20
20
|
end
|
@@ -25,13 +25,13 @@ describe Kuhsaft::PagesController do
|
|
25
25
|
describe 'routing' do
|
26
26
|
context 'without url' do
|
27
27
|
before do
|
28
|
-
@page = FactoryGirl.create(:page, :
|
28
|
+
@page = FactoryGirl.create(:page, url_de: 'de')
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'with matching locale' do
|
32
32
|
it 'sets the corresponding page' do
|
33
33
|
I18n.with_locale(:de) do
|
34
|
-
get(:show,
|
34
|
+
get(:show, use_route: :kuhsaft)
|
35
35
|
end
|
36
36
|
assigns(:page).should eq(@page)
|
37
37
|
end
|
@@ -40,7 +40,7 @@ describe Kuhsaft::PagesController do
|
|
40
40
|
context 'without matching locale' do
|
41
41
|
it 'raises a routing error' do
|
42
42
|
I18n.with_locale(:en) do
|
43
|
-
expect { get(:show,
|
43
|
+
expect { get(:show, use_route: :kuhsaft) }.to raise_error(ActionController::RoutingError)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -56,28 +56,32 @@ describe Kuhsaft::PagesController do
|
|
56
56
|
|
57
57
|
context 'when page is not a redirect page' do
|
58
58
|
it 'responds with page' do
|
59
|
-
page = FactoryGirl.create(:page, :
|
60
|
-
|
59
|
+
page = FactoryGirl.create(:page, slug: 'dumdidum',
|
60
|
+
url: 'de/dumdidum')
|
61
|
+
get :show, url: page.slug, use_route: :kuhsaft
|
61
62
|
assigns(:page).should eq(page)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
|
65
66
|
context 'when page is a redirect page' do
|
66
67
|
it 'redirects to the redirected url' do
|
67
|
-
page = FactoryGirl.create(:page, :
|
68
|
-
|
68
|
+
page = FactoryGirl.create(:page, page_type: 'redirect', slug: 'dumdidum',
|
69
|
+
url: 'de/dumdidum', redirect_url: 'de/redirect_page')
|
70
|
+
get :show, url: page.slug, use_route: :kuhsaft
|
69
71
|
expect(response).to redirect_to('/de/redirect_page')
|
70
72
|
end
|
71
73
|
|
72
74
|
it 'redirects to invalid redirect urls with too many preceding slashes' do
|
73
|
-
page = FactoryGirl.create(:page, :
|
74
|
-
|
75
|
+
page = FactoryGirl.create(:page, page_type: 'redirect', slug: 'dumdidum',
|
76
|
+
url: 'de/dumdidum', redirect_url: '///de/redirect_page')
|
77
|
+
get :show, url: page.slug, use_route: :kuhsaft
|
75
78
|
expect(response).to redirect_to('/de/redirect_page')
|
76
79
|
end
|
77
80
|
|
78
81
|
it 'redirects to root' do
|
79
|
-
page = FactoryGirl.create(:page, :
|
80
|
-
|
82
|
+
page = FactoryGirl.create(:page, page_type: 'redirect', slug: 'dumdidum',
|
83
|
+
url: 'de/dumdidum', redirect_url: '/')
|
84
|
+
get :show, url: page.slug, use_route: :kuhsaft
|
81
85
|
expect(response).to redirect_to('/')
|
82
86
|
end
|
83
87
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::SitemapsController do
|
4
|
+
describe '#index' do
|
5
|
+
before do
|
6
|
+
@page = FactoryGirl.create(:page)
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should be able to send a xml file' do
|
10
|
+
get(:index, use_route: :kuhsaft, format: 'xml')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
CKEDITOR.editorConfig = (config) ->
|
2
2
|
config.language = "de"
|
3
|
+
config.extraAllowedContent = 'iframe[*]'
|
3
4
|
config.removeButtons = "Anchor,Underline,Strike,Subscript,Superscript"
|
4
5
|
config.format_tags = "p;h1;h2;h3;h4;pre"
|
5
6
|
config.toolbar = [["Format"],
|
@@ -9,6 +10,12 @@ CKEDITOR.editorConfig = (config) ->
|
|
9
10
|
["Source", "-", "ShowBlocks", "-", "About"],
|
10
11
|
["Maximize"]]
|
11
12
|
|
13
|
+
config.linkShowAdvancedTab = false
|
14
|
+
config.linkShowTargetTab = false
|
15
|
+
|
16
|
+
config.removePlugins = 'link'
|
17
|
+
config.extraPlugins = 'adv_link'
|
18
|
+
|
12
19
|
true
|
13
20
|
|
14
21
|
# FULL OPTIONS:
|
@@ -20,6 +20,7 @@ module Dummy
|
|
20
20
|
|
21
21
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
22
22
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
23
|
-
|
23
|
+
config.i18n.available_locales = [:de, :en]
|
24
|
+
#config.i18n.default_locale = :de
|
24
25
|
end
|
25
26
|
end
|
data/spec/factories.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
sequence(:title) { |n| n }
|
3
3
|
|
4
|
-
factory :page, :
|
4
|
+
factory :page, class: 'Kuhsaft::Page' do |p|
|
5
5
|
p.parent nil
|
6
6
|
p.position 1
|
7
7
|
p.title { "English Title #{FactoryGirl.generate(:title)}" }
|
@@ -10,12 +10,12 @@ FactoryGirl.define do
|
|
10
10
|
p.url ''
|
11
11
|
end
|
12
12
|
|
13
|
-
factory :text_brick, :
|
13
|
+
factory :text_brick, class: 'Kuhsaft::TextBrick' do |tb|
|
14
14
|
tb.type 'Kuhsaft::TextBrick'
|
15
15
|
tb.text 'DummyText'
|
16
16
|
end
|
17
17
|
|
18
|
-
factory :asset, :
|
18
|
+
factory :asset, class: Kuhsaft::Asset do |a|
|
19
19
|
a.file File.open("#{Kuhsaft::Engine.root}/spec/dummy/app/assets/images/spec-image.png")
|
20
20
|
end
|
21
21
|
end
|
@@ -7,9 +7,9 @@ describe 'Cms/Pages' do
|
|
7
7
|
context '#new' do
|
8
8
|
before do
|
9
9
|
visit kuhsaft.new_cms_page_path
|
10
|
-
fill_in 'Titel', :
|
11
|
-
fill_in 'Stichwörter', :
|
12
|
-
fill_in 'Beschreibung', :
|
10
|
+
fill_in 'Titel', with: 'The Title of the page'
|
11
|
+
fill_in 'Stichwörter', with: 'My keywords'
|
12
|
+
fill_in 'Beschreibung', with: 'My Description'
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#create' do
|
@@ -25,9 +25,9 @@ describe 'Cms/Pages' do
|
|
25
25
|
|
26
26
|
context 'when page is invalid' do
|
27
27
|
it 'does not create a routing error by switching the locale' do
|
28
|
-
@page = FactoryGirl.create(:page, :
|
28
|
+
@page = FactoryGirl.create(:page, title: 'DummyPage', title_en: 'DummyEN', slug: 'dummy_page')
|
29
29
|
visit kuhsaft.edit_cms_page_path(@page)
|
30
|
-
fill_in 'page_title', :
|
30
|
+
fill_in 'page_title', with: ''
|
31
31
|
click_on 'Update Seite'
|
32
32
|
within '.nav-pills' do
|
33
33
|
click_on 'EN'
|
@@ -40,24 +40,24 @@ describe 'Cms/Pages' do
|
|
40
40
|
describe '#update' do
|
41
41
|
context 'when creating a redirect page' do
|
42
42
|
before do
|
43
|
-
@page = FactoryGirl.create(:page, :
|
43
|
+
@page = FactoryGirl.create(:page, url: 'de/dumdidum')
|
44
44
|
visit kuhsaft.edit_cms_page_path(@page)
|
45
|
-
select 'redirect', :
|
45
|
+
select 'redirect', from: 'Seitentyp'
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'has a value in redirect_page' do
|
49
|
-
fill_in 'Redirect URL', :
|
50
|
-
expect { click_on 'Update Seite' }.to change{ @page.reload.redirect_url }.to('target_page')
|
49
|
+
fill_in 'Redirect URL', with: 'target_page'
|
50
|
+
expect { click_on 'Update Seite' }.to change { @page.reload.redirect_url }.to('target_page')
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'is invalid when no value is in redirect_page' do
|
54
54
|
click_on 'Update Seite'
|
55
|
-
page.should have_css('.error', :
|
55
|
+
page.should have_css('.error', count: 1)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'does not change the value in url' do
|
59
|
-
fill_in 'Redirect URL', :
|
60
|
-
expect { click_on 'Update Seite' }.to_not change{ @page.reload.url }
|
59
|
+
fill_in 'Redirect URL', with: 'target_page'
|
60
|
+
expect { click_on 'Update Seite' }.to_not change { @page.reload.url }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -70,7 +70,7 @@ describe 'Cms/Pages' do
|
|
70
70
|
invalid_brick.save(validate: false)
|
71
71
|
|
72
72
|
visit kuhsaft.edit_cms_page_path(@page)
|
73
|
-
page.should have_css('.error', :
|
73
|
+
page.should have_css('.error', count: 1)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -4,35 +4,33 @@ describe 'pages#index' do
|
|
4
4
|
context 'with search parameter' do
|
5
5
|
let! :page1 do
|
6
6
|
p = create :page,
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
published: true,
|
8
|
+
title: 'Chromodorididae Ardeadoris'
|
9
|
+
p.bricks << Kuhsaft::TextBrick.new(locale: I18n.locale,
|
10
|
+
text: "#{'foo bar' * 300} Chromodorididae #{'foo bar' * 300}")
|
11
11
|
p.save!
|
12
12
|
p
|
13
13
|
end
|
14
14
|
|
15
15
|
let! :page2 do
|
16
16
|
create :page,
|
17
|
-
|
18
|
-
|
19
|
-
:title => 'Chromodorididae Berlanguella'
|
17
|
+
published: true,
|
18
|
+
title: 'Chromodorididae Berlanguella'
|
20
19
|
end
|
21
20
|
|
22
21
|
let! :page3 do
|
23
22
|
create :page,
|
24
|
-
|
25
|
-
|
26
|
-
:title => 'Gastropoda'
|
23
|
+
published: true,
|
24
|
+
title: 'Gastropoda'
|
27
25
|
end
|
28
26
|
|
29
27
|
context 'with fulltext' do
|
30
28
|
before do
|
31
|
-
visit kuhsaft.pages_path(:
|
29
|
+
visit kuhsaft.pages_path(locale: :en, search: 'Chromodorididae')
|
32
30
|
end
|
33
31
|
|
34
32
|
it 'highlights search term in preview' do
|
35
|
-
within(
|
33
|
+
within('ul.search-results.success') do
|
36
34
|
page.should have_content('Chromodorididae')
|
37
35
|
end
|
38
36
|
end
|
@@ -44,15 +42,15 @@ describe 'pages#index' do
|
|
44
42
|
|
45
43
|
context 'with multiple matches' do
|
46
44
|
before do
|
47
|
-
visit kuhsaft.pages_path(:
|
45
|
+
visit kuhsaft.pages_path(locale: :en, search: 'Chromodorididae')
|
48
46
|
end
|
49
47
|
|
50
48
|
it 'renders match count' do
|
51
|
-
page.should have_content(
|
49
|
+
page.should have_content('2 results')
|
52
50
|
end
|
53
51
|
|
54
52
|
it 'renders the search results list' do
|
55
|
-
within(
|
53
|
+
within('ul.search-results.success') do
|
56
54
|
page.should have_content('Chromodorididae Ardeadoris')
|
57
55
|
page.should have_content('Chromodorididae Berlanguella')
|
58
56
|
page.should_not have_content('Gastropoda')
|
@@ -60,7 +58,7 @@ describe 'pages#index' do
|
|
60
58
|
end
|
61
59
|
|
62
60
|
it 'renders links to the pages' do
|
63
|
-
within(
|
61
|
+
within('ul.search-results.success') do
|
64
62
|
page.should have_link('Chromodorididae Ardeadoris', href: page1.link)
|
65
63
|
page.should have_link('Chromodorididae Berlanguella', href: page2.link)
|
66
64
|
end
|
@@ -69,11 +67,11 @@ describe 'pages#index' do
|
|
69
67
|
|
70
68
|
context 'without matches' do
|
71
69
|
before do
|
72
|
-
visit kuhsaft.pages_path(:
|
70
|
+
visit kuhsaft.pages_path(locale: :en, search: 'foobar')
|
73
71
|
end
|
74
72
|
|
75
73
|
it 'renders match count' do
|
76
|
-
page.should have_content(
|
74
|
+
page.should have_content('No results')
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|