releaf-core 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. metadata +3 -193
  3. data/spec/builders/releaf/builders/association_reflector_spec.rb +0 -138
  4. data/spec/builders/releaf/builders/base_spec.rb +0 -272
  5. data/spec/builders/releaf/builders/collection_spec.rb +0 -18
  6. data/spec/builders/releaf/builders/confirm_destroy_dialog_builder_spec.rb +0 -71
  7. data/spec/builders/releaf/builders/confirm_dialog_builder_spec.rb +0 -107
  8. data/spec/builders/releaf/builders/edit_builder_spec.rb +0 -322
  9. data/spec/builders/releaf/builders/form_builder/associations_spec.rb +0 -129
  10. data/spec/builders/releaf/builders/form_builder/date_fields_spec.rb +0 -86
  11. data/spec/builders/releaf/builders/form_builder/i18n_fields_spec.rb +0 -48
  12. data/spec/builders/releaf/builders/form_builder/label_spec.rb +0 -106
  13. data/spec/builders/releaf/builders/form_builder/number_fields_spec.rb +0 -37
  14. data/spec/builders/releaf/builders/form_builder_spec.rb +0 -228
  15. data/spec/builders/releaf/builders/index_builder_spec.rb +0 -364
  16. data/spec/builders/releaf/builders/page/header_builder_spec.rb +0 -66
  17. data/spec/builders/releaf/builders/page/layout_builder_spec.rb +0 -237
  18. data/spec/builders/releaf/builders/page/menu_builder_spec.rb +0 -345
  19. data/spec/builders/releaf/builders/pagination_builder_spec.rb +0 -330
  20. data/spec/builders/releaf/builders/resource_dialog_spec.rb +0 -21
  21. data/spec/builders/releaf/builders/resource_view_spec.rb +0 -158
  22. data/spec/builders/releaf/builders/show_builder_spec.rb +0 -7
  23. data/spec/builders/releaf/builders/table_builder_spec.rb +0 -637
  24. data/spec/builders/releaf/builders/template_spec.rb +0 -12
  25. data/spec/builders/releaf/builders/toolbox_builder_spec.rb +0 -67
  26. data/spec/builders/releaf/builders/toolbox_spec.rb +0 -48
  27. data/spec/builders/releaf/builders/utilities/date_fields_spec.rb +0 -125
  28. data/spec/builders/releaf/builders/utilities/resolve_attribute_field_method_name_spec.rb +0 -318
  29. data/spec/builders/releaf/builders/view_spec.rb +0 -281
  30. data/spec/builders/releaf/builders_spec.rb +0 -144
  31. data/spec/builders/releaf/settings/form_builder_spec.rb +0 -48
  32. data/spec/builders/releaf/settings/table_builder_spec.rb +0 -23
  33. data/spec/controllers/concerns/releaf/richtext_attachments_spec.rb +0 -51
  34. data/spec/controllers/releaf/action_controller_spec.rb +0 -423
  35. data/spec/controllers/releaf/root_controller_spec.rb +0 -46
  36. data/spec/controllers/releaf/settings_controller_spec.rb +0 -52
  37. data/spec/error_hash_builder_spec.rb +0 -83
  38. data/spec/ext/array_reorder_spec.rb +0 -12
  39. data/spec/features/ajaxbox_spec.rb +0 -111
  40. data/spec/features/authorization_spec.rb +0 -50
  41. data/spec/features/breadcrumbs_spec.rb +0 -16
  42. data/spec/features/dragonfly_integration_spec.rb +0 -24
  43. data/spec/features/edit_actions_spec.rb +0 -186
  44. data/spec/features/errors_spec.rb +0 -47
  45. data/spec/features/index_actions_spec.rb +0 -86
  46. data/spec/features/index_table_spec.rb +0 -35
  47. data/spec/features/menu_spec.rb +0 -71
  48. data/spec/features/richtext_attachments_spec.rb +0 -64
  49. data/spec/features/richtext_custom_config_spec.rb +0 -28
  50. data/spec/features/richtext_embed_spec.rb +0 -29
  51. data/spec/features/richtext_spec.rb +0 -31
  52. data/spec/features/search_spec.rb +0 -825
  53. data/spec/features/settings_spec.rb +0 -70
  54. data/spec/features/title_spec.rb +0 -13
  55. data/spec/fixtures/common_fields.yml +0 -17
  56. data/spec/fixtures/cs.png +0 -0
  57. data/spec/fixtures/time.formats.xlsx +0 -0
  58. data/spec/fixtures/unicorn.jpg +0 -0
  59. data/spec/helpers/application_helper_spec.rb +0 -73
  60. data/spec/helpers/button_helper_spec.rb +0 -146
  61. data/spec/lib/releaf/action_controller/features_spec.rb +0 -171
  62. data/spec/lib/releaf/action_controller/search_spec.rb +0 -84
  63. data/spec/lib/releaf/application_spec.rb +0 -43
  64. data/spec/lib/releaf/assets_resolver_spec.rb +0 -130
  65. data/spec/lib/releaf/build_errors_hash_spec.rb +0 -141
  66. data/spec/lib/releaf/configuration_spec.rb +0 -205
  67. data/spec/lib/releaf/controller_definition_spec.rb +0 -78
  68. data/spec/lib/releaf/controller_group_definition_spec.rb +0 -33
  69. data/spec/lib/releaf/default_searchable_fields_spec.rb +0 -161
  70. data/spec/lib/releaf/instance_cache_spec.rb +0 -98
  71. data/spec/lib/releaf/resource_base_spec.rb +0 -212
  72. data/spec/lib/releaf/resource_fields_spec.rb +0 -12
  73. data/spec/lib/releaf/resource_params_spec.rb +0 -115
  74. data/spec/lib/releaf/resource_table_fields_spec.rb +0 -20
  75. data/spec/lib/releaf/resource_utilities_spec.rb +0 -87
  76. data/spec/lib/releaf/responders/access_denied_responder_spec.rb +0 -12
  77. data/spec/lib/releaf/responders/after_save_responder_spec.rb +0 -88
  78. data/spec/lib/releaf/responders/confirm_destroy_responder_spec.rb +0 -26
  79. data/spec/lib/releaf/responders/destroy_responder_spec.rb +0 -30
  80. data/spec/lib/releaf/responders/error_responder_spec.rb +0 -26
  81. data/spec/lib/releaf/responders/feature_disabled_responder_spec.rb +0 -12
  82. data/spec/lib/releaf/responders/page_not_found_responder_spec.rb +0 -12
  83. data/spec/lib/releaf/responders_spec.rb +0 -61
  84. data/spec/lib/releaf/root/configuration_spec.rb +0 -9
  85. data/spec/lib/releaf/root/default_controller_resolver_spec.rb +0 -44
  86. data/spec/lib/releaf/root_spec.rb +0 -13
  87. data/spec/lib/releaf/service_spec.rb +0 -20
  88. data/spec/lib/releaf/settings/normalize_value_spec.rb +0 -103
  89. data/spec/lib/releaf/settings/register_spec.rb +0 -135
  90. data/spec/lib/releaf/settings_manager_spec.rb +0 -22
  91. data/spec/lib/validation_error_codes_spec.rb +0 -56
  92. data/spec/misc/factories_spec.rb +0 -31
  93. data/spec/models/settings_spec.rb +0 -104
  94. data/spec/routing/route_mapper_spec.rb +0 -185
  95. data/spec/rspec_helpers/test_helpers_spec.rb +0 -20
  96. data/spec/rspec_helpers/test_spec.rb +0 -14
  97. data/spec/services/array/reorder_spec.rb +0 -121
@@ -1,281 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::Builders::View, type: :class do
4
- class ViewTestHelper < ActionView::Base
5
- include FontAwesome::Rails::IconHelper
6
- end
7
-
8
- class ViewTestIncluder
9
- include Releaf::Builders::Base
10
- include Releaf::Builders::Template
11
- include Releaf::Builders::View
12
- end
13
-
14
- subject { ViewTestIncluder.new(template) }
15
- let(:template){ ViewTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
16
-
17
- it "includes Releaf::Builders::Base" do
18
- expect(described_class.ancestors).to include(Releaf::Builders::Base)
19
- end
20
-
21
- it "includes Releaf::Builders::Template" do
22
- expect(described_class.ancestors).to include(Releaf::Builders::Template)
23
- end
24
-
25
- describe "#output" do
26
- before do
27
- allow(subject).to receive(:header).and_return(ActiveSupport::SafeBuffer.new("<"))
28
- allow(subject).to receive(:section).and_return(ActiveSupport::SafeBuffer.new(">"))
29
- end
30
-
31
- it "returns safely joined header and section outputs" do
32
- allow(subject).to receive(:dialog?).and_return(false)
33
- expect(subject.output).to eq("<>")
34
- end
35
-
36
- context "within dialog" do
37
- it "does not return header content" do
38
- allow(subject).to receive(:dialog?).and_return(true)
39
- expect(subject.output).to eq(">")
40
- end
41
- end
42
- end
43
-
44
- describe "#dialog?" do
45
- let(:controller){ Releaf::ActionController.new }
46
-
47
- before do
48
- allow(template).to receive(:controller).and_return(controller)
49
- end
50
-
51
- context "when controller has ajax mode enabled" do
52
- it "returns true" do
53
- allow(controller).to receive(:ajax?).and_return(true)
54
- expect(subject.dialog?).to be true
55
- end
56
- end
57
-
58
- context "when controller has ajax mode disabled" do
59
- it "returns false" do
60
- allow(controller).to receive(:ajax?).and_return(false)
61
- expect(subject.dialog?).to be false
62
- end
63
- end
64
- end
65
-
66
- describe "#dialog_name" do
67
- class UnitTestDialogBuilder
68
- include Releaf::Builders::Base
69
- include Releaf::Builders::Template
70
- include Releaf::Builders::View
71
- end
72
-
73
- it "returns normalized, dashed dialog name taken from dialog class name" do
74
- subject = UnitTestDialogBuilder.new(template)
75
- expect(subject.dialog_name).to eq("unit-test")
76
-
77
- subject = Releaf::Builders::EditBuilder.new(template)
78
- expect(subject.dialog_name).to eq("edit")
79
- end
80
- end
81
-
82
- describe "#header" do
83
- it "returns safely joined breadcrumbs, flash notices and header extras within header tag" do
84
- allow(subject).to receive(:breadcrumbs).and_return(ActiveSupport::SafeBuffer.new("breadcrumbs>"))
85
- allow(subject).to receive(:flash_notices).and_return(ActiveSupport::SafeBuffer.new(">_and_notices_"))
86
- allow(subject).to receive(:header_extras).and_return(ActiveSupport::SafeBuffer.new(">extras"))
87
- expect(subject.header).to eq("<header>breadcrumbs>>_and_notices_>extras</header>")
88
- end
89
- end
90
-
91
- describe "#section" do
92
- it "returns safely joined section blocks within section tag" do
93
- allow(subject).to receive(:section_attributes).and_return(class: "xx")
94
- allow(subject).to receive(:section_blocks).and_return([ '<', ActiveSupport::SafeBuffer.new(">")])
95
- expect(subject.section).to eq('<section class="xx">&lt;></section>')
96
- end
97
- end
98
-
99
- describe "#section_attributes" do
100
- context "within dialog" do
101
- it "returns hash with dialog classes" do
102
- allow(subject).to receive(:dialog?).and_return(true)
103
- allow(subject).to receive(:dialog_name).and_return("xxx")
104
- expect(subject.section_attributes).to eq(class: ["dialog", "xxx"])
105
- end
106
- end
107
-
108
- context "when not within dialog" do
109
- it "returns empty hash" do
110
- allow(subject).to receive(:dialog?).and_return(false)
111
- expect(subject.section_attributes).to eq({})
112
- end
113
- end
114
- end
115
-
116
- describe "#breadcrumbs" do
117
- context "when breadcrumbs template variable exists" do
118
- it "returns safely joined breadcrumbs items list within nav element" do
119
- allow(subject).to receive(:template_variable).with("breadcrumbs").and_return([:a, :b, :c])
120
- allow(subject).to receive(:breadcrumb_item).with(:a, false).and_return(">a")
121
- allow(subject).to receive(:breadcrumb_item).with(:b, false).and_return(ActiveSupport::SafeBuffer.new(">b"))
122
- allow(subject).to receive(:breadcrumb_item).with(:c, true).and_return(">c")
123
- content = '<nav><ul class="breadcrumbs">&gt;a>b&gt;c</ul></nav>'
124
- expect(subject.breadcrumbs).to eq(content)
125
- end
126
- end
127
-
128
- context "when breadcrumbs template variable does not exists" do
129
- it "returns nil" do
130
- allow(subject).to receive(:template_variable).with("breadcrumbs").and_return(nil)
131
- expect(subject.breadcrumbs).to be nil
132
- end
133
- end
134
- end
135
-
136
- describe "#breadcrumb_item" do
137
- context "when given breadcrumb item has url" do
138
- it "returns name wrapped within link" do
139
- expect(subject.breadcrumb_item({url: "asa", name: "x"}, true)).to eq('<li><a href="asa">x</a></li>')
140
- end
141
- end
142
-
143
- context "when given breadcrumb item has no url" do
144
- it "returns only name" do
145
- expect(subject.breadcrumb_item({name: "x"}, true)).to eq('<li>x</li>')
146
- end
147
- end
148
-
149
- it "adds breadcrumb icon after except when last element given" do
150
- expect(subject.breadcrumb_item({name: "x"}, true)).to eq('<li>x</li>')
151
- expect(subject.breadcrumb_item({name: "x"}, false)).to eq('<li>x<i class="fa fa-chevron-right"></i></li>')
152
- end
153
- end
154
-
155
- describe "#flash_notices" do
156
- it "returns safely joined flash items" do
157
- allow(subject).to receive(:flash).and_return(a: "xx", b: "yy")
158
- allow(subject).to receive(:flash_item).with(:a, "xx").and_return(ActiveSupport::SafeBuffer.new("<a"))
159
- allow(subject).to receive(:flash_item).with(:b, "yy").and_return("b>")
160
- expect(subject.flash_notices).to eq("<ab&gt;")
161
- end
162
- end
163
-
164
- describe "#flash_item" do
165
- it "returns flash item" do
166
- expect(subject.flash_item(:error, "some error")).to eq('<div class="flash" data-type="error">some error</div>')
167
- end
168
-
169
- it "supports flash item data as hash" do
170
- expect(subject.flash_item(:error, "id" => "unique", "message" => "errrrrror")).to eq('<div class="flash" data-type="error" data-id="unique">errrrrror</div>')
171
- end
172
- end
173
-
174
- describe "#header_extras" do
175
- it "returns nil (method to override in later classes)" do
176
- expect(subject.header_extras).to be nil
177
- end
178
- end
179
-
180
- describe "#section_blocks" do
181
- it "returns array of section header, body and footer blocks" do
182
- allow(subject).to receive(:section_header).and_return("a")
183
- allow(subject).to receive(:section_body).and_return("b")
184
- allow(subject).to receive(:section_footer).and_return("c")
185
-
186
- expect(subject.section_blocks).to eq(["a", "b", "c"])
187
- end
188
- end
189
-
190
- describe "#section_header" do
191
- it "returns header content with header extras" do
192
- allow(subject).to receive(:section_header_text).and_return("sektion h")
193
- allow(subject).to receive(:section_header_extras).and_return("extras")
194
- expect(subject.section_header).to eq("<header><h1>sektion h</h1>extras</header>")
195
- end
196
- end
197
-
198
- describe "#section_header_text" do
199
- it "returns nil (method to override in later classes)" do
200
- expect(subject.section_header_text).to be nil
201
- end
202
- end
203
-
204
- describe "#section_header_extras" do
205
- it "returns nil (method to override in later classes)" do
206
- expect(subject.section_header_extras).to be nil
207
- end
208
- end
209
-
210
- describe "#section_body" do
211
- it "returns nil (method to override in later classes)" do
212
- expect(subject.section_body).to be nil
213
- end
214
- end
215
-
216
- describe "#section_footer" do
217
- it "returns footer with footer attributes and content" do
218
- allow(subject).to receive(:section_footer_class).and_return(["axx", "b"])
219
- allow(subject).to receive(:footer_tools).and_return("footer content")
220
- expect(subject.section_footer).to eq('<footer class="axx b">footer content</footer>')
221
- end
222
- end
223
-
224
- describe "#section_footer_class" do
225
- context "within dialog" do
226
- it "returns nil" do
227
- allow(subject).to receive(:dialog?).and_return(true)
228
- expect(subject.section_footer_class).to be nil
229
- end
230
- end
231
-
232
- context "when not within dialog" do
233
- it "returns :main" do
234
- allow(subject).to receive(:dialog?).and_return(false)
235
- expect(subject.section_footer_class).to eq(:main)
236
- end
237
- end
238
- end
239
-
240
- describe "#footer_tools" do
241
- it "returns footer tools" do
242
- allow(subject).to receive(:footer_blocks).and_return([ActiveSupport::SafeBuffer.new("<a"), "b>"])
243
- expect(subject.footer_tools).to eq('<div class="tools"><ab&gt;</div>')
244
- end
245
- end
246
-
247
- describe "#footer_blocks" do
248
- it "returns array of footer primary and secondary blocks" do
249
- allow(subject).to receive(:footer_primary_block).and_return("a")
250
- allow(subject).to receive(:footer_secondary_block).and_return("b")
251
-
252
- expect(subject.footer_blocks).to eq(["a", "b"])
253
- end
254
- end
255
-
256
- describe "#footer_primary_block" do
257
- it "returns footer tools" do
258
- allow(subject).to receive(:footer_primary_tools).and_return([ActiveSupport::SafeBuffer.new("<a"), "b>"])
259
- expect(subject.footer_primary_block).to eq('<div class="primary"><ab&gt;</div>')
260
- end
261
- end
262
-
263
- describe "#footer_secondary_block" do
264
- it "returns footer tools" do
265
- allow(subject).to receive(:footer_secondary_tools).and_return([ActiveSupport::SafeBuffer.new("<a"), "b>"])
266
- expect(subject.footer_secondary_block).to eq('<div class="secondary"><ab&gt;</div>')
267
- end
268
- end
269
-
270
- describe "#footer_primary_tools" do
271
- it "returns nil (method to override in later classes)" do
272
- expect(subject.footer_primary_tools).to be nil
273
- end
274
- end
275
-
276
- describe "#footer_secondary_tools" do
277
- it "returns nil (method to override in later classes)" do
278
- expect(subject.footer_secondary_tools).to be nil
279
- end
280
- end
281
- end
@@ -1,144 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Releaf::Builders, type: :class do
4
- module Admin::Advanced
5
- class FormBuilder
6
- end
7
- class AuthorsController
8
- end
9
- end
10
-
11
- class Admin::Advanced::Builders < Releaf::Builders; end
12
-
13
- describe ".builder_class" do
14
- before do
15
- allow(described_class).to receive(:inherited_builder_scopes).and_return(["Releaf::Permissions::Users"])
16
- end
17
-
18
- it "returns first existing builder class from given and inherited scopes" do
19
- expect(described_class).to receive(:builder_class_at_scope).with("Admin::Advanced", :form)
20
- .and_return(nil).ordered
21
- expect(described_class).to receive(:builder_class_at_scope).with("Releaf::Permissions::Users", :form)
22
- .and_return(Releaf::Permissions::Users::FormBuilder).ordered
23
-
24
- expect(described_class.builder_class(["Admin::Advanced"], :form)).to eq(Releaf::Permissions::Users::FormBuilder)
25
- end
26
-
27
- context "when no builders exists for given scope and type" do
28
- it "raises error" do
29
- allow(described_class).to receive(:builder_class_at_scope).and_return(nil)
30
- error_message = 'unexisting builder (type: form; scopes: Admin::Advanced)'
31
- expect{ described_class.builder_class(["Admin::Advanced"], :form) }.to raise_error(ArgumentError, error_message)
32
- end
33
- end
34
- end
35
-
36
- describe ".builder_class_at_scope" do
37
- before do
38
- allow(described_class).to receive(:constant_defined_at_scope?)
39
- .with("Releaf::Builders", Object).and_return(true)
40
- allow(described_class).to receive(:constant_defined_at_scope?)
41
- .with("Releaf::Builders::EditBuilder", Releaf::Builders).and_return(true)
42
- end
43
-
44
- context "when scope and builder exists" do
45
- it "returns builder class" do
46
- expect(described_class.builder_class_at_scope("Releaf::Builders", :edit)).to eq(Releaf::Builders::EditBuilder)
47
- end
48
- end
49
-
50
- context "when scope exists but builder does not" do
51
- it "returns nil" do
52
- allow(described_class).to receive(:constant_defined_at_scope?)
53
- .with("Releaf::Builders", Object).and_return(false)
54
- expect(described_class.builder_class_at_scope("Releaf::Builders", :edit)).to be nil
55
- end
56
- end
57
-
58
- context "when scope does not exist" do
59
- it "returns nil" do
60
- allow(described_class).to receive(:constant_defined_at_scope?)
61
- .with("Releaf::Builders::EditBuilder", Releaf::Builders).and_return(false)
62
- expect(described_class.builder_class_at_scope("Releaf::Builders", :edit)).to be nil
63
- end
64
- end
65
- end
66
-
67
- describe ".constant_defined_at_scope?" do
68
- before do
69
- allow(Releaf).to receive(:const_get).and_call_original
70
- end
71
-
72
- it "checks constant existence within given scope" do
73
- expect(Releaf).to receive(:const_get).with("Releaf::Builders::FormBuilder").and_call_original
74
- described_class.constant_defined_at_scope?("Releaf::Builders::FormBuilder", Releaf)
75
-
76
- expect(Releaf).to receive(:const_get).with("Releaf::Builders::AnotherFormBuilder").and_call_original
77
- described_class.constant_defined_at_scope?("Releaf::Builders::AnotherFormBuilder", Releaf)
78
-
79
- expect(Admin).to receive(:const_get).with("Admin:xx").and_call_original
80
- described_class.constant_defined_at_scope?("Admin:xx", Admin)
81
- end
82
-
83
- context "when constant exists at given namespace" do
84
- it "returns true" do
85
- expect(described_class.constant_defined_at_scope?("Releaf::Builders::FormBuilder", Releaf)).to be true
86
- end
87
-
88
- it "compare constant with constant at given namespace and check whether it exists" do
89
- allow(Admin).to receive(:const_get).with("Admin:xx").and_return(true)
90
- expect(described_class.constant_defined_at_scope?("Admin:xx", Admin)).to be false
91
- end
92
- end
93
-
94
- context "when NameError raised" do
95
- context "when error message matches against constant name pattern" do
96
- it "returns false" do
97
- allow(described_class).to receive(:constant_name_error?)
98
- .with("uninitialized constant Releaf::Builders::AnotherFormBuilder", "Releaf::Builders::AnotherFormBuilder")
99
- .and_return(true)
100
- expect(described_class.constant_defined_at_scope?("Releaf::Builders::AnotherFormBuilder", Releaf)).to be false
101
- end
102
- end
103
-
104
- context "when error message does not match against constant name pattern" do
105
- it "reraises it" do
106
- allow(described_class).to receive(:constant_name_error?)
107
- .with("uninitialized constant Releaf::Builders::AnotherFormBuilder", "Releaf::Builders::AnotherFormBuilder")
108
- .and_return(false)
109
-
110
- expect{ described_class.constant_defined_at_scope?("Releaf::Builders::AnotherFormBuilder", Releaf) }
111
- .to raise_error(NameError, "uninitialized constant Releaf::Builders::AnotherFormBuilder")
112
- end
113
- end
114
- end
115
-
116
- context "when any other error raised" do
117
- it "does not rescue it" do
118
- allow(Releaf).to receive(:const_get).with("Releaf::Builders::FormBuilder")
119
- .and_raise(ArgumentError, "xxx")
120
- expect(described_class).to_not receive(:constant_name_error?)
121
-
122
- expect{ described_class.constant_defined_at_scope?("Releaf::Builders::FormBuilder", Releaf) }
123
- .to raise_error(ArgumentError, "xxx")
124
- end
125
- end
126
- end
127
-
128
- describe ".constant_name_error?" do
129
- it "returns true when error matches given mapping" do
130
- expect(described_class.constant_name_error?("Caused by NameError: uninitialized constant #<Class:0x00007fc1b79e8448>::AnotherFormBuilder", "Releaf::Builders::AnotherFormBuilder")).to be true
131
- end
132
-
133
- it "returns fales when error doesnt match given mapping" do
134
- expect(described_class.constant_name_error?("Caused by NameError: uninitialized something", "Releaf::Builders::AnotherFormBuilder")).to be false
135
- end
136
- end
137
-
138
- describe ".inherited_builder_scopes" do
139
- it "returns inherited classes except Object and BasicObject" do
140
- expect(described_class.inherited_builder_scopes).to eq(["Releaf::Builders"])
141
- expect(Admin::Advanced::Builders.inherited_builder_scopes).to eq(["Admin::Advanced::Builders", "Releaf::Builders"])
142
- end
143
- end
144
- end
@@ -1,48 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::Settings::FormBuilder, type: :class do
4
- class FormBuilderTestHelper < ActionView::Base; end
5
- let(:resource){ Releaf::Settings.new }
6
- let(:template){ FormBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
7
- let(:subject){ described_class.new(:resource, resource, template, {}) }
8
-
9
- describe "#field_names" do
10
- it "returns :value as only editable field within array" do
11
- expect(subject.field_names).to eq([:value])
12
- end
13
- end
14
-
15
- describe "#render_value" do
16
- it "renders with resolved label text and render method" do
17
- allow(subject).to receive(:value_label_text).and_return("x")
18
- allow(subject).to receive(:value_render_method_name).and_return("releaf_integer_field")
19
- allow(subject).to receive(:releaf_integer_field).with(:value, { options: { label: { label_text: "x" }}}).and_return("y")
20
- expect(subject.render_value).to eq("y")
21
- end
22
- end
23
-
24
- describe "#value_render_method_name" do
25
- it "returns render method built from input type" do
26
- allow(resource).to receive(:input_type).and_return(:superdate)
27
- expect(subject.value_render_method_name).to eq("releaf_superdate_field")
28
- end
29
- end
30
-
31
- describe "#value_label_text" do
32
- context "when description is available" do
33
- it "returns translated description text" do
34
- allow(resource).to receive(:description).and_return("x")
35
- allow(subject).to receive(:t).with("x", { scope: "settings"}).and_return("y")
36
- expect(subject.value_label_text).to eq("y")
37
- end
38
- end
39
-
40
- context "when description is not available" do
41
- it "returns translated 'value' attribute" do
42
- allow(subject).to receive(:translate_attribute).with(:value).and_return("xx")
43
- allow(resource).to receive(:description).and_return(nil)
44
- expect(subject.value_label_text).to eq("xx")
45
- end
46
- end
47
- end
48
- end