releaf-content 1.1.21 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/releaf_content_manifest.js +2 -0
- data/app/assets/javascripts/controllers/releaf/content/nodes.js +6 -9
- data/app/controllers/releaf/content/nodes_controller.rb +1 -1
- data/lib/releaf/content/engine.rb +2 -2
- data/lib/releaf/content/node.rb +3 -3
- data/lib/releaf/content/route.rb +0 -1
- metadata +12 -57
- data/spec/builders/content/nodes/action_dialog_spec.rb +0 -39
- data/spec/builders/content/nodes/content_form_builder_spec.rb +0 -24
- data/spec/builders/content/nodes/form_builder_spec.rb +0 -262
- data/spec/builders/content/nodes/toolbox_builder_spec.rb +0 -77
- data/spec/controllers/releaf/content/nodes_controller_spec.rb +0 -52
- data/spec/features/nodes_services_spec.rb +0 -437
- data/spec/features/nodes_spec.rb +0 -572
- data/spec/fixtures/dummy.png +0 -0
- data/spec/lib/releaf/content/acts_as_node_spec.rb +0 -90
- data/spec/lib/releaf/content/configuration_spec.rb +0 -159
- data/spec/lib/releaf/content/engine_spec.rb +0 -149
- data/spec/lib/releaf/content/node_spec.rb +0 -591
- data/spec/lib/releaf/content/route_spec.rb +0 -229
- data/spec/middleware/routes_reloader_spec.rb +0 -96
- data/spec/routing/node_mapper_spec.rb +0 -310
- data/spec/services/releaf/content/build_route_objects_spec.rb +0 -72
- data/spec/services/releaf/content/node/copy_spec.rb +0 -338
- data/spec/services/releaf/content/node/move_spec.rb +0 -20
- data/spec/services/releaf/content/node/save_under_parent_spec.rb +0 -49
- data/spec/services/releaf/content/node/service_spec.rb +0 -19
- data/spec/validators/content/node/parent_validator_spec.rb +0 -56
- data/spec/validators/content/node/root_validator_spec.rb +0 -69
- data/spec/validators/content/node/singleness_validator_spec.rb +0 -145
data/spec/features/nodes_spec.rb
DELETED
@@ -1,572 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
describe "Nodes", js: true, with_tree: true, with_root: true do
|
3
|
-
|
4
|
-
before do
|
5
|
-
Rails.cache.clear
|
6
|
-
# preload ActsAsNode classes
|
7
|
-
Rails.application.eager_load!
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
@default_app_host = Capybara.app_host
|
12
|
-
end
|
13
|
-
|
14
|
-
after do
|
15
|
-
Capybara.app_host = @default_app_host
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
before with_releaf_node_controller: true do
|
20
|
-
# stub node config and admin menu to use default releaf node controller
|
21
|
-
|
22
|
-
allow( Releaf.application.config).to receive(:content).and_return(Releaf::Content::Configuration.new(
|
23
|
-
resources: { 'Node' => { controller: 'Releaf::Content::NodesController' } }
|
24
|
-
))
|
25
|
-
|
26
|
-
# preserve default config because it will be needed in after block
|
27
|
-
@default_menu_config = Releaf.application.config.menu.dup
|
28
|
-
stubbed_menu_config = @default_menu_config.map do |item|
|
29
|
-
if item.is_a?(Releaf::ControllerDefinition) && item.controller_name == 'admin/nodes'
|
30
|
-
Releaf::ControllerDefinition.new("releaf/content/nodes")
|
31
|
-
else
|
32
|
-
item.dup
|
33
|
-
end
|
34
|
-
end
|
35
|
-
allow( Releaf.application.config ).to receive(:menu).and_return( Releaf::Configuration.normalize_controllers(stubbed_menu_config) )
|
36
|
-
# reset cached values
|
37
|
-
Releaf.application.config.instance_variable_set(:@controllers, nil)
|
38
|
-
Releaf.application.config.instance_variable_set(:@available_controllers, nil)
|
39
|
-
|
40
|
-
Dummy::Application.reload_routes!
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
before with_multiple_node_classes: true do
|
45
|
-
@default_port_inclusion_state = Capybara.always_include_port
|
46
|
-
Capybara.always_include_port = true
|
47
|
-
|
48
|
-
# stub node config and admin menu to use two node classes with separate controllers
|
49
|
-
|
50
|
-
allow( Releaf.application.config).to receive(:content).and_return(Releaf::Content::Configuration.new(
|
51
|
-
resources: {
|
52
|
-
'Node' => {
|
53
|
-
controller: 'Releaf::Content::NodesController',
|
54
|
-
routing: { site: "main_site", constraints: { host: Regexp.new( "^" + Regexp.escape("releaf.127.0.0.1.nip.io") + "$" ) } }
|
55
|
-
},
|
56
|
-
'OtherSite::OtherNode' => {
|
57
|
-
controller: 'Admin::OtherSite::OtherNodesController',
|
58
|
-
routing: { site: "other_site", constraints: { host: Regexp.new( "^" + Regexp.escape("other.releaf.127.0.0.1.nip.io") + "$" ) } }
|
59
|
-
}
|
60
|
-
}
|
61
|
-
))
|
62
|
-
|
63
|
-
# preserve default config because it will be needed in after block
|
64
|
-
@default_menu_config = Releaf.application.config.menu.dup
|
65
|
-
node_controller_item = Releaf::ControllerDefinition.new("releaf/content/nodes")
|
66
|
-
stubbed_menu_config = @default_menu_config.map do |item|
|
67
|
-
if item.is_a?(Releaf::ControllerDefinition) && item.controller_name == 'admin/nodes'
|
68
|
-
node_controller_item
|
69
|
-
else
|
70
|
-
item.dup
|
71
|
-
end
|
72
|
-
end
|
73
|
-
content_index = stubbed_menu_config.index( node_controller_item )
|
74
|
-
stubbed_menu_config.insert( content_index + 1, Releaf::ControllerDefinition.new("admin/other_site/other_nodes"))
|
75
|
-
|
76
|
-
allow( Releaf.application.config ).to receive(:menu).and_return( Releaf::Configuration.normalize_controllers(stubbed_menu_config) )
|
77
|
-
# reset cached values
|
78
|
-
Releaf.application.config.instance_variable_set(:@controllers, nil)
|
79
|
-
Releaf.application.config.instance_variable_set(:@available_controllers, nil)
|
80
|
-
|
81
|
-
Dummy::Application.reload_routes!
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
before do
|
86
|
-
@user = auth_as_user
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
before with_root: true do
|
91
|
-
@lv_root = create(:home_page_node, name: "lv", locale: "lv", slug: "lv")
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
before with_tree: true do
|
96
|
-
@how_to = create(:text_page_node, parent_id: @lv_root.id)
|
97
|
-
@about_us = create(:text_page_node, parent_id: @lv_root.id, name: "about us", slug: "about-us")
|
98
|
-
@history_node = create(:text_page_node, parent_id: @about_us.id, name: "history")
|
99
|
-
|
100
|
-
@en_root = create(:home_page_node, name: "en", locale: "en", slug: "en")
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
before with_tree: true do |example|
|
105
|
-
if example.metadata[:with_releaf_node_controller].blank? && example.metadata[:with_multiple_node_classes].blank?
|
106
|
-
visit admin_nodes_path
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
before with_other_tree: true do
|
112
|
-
@other_lv_root = create(:other_home_page_node, name: "Other lv", locale: "lv", slug: "lv")
|
113
|
-
@other_about_us = create(:other_text_page_node, parent_id: @other_lv_root.id, name: "Other about us", slug: "about-us")
|
114
|
-
@other_history = create(:other_text_page_node, parent_id: @other_lv_root.id, name: "Other history", slug: "other-history")
|
115
|
-
end
|
116
|
-
|
117
|
-
|
118
|
-
after with_multiple_node_classes: true do
|
119
|
-
Capybara.always_include_port = @default_port_inclusion_state
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
after do |example|
|
124
|
-
|
125
|
-
if example.metadata[:with_releaf_node_controller].present? || example.metadata[:with_multiple_node_classes].present?
|
126
|
-
allow( Releaf.application.config ).to receive(:content).and_call_original
|
127
|
-
allow( Releaf.application.config ).to receive(:menu).and_return(@default_menu_config)
|
128
|
-
|
129
|
-
# reset cached values
|
130
|
-
Releaf.application.config.instance_variable_set(:@controllers, nil)
|
131
|
-
Releaf.application.config.instance_variable_set(:@available_controllers, nil)
|
132
|
-
Dummy::Application.reload_routes!
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
after(:all) do
|
138
|
-
Dummy::Application.reload_routes!
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
describe "new node" do
|
143
|
-
|
144
|
-
context "when creating node under root" do
|
145
|
-
it "creates new node in content tree" do
|
146
|
-
@en_root.destroy
|
147
|
-
click_link "Create new resource"
|
148
|
-
click_link "Home page"
|
149
|
-
expect(page).to have_css('.button', text: 'Save')
|
150
|
-
expect(page).to have_no_css('.button', text: 'Save and create another')
|
151
|
-
create_resource do
|
152
|
-
fill_in "resource_name", with: "en"
|
153
|
-
select "en", from: "Locale"
|
154
|
-
end
|
155
|
-
|
156
|
-
expect(page).to have_breadcrumbs("Admin/nodes", "en")
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context "when creating node under another node" do
|
161
|
-
it "creates new node" do
|
162
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .toolbox-cell button').click
|
163
|
-
click_link "Add child"
|
164
|
-
click_link "Contacts controller"
|
165
|
-
expect(page).to have_css('.button', text: 'Save')
|
166
|
-
expect(page).to have_no_css('.button', text: 'Save and create another')
|
167
|
-
create_resource do
|
168
|
-
fill_in "resource_name", with: "Contacts"
|
169
|
-
end
|
170
|
-
|
171
|
-
expect(page).to have_breadcrumbs("Admin/nodes", "lv", "Contacts")
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "tree collapsing" do
|
177
|
-
context "when not opened before" do
|
178
|
-
it "does not show node's children" do
|
179
|
-
expect(page).to have_css('li[data-id="' + @lv_root.id.to_s + '"].collapsed')
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context "when clicked to uncollapse node" do
|
184
|
-
it "shows node children" do
|
185
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
186
|
-
|
187
|
-
expect(page).to have_css('li[data-id="' + @lv_root.id.to_s + '"]:not(.collapsed)')
|
188
|
-
end
|
189
|
-
|
190
|
-
it "keeps opened node children visibility permanent" do
|
191
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
192
|
-
wait_for_settings_update("content.tree.expanded.#{@lv_root.id}")
|
193
|
-
visit admin_nodes_path
|
194
|
-
|
195
|
-
expect(page).to have_css('li[data-id="' + @lv_root.id.to_s + '"]:not(.collapsed)')
|
196
|
-
end
|
197
|
-
|
198
|
-
it "keeps closed node children visibility permanent" do
|
199
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
200
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
201
|
-
wait_for_settings_update("content.tree.expanded.#{@lv_root.id}", false)
|
202
|
-
visit admin_nodes_path
|
203
|
-
|
204
|
-
expect(page).to have_css('li[data-id="' + @lv_root.id.to_s + '"].collapsed')
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe "copy node to" do
|
210
|
-
context "when copying node" do
|
211
|
-
it "shows copied node in tree" do
|
212
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
213
|
-
find('li[data-id="' + @about_us.id.to_s + '"] > .toolbox-cell button').click
|
214
|
-
click_link("Copy")
|
215
|
-
|
216
|
-
within_dialog do
|
217
|
-
find('label > span', text: "en").click
|
218
|
-
click_button "Copy"
|
219
|
-
end
|
220
|
-
|
221
|
-
expect(page).to have_notification("Copy succeeded")
|
222
|
-
|
223
|
-
find('li[data-id="' + @en_root.id.to_s + '"] > .collapser-cell button').click
|
224
|
-
expect(page).to have_css('li > .node-cell a', text: "about us", count: 2)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context "when copying node under itself" do
|
229
|
-
it "displays flash error message" do
|
230
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
231
|
-
find('li[data-id="' + @about_us.id.to_s + '"] > .toolbox-cell button').click
|
232
|
-
click_link("Copy")
|
233
|
-
|
234
|
-
within_dialog do
|
235
|
-
find('label > span', text: "about us").click
|
236
|
-
click_button "Copy"
|
237
|
-
end
|
238
|
-
|
239
|
-
error_text = "source or descendant node can't be parent of new node"
|
240
|
-
expect(page).to have_css('.dialog .form-error-box', text: error_text)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe "move node to", js: true do
|
246
|
-
context "when moving node to another parent" do
|
247
|
-
it "moves selected node to new position" do
|
248
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
249
|
-
find('li[data-id="' + @about_us.id.to_s + '"] > .toolbox-cell button').click
|
250
|
-
click_link("Move")
|
251
|
-
|
252
|
-
within_dialog do
|
253
|
-
find('label > span', text: "en").click
|
254
|
-
click_button "Move"
|
255
|
-
end
|
256
|
-
|
257
|
-
expect(page).to have_css('.notifications .notification .message', text: "Move succeeded")
|
258
|
-
expect(page).to have_css('li > .node-cell a', text: "about us", count: 0)
|
259
|
-
find('li[data-id="' + @en_root.id.to_s + '"] > .collapser-cell button').click
|
260
|
-
expect(page).to have_css('li > .node-cell a', text: "about us", count: 1)
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
context "when moving node under itself" do
|
265
|
-
it "displays flash error message" do
|
266
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
267
|
-
find('li[data-id="' + @about_us.id.to_s + '"] > .toolbox-cell button').click
|
268
|
-
click_link("Move")
|
269
|
-
|
270
|
-
within_dialog do
|
271
|
-
find('label > span', text: "about us").click
|
272
|
-
click_button "Move"
|
273
|
-
end
|
274
|
-
|
275
|
-
error_text = "can't be parent to itself"
|
276
|
-
expect(page).to have_css('.dialog .form-error-box', text: error_text)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
end
|
281
|
-
|
282
|
-
scenario "Slugs", with_tree: false do
|
283
|
-
visit admin_nodes_path
|
284
|
-
|
285
|
-
open_toolbox_dialog 'Add child', @lv_root, ".view-index .collection li"
|
286
|
-
within_dialog do
|
287
|
-
click_link("Text page")
|
288
|
-
end
|
289
|
-
|
290
|
-
fill_in "Slug", with: "some-slug"
|
291
|
-
fill_in 'Name', with: "About us"
|
292
|
-
expect(page).to have_field("Slug", with: "some-slug")
|
293
|
-
|
294
|
-
fill_in "Slug", with: ""
|
295
|
-
fill_in 'Name', with: "About them"
|
296
|
-
expect(page).to have_field("Slug", with: "about-them")
|
297
|
-
|
298
|
-
# fill text to allow text page save
|
299
|
-
fill_in_richtext "Text", with: "asdasd"
|
300
|
-
|
301
|
-
fill_in "Slug", with: "invalid slug <>!"
|
302
|
-
click_button "Save"
|
303
|
-
expect(page).to have_error("is invalid", field: "Slug")
|
304
|
-
click_button "Suggest slug"
|
305
|
-
expect(page).to have_field("Slug", with: "about-them")
|
306
|
-
click_button "Save"
|
307
|
-
expect(page).to have_notification("Create succeeded")
|
308
|
-
end
|
309
|
-
|
310
|
-
describe "node order", with_tree: false do
|
311
|
-
def create_child parent, child_text, position=nil
|
312
|
-
visit admin_nodes_path
|
313
|
-
|
314
|
-
open_toolbox_dialog 'Add child', parent, ".view-index .collection li"
|
315
|
-
within_dialog do
|
316
|
-
click_link("Text page")
|
317
|
-
end
|
318
|
-
|
319
|
-
create_resource do
|
320
|
-
fill_in 'Name', with: child_text
|
321
|
-
fill_in "Slug", with: child_text
|
322
|
-
fill_in_richtext 'Text', with: child_text
|
323
|
-
if position
|
324
|
-
select position, from: 'Item position'
|
325
|
-
end
|
326
|
-
end
|
327
|
-
|
328
|
-
end
|
329
|
-
|
330
|
-
it "creates nodes in correct order" do
|
331
|
-
create_child @lv_root, 'a'
|
332
|
-
create_child @lv_root, 'b', 'After a'
|
333
|
-
create_child @lv_root, 'c', 'After b'
|
334
|
-
create_child @lv_root, 'd', 'After b'
|
335
|
-
create_child @lv_root, 'e', 'First'
|
336
|
-
|
337
|
-
visit admin_nodes_path
|
338
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
339
|
-
|
340
|
-
within(".collection li[data-level='1'][data-id='#{@lv_root.id}'] ul") do
|
341
|
-
expect( page ).to have_content 'e a b d c'
|
342
|
-
end
|
343
|
-
end
|
344
|
-
|
345
|
-
it "by default adds new nodes as last" do
|
346
|
-
create_child @lv_root, 'a'
|
347
|
-
create_child @lv_root, 'b'
|
348
|
-
create_child @lv_root, 'c'
|
349
|
-
|
350
|
-
visit admin_nodes_path
|
351
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
352
|
-
|
353
|
-
within(".collection li[data-level='1'][data-id='#{@lv_root.id}'] ul") do
|
354
|
-
expect( page ).to have_content 'a b c'
|
355
|
-
end
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
describe "creating node for placeholder model", with_tree: false, with_root: false, js: false do
|
360
|
-
it "create record in association table" do
|
361
|
-
allow_any_instance_of(Releaf::Content::Node::RootValidator).to receive(:validate)
|
362
|
-
visit new_admin_node_path(content_type: 'Bundle')
|
363
|
-
fill_in("resource_name", with: "placeholder model node")
|
364
|
-
expect do
|
365
|
-
click_button 'Save'
|
366
|
-
end.to change { [Node.count, Bundle.count] }.from([0, 0]).to([1, 1])
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
|
371
|
-
feature "using default releaf content controller", with_releaf_node_controller: true do
|
372
|
-
|
373
|
-
# for this case do not re-test all node features from above
|
374
|
-
# just click around a bit to ensure that the controllers, builders and assets work
|
375
|
-
# and make sure the public page of the created node works
|
376
|
-
|
377
|
-
scenario "basic node operations" do
|
378
|
-
visit "/admin"
|
379
|
-
|
380
|
-
expect(page).to have_no_content 'Admin/nodes'
|
381
|
-
within "aside nav" do
|
382
|
-
click_link "Releaf/content/nodes"
|
383
|
-
end
|
384
|
-
expect(current_path).to eq releaf_content_nodes_path
|
385
|
-
|
386
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .toolbox-cell button').click
|
387
|
-
click_link "Add child"
|
388
|
-
within '.ajaxbox-inner .dialog.content-type' do
|
389
|
-
click_link "Contacts controller"
|
390
|
-
end
|
391
|
-
create_resource do
|
392
|
-
fill_in "resource_name", with: "Contacts"
|
393
|
-
end
|
394
|
-
|
395
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "Contacts")
|
396
|
-
|
397
|
-
visit lv_contacts_page_path
|
398
|
-
expect(page).to have_content "Node class: Node"
|
399
|
-
expect(page).to have_content "Releaf github repository"
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
feature "breadcrumbs ordering by depth", with_releaf_node_controller: true do
|
404
|
-
# create some nodes and then rearrange them to get some with oldest under newest
|
405
|
-
|
406
|
-
scenario "create and reorder node depth" do
|
407
|
-
visit releaf_content_nodes_path
|
408
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .toolbox-cell button').click
|
409
|
-
click_link "Add child"
|
410
|
-
within '.ajaxbox-inner .dialog.content-type' do
|
411
|
-
click_link "Text page"
|
412
|
-
end
|
413
|
-
create_resource do
|
414
|
-
fill_in "resource_name", with: "TextContent_1"
|
415
|
-
fill_in_richtext 'Text', with: "asdasd"
|
416
|
-
end
|
417
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "TextContent_1")
|
418
|
-
|
419
|
-
visit releaf_content_nodes_path
|
420
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .toolbox-cell button').click
|
421
|
-
click_link "Add child"
|
422
|
-
within '.ajaxbox-inner .dialog.content-type' do
|
423
|
-
click_link "Text page"
|
424
|
-
end
|
425
|
-
create_resource do
|
426
|
-
fill_in "resource_name", with: "TextContent_2"
|
427
|
-
fill_in_richtext 'Text', with: "asdasd"
|
428
|
-
end
|
429
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "TextContent_2")
|
430
|
-
|
431
|
-
visit releaf_content_nodes_path
|
432
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .toolbox-cell button').click
|
433
|
-
click_link "Add child"
|
434
|
-
within '.ajaxbox-inner .dialog.content-type' do
|
435
|
-
click_link "Text page"
|
436
|
-
end
|
437
|
-
create_resource do
|
438
|
-
fill_in "resource_name", with: "TextContent_3"
|
439
|
-
fill_in_richtext 'Text', with: "asdasd"
|
440
|
-
end
|
441
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "TextContent_3")
|
442
|
-
|
443
|
-
|
444
|
-
text_page_1_node_id = Node.find_by(name: "TextContent_1").id
|
445
|
-
text_page_2_node_id = Node.find_by(name: "TextContent_2").id
|
446
|
-
text_page_3_node_id = Node.find_by(name: "TextContent_3").id
|
447
|
-
|
448
|
-
visit edit_releaf_content_node_path(text_page_1_node_id)
|
449
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "TextContent_1")
|
450
|
-
open_toolbox_dialog "Move"
|
451
|
-
within ".dialog" do
|
452
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .collapser-cell button').click
|
453
|
-
find("label[for=new_parent_id_#{text_page_2_node_id}]").click
|
454
|
-
click_button "Move"
|
455
|
-
end
|
456
|
-
expect(page).to have_notification("Move succeeded")
|
457
|
-
|
458
|
-
visit edit_releaf_content_node_path(text_page_2_node_id)
|
459
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "TextContent_2")
|
460
|
-
open_toolbox_dialog "Move"
|
461
|
-
within ".dialog" do
|
462
|
-
find("label[for=new_parent_id_#{text_page_3_node_id}]").click
|
463
|
-
click_button "Move"
|
464
|
-
end
|
465
|
-
expect(page).to have_notification("Move succeeded")
|
466
|
-
|
467
|
-
visit edit_releaf_content_node_path(text_page_1_node_id)
|
468
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "TextContent_3", "TextContent_2", "TextContent_1")
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
|
-
feature "using multiple independent node trees", with_multiple_node_classes: true, with_other_tree: true do
|
473
|
-
|
474
|
-
# here also do not re-test all node features
|
475
|
-
# but ensure that controllers, builders and assets work in both admin node controllers
|
476
|
-
# and that the per-site configuration and hostname restrictions defined in the node config work on public routes
|
477
|
-
|
478
|
-
scenario "multiple site node operations" do
|
479
|
-
|
480
|
-
visit "/admin"
|
481
|
-
|
482
|
-
# make sure that the admin/nodes controller is not available in menu
|
483
|
-
expect(page).to have_no_content 'Admin/nodes'
|
484
|
-
|
485
|
-
# test node creation in releaf/content/nodes controller
|
486
|
-
within "aside nav" do
|
487
|
-
click_link "Releaf/content/nodes"
|
488
|
-
end
|
489
|
-
expect(current_path).to eq releaf_content_nodes_path
|
490
|
-
|
491
|
-
find('li[data-id="' + @lv_root.id.to_s + '"] > .toolbox-cell button').click
|
492
|
-
click_link "Add child"
|
493
|
-
within '.ajaxbox-inner .dialog.content-type' do
|
494
|
-
click_link "Contacts controller"
|
495
|
-
end
|
496
|
-
create_resource do
|
497
|
-
fill_in "resource_name", with: "Main contacts"
|
498
|
-
fill_in "resource_slug", with: "contacts"
|
499
|
-
end
|
500
|
-
expect(page).to have_breadcrumbs("Releaf/content/nodes", "lv", "Main contacts")
|
501
|
-
|
502
|
-
|
503
|
-
# test node creation in the other site nodes controller
|
504
|
-
within "aside nav" do
|
505
|
-
click_link "Admin/other site/other nodes"
|
506
|
-
end
|
507
|
-
expect(current_path).to eq admin_other_site_other_nodes_path
|
508
|
-
find('li[data-id="' + @other_lv_root.id.to_s + '"] > .toolbox-cell button').click
|
509
|
-
click_link "Add child"
|
510
|
-
within '.ajaxbox-inner .dialog.content-type' do
|
511
|
-
click_link "Contacts controller"
|
512
|
-
end
|
513
|
-
create_resource do
|
514
|
-
fill_in "resource_name", with: "Other contacts"
|
515
|
-
fill_in "resource_slug", with: "contacts"
|
516
|
-
end
|
517
|
-
expect(page).to have_breadcrumbs("Admin/other site/other nodes", "lv", "Other contacts")
|
518
|
-
|
519
|
-
|
520
|
-
# test public websites for correct url helpers, node types, site settings and host name constraints
|
521
|
-
|
522
|
-
Capybara.app_host = "http://releaf.127.0.0.1.nip.io"
|
523
|
-
|
524
|
-
visit main_site_lv_home_page_path
|
525
|
-
expect(page).to have_content "Site: main_site"
|
526
|
-
expect(page).to have_content "Node class: Node"
|
527
|
-
expect(page).to have_content "Node name: lv"
|
528
|
-
|
529
|
-
visit "/lv/about-us"
|
530
|
-
expect(URI.parse(current_url).host).to eq "releaf.127.0.0.1.nip.io"
|
531
|
-
expect(page).to have_content "Site: main_site"
|
532
|
-
expect(page).to have_content "Node class: Node"
|
533
|
-
expect(page).to have_content "Node name: about us"
|
534
|
-
|
535
|
-
visit main_site_lv_contacts_page_path
|
536
|
-
expect(page).to have_content "Site: main_site"
|
537
|
-
expect(page).to have_content "Node class: Node"
|
538
|
-
expect(page).to have_content "Node name: Main contacts"
|
539
|
-
|
540
|
-
# make sure the nodes from other site are not reachable via this hostname
|
541
|
-
visit "/lv/other-history"
|
542
|
-
expect( page ).to have_content "The page you were looking for doesn't exist."
|
543
|
-
|
544
|
-
|
545
|
-
Capybara.app_host = "http://other.releaf.127.0.0.1.nip.io"
|
546
|
-
visit other_site_lv_home_page_path
|
547
|
-
expect(page).to have_content "Site: other_site"
|
548
|
-
expect(page).to have_content "Node class: OtherSite::OtherNode"
|
549
|
-
expect(page).to have_content "Node name: Other lv"
|
550
|
-
|
551
|
-
visit "/lv/about-us"
|
552
|
-
expect(URI.parse(current_url).host).to eq "other.releaf.127.0.0.1.nip.io"
|
553
|
-
expect(page).to have_content "Site: other_site"
|
554
|
-
expect(page).to have_content "Node class: OtherSite::OtherNode"
|
555
|
-
expect(page).to have_content "Node name: Other about us"
|
556
|
-
|
557
|
-
visit "/lv/other-history"
|
558
|
-
expect(page).to have_content "Site: other_site"
|
559
|
-
expect(page).to have_content "Node class: OtherSite::OtherNode"
|
560
|
-
expect(page).to have_content "Node name: Other history"
|
561
|
-
|
562
|
-
|
563
|
-
# other site contacts node should not have a route
|
564
|
-
# because the route is constrained to main site in dummy application's routes.rb
|
565
|
-
visit "/lv/contacts"
|
566
|
-
expect( page ).to have_content "The page you were looking for doesn't exist."
|
567
|
-
end
|
568
|
-
|
569
|
-
end
|
570
|
-
|
571
|
-
|
572
|
-
end
|