releaf-content 1.1.7 → 1.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa481f6a30e7c564290ef48583adb025ca5d8475
4
- data.tar.gz: 829d11c08698bbd9b26b70132960a34c53bfb3a8
3
+ metadata.gz: c4264fda83d8b605ecd17a70329d4ce75725acb0
4
+ data.tar.gz: c99c850cfb7c4bda98c78a13a15378552b057e1e
5
5
  SHA512:
6
- metadata.gz: 82f4e66f449a3dae21530196dcf36e5fc706c6e03f315feace43f595f651235e6b5cfb0cade4bae0acf8dba603a5f6d618e31551ba9000316c5a4ecaff7db9e0
7
- data.tar.gz: e3fd81640a30fceabb6e0cb3162633c130661e893d867d6306e1cf9528bbb0bd712008124f21ad579f2975e7aaef82d0820f831add2ca47fea349966b28aad14
6
+ metadata.gz: 6736327a031ad770d886bb5726a66e8e8ead7f94baab94eabe235ef534ab12bc4071d65c37a71b815ebd464de0796f3a6332cec1abcac625743971cb94d57686
7
+ data.tar.gz: 8d8fb0fa4eaa731f81fed1db930b2014268b66b020d758de81b656087efb416455d3fc126fbdd1f56fe36a20cdd8c2f6a4fd184ef3e4173970294097018f3727
@@ -12,6 +12,48 @@ module Releaf::Content::Builders
12
12
  classes
13
13
  end
14
14
 
15
+ def sorted_tree
16
+ sort_tree(build_tree)
17
+ end
18
+
19
+ def sort_tree(nodes)
20
+ nodes.sort_by! { |item| item[:node].item_position }
21
+
22
+ nodes.each do |node|
23
+ sort_tree(node[:children]) if node[:children].present?
24
+ end
25
+ end
26
+
27
+ def build_tree
28
+ stack = []
29
+ result = []
30
+
31
+ collection.each do |node|
32
+ if stack.empty?
33
+ stack.push({ node: node, children: [] })
34
+ result << stack.last
35
+ next
36
+ end
37
+
38
+ if stack.last[:node].lft < node.lft && node.lft < stack.last[:node].rgt
39
+ child = { node: node, children: [] }
40
+ stack.last[:children] << child
41
+
42
+ if node.rgt + 1 == stack.last[:node].rgt
43
+ stack.pop
44
+ end
45
+
46
+ unless node.leaf?
47
+ stack.push(child)
48
+ end
49
+ else
50
+ stack.pop
51
+ end
52
+ end
53
+
54
+ result
55
+ end
56
+
15
57
  def tree
16
58
  tag(:div, class: "collection") do
17
59
  root_level
@@ -20,7 +62,7 @@ module Releaf::Content::Builders
20
62
 
21
63
  def root_level
22
64
  return empty_body if collection.size < 1
23
- tree_level(collection, 1)
65
+ tree_level(sorted_tree, 1)
24
66
  end
25
67
 
26
68
  def empty_body
@@ -38,31 +80,31 @@ module Releaf::Content::Builders
38
80
  end
39
81
 
40
82
  def tree_resource(resource, level)
41
- expanded = (layout_settings("content.tree.expanded.#{resource.id}") == true)
83
+ expanded = (layout_settings("content.tree.expanded.#{resource[:node].id}") == true)
42
84
  classes = []
43
85
  classes << 'collapsed' unless expanded
44
- classes << 'has-children' unless resource.children.empty?
86
+ classes << 'has-children' unless resource[:children].empty?
45
87
 
46
- tag(:li, class: classes, data: {level: level, id: resource.id}) do
88
+ tag(:li, class: classes, data: {level: level, id: resource[:node].id}) do
47
89
  tree_resource_blocks(resource, level, expanded)
48
90
  end
49
91
  end
50
92
 
51
93
  def tree_resource_blocks(resource, level, expanded)
52
94
  [tree_resource_collapser(resource, expanded),
53
- tree_resource_name(resource), tree_resource_children(resource, level)]
95
+ tree_resource_name(resource[:node]), tree_resource_children(resource, level)]
54
96
  end
55
97
 
56
98
  def tree_resource_collapser(resource, expanded)
57
- return if resource.children.empty?
99
+ return if resource[:children].empty?
58
100
  tag(:div, class: "collapser-cell") do
59
101
  button(nil, (expanded ? 'chevron-down' : 'chevron-right'), class: %w(secondary collapser trigger), title: t(expanded ? "Collapse" : "Expand"))
60
102
  end
61
103
  end
62
104
 
63
105
  def tree_resource_children(resource, level)
64
- return if resource.children.empty?
65
- tree_level(resource.children, level + 1)
106
+ return if resource[:children].empty?
107
+ tree_level(resource[:children], level + 1)
66
108
  end
67
109
 
68
110
  def tree_resource_name(resource)
@@ -78,17 +78,23 @@ module Releaf::Content::Nodes
78
78
  def item_position_select_options
79
79
  after_text = t("After")
80
80
  list = [[t("First"), 0]]
81
- order_nodes.each do |node|
82
- list.push [after_text + ' ' + node.name, node.lower_item ? node.lower_item.item_position : node.item_position + 1 ]
81
+
82
+ order_nodes = object.self_and_siblings.reorder(:item_position).to_a
83
+ order_nodes.each_with_index do |node, index|
84
+ next if node == object
85
+
86
+ if index == order_nodes.size - 1
87
+ next_position = node.item_position + 1
88
+ else
89
+ next_position = order_nodes[index + 1].item_position
90
+ end
91
+
92
+ list.push [after_text + ' ' + node.name, next_position ]
83
93
  end
84
94
 
85
95
  list
86
96
  end
87
97
 
88
- def order_nodes
89
- object.class.where(parent_id: object.parent_id).where('id <> ?', object.id.to_i)
90
- end
91
-
92
98
  def slug_base_url
93
99
  "#{request.protocol}#{request.host_with_port}#{object.parent.try(:path)}" + (object.trailing_slash_for_path? ? "" : "/")
94
100
  end
@@ -9,7 +9,7 @@ module Releaf::Content::Nodes
9
9
 
10
10
  def tree_resource_toolbox(resource)
11
11
  tag(:div, class: "only-icon toolbox-cell") do
12
- toolbox(resource, index_path: index_path)
12
+ toolbox(resource[:node], index_path: index_path)
13
13
  end
14
14
  end
15
15
 
@@ -67,7 +67,7 @@ class Releaf::Content::NodesController < Releaf::ActionController
67
67
  protected
68
68
 
69
69
  def prepare_index
70
- @collection = resource_class.roots
70
+ @collection = resource_class.reorder(lft: :asc)
71
71
  end
72
72
 
73
73
  private
@@ -99,7 +99,7 @@ class Releaf::Content::NodesController < Releaf::ActionController
99
99
 
100
100
  def copy_move_dialog_common
101
101
  @resource = resource_class.find params[:id]
102
- @collection = resource_class.roots
102
+ @collection = resource_class.reorder(lft: :asc)
103
103
  end
104
104
 
105
105
  def prepare_resource
@@ -0,0 +1,52 @@
1
+ module Releaf
2
+ module Content
3
+ class BuildRouteObjects
4
+ include Releaf::Service
5
+ include Releaf::InstanceCache
6
+
7
+ cache_instance_method :nodes
8
+
9
+ attribute :node_class
10
+ attribute :node_content_class
11
+ attribute :default_controller
12
+
13
+ def call
14
+ content_nodes.map { |node| build_route_object(node) }.compact
15
+ end
16
+
17
+ def content_nodes
18
+ nodes.select { |item| item.content_type == node_content_class.name }
19
+ end
20
+
21
+ def nodes
22
+ node_class.all
23
+ end
24
+
25
+ def build_route_object(node)
26
+ node.preloaded_self_and_ancestors = self_and_ancestors(node)
27
+
28
+ if node.available?
29
+ route = Releaf::Content::Route.new
30
+ route.node_class = node.class
31
+ route.node_id = node.id.to_s
32
+ route.path = build_path(node)
33
+ route.locale = node.self_and_ancestors_array.first.locale
34
+ route.default_controller = default_controller
35
+ route.site = Releaf::Content.routing[node.class.name][:site]
36
+ route
37
+ end
38
+ end
39
+
40
+ def self_and_ancestors(node)
41
+ nodes.select { |item| item.lft <= node.lft && item.rgt >= node.rgt }.sort_by(&:depth)
42
+ end
43
+
44
+ def build_path(node)
45
+ path = "/"
46
+ path += node.self_and_ancestors_array.map(&:slug).join("/")
47
+ path += node.trailing_slash_for_path? ? "/" : ""
48
+ path
49
+ end
50
+ end
51
+ end
52
+ end
@@ -11,12 +11,11 @@ module Releaf
11
11
  node.class.transaction do
12
12
  new_node = make_copy
13
13
  end
14
-
15
- new_node
16
14
  rescue ActiveRecord::RecordInvalid
17
15
  add_error_and_raise 'descendant invalid'
18
16
  else
19
17
  node.update_settings_timestamp
18
+ new_node
20
19
  end
21
20
  end
22
21
 
@@ -5,7 +5,7 @@ module Releaf
5
5
  attribute :parent_id, Integer, strict: false
6
6
 
7
7
  def call
8
- return if node.parent_id.to_i == parent_id
8
+ return node if node.parent_id.to_i == parent_id
9
9
 
10
10
  node.class.transaction do
11
11
  Releaf::Content::Node::SaveUnderParent.call(node: node, parent_id: parent_id)
@@ -15,6 +15,8 @@ module Releaf
15
15
  add_error_and_raise("descendant invalid")
16
16
  end
17
17
  end
18
+
19
+ node
18
20
  end
19
21
  end
20
22
  end
@@ -14,7 +14,7 @@ module Releaf
14
14
  end
15
15
 
16
16
  node.maintain_name
17
- node.reasign_slug
17
+ node.maintain_slug
18
18
  node.save!
19
19
  end
20
20
  end
@@ -51,7 +51,7 @@ module Releaf::Content
51
51
  end
52
52
 
53
53
  def attributes_to_not_copy
54
- list = %w[content_id depth id item_position lft rgt slug created_at updated_at]
54
+ list = %w[content_id depth id item_position lft rgt created_at updated_at]
55
55
  list << "locale" if locale_before_type_cast.blank?
56
56
  list
57
57
  end
@@ -84,6 +84,22 @@ module Releaf::Content
84
84
  end
85
85
  end
86
86
 
87
+ # Maintain unique slug within parent_id scope.
88
+ # If slug is not unique add numeric postfix.
89
+ def maintain_slug
90
+ postfix = nil
91
+ total_count = 0
92
+
93
+ while self.class.where(parent_id: parent_id, slug: "#{slug}#{postfix}").where("id != ?", id.to_i).exists? do
94
+ total_count += 1
95
+ postfix = "-#{total_count}"
96
+ end
97
+
98
+ if postfix
99
+ self.slug = "#{slug}#{postfix}"
100
+ end
101
+ end
102
+
87
103
  # Returns closest existing locale starting from object itself
88
104
  # @return [String] locale
89
105
  def locale
@@ -100,9 +116,11 @@ module Releaf::Content
100
116
  # Check whether object and all its ancestors are active
101
117
  # @return [Boolean] returns true if object is available
102
118
  def available?
103
- # There seams to be bug in Rails 4.0.0, that prevents us from using exists?
104
- # exists? will return nil or 1 in this query, instead of true/false (as it should)
105
- self_and_ancestors.where(active: false).any? == false
119
+ self_and_ancestors_array.all?(&:active?)
120
+ end
121
+
122
+ def self_and_ancestors_array
123
+ preloaded_self_and_ancestors.nil? ? self_and_ancestors.to_a : preloaded_self_and_ancestors
106
124
  end
107
125
 
108
126
  def reasign_slug
@@ -212,7 +230,9 @@ module Releaf::Content
212
230
 
213
231
  after_save :update_settings_timestamp, unless: :prevent_auto_update_settings_timestamp?
214
232
 
215
- acts_as_url :name, url_attribute: :slug, scope: :parent_id, :only_when_blank => true
233
+ acts_as_url :name, url_attribute: :slug, scope: :parent_id, only_when_blank: true
234
+
235
+ attr_accessor :preloaded_self_and_ancestors
216
236
  end
217
237
  end
218
238
  end
@@ -57,26 +57,15 @@ 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
- node_class.where(content_type: node_content_class).each.inject([]) do |routes, node|
61
- routes << build_route_object(node, default_controller) if node.available?
62
- routes
63
- end
60
+
61
+ Releaf::Content::BuildRouteObjects.call(
62
+ node_class: node_class,
63
+ node_content_class: node_content_class,
64
+ default_controller: default_controller)
64
65
  rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid
65
66
  []
66
67
  end
67
68
 
68
- # Build Content::Route from Node object
69
- def self.build_route_object(node, default_controller)
70
- route = new
71
- route.node_class = node.class
72
- route.node_id = node.id.to_s
73
- route.path = node.path
74
- route.locale = node.root.locale
75
- route.default_controller = default_controller
76
- route.site = Releaf::Content.routing[node.class.name][:site]
77
- route
78
- end
79
-
80
69
  def path_for(method_or_path, options)
81
70
  if method_or_path.include?('#')
82
71
  path
@@ -64,7 +64,7 @@ describe "Nodes services (copy, move)" do
64
64
 
65
65
  end
66
66
 
67
- describe "Basic node copying", create_nodes: true do
67
+ describe "Node copying", create_nodes: true do
68
68
  before create_nodes: true do
69
69
  @home_page_node = create(:home_page_node, locale: "lv")
70
70
  @home_page_node_2 = create(:home_page_node, locale: "en")
@@ -95,7 +95,7 @@ describe "Nodes services (copy, move)" do
95
95
  rescue ActiveRecord::RecordInvalid => e
96
96
  expect( e.record ).to eq @text_page_node_3
97
97
  end
98
- expect(@text_page_node_3.errors.messages).to eq(base: ["descendant invalid"])
98
+ expect(@text_page_node_3.errors.messages).to eq(name: [], base: ["descendant invalid"])
99
99
  end
100
100
 
101
101
  it "doesn't create any new nodes" do
@@ -203,6 +203,50 @@ describe "Nodes services (copy, move)" do
203
203
  expect{ @text_page_node_3.copy(@text_page_node_4.id) }.to raise_error(ActiveRecord::RecordInvalid)
204
204
  end
205
205
  end
206
+
207
+ describe "slug handling" do
208
+
209
+ before do
210
+ @nodes = {}
211
+
212
+ @nodes[:parent_one] = create(:text_page_node, parent: @home_page_node)
213
+ @nodes[:parent_two] = create(:text_page_node, parent: @home_page_node)
214
+
215
+ @nodes[:child] = create(:text_page_node, parent: @nodes[:parent_one], slug: "child-slug")
216
+ @nodes[:grandchild] = create(:text_page_node, parent: @nodes[:child], slug: "grandchild-slug")
217
+ @nodes[:great_grandchild] = create(:text_page_node, parent: @nodes[:grandchild], slug: "great-grandchild-slug")
218
+
219
+ @nodes[:other_child] = create(:text_page_node, parent: @nodes[:parent_two], slug: "other-child-slug")
220
+ end
221
+
222
+ context "when copying a node tree to a parent that already has a child node with the same slug" do
223
+ it "adds incremental index to the slug of the main copied node, preserving slugs of deeper descendants" do
224
+ @nodes[:other_child].update! slug: "child-slug"
225
+ @nodes[:child].copy( @nodes[:parent_two].id )
226
+
227
+ copy = @nodes[:parent_two].children.last
228
+
229
+ expect(copy.slug).to eq "child-slug-1"
230
+ expect(copy.children.map(&:slug)).to eq ["grandchild-slug"]
231
+ expect(copy.children.first.children.map(&:slug)).to eq ["great-grandchild-slug"]
232
+
233
+ end
234
+ end
235
+
236
+ context "when copying a node tree to a parent that does not have a child node with the same slug" do
237
+ it "copies slugs without any changes" do
238
+ @nodes[:child].copy( @nodes[:parent_two].id )
239
+ copy = @nodes[:parent_two].children.last
240
+
241
+ expect(copy.slug).to eq "child-slug"
242
+
243
+ expect(copy.children.map(&:slug)).to eq ["grandchild-slug"]
244
+ expect(copy.children.first.children.map(&:slug)).to eq ["great-grandchild-slug"]
245
+ end
246
+ end
247
+
248
+ end
249
+
206
250
  end
207
251
 
208
252
 
@@ -387,4 +431,7 @@ describe "Nodes services (copy, move)" do
387
431
  end
388
432
 
389
433
  end
434
+
435
+
436
+
390
437
  end
@@ -122,12 +122,12 @@ describe Node do
122
122
  describe "#attributes_to_not_copy" do
123
123
  it "returns array with attributes" do
124
124
  subject.locale = "lv"
125
- expect( subject.attributes_to_not_copy ).to match_array %w[content_id depth id item_position lft rgt slug created_at updated_at]
125
+ expect( subject.attributes_to_not_copy ).to match_array %w[content_id depth id item_position lft rgt created_at updated_at]
126
126
  end
127
127
 
128
128
  context "when locale is blank" do
129
129
  it "includes locale within returned list" do
130
- expect( subject.attributes_to_not_copy ).to match_array %w[content_id depth id item_position lft rgt slug created_at updated_at locale]
130
+ expect( subject.attributes_to_not_copy ).to match_array %w[content_id depth id item_position lft rgt created_at updated_at locale]
131
131
  end
132
132
  end
133
133
  end
@@ -237,6 +237,32 @@ describe Node do
237
237
  end
238
238
  end
239
239
 
240
+ describe "#maintain_slug" do
241
+ let(:root) { create(:home_page_node) }
242
+ let(:node) { create(:text_page_node, parent_id: root.id, name: "Test node", slug: "test-node") }
243
+ let(:sibling) { create(:text_page_node, parent_id: root.id, name: "Test node(1)", slug: "test-node-1") }
244
+
245
+ context "when node don't have sibling/s with same name" do
246
+ it "does not changes node's slug" do
247
+ new_node = Node.new(name: "another name", parent_id: root.id)
248
+ expect{ new_node.maintain_slug }.to_not change{new_node.slug}
249
+ end
250
+ end
251
+
252
+ context "when node have sibling/s with same slug" do
253
+ it "changes node's slug" do
254
+ new_node = Node.new(name: node.name, slug: node.slug, parent_id: root.id)
255
+ expect{ new_node.maintain_slug }.to change{new_node.slug}.from(node.slug).to("#{node.slug}-1")
256
+ end
257
+
258
+ it "increments node's slug number" do
259
+ sibling
260
+ new_node = Node.new(name: node.name, slug: node.slug, parent_id: root.id)
261
+ expect{ new_node.maintain_slug }.to change{new_node.slug}.from(node.slug).to("#{node.slug}-2")
262
+ end
263
+ end
264
+ end
265
+
240
266
  describe ".updated_at" do
241
267
  it "returns last node update time" do
242
268
  expect( Releaf::Settings ).to receive(:[]).with('releaf.content.nodes.updated_at').and_return('test')
@@ -213,62 +213,17 @@ describe Releaf::Content::Route do
213
213
  end
214
214
 
215
215
  context "when node table exists" do
216
- it "returns an array of Node::Route objects returned by build_route_object" do
217
- expect(described_class).to receive(:build_route_object).and_call_original
216
+ it "returns an array of Node::Route objects processed by Releaf::Content::BuildRouteObjects" do
217
+ expect(Releaf::Content::BuildRouteObjects).to receive(:call).with(node_class: Node, node_content_class: HomePage, default_controller: 'foo').and_call_original
218
218
  result = described_class.for(Node, HomePage, 'foo')
219
219
  expect(result.count).to eq(1)
220
220
  expect(result.first.class).to eq(described_class)
221
221
  end
222
222
 
223
- context "when node is not available" do
224
- it "does not include it in return" do
225
- allow_any_instance_of(Node).to receive(:available?).and_return(false)
226
- expect(described_class.for(Node, HomePage, 'foo')).to eq([])
227
- end
228
- end
229
-
230
223
  it "accepts node_class as string also" do
231
224
  result = described_class.for('Node', HomePage, 'foo')
232
225
  expect(result.count).to eq(1)
233
226
  end
234
-
235
- end
236
- end
237
-
238
-
239
- describe ".build_route_object" do
240
-
241
- let(:node) { create(:home_page_node, id: 23, locale: "lv", slug: "llvv") }
242
- let(:controller) { described_class.default_controller( node.class ) }
243
- let(:route) { described_class.build_route_object(node, controller) }
244
-
245
- it "returns a route instance" do
246
- expect(route).to be_a Releaf::Content::Route
247
- end
248
-
249
- it "assigns node_class from given node" do
250
- expect(route.node_class).to be Node
251
- end
252
-
253
- it "assigns node_id from given node" do
254
- expect(route.node_id).to eq "23"
255
- end
256
-
257
- it "assigns path from given node" do
258
- expect(route.path).to eq "/llvv"
259
- end
260
-
261
- it "assigns locale from given node" do
262
- expect(route.locale).to eq "lv"
263
- end
264
-
265
- it "assigns default_controller from given argument" do
266
- expect(route.default_controller).to be controller
267
- end
268
-
269
- it "assigns site from content routing configuration" do
270
- allow( Releaf::Content).to receive(:routing).and_return('Node' => {site: 'some_site'})
271
- expect(route.site).to eq 'some_site'
272
227
  end
273
228
  end
274
229
  end
@@ -0,0 +1,72 @@
1
+ require "rails_helper"
2
+
3
+ describe Releaf::Content::BuildRouteObjects do
4
+ let(:home_page_node) { create(:home_page_node, id: 23, locale: "lv", slug: "llvv") }
5
+ let(:node) { create(:text_page_node, id: 27, parent: home_page_node, slug: "some-text") }
6
+ let(:controller) { Releaf::Content::Route.default_controller( node.class ) }
7
+ let(:subject) { described_class.new(node_class: node.class, node_content_class: TextPage, default_controller: controller) }
8
+
9
+ describe "#call" do
10
+ it "returns an array" do
11
+ expect(subject.call).to be_a Array
12
+ end
13
+
14
+ it "returns an array of Node::Route objects" do
15
+ result = subject.call
16
+ expect(result.count).to eq(1)
17
+ expect(result.first.class).to eq(Releaf::Content::Route)
18
+ end
19
+ end
20
+
21
+ describe "#nodes" do
22
+ it "returns all nodes" do
23
+ expect(subject.nodes).to match_array([home_page_node, node])
24
+ end
25
+ end
26
+
27
+ describe "#content_nodes" do
28
+ it "returns nodes with a specified content class" do
29
+ expect(subject.content_nodes).to eq([node])
30
+ end
31
+ end
32
+
33
+ describe "#build_route_object" do
34
+ let(:route) { subject.build_route_object(node) }
35
+
36
+ context "when node is not available" do
37
+ it "does not include it in return" do
38
+ allow_any_instance_of(Node).to receive(:available?).and_return(false)
39
+ expect(route).to be_nil
40
+ end
41
+ end
42
+
43
+ it "returns a route instance" do
44
+ expect(route).to be_a Releaf::Content::Route
45
+ end
46
+
47
+ it "assigns node_class from given node" do
48
+ expect(route.node_class).to be Node
49
+ end
50
+
51
+ it "assigns node_id from given node" do
52
+ expect(route.node_id).to eq "27"
53
+ end
54
+
55
+ it "assigns path from given node" do
56
+ expect(route.path).to eq "/llvv/some-text"
57
+ end
58
+
59
+ it "assigns locale from given node" do
60
+ expect(route.locale).to eq "lv"
61
+ end
62
+
63
+ it "assigns default_controller from given argument" do
64
+ expect(route.default_controller).to be controller
65
+ end
66
+
67
+ it "assigns site from content routing configuration" do
68
+ allow( Releaf::Content).to receive(:routing).and_return('Node' => {site: 'some_site'})
69
+ expect(route.site).to eq 'some_site'
70
+ end
71
+ end
72
+ end
@@ -25,6 +25,13 @@ describe Releaf::Content::Node::Copy do
25
25
 
26
26
  let(:original) { create(content_factory, content_attributes) }
27
27
 
28
+ describe "#call" do
29
+ subject { described_class.new(node: node, parent_id: root_node.id ) }
30
+
31
+ it "returns node" do
32
+ expect(subject.call.class).to eq(node.class)
33
+ end
34
+ end
28
35
 
29
36
  describe "#make_copy" do
30
37
  # this is a double check to verify file duplication by doing the full copying process.
@@ -10,10 +10,10 @@ describe Releaf::Content::Node::Move do
10
10
 
11
11
  describe "#call" do
12
12
  context "when parent is same" do
13
- it "does nothing" do
13
+ it "does nothing and returns self" do
14
14
  node.parent_id = 12
15
15
  expect(node.class).to_not receive(:transaction)
16
- subject.call
16
+ expect(subject.call).to eq(node)
17
17
  end
18
18
  end
19
19
  end
@@ -19,9 +19,9 @@ describe Releaf::Content::Node::SaveUnderParent do
19
19
  expect( node.parent ).to eq node2
20
20
  end
21
21
 
22
- it "maintains node name, updates slug and then saves record" do
22
+ it "maintains node name and slug, then saves record" do
23
23
  expect( node ).to receive(:maintain_name).ordered.and_call_original
24
- expect( node ).to receive(:reasign_slug).ordered.and_call_original
24
+ expect( node ).to receive(:maintain_slug).ordered.and_call_original
25
25
  expect( node ).to receive(:save!).ordered.and_call_original
26
26
  subject.call
27
27
  end
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: 1.1.7
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-10 00:00:00.000000000 Z
11
+ date: 2017-12-15 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: 1.1.7
19
+ version: 1.1.9
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: 1.1.7
26
+ version: 1.1.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: stringex
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +87,7 @@ files:
87
87
  - app/builders/releaf/content/nodes/toolbox_builder.rb
88
88
  - app/controllers/releaf/content/nodes_controller.rb
89
89
  - app/middleware/releaf/content/routes_reloader.rb
90
+ - app/services/releaf/content/build_route_objects.rb
90
91
  - app/services/releaf/content/node/copy.rb
91
92
  - app/services/releaf/content/node/move.rb
92
93
  - app/services/releaf/content/node/save_under_parent.rb
@@ -122,6 +123,7 @@ files:
122
123
  - spec/lib/releaf/content/route_spec.rb
123
124
  - spec/middleware/routes_reloader_spec.rb
124
125
  - spec/routing/node_mapper_spec.rb
126
+ - spec/services/releaf/content/build_route_objects_spec.rb
125
127
  - spec/services/releaf/content/node/copy_spec.rb
126
128
  - spec/services/releaf/content/node/move_spec.rb
127
129
  - spec/services/releaf/content/node/save_under_parent_spec.rb
@@ -154,25 +156,26 @@ signing_key:
154
156
  specification_version: 4
155
157
  summary: Node and content routes support for releaf
156
158
  test_files:
157
- - spec/middleware/routes_reloader_spec.rb
158
- - spec/builders/content/nodes/toolbox_builder_spec.rb
159
159
  - spec/builders/content/nodes/action_dialog_spec.rb
160
160
  - spec/builders/content/nodes/content_form_builder_spec.rb
161
161
  - spec/builders/content/nodes/form_builder_spec.rb
162
+ - spec/builders/content/nodes/toolbox_builder_spec.rb
163
+ - spec/controllers/releaf/content/nodes_controller_spec.rb
162
164
  - spec/features/nodes_services_spec.rb
163
165
  - spec/features/nodes_spec.rb
164
- - spec/lib/releaf/content/node_spec.rb
166
+ - spec/fixtures/dummy.png
165
167
  - spec/lib/releaf/content/acts_as_node_spec.rb
166
168
  - spec/lib/releaf/content/configuration_spec.rb
167
169
  - spec/lib/releaf/content/engine_spec.rb
170
+ - spec/lib/releaf/content/node_spec.rb
168
171
  - spec/lib/releaf/content/route_spec.rb
169
- - spec/fixtures/dummy.png
170
- - spec/validators/content/node/singleness_validator_spec.rb
171
- - spec/validators/content/node/parent_validator_spec.rb
172
- - spec/validators/content/node/root_validator_spec.rb
172
+ - spec/middleware/routes_reloader_spec.rb
173
173
  - spec/routing/node_mapper_spec.rb
174
- - spec/controllers/releaf/content/nodes_controller_spec.rb
175
- - spec/services/releaf/content/node/save_under_parent_spec.rb
174
+ - spec/services/releaf/content/build_route_objects_spec.rb
176
175
  - spec/services/releaf/content/node/copy_spec.rb
177
- - spec/services/releaf/content/node/service_spec.rb
178
176
  - spec/services/releaf/content/node/move_spec.rb
177
+ - spec/services/releaf/content/node/save_under_parent_spec.rb
178
+ - spec/services/releaf/content/node/service_spec.rb
179
+ - spec/validators/content/node/parent_validator_spec.rb
180
+ - spec/validators/content/node/root_validator_spec.rb
181
+ - spec/validators/content/node/singleness_validator_spec.rb