releaf-content 2.0.0 → 2.0.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
- metadata +5 -51
- 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 -573
- 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 -593
- 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 -311
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 247c29199dd1b9cdf4b27dd61e0d49fd2022c6202a6fcd3056cd5380b05d1414
|
4
|
+
data.tar.gz: fd3de41c90ceaf40c064758159962ec5c44b1c75445e8267b964e4e90b3a80f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d10d6bf6b1994b58a1825288ad4aef3d542a1f0cf942e25d5199770490b7d07bd7a8630d104c0d352e93d1b12de93ed9e69ea17645ad1f25a787bd9389a138
|
7
|
+
data.tar.gz: 0bbf98d57200bef2f370958afffd43ec490390b7ed2128485ff545a179ef8cadcd7b599e983f179610a014d53b50aa83765368a967c93093cb0c5f10007d0f9f
|
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: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-14 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: 2.0.
|
19
|
+
version: 2.0.1
|
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: 2.0.
|
26
|
+
version: 2.0.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: stringex
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,29 +109,6 @@ files:
|
|
109
109
|
- lib/releaf/content/node_mapper.rb
|
110
110
|
- lib/releaf/content/route.rb
|
111
111
|
- lib/releaf/content/router_proxy.rb
|
112
|
-
- spec/builders/content/nodes/action_dialog_spec.rb
|
113
|
-
- spec/builders/content/nodes/content_form_builder_spec.rb
|
114
|
-
- spec/builders/content/nodes/form_builder_spec.rb
|
115
|
-
- spec/builders/content/nodes/toolbox_builder_spec.rb
|
116
|
-
- spec/controllers/releaf/content/nodes_controller_spec.rb
|
117
|
-
- spec/features/nodes_services_spec.rb
|
118
|
-
- spec/features/nodes_spec.rb
|
119
|
-
- spec/fixtures/dummy.png
|
120
|
-
- spec/lib/releaf/content/acts_as_node_spec.rb
|
121
|
-
- spec/lib/releaf/content/configuration_spec.rb
|
122
|
-
- spec/lib/releaf/content/engine_spec.rb
|
123
|
-
- spec/lib/releaf/content/node_spec.rb
|
124
|
-
- spec/lib/releaf/content/route_spec.rb
|
125
|
-
- spec/middleware/routes_reloader_spec.rb
|
126
|
-
- spec/routing/node_mapper_spec.rb
|
127
|
-
- spec/services/releaf/content/build_route_objects_spec.rb
|
128
|
-
- spec/services/releaf/content/node/copy_spec.rb
|
129
|
-
- spec/services/releaf/content/node/move_spec.rb
|
130
|
-
- spec/services/releaf/content/node/save_under_parent_spec.rb
|
131
|
-
- spec/services/releaf/content/node/service_spec.rb
|
132
|
-
- spec/validators/content/node/parent_validator_spec.rb
|
133
|
-
- spec/validators/content/node/root_validator_spec.rb
|
134
|
-
- spec/validators/content/node/singleness_validator_spec.rb
|
135
112
|
homepage: https://github.com/cubesystems/releaf
|
136
113
|
licenses:
|
137
114
|
- MIT
|
@@ -155,27 +132,4 @@ rubygems_version: 3.0.8
|
|
155
132
|
signing_key:
|
156
133
|
specification_version: 4
|
157
134
|
summary: Node and content routes support for releaf
|
158
|
-
test_files:
|
159
|
-
- spec/middleware/routes_reloader_spec.rb
|
160
|
-
- spec/builders/content/nodes/toolbox_builder_spec.rb
|
161
|
-
- spec/builders/content/nodes/action_dialog_spec.rb
|
162
|
-
- spec/builders/content/nodes/content_form_builder_spec.rb
|
163
|
-
- spec/builders/content/nodes/form_builder_spec.rb
|
164
|
-
- spec/features/nodes_services_spec.rb
|
165
|
-
- spec/features/nodes_spec.rb
|
166
|
-
- spec/lib/releaf/content/node_spec.rb
|
167
|
-
- spec/lib/releaf/content/acts_as_node_spec.rb
|
168
|
-
- spec/lib/releaf/content/configuration_spec.rb
|
169
|
-
- spec/lib/releaf/content/engine_spec.rb
|
170
|
-
- spec/lib/releaf/content/route_spec.rb
|
171
|
-
- spec/fixtures/dummy.png
|
172
|
-
- spec/validators/content/node/singleness_validator_spec.rb
|
173
|
-
- spec/validators/content/node/parent_validator_spec.rb
|
174
|
-
- spec/validators/content/node/root_validator_spec.rb
|
175
|
-
- spec/routing/node_mapper_spec.rb
|
176
|
-
- spec/controllers/releaf/content/nodes_controller_spec.rb
|
177
|
-
- spec/services/releaf/content/build_route_objects_spec.rb
|
178
|
-
- spec/services/releaf/content/node/save_under_parent_spec.rb
|
179
|
-
- spec/services/releaf/content/node/copy_spec.rb
|
180
|
-
- spec/services/releaf/content/node/service_spec.rb
|
181
|
-
- spec/services/releaf/content/node/move_spec.rb
|
135
|
+
test_files: []
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Releaf::Content::Builders::ActionDialog, type: :class do
|
4
|
-
class ConfirmDestroyDialogTestHelper < ActionView::Base
|
5
|
-
include Releaf::ApplicationHelper
|
6
|
-
end
|
7
|
-
|
8
|
-
class ActionDialogIncluder
|
9
|
-
include Releaf::Content::Builders::ActionDialog
|
10
|
-
def action; end
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:template){ ConfirmDestroyDialogTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
14
|
-
let(:object){ Book.new }
|
15
|
-
let(:subject){ ActionDialogIncluder.new(template) }
|
16
|
-
|
17
|
-
describe "#confirm_button_text" do
|
18
|
-
it "returns translation for humanized builder action" do
|
19
|
-
allow(subject).to receive(:action).and_return(:move_to_the_right)
|
20
|
-
allow(subject).to receive(:t).with("Move to the right").and_return("to the left")
|
21
|
-
expect(subject.confirm_button_text).to eq("to the left")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#confirm_button_attributes" do
|
26
|
-
it "returns hash with confirm button attributes" do
|
27
|
-
expect(subject.confirm_button_attributes).to be_instance_of Hash
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#confirm_button" do
|
32
|
-
it "returns confirm button" do
|
33
|
-
allow(subject).to receive(:confirm_button_text).and_return("Yess")
|
34
|
-
allow(subject).to receive(:confirm_button_attributes).and_return(a: "b")
|
35
|
-
allow(subject).to receive(:button).with("Yess", "check", a: "b").and_return("x")
|
36
|
-
expect(subject.confirm_button).to eq("x")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Releaf::Content::Nodes::ContentFormBuilder, type: :class do
|
4
|
-
class FormBuilderTestHelper < ActionView::Base
|
5
|
-
include Releaf::ApplicationHelper
|
6
|
-
include Releaf::ButtonHelper
|
7
|
-
include FontAwesome::Rails::IconHelper
|
8
|
-
def controller_scope_name; end
|
9
|
-
def generate_url_releaf_content_nodes_path(args); end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:template){ FormBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
13
|
-
let(:node){ Node.new(content_type: "TextPage", slug: "b", id: 2,
|
14
|
-
parent: Node.new(content_type: "TextPage", slug: "a", id: 1)) }
|
15
|
-
let(:object){ node.build_content }
|
16
|
-
let(:subject){ described_class.new(:resource, object, template, {}) }
|
17
|
-
|
18
|
-
describe "#field_names" do
|
19
|
-
it "returns array of node content object fields" do
|
20
|
-
allow(object.class).to receive(:acts_as_node_fields).and_return(["a", "b"])
|
21
|
-
expect(subject.field_names).to eq(["a", "b"])
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,262 +0,0 @@
|
|
1
|
-
require "rails_helper"
|
2
|
-
|
3
|
-
describe Releaf::Content::Nodes::FormBuilder, type: :class do
|
4
|
-
class FormBuilderTestHelper < ActionView::Base
|
5
|
-
include Releaf::ApplicationHelper
|
6
|
-
include Releaf::ButtonHelper
|
7
|
-
include FontAwesome::Rails::IconHelper
|
8
|
-
def controller_scope_name; end
|
9
|
-
def generate_url_releaf_content_nodes_path(args); end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:template){ FormBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
13
|
-
let(:object){ Node.new(content_type: "TextPage", slug: "b", id: 2,
|
14
|
-
parent: Node.new(content_type: "TextPage", slug: "a", id: 1)) }
|
15
|
-
let(:subject){ described_class.new(:resource, object, template, {}) }
|
16
|
-
|
17
|
-
describe "#field_names" do
|
18
|
-
it "returns hidden, node and content object fields" do
|
19
|
-
expect(subject.field_names).to eq(["node_fields_block", "content_fields_block"])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#node_fields" do
|
24
|
-
it "returns array with renderable node fields" do
|
25
|
-
list = [:parent_id, :name, :content_type, :slug, :item_position, :active, :locale]
|
26
|
-
expect(subject.node_fields).to eq(list)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#render_node_fields_block" do
|
31
|
-
it "renders node fields" do
|
32
|
-
allow(subject).to receive(:node_fields).and_return([1, 2])
|
33
|
-
allow(subject).to receive(:releaf_fields).with([1, 2]).and_return("x")
|
34
|
-
content = '<div class="section node-fields">x</div>'
|
35
|
-
expect(subject.render_node_fields_block).to eq(content)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "#render_parent_id" do
|
40
|
-
it "renders hidden parent if field for new object" do
|
41
|
-
allow(subject.object).to receive(:new_record?).and_return(true)
|
42
|
-
allow(subject).to receive(:hidden_field).with(:parent_id).and_return("x")
|
43
|
-
expect(subject.render_parent_id).to eq("x")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "renders nothing for existing object" do
|
47
|
-
allow(subject.object).to receive(:new_record?).and_return(false)
|
48
|
-
expect(subject.render_parent_id).to eq(nil)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "#render_content_fields_block?" do
|
53
|
-
before do
|
54
|
-
subject.object.build_content
|
55
|
-
end
|
56
|
-
|
57
|
-
it "returns array of node content object fields" do
|
58
|
-
allow(object.content_class).to receive(:respond_to?).with(:acts_as_node_fields).and_return(true)
|
59
|
-
expect(subject.render_content_fields_block?).to be true
|
60
|
-
end
|
61
|
-
|
62
|
-
context "when object content class do not respond to `acts_as_node_fields`" do
|
63
|
-
it "returns nil" do
|
64
|
-
allow(object.content_class).to receive(:respond_to?).with(:acts_as_node_fields).and_return(false)
|
65
|
-
expect(subject.render_content_fields_block?).to be false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#render_content_fields_block" do
|
71
|
-
before do
|
72
|
-
subject.object.build_content
|
73
|
-
end
|
74
|
-
|
75
|
-
it "renders content fields block" do
|
76
|
-
allow(subject).to receive(:content_builder_class).and_return("_b_")
|
77
|
-
allow(subject).to receive(:render_content_fields_block?).and_return(true)
|
78
|
-
subform = described_class.new(:resource, object, template, {})
|
79
|
-
allow(subject).to receive(:fields_for).with(:content, subject.object.content, builder: "_b_").and_yield(subform)
|
80
|
-
allow(subform).to receive(:field_names).and_return([1, 2])
|
81
|
-
allow(subform).to receive(:releaf_fields).with([1, 2]).and_return("yy")
|
82
|
-
content = '<div class="section content-fields">yy</div>'
|
83
|
-
expect(subject.render_content_fields_block).to eq(content)
|
84
|
-
end
|
85
|
-
|
86
|
-
it "casts form fields to array before passign to `releaf_fields`" do
|
87
|
-
allow(subject).to receive(:content_builder_class).and_return("_b_")
|
88
|
-
allow(subject).to receive(:render_content_fields_block?).and_return(true)
|
89
|
-
subform = described_class.new(:resource, object, template, {})
|
90
|
-
allow(subject).to receive(:fields_for).with(:content, subject.object.content, builder: "_b_").and_yield(subform)
|
91
|
-
allow(subform).to receive(:field_names).and_return({a: 1, b: 2})
|
92
|
-
expect(subform).to receive(:releaf_fields).with([[:a, 1], [:b, 2]])
|
93
|
-
subject.render_content_fields_block
|
94
|
-
end
|
95
|
-
|
96
|
-
context "when content have no fields" do
|
97
|
-
it "returns nil" do
|
98
|
-
allow(subject).to receive(:render_content_fields_block?).and_return(false)
|
99
|
-
expect(subject.render_content_fields_block).to be nil
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
describe "#content_builder_class" do
|
105
|
-
it "returns `Releaf::Content::Nodes::ContentFormBuilder`" do
|
106
|
-
expect(subject.content_builder_class).to eq(Releaf::Content::Nodes::ContentFormBuilder)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe "#render_locale" do
|
111
|
-
context "when node node has locale select enabled" do
|
112
|
-
it "renders locale with #render_locale_options" do
|
113
|
-
allow(subject.object).to receive(:locale_selection_enabled?).and_return(true)
|
114
|
-
allow(subject).to receive(:render_locale_options).and_return(a: "b")
|
115
|
-
allow(subject).to receive(:releaf_item_field).with(:locale, options: {a: "b"}).and_return("x")
|
116
|
-
expect(subject.render_locale).to eq("x")
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context "when node node does not have locale select enabled" do
|
121
|
-
it "renders locale with #render_locale_options" do
|
122
|
-
allow(subject.object).to receive(:locale_selection_enabled?).and_return(false)
|
123
|
-
expect(subject.render_locale).to be nil
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "#render_locale_options" do
|
129
|
-
it "returns :select_options and :include_blank values" do
|
130
|
-
expect(subject.render_locale_options.keys).to eq([:select_options, :include_blank])
|
131
|
-
end
|
132
|
-
|
133
|
-
it ":select_options contains all available locales" do
|
134
|
-
allow(I18n).to receive(:available_locales).and_return([:lt, :et])
|
135
|
-
expect(subject.render_locale_options[:select_options]).to eq([:lt, :et])
|
136
|
-
end
|
137
|
-
|
138
|
-
context "when subject have defined locale" do
|
139
|
-
it ":include_blank is false" do
|
140
|
-
subject.object.locale = :lt
|
141
|
-
expect(subject.render_locale_options[:include_blank]).to be false
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context "when subject have no locale" do
|
146
|
-
it ":include_blank is true" do
|
147
|
-
subject.object.locale = nil
|
148
|
-
expect(subject.render_locale_options[:include_blank]).to be true
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "#render_content_type" do
|
154
|
-
it "renders disabled content type field with localized content type value" do
|
155
|
-
options = {disabled: true, value: "Translated content type"}
|
156
|
-
allow(I18n).to receive(:t).with("text_page", scope: "admin.content_types").and_return("Translated content type")
|
157
|
-
allow(subject).to receive(:releaf_text_field).with(:content_type, input: options).and_return("x")
|
158
|
-
expect(subject.render_content_type).to eq("x")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "#slug_base_url" do
|
163
|
-
before do
|
164
|
-
request = double(:request, protocol: "http:://", host_with_port: "somehost:8080")
|
165
|
-
allow(subject).to receive(:request).and_return(request)
|
166
|
-
allow(object).to receive(:parent).and_return(Node.new)
|
167
|
-
end
|
168
|
-
|
169
|
-
context "when trailing slash for path enabled" do
|
170
|
-
it "returns absolute url without extra slash added" do
|
171
|
-
allow(object).to receive(:trailing_slash_for_path?).and_return(true)
|
172
|
-
allow(object.parent).to receive(:path).and_return("/parent/path/")
|
173
|
-
expect(subject.slug_base_url).to eq("http:://somehost:8080/parent/path/")
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context "when trailing slash for path disabled" do
|
178
|
-
it "returns absolute url with extra slash added" do
|
179
|
-
allow(object).to receive(:trailing_slash_for_path?).and_return(false)
|
180
|
-
allow(object.parent).to receive(:path).and_return("/parent/path")
|
181
|
-
expect(subject.slug_base_url).to eq("http:://somehost:8080/parent/path/")
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe "#slug_link" do
|
187
|
-
before do
|
188
|
-
allow(subject).to receive(:slug_base_url).and_return("http://some.host/parent/path/")
|
189
|
-
end
|
190
|
-
|
191
|
-
context "when trailing slash for path enabled" do
|
192
|
-
it "returns absolute url without extra slash added" do
|
193
|
-
allow(object).to receive(:trailing_slash_for_path?).and_return(true)
|
194
|
-
expect(subject.slug_link).to eq('<a href="/a/b/">http://some.host/parent/path/<span>b</span>/</a>')
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context "when trailing slash for path disabled" do
|
199
|
-
it "returns absolute url with extra slash added" do
|
200
|
-
allow(object).to receive(:trailing_slash_for_path?).and_return(false)
|
201
|
-
expect(subject.slug_link).to eq('<a href="/a/b">http://some.host/parent/path/<span>b</span></a>')
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe "#render_slug" do
|
207
|
-
it "renders customized field" do
|
208
|
-
controller = Admin::NodesController.new
|
209
|
-
allow(subject).to receive(:controller).and_return(controller)
|
210
|
-
allow(subject).to receive(:slug_base_url).and_return("http://localhost/parent")
|
211
|
-
allow(subject).to receive(:url_for).with(controller: "admin/nodes", action: "generate_url", parent_id: 1, id: 2)
|
212
|
-
.and_return("http://localhost/slug-generation-url")
|
213
|
-
|
214
|
-
content = '
|
215
|
-
<div class="field type-text" data-name="slug">
|
216
|
-
<div class="label-wrap">
|
217
|
-
<label for="resource_slug">Slug</label>
|
218
|
-
</div>
|
219
|
-
<div class="value">
|
220
|
-
<input value="b" class="text" data-generator-url="http://localhost/slug-generation-url" type="text" name="resource[slug]" id="resource_slug" />
|
221
|
-
<button class="button only-icon secondary generate" title="Suggest slug" type="button" autocomplete="off">
|
222
|
-
<i class="fa fa-keyboard-o"></i>
|
223
|
-
</button>
|
224
|
-
<div class="link">
|
225
|
-
<a href="/a/b">http://localhost/parent<span>b</span></a>
|
226
|
-
</div>
|
227
|
-
</div>
|
228
|
-
</div>
|
229
|
-
'
|
230
|
-
|
231
|
-
expect(subject.render_slug).to match_html(content)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
describe "#render_item_position" do
|
236
|
-
it "renders locale with #item_position_options" do
|
237
|
-
allow(subject).to receive(:item_position_options).and_return(a: "b")
|
238
|
-
allow(subject).to receive(:releaf_item_field).with(:item_position, options: {a: "b"}).and_return("x")
|
239
|
-
expect(subject.render_item_position).to eq("x")
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
describe "#item_position_options" do
|
244
|
-
before do
|
245
|
-
object.item_position = 2
|
246
|
-
allow(subject).to receive(:item_position_select_options).and_return([["a", 1], ["b", 2], ["c", 3]])
|
247
|
-
end
|
248
|
-
|
249
|
-
it "returns :select_options and :include_blank values" do
|
250
|
-
expect(subject.item_position_options.keys).to eq([:include_blank, :select_options])
|
251
|
-
end
|
252
|
-
|
253
|
-
it ":select_options correct select options" do
|
254
|
-
options = '<option value="1">a</option>'
|
255
|
-
options << "\n"
|
256
|
-
options << '<option selected="selected" value="2">b</option>'
|
257
|
-
options << "\n"
|
258
|
-
options << '<option value="3">c</option>'
|
259
|
-
expect(subject.item_position_options[:select_options]).to eq(options)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Releaf::Content::Nodes::ToolboxBuilder, type: :class do
|
4
|
-
|
5
|
-
class NodeToolboxBuilderTestHelper < ActionView::Base
|
6
|
-
include Releaf::ButtonHelper
|
7
|
-
include Releaf::ApplicationHelper
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:template){ NodeToolboxBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
|
11
|
-
subject { described_class.new(template) }
|
12
|
-
|
13
|
-
let(:node){ Node.new(content_type: "TextPage", slug: "a", id: 99) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
allow(subject).to receive(:resource).and_return(node)
|
17
|
-
allow(subject).to receive(:destroy_confirmation_link).and_return(:super_item)
|
18
|
-
allow(subject).to receive(:feature_available?).with(:destroy).and_return true
|
19
|
-
end
|
20
|
-
|
21
|
-
it "extends Releaf::Builders::ToolboxBuilder" do
|
22
|
-
expect(described_class.ancestors).to include Releaf::Builders::ToolboxBuilder
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "#items" do
|
26
|
-
|
27
|
-
before do
|
28
|
-
allow(subject).to receive(:params).and_return({})
|
29
|
-
allow(subject).to receive(:add_child_button).and_return( :add_child_item )
|
30
|
-
allow(subject).to receive(:copy_button).and_return( :copy_item )
|
31
|
-
allow(subject).to receive(:move_button).and_return( :move_item )
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when applied to a new record" do
|
35
|
-
|
36
|
-
it "returns only items returned by parent class" do
|
37
|
-
allow(node).to receive(:new_record?).and_return true
|
38
|
-
expect(subject.items).to eq([ :super_item ])
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "item methods" do
|
46
|
-
|
47
|
-
describe "#add_child_button" do
|
48
|
-
it "returns an ajaxbox link to content type dialog" do
|
49
|
-
allow(subject).to receive(:t).with('Add child').and_return('addchildxx')
|
50
|
-
allow(subject).to receive(:url_for).with(action: 'content_type_dialog', parent_id: 99).and_return('dialogurl')
|
51
|
-
html = '<a class="button ajaxbox" title="addchildxx" href="dialogurl">addchildxx</a>'
|
52
|
-
expect(subject.add_child_button).to eq(html)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#copy_button" do
|
57
|
-
it "returns an ajaxbox link to copy dialog" do
|
58
|
-
allow(subject).to receive(:t).with('Copy').and_return('copyxx')
|
59
|
-
allow(subject).to receive(:url_for).with(action: 'copy_dialog', id: 99).and_return('dialogurl')
|
60
|
-
html = '<a class="button ajaxbox" title="copyxx" href="dialogurl">copyxx</a>'
|
61
|
-
expect(subject.copy_button).to eq(html)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
describe "#move_button" do
|
67
|
-
it "returns an ajaxbox link to move dialog" do
|
68
|
-
allow(subject).to receive(:t).with('Move').and_return('movexx')
|
69
|
-
allow(subject).to receive(:url_for).with(action: 'move_dialog', id: 99).and_return('dialogurl')
|
70
|
-
html = '<a class="button ajaxbox" title="movexx" href="dialogurl">movexx</a>'
|
71
|
-
expect(subject.move_button).to eq(html)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|