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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/releaf_content_manifest.js +2 -0
  3. data/app/assets/javascripts/controllers/releaf/content/nodes.js +6 -9
  4. data/app/controllers/releaf/content/nodes_controller.rb +1 -1
  5. data/lib/releaf/content/engine.rb +2 -2
  6. data/lib/releaf/content/node.rb +3 -3
  7. data/lib/releaf/content/route.rb +0 -1
  8. metadata +12 -57
  9. data/spec/builders/content/nodes/action_dialog_spec.rb +0 -39
  10. data/spec/builders/content/nodes/content_form_builder_spec.rb +0 -24
  11. data/spec/builders/content/nodes/form_builder_spec.rb +0 -262
  12. data/spec/builders/content/nodes/toolbox_builder_spec.rb +0 -77
  13. data/spec/controllers/releaf/content/nodes_controller_spec.rb +0 -52
  14. data/spec/features/nodes_services_spec.rb +0 -437
  15. data/spec/features/nodes_spec.rb +0 -572
  16. data/spec/fixtures/dummy.png +0 -0
  17. data/spec/lib/releaf/content/acts_as_node_spec.rb +0 -90
  18. data/spec/lib/releaf/content/configuration_spec.rb +0 -159
  19. data/spec/lib/releaf/content/engine_spec.rb +0 -149
  20. data/spec/lib/releaf/content/node_spec.rb +0 -591
  21. data/spec/lib/releaf/content/route_spec.rb +0 -229
  22. data/spec/middleware/routes_reloader_spec.rb +0 -96
  23. data/spec/routing/node_mapper_spec.rb +0 -310
  24. data/spec/services/releaf/content/build_route_objects_spec.rb +0 -72
  25. data/spec/services/releaf/content/node/copy_spec.rb +0 -338
  26. data/spec/services/releaf/content/node/move_spec.rb +0 -20
  27. data/spec/services/releaf/content/node/save_under_parent_spec.rb +0 -49
  28. data/spec/services/releaf/content/node/service_spec.rb +0 -19
  29. data/spec/validators/content/node/parent_validator_spec.rb +0 -56
  30. data/spec/validators/content/node/root_validator_spec.rb +0 -69
  31. 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: f50bae97d36faa892d7625dc724a6bbc417fd17a1e7fc4775f6c2e90d47f63c5
4
- data.tar.gz: 5391252e2e4c227b8026e7a9e9ac134cd8eda185e5ca862f59551dccd1d266ed
3
+ metadata.gz: 05d7d2665a78cc7ba8d5c8eeb8f6a93da866a4fc80cdf3c62237105fb52759f7
4
+ data.tar.gz: 43f5443596612617c486584c239d9d1893519c1d014ed5fc9ab1d206ac049fd5
5
5
  SHA512:
6
- metadata.gz: 45e4e89c5086ca7ab9d0f9e9588409bc6d50ce3bb1de4624da61d63327169120f07af15881ca2ce286cb440bb482cfc1efd2b5542fa88f6f22f316543871a0b7
7
- data.tar.gz: 9da7c799086ee4bdfc14efaf536d4ab17326529168353397d4d5d11a487b92dde4f7a6f4d4208def12c680d0d0ae7141695469149b9d127a99cee01cabd0c1b5
6
+ metadata.gz: dac92e5f51f1c8987842000c396ccaf47cb3a5024b1bb5737d0876100be6d69ebb5792d6ba189b7458500c13947593ca37f50c6d1e45d0ebc4e0533eead2d9b4
7
+ data.tar.gz: b4dae906a59ea28006f3a65f0d03d82d8e09fc01a2652c8766980b0e9afa06c4fba84c6056e358e66c2a9dd86a58806b366909e0bcf5b752376a762f0400c03b
@@ -0,0 +1,2 @@
1
+ //= link controllers/releaf/content/nodes.css
2
+ //= link controllers/releaf/content/nodes.js
@@ -76,17 +76,14 @@ jQuery(function()
76
76
  slug_input.trigger('sluggenerate');
77
77
  });
78
78
 
79
- if (name_input.val() === '')
79
+ // bind onchange slug generation only if starting out with an empty name
80
+ name_input.on('change', function()
80
81
  {
81
- // bind onchange slug generation only if starting out with an empty name
82
- name_input.on('change', function()
82
+ if(slug_input.val().length === 0)
83
83
  {
84
- if(slug_input.val().length === 0)
85
- {
86
- slug_input.trigger('sluggenerate');
87
- }
88
- });
89
- }
84
+ slug_input.trigger('sluggenerate');
85
+ }
86
+ });
90
87
  }
91
88
 
92
89
  });
@@ -10,7 +10,7 @@ class Releaf::Content::NodesController < Releaf::ActionController
10
10
  tmp_resource.name = params[:name]
11
11
  tmp_resource.reasign_slug
12
12
 
13
- render text: tmp_resource.slug
13
+ render plain: tmp_resource.slug
14
14
  end
15
15
 
16
16
  def content_type_dialog
@@ -1,7 +1,7 @@
1
1
  module Releaf::Content
2
2
  class Engine < ::Rails::Engine
3
- initializer 'precompile', group: :all do |app|
4
- app.config.assets.precompile += %w(controllers/releaf/content/*)
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
@@ -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?
@@ -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,
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.21
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-29 00:00:00.000000000 Z
11
+ date: 2021-01-25 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.21
19
+ version: 2.1.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: 1.1.21
26
+ version: 2.1.1
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: 2.2.2
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: 2.2.2
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
@@ -108,34 +109,11 @@ files:
108
109
  - lib/releaf/content/node_mapper.rb
109
110
  - lib/releaf/content/route.rb
110
111
  - lib/releaf/content/router_proxy.rb
111
- - spec/builders/content/nodes/action_dialog_spec.rb
112
- - spec/builders/content/nodes/content_form_builder_spec.rb
113
- - spec/builders/content/nodes/form_builder_spec.rb
114
- - spec/builders/content/nodes/toolbox_builder_spec.rb
115
- - spec/controllers/releaf/content/nodes_controller_spec.rb
116
- - spec/features/nodes_services_spec.rb
117
- - spec/features/nodes_spec.rb
118
- - spec/fixtures/dummy.png
119
- - spec/lib/releaf/content/acts_as_node_spec.rb
120
- - spec/lib/releaf/content/configuration_spec.rb
121
- - spec/lib/releaf/content/engine_spec.rb
122
- - spec/lib/releaf/content/node_spec.rb
123
- - spec/lib/releaf/content/route_spec.rb
124
- - spec/middleware/routes_reloader_spec.rb
125
- - spec/routing/node_mapper_spec.rb
126
- - spec/services/releaf/content/build_route_objects_spec.rb
127
- - spec/services/releaf/content/node/copy_spec.rb
128
- - spec/services/releaf/content/node/move_spec.rb
129
- - spec/services/releaf/content/node/save_under_parent_spec.rb
130
- - spec/services/releaf/content/node/service_spec.rb
131
- - spec/validators/content/node/parent_validator_spec.rb
132
- - spec/validators/content/node/root_validator_spec.rb
133
- - spec/validators/content/node/singleness_validator_spec.rb
134
112
  homepage: https://github.com/cubesystems/releaf
135
113
  licenses:
136
114
  - MIT
137
115
  metadata: {}
138
- post_install_message:
116
+ post_install_message:
139
117
  rdoc_options: []
140
118
  require_paths:
141
119
  - lib
@@ -150,31 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
128
  - !ruby/object:Gem::Version
151
129
  version: '0'
152
130
  requirements: []
153
- rubygems_version: 3.0.2
154
- signing_key:
131
+ rubygems_version: 3.2.6
132
+ signing_key:
155
133
  specification_version: 4
156
134
  summary: Node and content routes support for releaf
157
- test_files:
158
- - spec/middleware/routes_reloader_spec.rb
159
- - spec/builders/content/nodes/toolbox_builder_spec.rb
160
- - spec/builders/content/nodes/action_dialog_spec.rb
161
- - spec/builders/content/nodes/content_form_builder_spec.rb
162
- - spec/builders/content/nodes/form_builder_spec.rb
163
- - spec/features/nodes_services_spec.rb
164
- - spec/features/nodes_spec.rb
165
- - spec/lib/releaf/content/node_spec.rb
166
- - spec/lib/releaf/content/acts_as_node_spec.rb
167
- - spec/lib/releaf/content/configuration_spec.rb
168
- - spec/lib/releaf/content/engine_spec.rb
169
- - spec/lib/releaf/content/route_spec.rb
170
- - spec/fixtures/dummy.png
171
- - spec/validators/content/node/singleness_validator_spec.rb
172
- - spec/validators/content/node/parent_validator_spec.rb
173
- - spec/validators/content/node/root_validator_spec.rb
174
- - spec/routing/node_mapper_spec.rb
175
- - spec/controllers/releaf/content/nodes_controller_spec.rb
176
- - spec/services/releaf/content/build_route_objects_spec.rb
177
- - spec/services/releaf/content/node/save_under_parent_spec.rb
178
- - spec/services/releaf/content/node/copy_spec.rb
179
- - spec/services/releaf/content/node/service_spec.rb
180
- - 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 }
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 }
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 }
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