releaf-content 1.1.22 → 2.0.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.
- 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
- data/spec/builders/content/nodes/action_dialog_spec.rb +1 -1
- data/spec/builders/content/nodes/content_form_builder_spec.rb +1 -1
- data/spec/builders/content/nodes/form_builder_spec.rb +1 -1
- data/spec/builders/content/nodes/toolbox_builder_spec.rb +1 -1
- data/spec/features/nodes_services_spec.rb +2 -2
- data/spec/features/nodes_spec.rb +2 -1
- data/spec/lib/releaf/content/node_spec.rb +10 -8
- data/spec/lib/releaf/content/route_spec.rb +1 -1
- data/spec/routing/node_mapper_spec.rb +2 -1
- data/spec/services/releaf/content/node/copy_spec.rb +1 -1
- data/spec/validators/content/node/parent_validator_spec.rb +7 -7
- data/spec/validators/content/node/root_validator_spec.rb +2 -2
- data/spec/validators/content/node/singleness_validator_spec.rb +2 -2
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900ae0e38ceb2c4d2a99f33aeac58222a7d3bf9dd3101527d00b52048754f951
|
4
|
+
data.tar.gz: 7cc316c4cc9351d81a7012debc8c26c1df209c8b37c95ab9e702377ccf56f247
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 889dd3be635bc6a64c219a700253f2c46770624314af350c072566e07c168b86186e5fae5d3c63cae2c7f107d6c10a9f50a9b893a9c7feb3c6701f9e4787669d
|
7
|
+
data.tar.gz: f17de37b5b96ab4dcfe50c71802076b2e96897a2f524975d834f4ccf47740986ec24aaf12b0f4e80863ccd1623dbc7dbbd9e74dd95ae8a05e97458f85fa16bb1
|
@@ -76,17 +76,14 @@ jQuery(function()
|
|
76
76
|
slug_input.trigger('sluggenerate');
|
77
77
|
});
|
78
78
|
|
79
|
-
if
|
79
|
+
// bind onchange slug generation only if starting out with an empty name
|
80
|
+
name_input.on('change', function()
|
80
81
|
{
|
81
|
-
|
82
|
-
name_input.on('change', function()
|
82
|
+
if(slug_input.val().length === 0)
|
83
83
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
}
|
88
|
-
});
|
89
|
-
}
|
84
|
+
slug_input.trigger('sluggenerate');
|
85
|
+
}
|
86
|
+
});
|
90
87
|
}
|
91
88
|
|
92
89
|
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Releaf::Content
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
initializer '
|
4
|
-
app.config.assets.precompile
|
3
|
+
initializer 'releaf_content.assets_precompile', group: :all do |app|
|
4
|
+
app.config.assets.precompile << "releaf_content_manifest.js"
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
data/lib/releaf/content/node.rb
CHANGED
@@ -218,14 +218,14 @@ module Releaf::Content
|
|
218
218
|
scope :active, ->() { where(active: true) }
|
219
219
|
|
220
220
|
validates_presence_of :name, :slug, :content_type
|
221
|
-
validates_uniqueness_of :slug, scope: :parent_id
|
221
|
+
validates_uniqueness_of :slug, scope: :parent_id, case_sensitive: false
|
222
222
|
validates_length_of :name, :slug, :content_type, maximum: 255
|
223
|
-
validates_uniqueness_of :locale, scope: :parent_id, if: :validate_root_locale_uniqueness
|
223
|
+
validates_uniqueness_of :locale, scope: :parent_id, if: :validate_root_locale_uniqueness?, case_sensitive: false
|
224
224
|
validates_presence_of :parent, if: :parent_id?
|
225
225
|
validate :validate_parent_node_is_not_self
|
226
226
|
validate :validate_parent_is_not_descendant
|
227
227
|
validate :validate_slug
|
228
|
-
belongs_to :content, polymorphic: true, dependent: :destroy
|
228
|
+
belongs_to :content, polymorphic: true, dependent: :destroy, required: false
|
229
229
|
accepts_nested_attributes_for :content
|
230
230
|
|
231
231
|
after_save :update_settings_timestamp, unless: :prevent_auto_update_settings_timestamp?
|
data/lib/releaf/content/route.rb
CHANGED
@@ -57,7 +57,6 @@ module Releaf::Content
|
|
57
57
|
# @return [Array] array of Content::Route objects
|
58
58
|
def self.for(node_class, node_content_class, default_controller)
|
59
59
|
node_class = node_class.constantize if node_class.is_a? String
|
60
|
-
|
61
60
|
Releaf::Content::BuildRouteObjects.call(
|
62
61
|
node_class: node_class,
|
63
62
|
node_content_class: node_content_class,
|
@@ -10,7 +10,7 @@ describe Releaf::Content::Builders::ActionDialog, type: :class do
|
|
10
10
|
def action; end
|
11
11
|
end
|
12
12
|
|
13
|
-
let(:template){ ConfirmDestroyDialogTestHelper.new }
|
13
|
+
let(:template){ ConfirmDestroyDialogTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
14
14
|
let(:object){ Book.new }
|
15
15
|
let(:subject){ ActionDialogIncluder.new(template) }
|
16
16
|
|
@@ -9,7 +9,7 @@ describe Releaf::Content::Nodes::ContentFormBuilder, type: :class do
|
|
9
9
|
def generate_url_releaf_content_nodes_path(args); end
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:template){ FormBuilderTestHelper.new }
|
12
|
+
let(:template){ FormBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
13
13
|
let(:node){ Node.new(content_type: "TextPage", slug: "b", id: 2,
|
14
14
|
parent: Node.new(content_type: "TextPage", slug: "a", id: 1)) }
|
15
15
|
let(:object){ node.build_content }
|
@@ -9,7 +9,7 @@ describe Releaf::Content::Nodes::FormBuilder, type: :class do
|
|
9
9
|
def generate_url_releaf_content_nodes_path(args); end
|
10
10
|
end
|
11
11
|
|
12
|
-
let(:template){ FormBuilderTestHelper.new }
|
12
|
+
let(:template){ FormBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
13
13
|
let(:object){ Node.new(content_type: "TextPage", slug: "b", id: 2,
|
14
14
|
parent: Node.new(content_type: "TextPage", slug: "a", id: 1)) }
|
15
15
|
let(:subject){ described_class.new(:resource, object, template, {}) }
|
@@ -7,7 +7,7 @@ describe Releaf::Content::Nodes::ToolboxBuilder, type: :class do
|
|
7
7
|
include Releaf::ApplicationHelper
|
8
8
|
end
|
9
9
|
|
10
|
-
let(:template){ NodeToolboxBuilderTestHelper.new }
|
10
|
+
let(:template){ NodeToolboxBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
11
11
|
subject { described_class.new(template) }
|
12
12
|
|
13
13
|
let(:node){ Node.new(content_type: "TextPage", slug: "a", id: 99) }
|
@@ -423,8 +423,8 @@ describe "Nodes services (copy, move)" do
|
|
423
423
|
expect_different_values(original_url, copied_file_urls[key])
|
424
424
|
|
425
425
|
[original_url, copied_file_urls[key]].each do |file_url|
|
426
|
-
|
427
|
-
expect(
|
426
|
+
tmpfile = download_file(file_url)
|
427
|
+
expect(Digest::SHA256.file(tmpfile)).to eq(Digest::SHA256.file(dummy_file_path))
|
428
428
|
end
|
429
429
|
end
|
430
430
|
|
data/spec/features/nodes_spec.rb
CHANGED
@@ -284,7 +284,7 @@ describe "Nodes", js: true, with_tree: true, with_root: true do
|
|
284
284
|
|
285
285
|
open_toolbox_dialog 'Add child', @lv_root, ".view-index .collection li"
|
286
286
|
within_dialog do
|
287
|
-
|
287
|
+
click_link("Text page")
|
288
288
|
end
|
289
289
|
|
290
290
|
fill_in "Slug", with: "some-slug"
|
@@ -293,6 +293,7 @@ describe "Nodes", js: true, with_tree: true, with_root: true do
|
|
293
293
|
|
294
294
|
fill_in "Slug", with: ""
|
295
295
|
fill_in 'Name', with: "About them"
|
296
|
+
blur_from "Name"
|
296
297
|
expect(page).to have_field("Slug", with: "about-them")
|
297
298
|
|
298
299
|
# fill text to allow text page save
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
|
-
describe Node do
|
3
|
+
describe Node, type: :model do
|
4
4
|
class PlainNode < ActiveRecord::Base
|
5
5
|
include Releaf::Content::Node
|
6
6
|
self.table_name = "nodes"
|
@@ -9,7 +9,7 @@ describe Node do
|
|
9
9
|
let(:plain_subject){ PlainNode.new }
|
10
10
|
|
11
11
|
it { is_expected.to accept_nested_attributes_for(:content) }
|
12
|
-
it { is_expected.to belong_to(:content) }
|
12
|
+
it { is_expected.to belong_to(:content).required(false) }
|
13
13
|
|
14
14
|
it "includes Releaf::Content::Node module" do
|
15
15
|
expect( Node.included_modules ).to include Releaf::Content::Node
|
@@ -19,7 +19,7 @@ describe Node do
|
|
19
19
|
it { is_expected.to validate_presence_of(:name) }
|
20
20
|
it { is_expected.to validate_presence_of(:slug) }
|
21
21
|
it { is_expected.to validate_presence_of(:content_type) }
|
22
|
-
it { is_expected.to validate_uniqueness_of(:slug).scoped_to(:parent_id) }
|
22
|
+
it { is_expected.to validate_uniqueness_of(:slug).scoped_to(:parent_id).case_insensitive }
|
23
23
|
it { is_expected.to validate_length_of(:name).is_at_most(255) }
|
24
24
|
it { is_expected.to validate_length_of(:slug).is_at_most(255) }
|
25
25
|
end
|
@@ -31,10 +31,12 @@ describe Node do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "
|
34
|
+
describe ":active scope" do
|
35
35
|
it "returns active nodes" do
|
36
|
-
|
37
|
-
|
36
|
+
item_1 = create(:node, active: true, locale: "en")
|
37
|
+
item_2 = create(:node, active: false, locale: "de")
|
38
|
+
item_3 = create(:node, active: true, locale: "lv")
|
39
|
+
expect(Node.active).to eq [item_1, item_3]
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -519,7 +521,7 @@ describe Node do
|
|
519
521
|
|
520
522
|
context "when #prevent_auto_update_settings_timestamp? is false" do
|
521
523
|
it "is called after save" do
|
522
|
-
node =
|
524
|
+
node = build(:node)
|
523
525
|
allow( node ).to receive(:prevent_auto_update_settings_timestamp?).and_return(false)
|
524
526
|
expect( node ).to receive(:update_settings_timestamp).and_call_original
|
525
527
|
node.save!
|
@@ -528,7 +530,7 @@ describe Node do
|
|
528
530
|
|
529
531
|
context "when #prevent_auto_update_settings_timestamp? is true" do
|
530
532
|
it "is not called after save" do
|
531
|
-
node =
|
533
|
+
node = build(:node)
|
532
534
|
allow( node ).to receive(:prevent_auto_update_settings_timestamp?).and_return(true)
|
533
535
|
expect( node ).to_not receive(:update_settings_timestamp)
|
534
536
|
node.save!
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
3
|
describe Releaf::Content::Route do
|
4
|
-
let(:node_route) {
|
4
|
+
let(:node_route) { FactoryBot.build(:node_route, node_class: Node, node_id: 12, locale: "en", path: "/en") }
|
5
5
|
|
6
6
|
|
7
7
|
describe ".default_controller" do
|
@@ -165,7 +165,8 @@ describe Releaf::Content::NodeMapper do
|
|
165
165
|
it "uses the custom path for public website route" do
|
166
166
|
routes.draw do
|
167
167
|
node_routes_for(TextPage) do |route|
|
168
|
-
|
168
|
+
route.path += "/abc/:my_id"
|
169
|
+
get 'home_pages#show'
|
169
170
|
end
|
170
171
|
end
|
171
172
|
|
@@ -53,7 +53,7 @@ describe Releaf::Content::Node::Copy do
|
|
53
53
|
|
54
54
|
# make sure the files are stored and exist
|
55
55
|
expect(copy.content.top_banner.path).to start_with Dragonfly.app.datastore.root_path
|
56
|
-
expect(node.content.top_banner.path).to start_with Dragonfly.app.datastore.root_path
|
56
|
+
expect(node.content.class.find(node.content.id).top_banner.path).to start_with Dragonfly.app.datastore.root_path
|
57
57
|
expect(copy.content.top_banner.path).to_not eq node.content.top_banner.path
|
58
58
|
end
|
59
59
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe Releaf::Content::Node::ParentValidator do
|
4
|
-
let!(:root_node) {
|
4
|
+
let!(:root_node) { FactoryBot.create(:node, content_type: 'HomePage') }
|
5
5
|
|
6
6
|
class DummyNodeParentValidatorModel < ActiveRecord::Base
|
7
7
|
acts_as_node
|
@@ -25,8 +25,8 @@ describe Releaf::Content::Node::ParentValidator do
|
|
25
25
|
|
26
26
|
context "when parent is valid" do
|
27
27
|
it "doesn't add error" do
|
28
|
-
parent = DummyNodeParentValidatorNode.create!(
|
29
|
-
child = DummyNodeParentValidatorNode.new(
|
28
|
+
parent = DummyNodeParentValidatorNode.create!( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator1Controller') )
|
29
|
+
child = DummyNodeParentValidatorNode.new( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidatorModel', parent_id: parent.id) )
|
30
30
|
|
31
31
|
expect( child ).to be_valid
|
32
32
|
end
|
@@ -34,8 +34,8 @@ describe Releaf::Content::Node::ParentValidator do
|
|
34
34
|
|
35
35
|
context "when parent is invalid" do
|
36
36
|
it "adds error on content_type" do
|
37
|
-
parent = DummyNodeParentValidatorNode.create!(
|
38
|
-
child = DummyNodeParentValidatorNode.new(
|
37
|
+
parent = DummyNodeParentValidatorNode.create!( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator2Controller') )
|
38
|
+
child = DummyNodeParentValidatorNode.new( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidatorModel', parent_id: parent.id) )
|
39
39
|
|
40
40
|
expect( child ).to be_invalid
|
41
41
|
expect( child.errors[:content_type].size ).to eq(1)
|
@@ -46,8 +46,8 @@ describe Releaf::Content::Node::ParentValidator do
|
|
46
46
|
|
47
47
|
context "when content_type is not in child list" do
|
48
48
|
it "doesn't add error" do
|
49
|
-
parent = DummyNodeParentValidatorNode.create!(
|
50
|
-
child = DummyNodeParentValidatorNode.new(
|
49
|
+
parent = DummyNodeParentValidatorNode.create!( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator1Controller') )
|
50
|
+
child = DummyNodeParentValidatorNode.new( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator2Controller', parent_id: parent.id) )
|
51
51
|
|
52
52
|
expect( child ).to be_valid
|
53
53
|
end
|
@@ -19,11 +19,11 @@ describe Releaf::Content::Node::RootValidator do
|
|
19
19
|
|
20
20
|
|
21
21
|
def create_node *params
|
22
|
-
DummyRootValidatorNode.create!(
|
22
|
+
DummyRootValidatorNode.create!( FactoryBot.attributes_for(:node, *params) )
|
23
23
|
end
|
24
24
|
|
25
25
|
def build_node *params
|
26
|
-
DummyRootValidatorNode.new(
|
26
|
+
DummyRootValidatorNode.new( FactoryBot.attributes_for(:node, *params) )
|
27
27
|
end
|
28
28
|
|
29
29
|
context "when node is allowed to be root node" do
|
@@ -30,11 +30,11 @@ describe Releaf::Content::Node::SinglenessValidator do
|
|
30
30
|
|
31
31
|
|
32
32
|
def create_node *params
|
33
|
-
DummySinglenessValidatorNode.create!(
|
33
|
+
DummySinglenessValidatorNode.create!( FactoryBot.attributes_for(:node, *params) )
|
34
34
|
end
|
35
35
|
|
36
36
|
def build_node *params
|
37
|
-
DummySinglenessValidatorNode.new(
|
37
|
+
DummySinglenessValidatorNode.new( FactoryBot.attributes_for(:node, *params) )
|
38
38
|
end
|
39
39
|
|
40
40
|
let!(:root_node) { create_node(content_type: 'HomePage') }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: releaf-content
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: releaf-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: stringex
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '3.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '3.0'
|
69
69
|
description: Content subsystem for releaf
|
70
70
|
email: info@cubesystems.lv
|
71
71
|
executables: []
|
@@ -73,6 +73,7 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- LICENSE
|
76
|
+
- app/assets/config/releaf_content_manifest.js
|
76
77
|
- app/assets/javascripts/controllers/releaf/content/nodes.js
|
77
78
|
- app/assets/stylesheets/controllers/releaf/content/nodes.scss
|
78
79
|
- app/builders/releaf/content/builders/action_dialog.rb
|
@@ -135,7 +136,7 @@ homepage: https://github.com/cubesystems/releaf
|
|
135
136
|
licenses:
|
136
137
|
- MIT
|
137
138
|
metadata: {}
|
138
|
-
post_install_message:
|
139
|
+
post_install_message:
|
139
140
|
rdoc_options: []
|
140
141
|
require_paths:
|
141
142
|
- lib
|
@@ -150,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
- !ruby/object:Gem::Version
|
151
152
|
version: '0'
|
152
153
|
requirements: []
|
153
|
-
rubygems_version: 3.0.
|
154
|
-
signing_key:
|
154
|
+
rubygems_version: 3.0.8
|
155
|
+
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: Node and content routes support for releaf
|
157
158
|
test_files:
|