releaf-core 1.1.10 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b630a015d5b90273ddac8d6833a1e3e4593d5692
|
4
|
+
data.tar.gz: 3a5a40a7016c526ee7661c39f44f6e34263729f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1758b1b03be6700dbbeb322bd826f02cb5333301969b9bfb26cfe4d585331c5e1567fbe4533b3e745f39db7f6955590a6788a5bb630e9db5bc4b557ab9b83631
|
7
|
+
data.tar.gz: 15df83b1989316d55197c1c70387fec7ab8dc712916ae85b12ca845a9fee48731466fce662cf214cfaa86beeaa22c953a9be32b3110ccce4b22d9039655edaab
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Releaf::ControllerDefinition
|
2
|
-
attr_accessor :name, :controller_name
|
2
|
+
attr_accessor :name, :controller_name, :helper
|
3
3
|
|
4
4
|
def self.for(controller_name)
|
5
5
|
Releaf.application.config.controllers[controller_name]
|
@@ -10,6 +10,7 @@ class Releaf::ControllerDefinition
|
|
10
10
|
options[:name] ||= options[:controller]
|
11
11
|
self.name = options[:name]
|
12
12
|
self.controller_name = options[:controller]
|
13
|
+
self.helper = "#{options[:helper]}_path" if options[:helper]
|
13
14
|
end
|
14
15
|
|
15
16
|
def localized_name
|
@@ -17,6 +18,10 @@ class Releaf::ControllerDefinition
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def path
|
20
|
-
|
21
|
+
if helper
|
22
|
+
Rails.application.routes.url_helpers.send(helper)
|
23
|
+
else
|
24
|
+
Rails.application.routes.url_helpers.url_for(action: :index, controller: controller_name, only_path: true)
|
25
|
+
end
|
21
26
|
end
|
22
27
|
end
|
@@ -4,34 +4,11 @@ module Releaf::Root
|
|
4
4
|
attribute :current_controller
|
5
5
|
|
6
6
|
def call
|
7
|
-
controllers.
|
8
|
-
path = controller_index_path(controller_name)
|
9
|
-
return path if path
|
10
|
-
end
|
11
|
-
|
12
|
-
nil
|
13
|
-
end
|
14
|
-
|
15
|
-
def controller_index_path(controller_name)
|
16
|
-
route_options = {controller: controller_name, action: "index"}
|
17
|
-
|
18
|
-
subdomain.present? && route_path(route_options.merge(subdomain: subdomain)) || route_path(route_options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def route_path(route_options)
|
22
|
-
Rails.application.routes.url_helpers.url_for(route_options.merge(only_path: true)) if route_exists?(route_options)
|
7
|
+
Releaf.application.config.controllers[controllers.first].path if controllers.first
|
23
8
|
end
|
24
9
|
|
25
10
|
def controllers
|
26
11
|
Releaf.application.config.available_controllers
|
27
12
|
end
|
28
|
-
|
29
|
-
def route_exists?(route_options)
|
30
|
-
Rails.application.routes.routes.map(&:defaults).include?(route_options)
|
31
|
-
end
|
32
|
-
|
33
|
-
def subdomain
|
34
|
-
current_controller.request.subdomain
|
35
|
-
end
|
36
13
|
end
|
37
14
|
end
|
@@ -19,6 +19,20 @@ describe Releaf::ControllerDefinition do
|
|
19
19
|
expect(subject.controller_name).to eq("admin/books")
|
20
20
|
end
|
21
21
|
|
22
|
+
context "when `helper` option value given" do
|
23
|
+
it "assigns `helper` option value postfixed with `_path` to helper accessor" do
|
24
|
+
subject = described_class.new(controller: "admin/books", helper: "some-route")
|
25
|
+
expect(subject.helper).to eq("some-route_path")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when no `helper` option value given" do
|
30
|
+
it "does not assign anything to helper accessor" do
|
31
|
+
subject = described_class.new(controller: "admin/books")
|
32
|
+
expect(subject.helper).to be nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
context "when no `name` option value given" do
|
23
37
|
it "takes `controller` option value as `name` value" do
|
24
38
|
subject = described_class.new(controller: "admin/books")
|
@@ -42,8 +56,17 @@ describe Releaf::ControllerDefinition do
|
|
42
56
|
end
|
43
57
|
|
44
58
|
describe "#path" do
|
45
|
-
|
46
|
-
|
59
|
+
context "when helper exists" do
|
60
|
+
it "returns helper value" do
|
61
|
+
subject.helper = "new_admin_chapter_path"
|
62
|
+
expect(subject.path).to eq("/admin/chapters/new")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when helper is not set" do
|
67
|
+
it "returns controller index path" do
|
68
|
+
expect(subject.path).to eq("/admin/books")
|
69
|
+
end
|
47
70
|
end
|
48
71
|
end
|
49
72
|
end
|
@@ -2,103 +2,39 @@ require "rails_helper"
|
|
2
2
|
|
3
3
|
describe Releaf::Root::DefaultControllerResolver do
|
4
4
|
let(:controller) { Releaf::RootController.new }
|
5
|
-
let(:request) { instance_double(ActionDispatch::Request
|
5
|
+
#let(:request) { instance_double(ActionDispatch::Request) }
|
6
6
|
subject { described_class.new(current_controller: controller) }
|
7
7
|
|
8
|
-
before do
|
9
|
-
allow( controller ).to receive(:request).and_return(request)
|
10
|
-
end
|
8
|
+
#before do
|
9
|
+
#allow( controller ).to receive(:request).and_return(request)
|
10
|
+
#end
|
11
11
|
|
12
12
|
it_behaves_like "an Releaf::Service includer"
|
13
13
|
|
14
14
|
describe "#call" do
|
15
|
-
it "returns first available controller
|
16
|
-
|
17
|
-
|
18
|
-
allow(
|
19
|
-
allow(
|
15
|
+
it "returns first available controller definition path" do
|
16
|
+
controller_a_definition = Releaf::ControllerDefinition.new("a")
|
17
|
+
controller_b_definition = Releaf::ControllerDefinition.new("b")
|
18
|
+
allow(controller_a_definition).to receive(:path).and_return("aa_path")
|
19
|
+
allow(controller_b_definition).to receive(:path).and_return("bb_path")
|
20
|
+
|
21
|
+
allow(Releaf.application.config).to receive(:controllers).and_return(
|
22
|
+
"a" => controller_a_definition,
|
23
|
+
"b" => controller_b_definition,
|
24
|
+
)
|
25
|
+
allow(subject).to receive(:controllers).and_return(["a", "b"])
|
20
26
|
|
21
|
-
expect(subject.call).to eq("
|
27
|
+
expect(subject.call).to eq("aa_path")
|
22
28
|
end
|
23
29
|
|
24
30
|
context "when no controller path is available" do
|
25
31
|
it "returns nil" do
|
26
|
-
allow(subject).to receive(:controllers).and_return([
|
27
|
-
allow(subject).to receive(:controller_index_path).with("a").and_return(nil)
|
28
|
-
allow(subject).to receive(:controller_index_path).with("b").and_return(nil)
|
29
|
-
|
32
|
+
allow(subject).to receive(:controllers).and_return([])
|
30
33
|
expect(subject.call).to be nil
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
|
-
describe "#controller_index_path" do
|
36
|
-
before do
|
37
|
-
allow(subject).to receive(:route_path).with(controller: "x", action: "index")
|
38
|
-
.and_return("_index_path_")
|
39
|
-
allow(subject).to receive(:route_path).with(controller: "x", action: "index", subdomain: "shop")
|
40
|
-
.and_return("_shop_index_path_")
|
41
|
-
end
|
42
|
-
|
43
|
-
context "when subdomain is not present" do
|
44
|
-
it "returns index path for given controller" do
|
45
|
-
allow(subject).to receive(:subdomain).and_return("")
|
46
|
-
expect(subject.controller_index_path("x")).to eq("_index_path_")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when subdomain is present" do
|
51
|
-
before do
|
52
|
-
allow(subject).to receive(:subdomain).and_return("shop")
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when subdomain index exists" do
|
56
|
-
it "returns subdomain index path for given controller" do
|
57
|
-
expect(subject.controller_index_path("x")).to eq("_shop_index_path_")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when subdomain index does not exist" do
|
62
|
-
it "returns index path for given controller" do
|
63
|
-
allow(subject).to receive(:route_path).with(controller: "x", action: "index", subdomain: "shop")
|
64
|
-
.and_return(nil)
|
65
|
-
expect(subject.controller_index_path("x")).to eq("_index_path_")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "#route_path" do
|
72
|
-
context "when route exists" do
|
73
|
-
it "returns route path" do
|
74
|
-
allow(subject).to receive(:route_exists?).with(controller: "admin/books", action: "index").and_return(true)
|
75
|
-
expect(subject.route_path(controller: "admin/books", action: "index")).to eq("/admin/books")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context "when given route does not exist" do
|
80
|
-
it "returns nil" do
|
81
|
-
allow(subject).to receive(:route_exists?).with(controller: "admin/books", action: "index").and_return(false)
|
82
|
-
expect(subject.route_path(controller: "admin/books", action: "index")).to be nil
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "#route_exists?" do
|
88
|
-
context "when given route exists" do
|
89
|
-
it "returns true" do
|
90
|
-
expect(subject.route_exists?(controller: "admin/books", action: "index")).to be true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "when given route does not exist" do
|
95
|
-
it "returns false" do
|
96
|
-
expect(subject.route_exists?(controller: "releaf/permissions/profile", action: "index")).to be false
|
97
|
-
expect(subject.route_exists?(controller: "admin/asdasd", action: "index")).to be false
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
38
|
describe "#controllers" do
|
103
39
|
it "returns available controllers from Releaf config" do
|
104
40
|
allow(Releaf.application.config).to receive(:available_controllers).and_return("x")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: releaf-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CubeSystems
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -639,103 +639,103 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
639
639
|
version: '0'
|
640
640
|
requirements: []
|
641
641
|
rubyforge_project:
|
642
|
-
rubygems_version: 2.6.
|
642
|
+
rubygems_version: 2.6.14
|
643
643
|
signing_key:
|
644
644
|
specification_version: 4
|
645
645
|
summary: core gem for releaf
|
646
646
|
test_files:
|
647
|
-
- spec/
|
648
|
-
- spec/builders/releaf/
|
647
|
+
- spec/misc/factories_spec.rb
|
648
|
+
- spec/builders/releaf/settings/table_builder_spec.rb
|
649
|
+
- spec/builders/releaf/settings/form_builder_spec.rb
|
649
650
|
- spec/builders/releaf/builders/collection_spec.rb
|
650
|
-
- spec/builders/releaf/builders/confirm_destroy_dialog_builder_spec.rb
|
651
651
|
- spec/builders/releaf/builders/confirm_dialog_builder_spec.rb
|
652
|
-
- spec/builders/releaf/builders/
|
652
|
+
- spec/builders/releaf/builders/table_builder_spec.rb
|
653
|
+
- spec/builders/releaf/builders/page/menu_builder_spec.rb
|
654
|
+
- spec/builders/releaf/builders/page/layout_builder_spec.rb
|
655
|
+
- spec/builders/releaf/builders/page/header_builder_spec.rb
|
656
|
+
- spec/builders/releaf/builders/toolbox_builder_spec.rb
|
657
|
+
- spec/builders/releaf/builders/view_spec.rb
|
658
|
+
- spec/builders/releaf/builders/index_builder_spec.rb
|
659
|
+
- spec/builders/releaf/builders/utilities/date_fields_spec.rb
|
660
|
+
- spec/builders/releaf/builders/utilities/resolve_attribute_field_method_name_spec.rb
|
661
|
+
- spec/builders/releaf/builders/template_spec.rb
|
662
|
+
- spec/builders/releaf/builders/resource_view_spec.rb
|
663
|
+
- spec/builders/releaf/builders/pagination_builder_spec.rb
|
653
664
|
- spec/builders/releaf/builders/form_builder/associations_spec.rb
|
654
665
|
- spec/builders/releaf/builders/form_builder/date_fields_spec.rb
|
655
|
-
- spec/builders/releaf/builders/form_builder/i18n_fields_spec.rb
|
656
666
|
- spec/builders/releaf/builders/form_builder/label_spec.rb
|
667
|
+
- spec/builders/releaf/builders/form_builder/i18n_fields_spec.rb
|
657
668
|
- spec/builders/releaf/builders/form_builder/number_fields_spec.rb
|
658
669
|
- spec/builders/releaf/builders/form_builder_spec.rb
|
659
|
-
- spec/builders/releaf/builders/
|
660
|
-
- spec/builders/releaf/builders/
|
661
|
-
- spec/builders/releaf/builders/
|
662
|
-
- spec/builders/releaf/builders/
|
663
|
-
- spec/builders/releaf/builders/
|
670
|
+
- spec/builders/releaf/builders/association_reflector_spec.rb
|
671
|
+
- spec/builders/releaf/builders/base_spec.rb
|
672
|
+
- spec/builders/releaf/builders/confirm_destroy_dialog_builder_spec.rb
|
673
|
+
- spec/builders/releaf/builders/toolbox_spec.rb
|
674
|
+
- spec/builders/releaf/builders/edit_builder_spec.rb
|
664
675
|
- spec/builders/releaf/builders/resource_dialog_spec.rb
|
665
|
-
- spec/builders/releaf/builders/resource_view_spec.rb
|
666
676
|
- spec/builders/releaf/builders/show_builder_spec.rb
|
667
|
-
- spec/builders/releaf/builders/table_builder_spec.rb
|
668
|
-
- spec/builders/releaf/builders/template_spec.rb
|
669
|
-
- spec/builders/releaf/builders/toolbox_builder_spec.rb
|
670
|
-
- spec/builders/releaf/builders/toolbox_spec.rb
|
671
|
-
- spec/builders/releaf/builders/utilities/date_fields_spec.rb
|
672
|
-
- spec/builders/releaf/builders/utilities/resolve_attribute_field_method_name_spec.rb
|
673
|
-
- spec/builders/releaf/builders/view_spec.rb
|
674
677
|
- spec/builders/releaf/builders_spec.rb
|
675
|
-
- spec/
|
676
|
-
- spec/
|
677
|
-
- spec/controllers/concerns/releaf/richtext_attachments_spec.rb
|
678
|
-
- spec/controllers/releaf/action_controller_spec.rb
|
679
|
-
- spec/controllers/releaf/root_controller_spec.rb
|
680
|
-
- spec/controllers/releaf/settings_controller_spec.rb
|
681
|
-
- spec/error_hash_builder_spec.rb
|
678
|
+
- spec/rspec_helpers/test_helpers_spec.rb
|
679
|
+
- spec/rspec_helpers/test_spec.rb
|
682
680
|
- spec/ext/array_reorder_spec.rb
|
683
|
-
- spec/features/ajaxbox_spec.rb
|
684
|
-
- spec/features/authorization_spec.rb
|
685
|
-
- spec/features/breadcrumbs_spec.rb
|
686
|
-
- spec/features/dragonfly_integration_spec.rb
|
687
|
-
- spec/features/edit_actions_spec.rb
|
688
|
-
- spec/features/errors_spec.rb
|
689
|
-
- spec/features/index_actions_spec.rb
|
690
681
|
- spec/features/index_table_spec.rb
|
682
|
+
- spec/features/index_actions_spec.rb
|
683
|
+
- spec/features/title_spec.rb
|
684
|
+
- spec/features/richtext_embed_spec.rb
|
685
|
+
- spec/features/search_spec.rb
|
686
|
+
- spec/features/breadcrumbs_spec.rb
|
687
|
+
- spec/features/authorization_spec.rb
|
691
688
|
- spec/features/menu_spec.rb
|
692
|
-
- spec/features/
|
689
|
+
- spec/features/ajaxbox_spec.rb
|
690
|
+
- spec/features/edit_actions_spec.rb
|
693
691
|
- spec/features/richtext_custom_config_spec.rb
|
694
|
-
- spec/features/richtext_embed_spec.rb
|
695
692
|
- spec/features/richtext_spec.rb
|
696
|
-
- spec/features/search_spec.rb
|
697
693
|
- spec/features/settings_spec.rb
|
698
|
-
- spec/features/
|
699
|
-
- spec/
|
700
|
-
- spec/
|
701
|
-
- spec/
|
702
|
-
- spec/
|
703
|
-
- spec/
|
704
|
-
- spec/
|
705
|
-
- spec/lib/releaf/
|
694
|
+
- spec/features/richtext_attachments_spec.rb
|
695
|
+
- spec/features/dragonfly_integration_spec.rb
|
696
|
+
- spec/features/errors_spec.rb
|
697
|
+
- spec/models/settings_spec.rb
|
698
|
+
- spec/error_hash_builder_spec.rb
|
699
|
+
- spec/lib/releaf/responders/error_responder_spec.rb
|
700
|
+
- spec/lib/releaf/responders/confirm_destroy_responder_spec.rb
|
701
|
+
- spec/lib/releaf/responders/feature_disabled_responder_spec.rb
|
702
|
+
- spec/lib/releaf/responders/page_not_found_responder_spec.rb
|
703
|
+
- spec/lib/releaf/responders/after_save_responder_spec.rb
|
704
|
+
- spec/lib/releaf/responders/destroy_responder_spec.rb
|
705
|
+
- spec/lib/releaf/responders/access_denied_responder_spec.rb
|
706
706
|
- spec/lib/releaf/action_controller/search_spec.rb
|
707
|
-
- spec/lib/releaf/
|
708
|
-
- spec/lib/releaf/
|
707
|
+
- spec/lib/releaf/action_controller/features_spec.rb
|
708
|
+
- spec/lib/releaf/settings/register_spec.rb
|
709
|
+
- spec/lib/releaf/settings/normalize_value_spec.rb
|
710
|
+
- spec/lib/releaf/settings_manager_spec.rb
|
711
|
+
- spec/lib/releaf/resource_base_spec.rb
|
709
712
|
- spec/lib/releaf/build_errors_hash_spec.rb
|
713
|
+
- spec/lib/releaf/assets_resolver_spec.rb
|
714
|
+
- spec/lib/releaf/instance_cache_spec.rb
|
710
715
|
- spec/lib/releaf/configuration_spec.rb
|
711
716
|
- spec/lib/releaf/controller_definition_spec.rb
|
712
|
-
- spec/lib/releaf/
|
713
|
-
- spec/lib/releaf/
|
714
|
-
- spec/lib/releaf/instance_cache_spec.rb
|
715
|
-
- spec/lib/releaf/resource_base_spec.rb
|
716
|
-
- spec/lib/releaf/resource_fields_spec.rb
|
717
|
-
- spec/lib/releaf/resource_params_spec.rb
|
718
|
-
- spec/lib/releaf/resource_table_fields_spec.rb
|
719
|
-
- spec/lib/releaf/resource_utilities_spec.rb
|
720
|
-
- spec/lib/releaf/responders/access_denied_responder_spec.rb
|
721
|
-
- spec/lib/releaf/responders/after_save_responder_spec.rb
|
722
|
-
- spec/lib/releaf/responders/confirm_destroy_responder_spec.rb
|
723
|
-
- spec/lib/releaf/responders/destroy_responder_spec.rb
|
724
|
-
- spec/lib/releaf/responders/error_responder_spec.rb
|
725
|
-
- spec/lib/releaf/responders/feature_disabled_responder_spec.rb
|
726
|
-
- spec/lib/releaf/responders/page_not_found_responder_spec.rb
|
717
|
+
- spec/lib/releaf/service_spec.rb
|
718
|
+
- spec/lib/releaf/root_spec.rb
|
727
719
|
- spec/lib/releaf/responders_spec.rb
|
720
|
+
- spec/lib/releaf/resource_params_spec.rb
|
721
|
+
- spec/lib/releaf/resource_fields_spec.rb
|
722
|
+
- spec/lib/releaf/controller_group_definition_spec.rb
|
728
723
|
- spec/lib/releaf/root/configuration_spec.rb
|
729
724
|
- spec/lib/releaf/root/default_controller_resolver_spec.rb
|
730
|
-
- spec/lib/releaf/
|
731
|
-
- spec/lib/releaf/
|
732
|
-
- spec/lib/releaf/
|
733
|
-
- spec/lib/releaf/
|
734
|
-
- spec/lib/releaf/settings_manager_spec.rb
|
725
|
+
- spec/lib/releaf/resource_table_fields_spec.rb
|
726
|
+
- spec/lib/releaf/default_searchable_fields_spec.rb
|
727
|
+
- spec/lib/releaf/application_spec.rb
|
728
|
+
- spec/lib/releaf/resource_utilities_spec.rb
|
735
729
|
- spec/lib/validation_error_codes_spec.rb
|
736
|
-
- spec/
|
737
|
-
- spec/
|
730
|
+
- spec/fixtures/unicorn.jpg
|
731
|
+
- spec/fixtures/time.formats.xlsx
|
732
|
+
- spec/fixtures/common_fields.yml
|
733
|
+
- spec/fixtures/cs.png
|
738
734
|
- spec/routing/route_mapper_spec.rb
|
739
|
-
- spec/
|
740
|
-
- spec/
|
735
|
+
- spec/controllers/releaf/root_controller_spec.rb
|
736
|
+
- spec/controllers/releaf/action_controller_spec.rb
|
737
|
+
- spec/controllers/releaf/settings_controller_spec.rb
|
738
|
+
- spec/controllers/concerns/releaf/richtext_attachments_spec.rb
|
739
|
+
- spec/helpers/application_helper_spec.rb
|
740
|
+
- spec/helpers/button_helper_spec.rb
|
741
741
|
- spec/services/array/reorder_spec.rb
|