alchemy_cms 2.3.rc5 → 2.3.0
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/.travis.yml +4 -1
- data/README.md +8 -13
- data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
- data/app/assets/stylesheets/alchemy/frame.css.scss +1 -0
- data/app/controllers/alchemy/pages_controller.rb +2 -2
- data/app/helpers/alchemy/admin/base_helper.rb +15 -9
- data/app/helpers/alchemy/admin/essences_helper.rb +22 -11
- data/app/helpers/alchemy/elements_helper.rb +4 -5
- data/app/helpers/alchemy/pages_helper.rb +0 -1
- data/app/sweepers/alchemy/content_sweeper.rb +1 -1
- data/app/views/alchemy/essences/_essence_select_editor.html.erb +3 -3
- data/app/views/alchemy/search/_result.html.erb +0 -1
- data/lib/alchemy/version.rb +1 -1
- data/spec/helpers/admin/base_helper_spec.rb +142 -96
- data/spec/helpers/admin/essences_helper_spec.rb +33 -0
- data/spec/integration/pages_controller_spec.rb +27 -5
- data/spec/support/alchemy/specs_helpers.rb +0 -2
- metadata +8 -5
data/.travis.yml
CHANGED
@@ -5,7 +5,7 @@ rvm:
|
|
5
5
|
- 1.9.3
|
6
6
|
branches:
|
7
7
|
only:
|
8
|
-
-
|
8
|
+
- 2.3-stable
|
9
9
|
before_script:
|
10
10
|
- "phantomjs -v"
|
11
11
|
- "sh -c 'cd spec/dummy && RAILS_ENV=test bundle exec rake db:create db:schema:load --trace'"
|
@@ -13,3 +13,6 @@ script: "bundle exec rspec spec"
|
|
13
13
|
env:
|
14
14
|
- DB=mysql
|
15
15
|
- DB=postgresql
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- rvm: ree
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Alchemy CMS
|
2
2
|
===========
|
3
3
|
|
4
|
-
[](http://travis-ci.org/magiclabs/alchemy_cms)
|
5
5
|
[](http://stillmaintained.com/magiclabs/alchemy_cms)
|
6
6
|
[](https://codeclimate.com/github/magiclabs/alchemy_cms)
|
7
7
|
[](https://gemnasium.com/magiclabs/alchemy_cms)
|
@@ -9,8 +9,6 @@ Alchemy CMS
|
|
9
9
|
About
|
10
10
|
-----
|
11
11
|
|
12
|
-
**This branch is a beta development branch. For productive environments use the current rubygems version, or the [latest stable branch (2.2-stable)](https://github.com/magiclabs/alchemy_cms/tree/2.2-stable).**
|
13
|
-
|
14
12
|
Alchemy is a Rails 3 CMS with a flexible content storing architecture.
|
15
13
|
|
16
14
|
Read more on the [website](http://alchemy-cms.com) and in the [guidelines](http://guides.alchemy-cms.com).
|
@@ -37,9 +35,9 @@ Features
|
|
37
35
|
Rails Version
|
38
36
|
-------------
|
39
37
|
|
40
|
-
This version of Alchemy runs with Rails 3.2.
|
38
|
+
This version of Alchemy runs with Rails 3.2.8+.
|
41
39
|
|
42
|
-
If you are looking for a Rails 3.1 compatible version check the 2.
|
40
|
+
If you are looking for a Rails 3.1 compatible version check the 2.1-stable branch.
|
43
41
|
|
44
42
|
If you are looking for a Rails 3.0 compatible version check the 2.0-stable branch.
|
45
43
|
|
@@ -49,13 +47,14 @@ Ruby Version
|
|
49
47
|
------------
|
50
48
|
|
51
49
|
Alchemy runs under Ruby 1.8.7, Ruby 1.9.2, Ruby 1.9.3 and REE (Ruby Enterprise Edition).
|
50
|
+
We strongly recommend Ruby 1.9.3 for best performance and maximum security.
|
52
51
|
|
53
52
|
Installation
|
54
53
|
------------
|
55
54
|
|
56
55
|
Use the installer (recommended):
|
57
56
|
|
58
|
-
gem install alchemy_cms
|
57
|
+
gem install alchemy_cms
|
59
58
|
alchemy new my_magicpage
|
60
59
|
|
61
60
|
Start the local server:
|
@@ -67,13 +66,9 @@ Then just switch to your browser and open `http://localhost:3000`
|
|
67
66
|
Upgrading
|
68
67
|
------------
|
69
68
|
|
70
|
-
Projects running with Alchemy CMS version < 2.
|
71
|
-
|
72
|
-
Otherwise errors will be raised like this:
|
73
|
-
`uninitialized constant EssenceText`
|
69
|
+
Projects running with Alchemy CMS version < 2.2 needs to be upgraded.
|
74
70
|
|
75
|
-
|
76
|
-
Run in terminal:
|
71
|
+
Use the following Upgrade-Task:
|
77
72
|
|
78
73
|
rake alchemy:upgrade
|
79
74
|
|
@@ -83,7 +78,7 @@ Add to existing Rails project
|
|
83
78
|
|
84
79
|
In your Gemfile:
|
85
80
|
|
86
|
-
gem 'alchemy_cms', :github => 'magiclabs/alchemy_cms'
|
81
|
+
gem 'alchemy_cms', :github => 'magiclabs/alchemy_cms', :branch => '2.3-stable'
|
87
82
|
|
88
83
|
Run in terminal:
|
89
84
|
|
@@ -72,7 +72,7 @@ Alchemy.initAlchemyPreviewMode = function() {
|
|
72
72
|
clickElement: function(e) {
|
73
73
|
var $this = $(this);
|
74
74
|
var parent$ = window.parent.jQuery;
|
75
|
-
var target_id = $this.
|
75
|
+
var target_id = $this.data('alchemy-element');
|
76
76
|
var $element_editor = parent$('#element_area .element_editor').closest('[id="element_' + target_id + '"]');
|
77
77
|
var $elementsWindow = parent$('#alchemyElementWindow');
|
78
78
|
e.preventDefault();
|
@@ -126,8 +126,8 @@ module Alchemy
|
|
126
126
|
"*#{params[:query]}*",
|
127
127
|
{:limit => :all},
|
128
128
|
{:conditions => [
|
129
|
-
'alchemy_pages.public = ? AND alchemy_pages.layoutpage = ? AND alchemy_pages.restricted = ?',
|
130
|
-
true, false, false
|
129
|
+
'alchemy_pages.public = ? AND alchemy_pages.layoutpage = ? AND alchemy_pages.restricted = ? AND alchemy_pages.language_id = ?',
|
130
|
+
true, false, false, session[:language_id]
|
131
131
|
]}
|
132
132
|
)
|
133
133
|
end
|
@@ -161,20 +161,26 @@ module Alchemy
|
|
161
161
|
select_options
|
162
162
|
end
|
163
163
|
|
164
|
-
# Returns all public pages
|
164
|
+
# Returns all public pages from current language as an option tags string suitable or the Rails +select_tag+ helper.
|
165
165
|
#
|
166
|
-
#
|
167
|
-
#
|
168
|
-
#
|
169
|
-
#
|
166
|
+
# === Parameters
|
167
|
+
#
|
168
|
+
# 1. A collection of pages so it only returns these pages and does not query the database.
|
169
|
+
# 2. Pass a +Page#name+ or +Page#id+ as second parameter to be passed as selected item to the +options_for_select+ helper.
|
170
|
+
# 3. The third parameter is used as prompt message in the select tag
|
171
|
+
# 4. The fourth parameter is the method that is called on the page object to get the value that is passed with the params of the form.
|
170
172
|
#
|
171
173
|
def pages_for_select(pages = nil, selected = nil, prompt = "", page_attribute = :id)
|
172
174
|
result = [[prompt.blank? ? t('Choose page') : prompt, ""]]
|
173
175
|
if pages.blank?
|
174
|
-
pages = Page.with_language(session[:language_id]).published
|
175
|
-
|
176
|
-
|
177
|
-
|
176
|
+
pages = Page.with_language(session[:language_id]).published.order(:lft)
|
177
|
+
pages.each do |p|
|
178
|
+
result << [(" " * (p.level - 1) + p.name).html_safe, p.send(page_attribute).to_s]
|
179
|
+
end
|
180
|
+
else
|
181
|
+
pages.each do |p|
|
182
|
+
result << [p.name, p.send(page_attribute).to_s]
|
183
|
+
end
|
178
184
|
end
|
179
185
|
options_for_select(result, selected.to_s)
|
180
186
|
end
|
@@ -78,31 +78,42 @@ module Alchemy
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
# Renders the
|
81
|
+
# Renders the EssenceSelect editor partial with a form select for storing page urlnames
|
82
82
|
#
|
83
83
|
# === Options:
|
84
84
|
#
|
85
85
|
# :only [Hash] # Pagelayout names. Only pages with this page_layout will be displayed inside the select.
|
86
86
|
# :page_attribute [Symbol] # The Page attribute which will be stored.
|
87
87
|
# :global [Boolean] # Display only global pages. Default is false.
|
88
|
+
# :order_by [Symbol] # Order pages by this attribute.
|
89
|
+
#
|
90
|
+
# NOTE: The order option only works if the +only+ option is also set.
|
91
|
+
# Then the default is :name.
|
92
|
+
# Otherwise the pages are ordered by their position in the nested set.
|
88
93
|
#
|
89
94
|
def page_selector(element, content_name, options = {}, select_options = {})
|
90
95
|
default_options = {
|
91
96
|
:page_attribute => :id,
|
92
97
|
:global => false,
|
93
|
-
:prompt => t('Choose page')
|
98
|
+
:prompt => t('Choose page'),
|
99
|
+
:order_by => :name
|
94
100
|
}
|
95
101
|
options = default_options.merge(options)
|
96
|
-
pages = Page.where({
|
97
|
-
:language_id => session[:language_id],
|
98
|
-
:layoutpage => options[:global] == true,
|
99
|
-
:public => options[:global] == false
|
100
|
-
})
|
101
|
-
pages = pages.where({:page_layout => options[:only]}) if options[:only].present?
|
102
102
|
content = element.content_by_name(content_name)
|
103
|
-
options.
|
104
|
-
|
105
|
-
|
103
|
+
if options[:global] || options[:only].present?
|
104
|
+
pages = Page.where({
|
105
|
+
:language_id => session[:language_id],
|
106
|
+
:layoutpage => options[:global] == true,
|
107
|
+
:public => options[:global] == false
|
108
|
+
})
|
109
|
+
if options[:only].present?
|
110
|
+
pages = pages.where({:page_layout => options[:only]})
|
111
|
+
end
|
112
|
+
pages_options_tags = pages_for_select(pages.order(options[:order_by]), content ? content.ingredient : nil, options[:prompt], options[:page_attribute])
|
113
|
+
else
|
114
|
+
pages_options_tags = pages_for_select(nil, content ? content.ingredient : nil, options[:prompt], options[:page_attribute])
|
115
|
+
end
|
116
|
+
options.update(:select_values => pages_options_tags)
|
106
117
|
if content.nil?
|
107
118
|
render_missing_content(element, content_name, options)
|
108
119
|
else
|
@@ -50,11 +50,10 @@ module Alchemy
|
|
50
50
|
warning('Page is nil')
|
51
51
|
return ""
|
52
52
|
else
|
53
|
-
show_non_public = configuration(:cache_pages) ? false : defined?(current_user)
|
54
53
|
if page.class == Array
|
55
|
-
all_elements = page.collect { |p| p.find_elements(options
|
54
|
+
all_elements = page.collect { |p| p.find_elements(options) }.flatten
|
56
55
|
else
|
57
|
-
all_elements = page.find_elements(options
|
56
|
+
all_elements = page.find_elements(options)
|
58
57
|
end
|
59
58
|
unless options[:sort_by].blank?
|
60
59
|
all_elements = all_elements.sort_by { |e| e.contents.detect { |c| c.name == options[:sort_by] }.ingredient }
|
@@ -153,13 +152,13 @@ module Alchemy
|
|
153
152
|
# Returns a string for the id attribute of a html element for the given element
|
154
153
|
def element_dom_id(element)
|
155
154
|
return "" if element.nil?
|
156
|
-
"#{element.name}_#{element.id}"
|
155
|
+
"#{element.name}_#{element.id}".html_safe
|
157
156
|
end
|
158
157
|
|
159
158
|
# Renders the data-alchemy-element HTML attribut used for the preview window hover effect.
|
160
159
|
def element_preview_code(element)
|
161
160
|
return "" if element.nil?
|
162
|
-
" data-alchemy-element='#{element.id}'" if @preview_mode && element.page == @page
|
161
|
+
" data-alchemy-element='#{element.id}'".html_safe if @preview_mode && element.page == @page
|
163
162
|
end
|
164
163
|
|
165
164
|
# Returns the full url containing host, page and anchor for the given element
|
@@ -11,7 +11,7 @@ module Alchemy
|
|
11
11
|
if object.class.to_s == "Alchemy::Element"
|
12
12
|
expire_cache_for(object.contents)
|
13
13
|
expire_contents_displayed_as_select
|
14
|
-
elsif object.class.to_s == "Alchemy::Page" && (object.urlname_changed? || object.name_changed?)
|
14
|
+
elsif object.class.to_s == "Alchemy::Page" && (object.public_changed? || object.urlname_changed? || object.name_changed?)
|
15
15
|
expire_contents_displayed_as_select
|
16
16
|
end
|
17
17
|
end
|
@@ -11,20 +11,20 @@
|
|
11
11
|
|
12
12
|
<%
|
13
13
|
if options[:select_values].is_a?(Hash)
|
14
|
-
|
14
|
+
options_tags = grouped_options_for_select(
|
15
15
|
options[:select_values],
|
16
16
|
content.ingredient,
|
17
17
|
''
|
18
18
|
)
|
19
19
|
else
|
20
|
-
|
20
|
+
options_tags = options_for_select(
|
21
21
|
options[:select_values],
|
22
22
|
content.ingredient
|
23
23
|
)
|
24
24
|
end
|
25
25
|
%>
|
26
26
|
|
27
|
-
<%= select_tag(content.form_field_name,
|
27
|
+
<%= select_tag(content.form_field_name, options_tags, {
|
28
28
|
:class => ["alchemy_selectbox", "essence_editor_select", html_options[:class]].join(' '),
|
29
29
|
:style => html_options[:style]
|
30
30
|
}) %>
|
@@ -2,7 +2,6 @@
|
|
2
2
|
<h3>
|
3
3
|
<%= t('search_result_page.result_page') %>:
|
4
4
|
<%= link_to page.name, show_alchemy_page_path(page) %>
|
5
|
-
<%= content_tag(:span, page.language_code.upcase, :class => 'language_code') if multi_language? && options[:show_language] %>
|
6
5
|
</h3>
|
7
6
|
<%- result.each do |highlight| -%>
|
8
7
|
<p><%= sanitize highlight %></p>
|
data/lib/alchemy/version.rb
CHANGED
@@ -1,149 +1,195 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Alchemy
|
4
|
-
|
4
|
+
describe Admin::BaseHelper do
|
5
5
|
|
6
|
-
|
6
|
+
context "maximum amount of images option" do
|
7
7
|
|
8
|
-
|
8
|
+
before(:each) do
|
9
|
+
@options = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with max_images option" do
|
9
13
|
|
10
|
-
|
11
|
-
@options =
|
14
|
+
it "should return nil for empty string" do
|
15
|
+
@options[:max_images] = ""
|
16
|
+
max_image_count.should be(nil)
|
12
17
|
end
|
13
18
|
|
14
|
-
|
19
|
+
it "should return an integer for string number" do
|
20
|
+
@options[:max_images] = "1"
|
21
|
+
max_image_count.should be(1)
|
22
|
+
end
|
15
23
|
|
16
|
-
|
17
|
-
@options[:max_images] = ""
|
18
|
-
max_image_count.should be(nil)
|
19
|
-
end
|
24
|
+
end
|
20
25
|
|
21
|
-
|
22
|
-
@options[:max_images] = "1"
|
23
|
-
max_image_count.should be(1)
|
24
|
-
end
|
26
|
+
context "with maximum_amount_of_images option" do
|
25
27
|
|
28
|
+
it "should return nil for empty string" do
|
29
|
+
@options[:maximum_amount_of_images] = ""
|
30
|
+
max_image_count.should be(nil)
|
26
31
|
end
|
27
32
|
|
28
|
-
|
33
|
+
it "should return an integer for string number" do
|
34
|
+
@options[:maximum_amount_of_images] = "1"
|
35
|
+
max_image_count.should be(1)
|
36
|
+
end
|
29
37
|
|
30
|
-
|
31
|
-
@options[:maximum_amount_of_images] = ""
|
32
|
-
max_image_count.should be(nil)
|
33
|
-
end
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
@options[:maximum_amount_of_images] = "1"
|
37
|
-
max_image_count.should be(1)
|
38
|
-
end
|
40
|
+
end
|
39
41
|
|
40
|
-
|
42
|
+
describe "#merge_params" do
|
43
|
+
before(:each) do
|
44
|
+
controller.stub!(:params).and_return({:first => '1', :second => '2'})
|
45
|
+
end
|
41
46
|
|
47
|
+
it "returns a hash that contains the current params and additional params given as attributes" do
|
48
|
+
helper.merge_params(:third => '3', :fourth => '4').should == {:first => '1', :second => '2', :third => '3', :fourth => '4'}
|
42
49
|
end
|
50
|
+
end
|
43
51
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
describe "#merge_params_without" do
|
53
|
+
before(:each) do
|
54
|
+
controller.stub!(:params).and_return({:first => '1', :second => '2'})
|
55
|
+
end
|
56
|
+
it "can delete a single param" do
|
57
|
+
helper.merge_params_without(:second).should == {:first => '1'}
|
58
|
+
end
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
60
|
+
it "can delete several params" do
|
61
|
+
helper.merge_params_without([:first, :second]).should == {}
|
52
62
|
end
|
53
63
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
it "can delete a single param" do
|
59
|
-
helper.merge_params_without(:second).should == {:first => '1'}
|
60
|
-
end
|
64
|
+
it "can delete a param and add new params at the same time" do
|
65
|
+
helper.merge_params_without([:first], {:third => '3'}).should == {:second => '2', :third => '3'}
|
66
|
+
end
|
61
67
|
|
62
|
-
|
63
|
-
|
64
|
-
|
68
|
+
it "should not change params" do
|
69
|
+
helper.merge_params_without([:first])
|
70
|
+
controller.params.should == {:first => '1', :second => '2'}
|
71
|
+
end
|
72
|
+
end
|
65
73
|
|
66
|
-
|
67
|
-
helper.merge_params_without([:first], {:third => '3'}).should == {:second => '2', :third => '3'}
|
68
|
-
end
|
74
|
+
describe "#merge_params_only" do
|
69
75
|
|
70
|
-
|
71
|
-
|
72
|
-
controller.params.should == {:first => '1', :second => '2'}
|
73
|
-
end
|
76
|
+
before(:each) do
|
77
|
+
controller.stub!(:params).and_return({:first => '1', :second => '2', :third => '3'})
|
74
78
|
end
|
75
79
|
|
76
|
-
|
80
|
+
it "can keep a single param" do
|
81
|
+
helper.merge_params_only(:second).should == {:second => '2'}
|
82
|
+
end
|
77
83
|
|
78
|
-
|
79
|
-
|
80
|
-
|
84
|
+
it "can keep several params" do
|
85
|
+
helper.merge_params_only([:first, :second]).should == {:first => '1', :second => '2'}
|
86
|
+
end
|
81
87
|
|
82
|
-
|
83
|
-
|
84
|
-
|
88
|
+
it "can keep a param and add new params at the same time" do
|
89
|
+
helper.merge_params_only([:first], {:third => '3'}).should == {:first => '1', :third => '3'}
|
90
|
+
end
|
85
91
|
|
86
|
-
|
87
|
-
|
88
|
-
|
92
|
+
it "should not change params" do
|
93
|
+
helper.merge_params_only([:first])
|
94
|
+
controller.params.should == {:first => '1', :second => '2', :third => '3'}
|
95
|
+
end
|
89
96
|
|
90
|
-
|
91
|
-
helper.merge_params_only([:first], {:third => '3'}).should == {:first => '1', :third => '3'}
|
92
|
-
end
|
97
|
+
end
|
93
98
|
|
94
|
-
|
95
|
-
helper.merge_params_only([:first])
|
96
|
-
controller.params.should == {:first => '1', :second => '2', :third => '3'}
|
97
|
-
end
|
99
|
+
context "Filtering pictures depending on tags from params" do
|
98
100
|
|
101
|
+
let(:tag) do
|
102
|
+
mock_model(ActsAsTaggableOn::Tag, :name => "foo")
|
99
103
|
end
|
100
104
|
|
101
|
-
|
105
|
+
describe "#pictures_filtered_by_tag?" do
|
106
|
+
it "should return true if the filterlist contains the given tag" do
|
107
|
+
controller.params[:tagged_with] = "foo,bar,baz"
|
108
|
+
helper.pictures_filtered_by_tag?(tag).should == true
|
109
|
+
end
|
102
110
|
|
103
|
-
|
104
|
-
|
111
|
+
it "should return false if the filterlist does not contain the given tag" do
|
112
|
+
controller.params[:tagged_with] = "bar,baz"
|
113
|
+
helper.pictures_filtered_by_tag?(tag).should == false
|
105
114
|
end
|
115
|
+
end
|
106
116
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
helper.
|
117
|
+
describe "#add_to_picture_tag_filter" do
|
118
|
+
context "if params[:tagged_with] is not present" do
|
119
|
+
it "should return an Array with the given tag name" do
|
120
|
+
helper.add_to_picture_tag_filter(tag).should == ["foo"]
|
111
121
|
end
|
122
|
+
end
|
112
123
|
|
113
|
-
|
124
|
+
context "if params[:tagged_with] contains some tag names" do
|
125
|
+
it "should return an Array of tag names including the given one" do
|
114
126
|
controller.params[:tagged_with] = "bar,baz"
|
115
|
-
helper.
|
127
|
+
helper.add_to_picture_tag_filter(tag).should == ["bar", "baz", "foo"]
|
116
128
|
end
|
117
129
|
end
|
130
|
+
end
|
118
131
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
132
|
+
describe "#remove_from_picture_tag_filter" do
|
133
|
+
context "if params[:tagged_with] is not present" do
|
134
|
+
it "should return an empty Array" do
|
135
|
+
helper.remove_from_picture_tag_filter(tag).should be_empty
|
124
136
|
end
|
137
|
+
end
|
125
138
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
139
|
+
context "if params[:tagged_with] contains some tag names" do
|
140
|
+
it "should return an Array of tag names without the given one" do
|
141
|
+
controller.params[:tagged_with] = "bar,baz,foo"
|
142
|
+
helper.remove_from_picture_tag_filter(tag).should == ["bar", "baz"]
|
131
143
|
end
|
132
144
|
end
|
145
|
+
end
|
133
146
|
|
134
|
-
|
135
|
-
context "if params[:tagged_with] is not present" do
|
136
|
-
it "should return an empty Array" do
|
137
|
-
helper.remove_from_picture_tag_filter(tag).should be_empty
|
138
|
-
end
|
139
|
-
end
|
147
|
+
end
|
140
148
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
149
|
+
describe '#pages_for_select' do
|
150
|
+
|
151
|
+
let(:contact_form) { FactoryGirl.create(:element, :name => 'contactform', :create_contents_after_create => true) }
|
152
|
+
let(:page_a) { FactoryGirl.create(:public_page, :name => 'Page A') }
|
153
|
+
let(:page_b) { FactoryGirl.create(:public_page, :name => 'Page B') }
|
154
|
+
let(:page_c) { FactoryGirl.create(:public_page, :name => 'Page C', :parent_id => page_b.id) }
|
155
|
+
|
156
|
+
before do
|
157
|
+
# to be shure the ordering is alphabetic
|
158
|
+
page_b
|
159
|
+
page_a
|
160
|
+
helper.session[:language_id] = 1
|
161
|
+
end
|
162
|
+
|
163
|
+
context "with no arguments given" do
|
164
|
+
|
165
|
+
it "should return options for select with all pages ordered by lft" do
|
166
|
+
helper.pages_for_select.should match(/option.*Page B.*Page A/m)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should return options for select with nested page names" do
|
170
|
+
page_c
|
171
|
+
output = helper.pages_for_select
|
172
|
+
output.should match(/option.*Startseite.*> Page B.*> Page C.*> Page A/m)
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
context "with pages passed in" do
|
178
|
+
|
179
|
+
before do
|
180
|
+
@pages = []
|
181
|
+
3.times { @pages << FactoryGirl.create(:public_page) }
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should return options for select with only these pages" do
|
185
|
+
output = helper.pages_for_select(@pages)
|
186
|
+
output.should match(/#{@pages.collect(&:name).join('.*')}/m)
|
187
|
+
output.should_not match(/Page A/m)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should not nest the page names" do
|
191
|
+
output = helper.pages_for_select(@pages)
|
192
|
+
output.should_not match(/option.* /m)
|
147
193
|
end
|
148
194
|
|
149
195
|
end
|
@@ -21,4 +21,37 @@ describe Alchemy::Admin::EssencesHelper do
|
|
21
21
|
helper.render_essence_editor_by_type(element, 'EssenceText').should match(/input.+type="text".+value="hello!/)
|
22
22
|
end
|
23
23
|
|
24
|
+
describe '#page_selector' do
|
25
|
+
|
26
|
+
let(:contact_form) { FactoryGirl.create(:element, :name => 'contactform', :create_contents_after_create => true) }
|
27
|
+
let(:contact_page) { FactoryGirl.create(:public_page, :page_layout => 'contact', :name => 'Contact') }
|
28
|
+
let(:page_a) { FactoryGirl.create(:public_page, :name => 'Page A') }
|
29
|
+
let(:page_b) { FactoryGirl.create(:public_page, :name => 'Page B') }
|
30
|
+
let(:page_c) { FactoryGirl.create(:public_page, :name => 'Page C') }
|
31
|
+
|
32
|
+
before do
|
33
|
+
helper.session[:language_id] = 1
|
34
|
+
contact_page
|
35
|
+
page_b
|
36
|
+
page_c
|
37
|
+
page_a
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with only option set to 'standard'" do
|
41
|
+
|
42
|
+
it "should render select tag with standard pages only" do
|
43
|
+
output = helper.page_selector(contact_form, 'success_page', :only => 'standard')
|
44
|
+
output.should match(/select.*Page A/m)
|
45
|
+
output.should_not match(/select.*Contact/m)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should render select tag with pages ordered by name" do
|
49
|
+
output = helper.page_selector(contact_form, 'success_page', :only => 'standard')
|
50
|
+
output.should match(/select.*Page A.*Page B.*Page C/m)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
24
57
|
end
|
@@ -46,38 +46,60 @@ module Alchemy
|
|
46
46
|
context "performing the search" do
|
47
47
|
|
48
48
|
it "should display search results for richtext essences" do
|
49
|
-
element.content_by_name('text').essence.update_attributes(:body => '<p>Welcome to Peters Petshop</p>'
|
49
|
+
element.content_by_name('text').essence.update_attributes(:body => '<p>Welcome to Peters Petshop</p>')
|
50
50
|
visit('/alchemy/suche?query=Petshop')
|
51
51
|
within('div#content .search_result') { page.should have_content('Petshop') }
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should display search results for text essences" do
|
55
|
-
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop'
|
55
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop')
|
56
56
|
visit('/alchemy/suche?query=Petshop')
|
57
57
|
within('div#content .search_result') { page.should have_content('Petshop') }
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should not find contents placed on global-pages (layoutpage => true)" do
|
61
61
|
public_page_1.update_attributes(:layoutpage => true)
|
62
|
-
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop'
|
62
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop')
|
63
63
|
visit('/alchemy/suche?query=Petshop')
|
64
64
|
within('div#content') { page.should have_css('h2.no_search_results') }
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should not find contents placed on unpublished pages (public => false)" do
|
68
68
|
public_page_1.update_attributes(:public => false)
|
69
|
-
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop'
|
69
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop')
|
70
70
|
visit('/alchemy/suche?query=Petshop')
|
71
71
|
within('div#content') { page.should have_css('h2.no_search_results') }
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should not find contents placed on restricted pages (restricted => true)" do
|
75
75
|
public_page_1.update_attributes(:restricted => true)
|
76
|
-
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop'
|
76
|
+
element.content_by_name('intro').essence.update_attributes(:body => 'Welcome to Peters Petshop')
|
77
77
|
visit('/alchemy/suche?query=Petshop')
|
78
78
|
within('div#content') { page.should have_css('h2.no_search_results') }
|
79
79
|
end
|
80
80
|
|
81
|
+
context "in multi_language mode" do
|
82
|
+
|
83
|
+
let(:english_language) { FactoryGirl.create(:english) }
|
84
|
+
let(:english_language_root) { FactoryGirl.create(:language_root_page, :language => english_language, :name => 'Home') }
|
85
|
+
let(:english_page) { FactoryGirl.create(:public_page, :parent_id => english_language_root.id, :language => english_language) }
|
86
|
+
let(:english_element) { FactoryGirl.create(:element, :page_id => english_page.id, :name => 'headline', :create_contents_after_create => true) }
|
87
|
+
|
88
|
+
before do
|
89
|
+
element
|
90
|
+
english_element
|
91
|
+
controller.stub!(:multi_language?).and_return(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should not display search results from other languages then current" do
|
95
|
+
english_element.content_by_name('headline').essence.update_attributes(:body => 'Joes Hardware')
|
96
|
+
visit('/alchemy/de/suche?query=Hardware')
|
97
|
+
within('div#content') { page.should have_css('h2.no_search_results') }
|
98
|
+
page.should_not have_css('div#content .search_result')
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
81
103
|
end
|
82
104
|
|
83
105
|
end
|
@@ -28,8 +28,6 @@ module Alchemy
|
|
28
28
|
#
|
29
29
|
def login_into_alchemy
|
30
30
|
visit '/alchemy/admin/login'
|
31
|
-
# Giving phantomjs some time to start under ruby 1.8.7 on travis-ci
|
32
|
-
sleep(5) if ENV['CI'] && RUBY_VERSION == "1.8.7"
|
33
31
|
fill_in('alchemy_user_session_login', :with => 'jdoe')
|
34
32
|
fill_in('alchemy_user_session_password', :with => 's3cr3t')
|
35
33
|
click_on('Login')
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
5
|
-
prerelease:
|
4
|
+
version: 2.3.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thomas von Deyen
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-09-
|
15
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -1089,9 +1089,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1089
1089
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1090
1090
|
none: false
|
1091
1091
|
requirements:
|
1092
|
-
- - ! '
|
1092
|
+
- - ! '>='
|
1093
1093
|
- !ruby/object:Gem::Version
|
1094
|
-
version:
|
1094
|
+
version: '0'
|
1095
|
+
segments:
|
1096
|
+
- 0
|
1097
|
+
hash: -4162011237072179792
|
1095
1098
|
requirements:
|
1096
1099
|
- ImageMagick (libmagick), v6.6 or greater.
|
1097
1100
|
rubyforge_project:
|