releaf-core 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.
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,31 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe "FactoryBot factories" do
4
-
5
- describe "admin factory" do
6
- it "creates new user" do
7
- expect { create(:user) }.to change { Releaf::Permissions::User.count }.by(1)
8
- end
9
- end
10
-
11
- describe "role factory" do
12
- it "creates new role" do
13
- expect { create(:admin_role) }.to change { Releaf::Permissions::Role.count }.by(1)
14
- end
15
- end
16
-
17
- describe "node factory" do
18
- it "creates new content node" do
19
- expect { create(:node) }.to change { Node.count }.by(1)
20
- end
21
-
22
- it "creates new HomePage content node" do
23
- expect { create(:home_page_node) }.to change { HomePage.count }.by(1)
24
- end
25
-
26
- it "creates new TextPage content node" do
27
- parent = create(:home_page_node)
28
- expect { create(:text_page_node, parent: parent) }.to change { TextPage.count }.by(1)
29
- end
30
- end
31
- end
@@ -1,104 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::Settings do
4
-
5
- describe ":registered scope" do
6
- it "returns only registed settings ordered by `var`" do
7
- item_1 = Releaf::Settings.create(var: "a", value: "1")
8
- item_2 = Releaf::Settings.create(var: "b", value: "2")
9
- Releaf::Settings.create(var: "c", value: "2")
10
- Releaf::Settings.create(var: "a", value: "3", thing_type: "Releaf::Permissions::User", thing_id: "1")
11
-
12
- Releaf::Settings.register(key: "a", default: "x", description: "some setting")
13
- Releaf::Settings.register(key: "b", default: "xxxx", description: "some other setting")
14
-
15
- expect(described_class.registered).to eq [item_1, item_2]
16
- end
17
-
18
- it "returns valid query" do
19
- expect(described_class.registered.count).to be_instance_of(Integer)
20
- end
21
-
22
- it "returns instance of `Releaf::Settings::ActiveRecord_Relation`" do
23
- expect(described_class.registered).to be_instance_of(Releaf::Settings.const_get(:ActiveRecord_Relation))
24
- end
25
- end
26
-
27
- describe "#releaf_title" do
28
- it "returns var value" do
29
- subject.var = "x"
30
- expect(subject.releaf_title).to eq("x")
31
- end
32
- end
33
-
34
- describe "#input_type" do
35
- it "returns type from metadata" do
36
- allow(subject).to receive(:metadata).and_return(type: "xx")
37
- expect(subject.input_type).to eq("xx")
38
- end
39
-
40
- context "when type not defined in meta data" do
41
- it "returns `:text` as default value" do
42
- allow(subject).to receive(:metadata).and_return(type: nil)
43
- expect(subject.input_type).to eq(:text)
44
-
45
- allow(subject).to receive(:metadata).and_return(asdasd: "xx")
46
- expect(subject.input_type).to eq(:text)
47
- end
48
- end
49
- end
50
-
51
- describe "#description" do
52
- it "returns type from metadata" do
53
- allow(subject).to receive(:metadata).and_return(description: "xxasd")
54
- expect(subject.description).to eq("xxasd")
55
- end
56
- end
57
-
58
- describe "#metadata" do
59
- before do
60
- subject.var = "xxx"
61
- end
62
-
63
- it "returns metadata values from settings registry fetched by object `var` value" do
64
- allow(described_class).to receive(:registry).and_return("xxx" => {a: "b"})
65
- expect(subject.metadata).to eq(a: "b")
66
- end
67
-
68
- context "when metadata does not exist" do
69
- it "returns empty hash" do
70
- allow(described_class).to receive(:registry).and_return("lasdh" => {a: "b"})
71
- expect(subject.metadata).to eq({})
72
- end
73
- end
74
- end
75
-
76
- describe ".register_scoped" do
77
- it "returns only register scoped settings" do
78
- allow(described_class).to receive(:where).with(var: ["a", "b"]).and_return("x")
79
- allow(described_class).to receive(:registered_keys).and_return(["a", "b"])
80
-
81
- expect(described_class.register_scoped).to eq("x")
82
- end
83
-
84
- it "returns instance of `Releaf::Settings::ActiveRecord_Relation`" do
85
- expect(described_class.register_scoped).to be_instance_of(Releaf::Settings.const_get(:ActiveRecord_Relation))
86
- end
87
- end
88
-
89
- describe ".register" do
90
- it "calls `Releaf::Settings::Register` service with given arguments as array" do
91
- expect(Releaf::Settings::Register).to receive(:call)
92
- .with(settings: [{key: "a", type: "b"}, {key: "c", type: "d"}])
93
- described_class.register({key: "a", type: "b"}, {key: "c", type: "d"})
94
- end
95
- end
96
-
97
- describe ".supported_types" do
98
- it "returns list of supported types as array with symbols" do
99
- described_class.supported_types.each do|type|
100
- expect(type).to be_instance_of Symbol
101
- end
102
- end
103
- end
104
- end
@@ -1,185 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::RouteMapper do
4
- after(:all) do
5
- # reset dummy app routes
6
- Dummy::Application.reload_routes!
7
- end
8
-
9
- describe "#mount_releaf_at" do
10
- it "it assigns normalized mount location to Releaf.application.config.mount_location" do
11
- expect{
12
- routes.draw do
13
- mount_releaf_at '/xxxx'
14
- end
15
- }.to change{ Releaf.application.config.mount_location }.to("xxxx")
16
-
17
- expect{
18
- routes.draw do
19
- mount_releaf_at '/'
20
- end
21
- }.to change{ Releaf.application.config.mount_location }.to("")
22
- end
23
- end
24
-
25
- describe "#releaf_resources" do
26
- before do
27
- routes.draw do
28
- mount_releaf_at '/admin' do
29
- releaf_resources :books
30
- end
31
- end
32
- end
33
-
34
- it "mounts resource toolbox route" do
35
- expect(get: "/admin/books/1/toolbox").to route_to(
36
- "action"=>"toolbox",
37
- "controller"=>"admin/books",
38
- "id"=>"1"
39
- )
40
- end
41
-
42
- it "mounts resource destroy confirm route" do
43
- expect(get: "/admin/books/1/confirm_destroy").to route_to(
44
- "action"=>"confirm_destroy",
45
- "controller"=>"admin/books",
46
- "id"=>"1"
47
- )
48
- end
49
-
50
- it "mounts resources index route" do
51
- expect(get: "/admin/books/").to route_to(
52
- "action"=>"index",
53
- "controller"=>"admin/books",
54
- )
55
- end
56
-
57
- it "mounts resource create route" do
58
- expect(post: "/admin/books/").to route_to(
59
- "action"=>"create",
60
- "controller"=>"admin/books",
61
- )
62
- end
63
-
64
- it "mounts resource new route" do
65
- expect(get: "/admin/books/new").to route_to(
66
- "action"=>"new",
67
- "controller"=>"admin/books",
68
- )
69
- end
70
-
71
- it "mounts resource edit route" do
72
- expect(get: "/admin/books/1/edit").to route_to(
73
- "action"=>"edit",
74
- "controller"=>"admin/books",
75
- "id"=>"1"
76
- )
77
- end
78
-
79
- it "mounts resource show route" do
80
- expect(get: "/admin/books/1").to route_to(
81
- "action"=>"show",
82
- "controller"=>"admin/books",
83
- "id"=>"1"
84
- )
85
- end
86
-
87
- it "mounts resource update route" do
88
- expect(put: "/admin/books/1").to route_to(
89
- "action"=>"update",
90
- "controller"=>"admin/books",
91
- "id"=>"1"
92
- )
93
- end
94
-
95
- it "mounts resource destroy route" do
96
- expect(delete: "/admin/books/1").to route_to(
97
- "action"=>"destroy",
98
- "controller"=>"admin/books",
99
- "id"=>"1"
100
- )
101
- end
102
-
103
- context "when toolbox route is disabled with except: option" do
104
- before do
105
- routes.draw do
106
- mount_releaf_at '/admin' do
107
- releaf_resources :books, except: [:toolbox]
108
- end
109
- end
110
- end
111
-
112
- it "route to page not found" do
113
- expect(get: "/admin/books/1/toolbox")
114
- .to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/toolbox")
115
- end
116
- end
117
-
118
- context "when destroy route is skiped within with only: option" do
119
- before do
120
- routes.draw do
121
- mount_releaf_at '/admin' do
122
- releaf_resources :books, only: [:index]
123
- end
124
- end
125
- end
126
-
127
- it "route to page not found" do
128
- expect(get: "/admin/books/1/toolbox")
129
- .to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/toolbox")
130
- end
131
- end
132
-
133
- context "when confirm destroy route is disabled with except: option" do
134
- before do
135
- routes.draw do
136
- mount_releaf_at '/admin' do
137
- releaf_resources :books, except: [:destroy]
138
- end
139
- end
140
- end
141
-
142
- it "does not mount destroy confirm route" do
143
- expect(get: "/admin/books/1/confirm_destroy")
144
- .to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/confirm_destroy")
145
- end
146
- end
147
-
148
- context "when confirm destroy route is skiped within with only: option" do
149
- before do
150
- routes.draw do
151
- mount_releaf_at '/admin' do
152
- releaf_resources :books, only: [:index]
153
- end
154
- end
155
- end
156
-
157
- it "does not mount destroy confirm route" do
158
- expect(get: "/admin/books/1/confirm_destroy")
159
- .to route_to(controller: "releaf/root", action: "page_not_found", path: "books/1/confirm_destroy")
160
- end
161
- end
162
-
163
- context "when custom block given" do
164
- before do
165
- routes.draw do
166
- mount_releaf_at '/admin' do
167
- releaf_resources :books, only: [:index] do
168
- member do
169
- get :download
170
- end
171
- end
172
- end
173
- end
174
- end
175
-
176
- it "calls it within resources method" do
177
- expect(get: "/admin/books/1/download").to route_to(
178
- "action"=>"download",
179
- "controller"=>"admin/books",
180
- "id"=>"1"
181
- )
182
- end
183
- end
184
- end
185
- end
@@ -1,20 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::Test::Helpers do
4
- describe ".stub_settings" do
5
- it "stubs given hash by key, value to Releaf::Settings" do
6
- stub_settings("some.settings" => "x", "something" => "nothing")
7
- expect(Releaf::Settings["some.settings"]).to eq("x")
8
- expect(Releaf::Settings["something"]).to eq("nothing")
9
- end
10
-
11
- it "mergs multiple stub calls" do
12
- stub_settings("some.settings" => "x")
13
- stub_settings("another.settings" => "xx")
14
-
15
- expect(Releaf::Settings["some.settings"]).to eq("x")
16
- expect(Releaf::Settings["another.settings"]).to eq("xx")
17
- expect(Releaf::Settings["unrelated.settings"]).to eq(nil)
18
- end
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::Test do
4
- describe ".reset!" do
5
- it "calls `Releaf::Content::RoutesReloader` reset" do
6
- # initial there are two calls
7
- expect(Releaf::Content::RoutesReloader).to receive(:reset!).twice
8
- described_class.reset!
9
-
10
- expect(Releaf::Content::RoutesReloader).to receive(:reset!).once
11
- described_class.reset!
12
- end
13
- end
14
- end
@@ -1,121 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Array::Reorder do
4
- subject{ described_class.new(array: ["a", "b", "c", "d", {items: "xx"}, "e", "f", "g"],
5
- values: "c", options: :first) }
6
-
7
- describe "#values=" do
8
- context "when `values` is not array" do
9
- it "wraps it within array before assigning" do
10
- expect{ subject.values = :a }.to change{ subject.values }.to([:a])
11
- end
12
- end
13
-
14
- context "when `values` is array" do
15
- it "does not modify it before assigning" do
16
- expect{ subject.values = [:a] }.to change{ subject.values }.to([:a])
17
- end
18
- end
19
- end
20
-
21
- describe "#call" do
22
- it "deletes given values and insert deleted values in reversed order at reorder index" do
23
- deleted_values = {a: "x", b: "y"}
24
- subject.values = [:a, :b]
25
- subject.options = :last
26
-
27
- expect(subject).to receive(:delete).with([:a, :b]).ordered.and_return(deleted_values)
28
- expect(subject).to receive(:reorder_index).with(:last).ordered.and_return(1)
29
- expect{ subject.call }.to change{ subject.array }
30
- .to(["a", "x", "y", "b", "c", "d", {items: "xx"}, "e", "f", "g"])
31
- end
32
-
33
- context "when given value is array" do
34
- it "process unmodified given value" do
35
- subject.values = [:a]
36
- subject.options = :last
37
- expect(subject).to receive(:delete).with([:a]).and_call_original
38
- subject.call
39
- end
40
- end
41
-
42
- context "when given value is not array" do
43
- it "puts value within array" do
44
- subject.values = [:a]
45
- subject.options = :last
46
- expect(subject).to receive(:delete).with([:a]).and_call_original
47
- subject.call
48
- end
49
- end
50
- end
51
-
52
- describe "#reorder_index" do
53
- context "when given options is :first" do
54
- it "returns 0" do
55
- expect(subject.reorder_index(:first)).to eq(0)
56
- end
57
- end
58
-
59
- context "when given options is :last" do
60
- it "returns size of array" do
61
- expect(subject.reorder_index(:last)).to eq(8)
62
- subject.array = [:a, :b]
63
- expect(subject.reorder_index(:last)).to eq(2)
64
- end
65
- end
66
-
67
- context "when given options is :before" do
68
- it "returns index of given `before` value" do
69
- allow(subject).to receive(:index).with(:items).and_return(4)
70
- expect(subject.reorder_index(before: :items)).to eq(4)
71
- end
72
- end
73
-
74
- context "when given options is :after" do
75
- it "returns index of given `after` value increased by 1" do
76
- allow(subject).to receive(:index).with(:items).and_return(4)
77
- expect(subject.reorder_index(after: :items)).to eq(5)
78
- end
79
- end
80
-
81
- context "when unknown option given" do
82
- it "raises ArgumentError" do
83
- expect{ subject.reorder_index(asdasd: :items) }.to raise_error(ArgumentError, "unknown reorder option")
84
- end
85
- end
86
- end
87
-
88
- describe "#index" do
89
- it "returns value index by comparing array and given values casted to strings" do
90
- expect(subject.index(:c)).to eq(2)
91
- expect(subject.index("c")).to eq(2)
92
- subject.array = ["a", :b, :c]
93
- expect(subject.index("c")).to eq(2)
94
- end
95
-
96
- context "when array value is Hash" do
97
- it "compares by hash first key casted to string" do
98
- expect(subject.index(:items)).to eq(4)
99
- expect(subject.index("items")).to eq(4)
100
-
101
- subject.array = ["a", {"items" => "x"}]
102
- expect(subject.index(:items)).to eq(1)
103
- expect(subject.index("items")).to eq(1)
104
- end
105
- end
106
- end
107
-
108
- describe "#delete" do
109
- before do
110
- subject.array = [:a, :b, :c, :d, {items: "x"}]
111
- end
112
-
113
- it "deletes given values from array" do
114
- expect{ subject.delete(["a", "b", "items"]) }.to change{ subject.array }.to([:c, :d])
115
- end
116
-
117
- it "returns hash with mapped deleted values" do
118
- expect(subject.delete(["a", "b", "items"])).to eq("a" => :a, "b" => :b, "items" => {items: "x"})
119
- end
120
- end
121
- end