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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '001499ff95838133a90ea99f984f203e2bdea01eaf7b9ee243a6ffed88eddfd8'
4
- data.tar.gz: ece23450569b4aa12a8937a9460d555f193e3a489d8f911335a398d8672e9d99
3
+ metadata.gz: 24550823b36995857b4010fe0adfab5d436046b9fb8b865dff703aae8fa5d18e
4
+ data.tar.gz: '0340851de16d3076de35a0993c4578c789ddee11ca51fca80b06105d83d50ca9'
5
5
  SHA512:
6
- metadata.gz: d108a1b5904c71a7074400e29c899642628fbd5f32c098d5c55b17899a06d3e1012ebd676a52d623165b1d78d2ced5335c89e190682ba17270636d55c5c28a82
7
- data.tar.gz: 735e0fad5cbe05ca84a0b5a489219bd2b47607cda899e69da384d8467f5486937a66cfb58d86f5e77878d3bb67409a5cb73905159773141840278ff804aee906
6
+ metadata.gz: 60637a9594b76ebba5401ea3a6717373c55b8786eea8eae274617c6247d114dd83837697ae3e14aa3baaab7463b2c52b8307ac9f512deec395508982ae37cbfc
7
+ data.tar.gz: bcec5f12fce19dde4f7229040811a1b44b4aa00182351d8a88a989b4b407b23ce594895c13ed73a96895461b9ad24cbdeb3ade8e4ed35277f4fb594724c0ec2c
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: 2.0.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-10-29 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -927,101 +927,6 @@ files:
927
927
  - lib/releaf/service.rb
928
928
  - lib/releaf/settings_ui.rb
929
929
  - lib/tasks/releaf_tasks.rake
930
- - spec/builders/releaf/builders/association_reflector_spec.rb
931
- - spec/builders/releaf/builders/base_spec.rb
932
- - spec/builders/releaf/builders/collection_spec.rb
933
- - spec/builders/releaf/builders/confirm_destroy_dialog_builder_spec.rb
934
- - spec/builders/releaf/builders/confirm_dialog_builder_spec.rb
935
- - spec/builders/releaf/builders/edit_builder_spec.rb
936
- - spec/builders/releaf/builders/form_builder/associations_spec.rb
937
- - spec/builders/releaf/builders/form_builder/date_fields_spec.rb
938
- - spec/builders/releaf/builders/form_builder/i18n_fields_spec.rb
939
- - spec/builders/releaf/builders/form_builder/label_spec.rb
940
- - spec/builders/releaf/builders/form_builder/number_fields_spec.rb
941
- - spec/builders/releaf/builders/form_builder_spec.rb
942
- - spec/builders/releaf/builders/index_builder_spec.rb
943
- - spec/builders/releaf/builders/page/header_builder_spec.rb
944
- - spec/builders/releaf/builders/page/layout_builder_spec.rb
945
- - spec/builders/releaf/builders/page/menu_builder_spec.rb
946
- - spec/builders/releaf/builders/pagination_builder_spec.rb
947
- - spec/builders/releaf/builders/resource_dialog_spec.rb
948
- - spec/builders/releaf/builders/resource_view_spec.rb
949
- - spec/builders/releaf/builders/show_builder_spec.rb
950
- - spec/builders/releaf/builders/table_builder_spec.rb
951
- - spec/builders/releaf/builders/template_spec.rb
952
- - spec/builders/releaf/builders/toolbox_builder_spec.rb
953
- - spec/builders/releaf/builders/toolbox_spec.rb
954
- - spec/builders/releaf/builders/utilities/date_fields_spec.rb
955
- - spec/builders/releaf/builders/utilities/resolve_attribute_field_method_name_spec.rb
956
- - spec/builders/releaf/builders/view_spec.rb
957
- - spec/builders/releaf/builders_spec.rb
958
- - spec/builders/releaf/settings/form_builder_spec.rb
959
- - spec/builders/releaf/settings/table_builder_spec.rb
960
- - spec/controllers/concerns/releaf/richtext_attachments_spec.rb
961
- - spec/controllers/releaf/action_controller_spec.rb
962
- - spec/controllers/releaf/root_controller_spec.rb
963
- - spec/controllers/releaf/settings_controller_spec.rb
964
- - spec/error_hash_builder_spec.rb
965
- - spec/ext/array_reorder_spec.rb
966
- - spec/features/ajaxbox_spec.rb
967
- - spec/features/authorization_spec.rb
968
- - spec/features/breadcrumbs_spec.rb
969
- - spec/features/dragonfly_integration_spec.rb
970
- - spec/features/edit_actions_spec.rb
971
- - spec/features/errors_spec.rb
972
- - spec/features/index_actions_spec.rb
973
- - spec/features/index_table_spec.rb
974
- - spec/features/menu_spec.rb
975
- - spec/features/richtext_attachments_spec.rb
976
- - spec/features/richtext_custom_config_spec.rb
977
- - spec/features/richtext_embed_spec.rb
978
- - spec/features/richtext_spec.rb
979
- - spec/features/search_spec.rb
980
- - spec/features/settings_spec.rb
981
- - spec/features/title_spec.rb
982
- - spec/fixtures/common_fields.yml
983
- - spec/fixtures/cs.png
984
- - spec/fixtures/time.formats.xlsx
985
- - spec/fixtures/unicorn.jpg
986
- - spec/helpers/application_helper_spec.rb
987
- - spec/helpers/button_helper_spec.rb
988
- - spec/lib/releaf/action_controller/features_spec.rb
989
- - spec/lib/releaf/action_controller/search_spec.rb
990
- - spec/lib/releaf/application_spec.rb
991
- - spec/lib/releaf/assets_resolver_spec.rb
992
- - spec/lib/releaf/build_errors_hash_spec.rb
993
- - spec/lib/releaf/configuration_spec.rb
994
- - spec/lib/releaf/controller_definition_spec.rb
995
- - spec/lib/releaf/controller_group_definition_spec.rb
996
- - spec/lib/releaf/default_searchable_fields_spec.rb
997
- - spec/lib/releaf/instance_cache_spec.rb
998
- - spec/lib/releaf/resource_base_spec.rb
999
- - spec/lib/releaf/resource_fields_spec.rb
1000
- - spec/lib/releaf/resource_params_spec.rb
1001
- - spec/lib/releaf/resource_table_fields_spec.rb
1002
- - spec/lib/releaf/resource_utilities_spec.rb
1003
- - spec/lib/releaf/responders/access_denied_responder_spec.rb
1004
- - spec/lib/releaf/responders/after_save_responder_spec.rb
1005
- - spec/lib/releaf/responders/confirm_destroy_responder_spec.rb
1006
- - spec/lib/releaf/responders/destroy_responder_spec.rb
1007
- - spec/lib/releaf/responders/error_responder_spec.rb
1008
- - spec/lib/releaf/responders/feature_disabled_responder_spec.rb
1009
- - spec/lib/releaf/responders/page_not_found_responder_spec.rb
1010
- - spec/lib/releaf/responders_spec.rb
1011
- - spec/lib/releaf/root/configuration_spec.rb
1012
- - spec/lib/releaf/root/default_controller_resolver_spec.rb
1013
- - spec/lib/releaf/root_spec.rb
1014
- - spec/lib/releaf/service_spec.rb
1015
- - spec/lib/releaf/settings/normalize_value_spec.rb
1016
- - spec/lib/releaf/settings/register_spec.rb
1017
- - spec/lib/releaf/settings_manager_spec.rb
1018
- - spec/lib/validation_error_codes_spec.rb
1019
- - spec/misc/factories_spec.rb
1020
- - spec/models/settings_spec.rb
1021
- - spec/routing/route_mapper_spec.rb
1022
- - spec/rspec_helpers/test_helpers_spec.rb
1023
- - spec/rspec_helpers/test_spec.rb
1024
- - spec/services/array/reorder_spec.rb
1025
930
  homepage: https://github.com/cubesystems/releaf
1026
931
  licenses:
1027
932
  - MIT
@@ -1045,99 +950,4 @@ rubygems_version: 3.0.8
1045
950
  signing_key:
1046
951
  specification_version: 4
1047
952
  summary: core gem for releaf
1048
- test_files:
1049
- - spec/misc/factories_spec.rb
1050
- - spec/builders/releaf/settings/table_builder_spec.rb
1051
- - spec/builders/releaf/settings/form_builder_spec.rb
1052
- - spec/builders/releaf/builders/collection_spec.rb
1053
- - spec/builders/releaf/builders/confirm_dialog_builder_spec.rb
1054
- - spec/builders/releaf/builders/table_builder_spec.rb
1055
- - spec/builders/releaf/builders/page/menu_builder_spec.rb
1056
- - spec/builders/releaf/builders/page/layout_builder_spec.rb
1057
- - spec/builders/releaf/builders/page/header_builder_spec.rb
1058
- - spec/builders/releaf/builders/toolbox_builder_spec.rb
1059
- - spec/builders/releaf/builders/view_spec.rb
1060
- - spec/builders/releaf/builders/index_builder_spec.rb
1061
- - spec/builders/releaf/builders/utilities/date_fields_spec.rb
1062
- - spec/builders/releaf/builders/utilities/resolve_attribute_field_method_name_spec.rb
1063
- - spec/builders/releaf/builders/template_spec.rb
1064
- - spec/builders/releaf/builders/resource_view_spec.rb
1065
- - spec/builders/releaf/builders/pagination_builder_spec.rb
1066
- - spec/builders/releaf/builders/form_builder/associations_spec.rb
1067
- - spec/builders/releaf/builders/form_builder/date_fields_spec.rb
1068
- - spec/builders/releaf/builders/form_builder/label_spec.rb
1069
- - spec/builders/releaf/builders/form_builder/i18n_fields_spec.rb
1070
- - spec/builders/releaf/builders/form_builder/number_fields_spec.rb
1071
- - spec/builders/releaf/builders/form_builder_spec.rb
1072
- - spec/builders/releaf/builders/association_reflector_spec.rb
1073
- - spec/builders/releaf/builders/base_spec.rb
1074
- - spec/builders/releaf/builders/confirm_destroy_dialog_builder_spec.rb
1075
- - spec/builders/releaf/builders/toolbox_spec.rb
1076
- - spec/builders/releaf/builders/edit_builder_spec.rb
1077
- - spec/builders/releaf/builders/resource_dialog_spec.rb
1078
- - spec/builders/releaf/builders/show_builder_spec.rb
1079
- - spec/builders/releaf/builders_spec.rb
1080
- - spec/rspec_helpers/test_helpers_spec.rb
1081
- - spec/rspec_helpers/test_spec.rb
1082
- - spec/ext/array_reorder_spec.rb
1083
- - spec/features/index_table_spec.rb
1084
- - spec/features/index_actions_spec.rb
1085
- - spec/features/title_spec.rb
1086
- - spec/features/richtext_embed_spec.rb
1087
- - spec/features/search_spec.rb
1088
- - spec/features/breadcrumbs_spec.rb
1089
- - spec/features/authorization_spec.rb
1090
- - spec/features/menu_spec.rb
1091
- - spec/features/ajaxbox_spec.rb
1092
- - spec/features/edit_actions_spec.rb
1093
- - spec/features/richtext_custom_config_spec.rb
1094
- - spec/features/richtext_spec.rb
1095
- - spec/features/settings_spec.rb
1096
- - spec/features/richtext_attachments_spec.rb
1097
- - spec/features/dragonfly_integration_spec.rb
1098
- - spec/features/errors_spec.rb
1099
- - spec/models/settings_spec.rb
1100
- - spec/error_hash_builder_spec.rb
1101
- - spec/lib/releaf/responders/error_responder_spec.rb
1102
- - spec/lib/releaf/responders/confirm_destroy_responder_spec.rb
1103
- - spec/lib/releaf/responders/feature_disabled_responder_spec.rb
1104
- - spec/lib/releaf/responders/page_not_found_responder_spec.rb
1105
- - spec/lib/releaf/responders/after_save_responder_spec.rb
1106
- - spec/lib/releaf/responders/destroy_responder_spec.rb
1107
- - spec/lib/releaf/responders/access_denied_responder_spec.rb
1108
- - spec/lib/releaf/action_controller/search_spec.rb
1109
- - spec/lib/releaf/action_controller/features_spec.rb
1110
- - spec/lib/releaf/settings/register_spec.rb
1111
- - spec/lib/releaf/settings/normalize_value_spec.rb
1112
- - spec/lib/releaf/settings_manager_spec.rb
1113
- - spec/lib/releaf/resource_base_spec.rb
1114
- - spec/lib/releaf/build_errors_hash_spec.rb
1115
- - spec/lib/releaf/assets_resolver_spec.rb
1116
- - spec/lib/releaf/instance_cache_spec.rb
1117
- - spec/lib/releaf/configuration_spec.rb
1118
- - spec/lib/releaf/controller_definition_spec.rb
1119
- - spec/lib/releaf/service_spec.rb
1120
- - spec/lib/releaf/root_spec.rb
1121
- - spec/lib/releaf/responders_spec.rb
1122
- - spec/lib/releaf/resource_params_spec.rb
1123
- - spec/lib/releaf/resource_fields_spec.rb
1124
- - spec/lib/releaf/controller_group_definition_spec.rb
1125
- - spec/lib/releaf/root/configuration_spec.rb
1126
- - spec/lib/releaf/root/default_controller_resolver_spec.rb
1127
- - spec/lib/releaf/resource_table_fields_spec.rb
1128
- - spec/lib/releaf/default_searchable_fields_spec.rb
1129
- - spec/lib/releaf/application_spec.rb
1130
- - spec/lib/releaf/resource_utilities_spec.rb
1131
- - spec/lib/validation_error_codes_spec.rb
1132
- - spec/fixtures/unicorn.jpg
1133
- - spec/fixtures/time.formats.xlsx
1134
- - spec/fixtures/common_fields.yml
1135
- - spec/fixtures/cs.png
1136
- - spec/routing/route_mapper_spec.rb
1137
- - spec/controllers/releaf/root_controller_spec.rb
1138
- - spec/controllers/releaf/action_controller_spec.rb
1139
- - spec/controllers/releaf/settings_controller_spec.rb
1140
- - spec/controllers/concerns/releaf/richtext_attachments_spec.rb
1141
- - spec/helpers/application_helper_spec.rb
1142
- - spec/helpers/button_helper_spec.rb
1143
- - spec/services/array/reorder_spec.rb
953
+ test_files: []
@@ -1,138 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Releaf::Builders::AssociationReflector, type: :class do
4
- let(:reflection){ Book.reflect_on_association("chapters") }
5
- subject{ described_class.new(reflection, :b, "xx") }
6
-
7
- describe "#initialize" do
8
- it "assigns given reflection" do
9
- expect(subject.reflection).to eq(reflection)
10
- end
11
-
12
- it "assigns given fields" do
13
- expect(subject.fields).to eq(:b)
14
- end
15
-
16
- it "normalizes to symbol and assigns given sortable name" do
17
- expect(subject.sortable_column_name).to eq(:xx)
18
- end
19
- end
20
-
21
- describe "#destroyable?" do
22
- context "when reflection allow to destroy through nested attributes" do
23
- it "returns true" do
24
- subject.reflection = Book.reflect_on_association("book_sequels")
25
- expect(subject.destroyable?).to be true
26
- end
27
- end
28
-
29
- context "when reflection does not allow to destroy through nested attributes" do
30
- it "returns false" do
31
- expect(subject.destroyable?).to be false
32
- end
33
- end
34
-
35
- it "caches result" do
36
- expect(subject.reflection.active_record).to receive(:nested_attributes_options).and_call_original.once
37
- subject.destroyable?
38
- subject.destroyable?
39
- subject.destroyable?
40
- end
41
- end
42
-
43
- describe "#sortable?" do
44
- context "when expected and actual order clauses are same" do
45
- it "returns true" do
46
- allow(subject).to receive(:expected_order_clause).and_return(:a)
47
- allow(subject).to receive(:actual_order_clause).and_return(:a)
48
- expect(subject.sortable?).to be true
49
- end
50
- end
51
-
52
- context "when expected and actual order clauses differs" do
53
- it "returns false" do
54
- allow(subject).to receive(:expected_order_clause).and_return(:a)
55
- allow(subject).to receive(:actual_order_clause).and_return(:b)
56
- expect(subject.sortable?).to be false
57
- end
58
- end
59
-
60
- it "caches result" do
61
- expect(subject).to receive(:expected_order_clause).and_return(:x).once
62
- expect(subject).to receive(:actual_order_clause).and_return(:y).once
63
- subject.sortable?
64
- subject.sortable?
65
- subject.sortable?
66
- end
67
- end
68
-
69
- describe "#actual_order_clause" do
70
- context "when scope exists within reflection" do
71
- it "returns actual reflection klass order clause with evaluated scope" do
72
- relation = reflection.klass.all.order(:item_position)
73
- allow(subject).to receive(:extract_order_clause).with(relation).and_return(:y)
74
- expect(subject.actual_order_clause).to eq(:y)
75
- end
76
- end
77
-
78
- context "when no scope exists within reflection" do
79
- it "returns actual reflection klass order clause" do
80
- subject.reflection = Book.reflect_on_association("sequels")
81
- relation = subject.reflection.klass.all
82
- allow(subject).to receive(:extract_order_clause).with(relation).and_return(:y)
83
- expect(subject.actual_order_clause).to eq(:y)
84
- end
85
- end
86
- end
87
-
88
- describe "#expected_order_clause" do
89
- it "returns expected reflection klass order clause for sortable column name" do
90
- subject.sortable_column_name = :title
91
- relation = reflection.klass.all.order(:title)
92
- allow(subject).to receive(:extract_order_clause).with(relation).and_return(:y)
93
- expect(subject.expected_order_clause).to eq(:y)
94
- end
95
- end
96
-
97
- describe "#extract_order_clause" do
98
- it "returns order clauses normalized to string for given relation" do
99
- relation = Book.order(genre: :desc)
100
- expected_result = if mysql?
101
- "`books`.`genre` DESC"
102
- elsif postgresql?
103
- '"books"."genre" DESC'
104
- else
105
- fail
106
- end
107
- expect(subject.extract_order_clause(relation)).to eq(expected_result)
108
- end
109
-
110
- context "when relation has no order clauses" do
111
- it "returns empty string" do
112
- relation = Book.all
113
- expect(subject.extract_order_clause(relation)).to eq("")
114
- end
115
- end
116
- end
117
-
118
- describe "#value_as_sql" do
119
- context "when given value respond to sql" do
120
- it "return resulting sql" do
121
- expected_result = if mysql?
122
- "SELECT `books`.* FROM `books`"
123
- elsif postgresql?
124
- 'SELECT "books".* FROM "books"'
125
- else
126
- fail
127
- end
128
- expect(subject.value_as_sql(Book.all)).to match "SELECT"
129
- end
130
- end
131
-
132
- context "when given value does not respond to sql" do
133
- it "return given value" do
134
- expect(subject.value_as_sql(12)).to eq(12)
135
- end
136
- end
137
- end
138
- end
@@ -1,272 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Releaf::Builders::Base, type: :module do
4
- class FormBuilderTestHelper < ActionView::Base
5
- include Releaf::ButtonHelper
6
- include Releaf::ApplicationHelper
7
- include FontAwesome::Rails::IconHelper
8
- end
9
- class BuilderIncluder
10
- include Releaf::Builders::Base
11
- attr_accessor :template
12
- end
13
-
14
- let(:subject){ BuilderIncluder.new }
15
- let(:template){ FormBuilderTestHelper.new(ActionView::LookupContext.new(nil), {}, nil) }
16
-
17
- before do
18
- subject.template = template
19
- end
20
-
21
- describe "delegations" do
22
- [:controller, :controller_name, :url_for, :form_for,
23
- :releaf_button, :params, :form_tag, :file_field_tag,
24
- :request, :check_box_tag, :label_tag, :content_tag, :hidden_field_tag,
25
- :render, :link_to, :flash, :truncate, :radio_button_tag,
26
- :options_for_select, :action_name, :options_from_collection_for_select,
27
- :select_tag, :text_field_tag,
28
- :image_tag, :cookies, :button_tag, :merge_attributes
29
- ].each do|method_name|
30
- it "deletages #{method_name} to template" do
31
- expect(subject).to delegate_method(method_name).to(:template)
32
- end
33
- end
34
-
35
- [:controller_scope_name, :feature_available?, :builder_class, :index_path].each do|method_name|
36
- it "delegates #{method_name} to controller" do
37
- expect(subject).to delegate_method(method_name).to(:controller)
38
- end
39
- end
40
- end
41
-
42
- describe "#layout_settings" do
43
- it "returns settings manager setting for given key" do
44
- allow(Releaf.application.config.settings_manager).to receive(:read)
45
- .with(controller: "_ctrl_", key: "a.x").and_return("xxxxx")
46
- allow(subject).to receive(:controller).and_return("_ctrl_")
47
-
48
- expect(subject.layout_settings("a.x")).to eq("xxxxx")
49
- end
50
- end
51
-
52
- describe "#html_escape" do
53
- it "escapes given value with " do
54
- allow(ERB::Util).to receive(:html_escape).with("a").and_return("b")
55
- expect(subject.html_escape("a")).to eq("b")
56
- end
57
- end
58
-
59
- it "aliases #button to #releaf_button" do
60
- allow(subject.template).to receive(:releaf_button).with("x", a: "y", b: "z").and_return("xx")
61
- expect(subject.button("x", a: "y", b: "z")).to eq("xx")
62
- end
63
-
64
- describe "#icon" do
65
- it "returns template fa_icon output" do
66
- expect(subject.icon("check")).to eq('<i class="fa fa-check"></i>')
67
- end
68
- end
69
-
70
- describe "#tag" do
71
- context "when block is not given" do
72
- context "when passing string as content" do
73
- let(:output) do
74
- subject.tag(:span, "<p>x</p>", class: "red")
75
- end
76
-
77
- it "returns an instance of ActiveSupport::SafeBuffer" do
78
- expect( output ).to be_a ActiveSupport::SafeBuffer
79
-
80
- end
81
-
82
- it "passes all arguments to template #content_tag method and returns properly escaped result" do
83
- expect( output ).to eq('<span class="red">&lt;p&gt;x&lt;/p&gt;</span>')
84
- end
85
- end
86
-
87
- context "when passing safe buffer as content" do
88
- let(:output) do
89
- subject.tag(:span, ActiveSupport::SafeBuffer.new("<p>x</p>"), class: "red")
90
- end
91
-
92
- it "returns an instance of ActiveSupport::SafeBuffer" do
93
- expect( output ).to be_a ActiveSupport::SafeBuffer
94
-
95
- end
96
-
97
- it "passes all arguments to template #content_tag method and returns properly escaped result" do
98
- expect( output ).to eq('<span class="red"><p>x</p></span>')
99
- end
100
- end
101
-
102
- end
103
-
104
- context "when block is given" do
105
- context "when block evaluates to array" do
106
- let(:content) do
107
- [
108
- '<p>foo</p>',
109
- 'bar',
110
- ActiveSupport::SafeBuffer.new('<p>baz</p>')
111
- ]
112
- end
113
-
114
- let(:output) do
115
- subject.tag(:div, class: 'important') { content }
116
- end
117
-
118
- it "returns an instance of ActiveSupport::SafeBuffer" do
119
- expect( output ).to be_a ActiveSupport::SafeBuffer
120
- end
121
-
122
- it "safely joins array" do
123
- expect( template ).to receive(:safe_join).with(content).and_call_original
124
- output
125
- end
126
-
127
- it "passes joined result to #template#content_tag as content" do
128
- allow( template ).to receive(:safe_join).with(content).and_return('super duper')
129
- expect( output ).to eq('<div class="important">super duper</div>')
130
- end
131
-
132
- it "returns properly escaped result" do
133
- expect( output ).to eq('<div class="important">&lt;p&gt;foo&lt;/p&gt;bar<p>baz</p></div>')
134
- end
135
-
136
- end
137
-
138
- context "when block evaluates to other than array" do
139
- let(:output) do
140
- subject.tag(:div, class: 'important') { '<p>content</p>' }
141
- end
142
-
143
- it "returns an instance of ActiveSupport::SafeBuffer" do
144
- expect( output ).to be_a ActiveSupport::SafeBuffer
145
- end
146
-
147
- it "doesn't call #template#safe_join" do
148
- expect( template ).to_not receive(:safe_join)
149
- output
150
- end
151
-
152
- it "keeps safe buffer unmodified and pass to #template#content_tag as content which won't be escaped" do
153
- expect( subject.tag(:div, class: 'important') { ActiveSupport::SafeBuffer.new('<p>content</p>') } ).to eq '<div class="important"><p>content</p></div>'
154
- end
155
-
156
- it "passes block result to #template#content_tag as content which will be escaped" do
157
- expect( output ).to eq '<div class="important">&lt;p&gt;content&lt;/p&gt;</div>'
158
- end
159
-
160
- it "casts block result to string" do
161
- expect( subject.tag(:div, class: 'important') { 1 } ).to eq '<div class="important">1</div>'
162
- end
163
- end
164
- end
165
- end
166
-
167
- describe "#wrapper" do
168
- context "when block is given" do
169
- let(:output) do
170
- subject.wrapper(class: 'c') do
171
- '<span class="a">b</span>'.html_safe
172
- end
173
- end
174
-
175
- it "wrapps given content within div element with given attributes" do
176
- expect(output).to eq('<div class="c"><span class="a">b</span></div>')
177
- end
178
- end
179
-
180
- context "when block is not given" do
181
- it "wrapps given content within div element with given attributes" do
182
- expect(subject.wrapper('<span class="a">b</span>'.html_safe, class: "c")).to eq('<div class="c"><span class="a">b</span></div>')
183
- end
184
- end
185
- end
186
-
187
- describe "#template_variable" do
188
- it "returns template instance variable value for given key" do
189
- template.instance_variable_set("@test", "xx")
190
- expect(subject.template_variable("test")).to eq("xx")
191
- end
192
- end
193
-
194
- describe "#safe_join" do
195
- let(:content) do
196
- ['foo', '<p>bar</p>', ActiveSupport::SafeBuffer.new('<p>baz</p>')]
197
- end
198
-
199
- let(:output) do
200
- subject.safe_join { content }
201
- end
202
-
203
- it "returns an instance of ActiveSupport::SafeBuffer" do
204
- expect( output ).to be_a ActiveSupport::SafeBuffer
205
- end
206
-
207
- it "passes block result to #template#safe_join" do
208
- expect( template ).to receive(:safe_join).with(content).and_call_original
209
- output
210
- end
211
-
212
- it "returns correctly escaped result" do
213
- expect( output ).to eq 'foo&lt;p&gt;bar&lt;/p&gt;<p>baz</p>'
214
- end
215
- end
216
-
217
- describe "#t" do
218
- before do
219
- allow(subject).to receive(:default_translation_scope).and_return("_default_scope_")
220
- end
221
-
222
- it "passes all arguments to I18n.t and returns translation" do
223
- allow(I18n).to receive(:t).with("x", default: "y", scope: "z").and_return("translated value")
224
- expect(subject.t("x", default: "y", scope: "z")).to eq("translated value")
225
- end
226
-
227
- context "when :scope option passed" do
228
- it "uses default translation scope controller translation scope" do
229
- expect(I18n).to receive(:t).with("x", scope: "zzz").and_return("asd")
230
- subject.t("x", scope: "zzz")
231
- end
232
- end
233
-
234
- context "when no :scope option passed" do
235
- it "adds controller translation scope" do
236
- expect(I18n).to receive(:t).with("x", scope: "_default_scope_").and_return("asd")
237
- subject.t("x")
238
- end
239
- end
240
- end
241
-
242
- describe "#translate_locale" do
243
- it "returns translated locale within `locales` scope" do
244
- allow(subject).to receive(:t).with("de", scope: "locales").and_return("dzerman")
245
- expect(subject.translate_locale("de")).to eq("dzerman")
246
- end
247
- end
248
-
249
- describe "#locale_options" do
250
- it "returns array with translated locales usable for rails options helper" do
251
- allow(subject).to receive(:t).with("de", scope: "locales").and_return("dzerman")
252
- allow(subject).to receive(:t).with("lv", scope: "locales").and_return("latvian")
253
- expect(subject.locale_options(["de", "lv"])).to eq([["dzerman", "de"], ["latvian", "lv"]])
254
- end
255
- end
256
-
257
- describe "#resource_title" do
258
- it "pass given resource to Releaf::ResourceBase.title and return result" do
259
- allow(Releaf::ResourceBase).to receive(:title).with("x").and_return("ljhg")
260
- expect(subject.resource_title("x")).to eq("ljhg")
261
- end
262
- end
263
-
264
- describe "#default_translation_scope" do
265
- it "returns controller scope" do
266
- controller = Releaf::ActionController.new
267
- allow(subject).to receive(:controller).and_return(controller)
268
- allow(controller).to receive(:controller_scope_name).and_return("x")
269
- expect(subject.default_translation_scope).to eq("x")
270
- end
271
- end
272
- end