alchemy_cms 2.9.0 → 2.9.1
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.
- checksums.yaml +4 -4
- data/app/controllers/alchemy/admin/elements_controller.rb +10 -9
- data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
- data/lib/alchemy/tasks/helpers.rb +4 -6
- data/lib/alchemy/version.rb +1 -1
- data/spec/controllers/admin/elements_controller_spec.rb +37 -21
- data/spec/controllers/admin/pages_controller_spec.rb +18 -0
- data/spec/features/pages_controller_spec.rb +11 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cea20dd64fa70cb769c8efaed115271f6299ac2
|
4
|
+
data.tar.gz: 7765f71df28daf51b5605c9729b88a63a06470c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc35cce02f544a78c3166f8dc6d6a4957b0534eb0bc910a570c0417ad2a9ac17935fe81c229b7edd1b50cad26b4c613e813544ac49f3cbc46187e0fd44cd2174
|
7
|
+
data.tar.gz: 8e3a5e4faa7efe8f93b594dd93452fd6d1513c68022f4f5b32ba2b9da48ee4b48373d96d666899063b568db2d640c09189a3beb264f6459c77936bad6e8a72cf
|
@@ -83,16 +83,17 @@ module Alchemy
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def order
|
86
|
-
@trashed_elements = []
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
@trashed_elements = Element.trashed.where(id: params[:element_ids]).pluck(:id)
|
87
|
+
Element.transaction do
|
88
|
+
params[:element_ids].each_with_index do |element_id, idx|
|
89
|
+
# Ensure to set page_id and cell_id to the current page and
|
90
|
+
# cell because of trashed elements could still have old values
|
91
|
+
Element.where(id: element_id).update_all(
|
92
|
+
page_id: params[:page_id],
|
93
|
+
cell_id: params[:cell_id],
|
94
|
+
position: idx + 1
|
95
|
+
)
|
94
96
|
end
|
95
|
-
element.move_to_bottom
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
@@ -309,7 +309,7 @@ module Alchemy
|
|
309
309
|
# A children node
|
310
310
|
#
|
311
311
|
def process_url(ancestors_path, item)
|
312
|
-
default_urlname = (ancestors_path.blank? ? "" : "#{ancestors_path}/") + item['slug']
|
312
|
+
default_urlname = (ancestors_path.blank? ? "" : "#{ancestors_path}/") + item['slug'].to_s
|
313
313
|
|
314
314
|
pair = {my_urlname: default_urlname, children_path: default_urlname}
|
315
315
|
|
@@ -12,12 +12,10 @@ module Alchemy
|
|
12
12
|
|
13
13
|
def database_config
|
14
14
|
raise "Could not find #{database_config_file}!" if !File.exists?(database_config_file)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
raise "Database configuration for #{environment} not found!"
|
20
|
-
end
|
15
|
+
config_file = YAML.load_file(database_config_file)
|
16
|
+
config_file.fetch(environment)
|
17
|
+
rescue KeyError
|
18
|
+
raise "Database configuration for #{environment} not found!"
|
21
19
|
end
|
22
20
|
|
23
21
|
private
|
data/lib/alchemy/version.rb
CHANGED
@@ -106,32 +106,48 @@ module Alchemy
|
|
106
106
|
|
107
107
|
end
|
108
108
|
|
109
|
-
describe "
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
109
|
+
describe "#order" do
|
110
|
+
let(:element_1) { FactoryGirl.create(:element) }
|
111
|
+
let(:element_2) { FactoryGirl.create(:element) }
|
112
|
+
let(:element_3) { FactoryGirl.create(:element) }
|
113
|
+
let(:element_ids) { [element_1.id, element_3.id, element_2.id] }
|
114
|
+
|
115
|
+
it "sets new position for given element ids" do
|
116
|
+
xhr :post, :order, element_ids: element_ids
|
117
|
+
expect(Element.scoped.pluck(:id)).to eq(element_ids)
|
115
118
|
end
|
116
119
|
|
117
|
-
|
118
|
-
|
119
|
-
@element.reload
|
120
|
-
@element.position.should_not == nil
|
121
|
-
end
|
120
|
+
context "untrashing" do
|
121
|
+
let(:trashed_element) { FactoryGirl.create(:element, public: false, position: nil, page_id: 58, cell_id: 32) }
|
122
122
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
123
|
+
before do
|
124
|
+
# Because of a before_create filter it can not be created with a nil position and needs to be trashed here
|
125
|
+
trashed_element.trash!
|
126
|
+
end
|
128
127
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
128
|
+
it "sets a list of trashed element ids" do
|
129
|
+
xhr :post, :order, element_ids: [trashed_element.id]
|
130
|
+
expect(assigns(:trashed_elements).to_a).to eq [trashed_element.id]
|
131
|
+
end
|
134
132
|
|
133
|
+
it "should set a new position to the element" do
|
134
|
+
xhr :post, :order, element_ids: [trashed_element.id]
|
135
|
+
trashed_element.reload
|
136
|
+
trashed_element.position.should_not == nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should assign the (new) page_id to the element" do
|
140
|
+
xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: nil
|
141
|
+
trashed_element.reload
|
142
|
+
trashed_element.page_id.should == 1
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should assign the (new) cell_id to the element" do
|
146
|
+
xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: 5
|
147
|
+
trashed_element.reload
|
148
|
+
trashed_element.cell_id.should == 5
|
149
|
+
end
|
150
|
+
end
|
135
151
|
end
|
136
152
|
|
137
153
|
describe '#new' do
|
@@ -140,6 +140,24 @@ module Alchemy
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
+
context 'with page having number as slug' do
|
144
|
+
let(:page_item_2) do
|
145
|
+
{
|
146
|
+
id: page_2.id,
|
147
|
+
slug: 42,
|
148
|
+
children: [page_item_3]
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
it "does not raise error" do
|
153
|
+
expect {
|
154
|
+
xhr :post, :order, set: set_of_pages.to_json
|
155
|
+
}.to_not raise_error(TypeError)
|
156
|
+
[page_1, page_2, page_3].map(&:reload)
|
157
|
+
expect(page_3.urlname).to eq("#{page_1.slug}/#{page_2.slug}/#{page_3.slug}")
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
143
161
|
it "creates legacy urls" do
|
144
162
|
xhr :post, :order, set: set_of_pages.to_json
|
145
163
|
[page_2, page_3].map(&:reload)
|
@@ -247,5 +247,16 @@ module Alchemy
|
|
247
247
|
|
248
248
|
end
|
249
249
|
|
250
|
+
context "with invalid byte code char in urlname parameter" do
|
251
|
+
it "should render page not found" do
|
252
|
+
begin
|
253
|
+
visit '/%ed'
|
254
|
+
page.status_code.should == 404
|
255
|
+
rescue ArgumentError
|
256
|
+
# capturing the invalid byte sequence in UTF-8 error
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
250
261
|
end
|
251
262
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.9.
|
4
|
+
version: 2.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -1099,7 +1099,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1099
1099
|
requirements:
|
1100
1100
|
- ImageMagick (libmagick), v6.6 or greater.
|
1101
1101
|
rubyforge_project:
|
1102
|
-
rubygems_version: 2.
|
1102
|
+
rubygems_version: 2.4.3
|
1103
1103
|
signing_key:
|
1104
1104
|
specification_version: 4
|
1105
1105
|
summary: A powerful, userfriendly and flexible CMS for Rails 3
|