wice_grid 3.5.0 → 3.6.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.inch.yml +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +181 -0
- data/.travis.yml +22 -0
- data/{CHANGELOG → CHANGELOG.md} +95 -31
- data/Gemfile +4 -1
- data/README.md +1517 -0
- data/Rakefile +51 -7
- data/{SAVED_QUERIES_HOWTO.rdoc → SAVED_QUERIES_HOWTO.md} +34 -31
- data/TODO.md +16 -0
- data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +4 -6
- data/lib/generators/wice_grid/install_generator.rb +2 -5
- data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +1 -0
- data/lib/generators/wice_grid/templates/wice_grid_config.rb +29 -34
- data/lib/wice/active_record_column_wrapper.rb +36 -17
- data/lib/wice/columns.rb +53 -52
- data/lib/wice/columns/column_action.rb +11 -13
- data/lib/wice/columns/column_boolean.rb +9 -11
- data/lib/wice/columns/column_bootstrap_datepicker.rb +48 -0
- data/lib/wice/columns/column_custom_dropdown.rb +22 -23
- data/lib/wice/columns/column_float.rb +2 -6
- data/lib/wice/columns/column_html5_datepicker.rb +31 -0
- data/lib/wice/columns/column_integer.rb +9 -13
- data/lib/wice/columns/column_jquery_datepicker.rb +49 -0
- data/lib/wice/columns/column_processor_index.rb +18 -13
- data/lib/wice/columns/column_rails_date_helper.rb +41 -0
- data/lib/wice/columns/column_rails_datetime_helper.rb +40 -0
- data/lib/wice/columns/column_range.rb +7 -11
- data/lib/wice/columns/column_string.rb +24 -20
- data/lib/wice/columns/common_date_datetime_mixin.rb +20 -0
- data/lib/wice/columns/common_js_date_datetime_conditions_generator_mixin.rb +39 -0
- data/lib/wice/columns/common_js_date_datetime_mixin.rb +15 -0
- data/lib/wice/columns/{column_date.rb → common_rails_date_datetime_conditions_generator_mixin.rb} +4 -22
- data/lib/wice/columns/common_standard_helper_date_datetime_mixin.rb +22 -0
- data/lib/wice/grid_output_buffer.rb +19 -10
- data/lib/wice/grid_renderer.rb +146 -85
- data/lib/wice/helpers/bs_calendar_helpers.rb +6 -7
- data/lib/wice/helpers/js_calendar_helpers.rb +19 -17
- data/lib/wice/helpers/wice_grid_misc_view_helpers.rb +18 -18
- data/lib/wice/helpers/wice_grid_serialized_queries_view_helpers.rb +44 -49
- data/lib/wice/helpers/wice_grid_view_helpers.rb +131 -134
- data/lib/wice/kaminari_monkey_patching.rb +3 -1
- data/lib/wice/table_column_matrix.rb +23 -8
- data/lib/wice/wice_grid_controller.rb +12 -16
- data/lib/wice/wice_grid_core_ext.rb +12 -20
- data/lib/wice/wice_grid_misc.rb +131 -53
- data/lib/wice/wice_grid_serialized_queries_controller.rb +10 -11
- data/lib/wice/wice_grid_serialized_query.rb +4 -3
- data/lib/wice/wice_grid_spreadsheet.rb +19 -18
- data/lib/wice_grid.rb +144 -135
- data/spec/schema.rb +9 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/support/active_record.rb +11 -0
- data/spec/support/wice_grid_test_config.rb +172 -0
- data/spec/wice/grid_output_buffer_spec.rb +41 -0
- data/spec/wice/table_column_matrix_spec.rb +38 -0
- data/spec/wice/wice_grid_misc_spec.rb +159 -0
- data/spec/wice/wice_grid_spreadsheet_spec.rb +14 -0
- data/test/readme.txt +1 -1
- data/vendor/assets/javascripts/wice_grid_init.js.coffee +14 -8
- data/vendor/assets/stylesheets/wice_grid.scss +84 -0
- data/wice_grid.gemspec +32 -16
- metadata +217 -25
- data/README.rdoc +0 -1325
- data/lib/generators/wice_grid/templates/wice_grid.scss +0 -140
- data/lib/wice/columns/column_datetime.rb +0 -171
- data/vendor/assets/images/icons/grid/arrow_down.gif +0 -0
- data/vendor/assets/images/icons/grid/arrow_up.gif +0 -0
- data/vendor/assets/images/icons/grid/calendar_view_month.png +0 -0
- data/vendor/assets/images/icons/grid/collapse.gif +0 -0
- data/vendor/assets/images/icons/grid/delete.png +0 -0
- data/vendor/assets/images/icons/grid/expand.gif +0 -0
- data/vendor/assets/images/icons/grid/page_white_excel.png +0 -0
- data/vendor/assets/images/icons/grid/page_white_find.png +0 -0
- data/vendor/assets/images/icons/grid/table.png +0 -0
- data/vendor/assets/images/icons/grid/table_refresh.png +0 -0
- data/vendor/assets/images/icons/grid/tick_all.png +0 -0
- data/vendor/assets/images/icons/grid/untick_all.png +0 -0
data/spec/schema.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
3
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
4
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
5
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
6
|
+
# files.
|
7
|
+
#
|
8
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
9
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
10
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
11
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
12
|
+
# a separate helper file that requires the additional dependencies and performs
|
13
|
+
# the additional setup, and require it from the spec files that actually need
|
14
|
+
# it.
|
15
|
+
#
|
16
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
17
|
+
# users commonly want.
|
18
|
+
#
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
20
|
+
|
21
|
+
require 'rspec'
|
22
|
+
require 'coveralls'
|
23
|
+
require 'codeclimate-test-reporter'
|
24
|
+
require 'simplecov'
|
25
|
+
|
26
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
27
|
+
Coveralls::SimpleCov::Formatter,
|
28
|
+
SimpleCov::Formatter::HTMLFormatter,
|
29
|
+
CodeClimate::TestReporter::Formatter
|
30
|
+
]
|
31
|
+
SimpleCov.start
|
32
|
+
|
33
|
+
begin
|
34
|
+
require 'support/active_record'
|
35
|
+
require 'action_controller'
|
36
|
+
require 'action_view'
|
37
|
+
require 'csv'
|
38
|
+
|
39
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
40
|
+
rescue LoadError
|
41
|
+
puts 'LoadError'
|
42
|
+
end
|
43
|
+
|
44
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
|
45
|
+
require 'wice_grid'
|
46
|
+
require 'support/wice_grid_test_config'
|
47
|
+
|
48
|
+
ActiveRecord::ConnectionAdapters::Column.send(:include, ::Wice::WiceGridExtentionToActiveRecordColumn)
|
49
|
+
|
50
|
+
::Wice.on_action_view_load
|
51
|
+
|
52
|
+
RSpec.configure do |config|
|
53
|
+
# rspec-expectations config goes here. You can use an alternate
|
54
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
55
|
+
# assertions if you prefer.
|
56
|
+
config.expect_with :rspec do |expectations|
|
57
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
58
|
+
# and `failure_message` of custom matchers include text for helper methods
|
59
|
+
# defined using `chain`, e.g.:
|
60
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
61
|
+
# # => "be bigger than 2 and smaller than 4"
|
62
|
+
# ...rather than:
|
63
|
+
# # => "be bigger than 2"
|
64
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
65
|
+
end
|
66
|
+
|
67
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
68
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
69
|
+
config.mock_with :rspec do |mocks|
|
70
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
71
|
+
# a real object. This is generally recommended, and will default to
|
72
|
+
# `true` in RSpec 4.
|
73
|
+
mocks.verify_partial_doubles = true
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Default number of rows to show per page.
|
4
|
+
Wice::Defaults::PER_PAGE = 20
|
5
|
+
|
6
|
+
# Default order direction
|
7
|
+
Wice::Defaults::ORDER_DIRECTION = 'asc'
|
8
|
+
|
9
|
+
# Default name for a grid. A grid name is the basis for a lot of
|
10
|
+
# names including parameter names, DOM IDs, etc
|
11
|
+
# The shorter the name is the shorter the request URI will be.
|
12
|
+
Wice::Defaults::GRID_NAME = 'grid'
|
13
|
+
|
14
|
+
# If REUSE_LAST_COLUMN_FOR_FILTER_ICONS is true and the last column doesn't have any filter and column name, it will be used
|
15
|
+
# for filter related icons (filter icon, reset icon, show/hide icon), otherwise an additional table column is added.
|
16
|
+
Wice::Defaults::REUSE_LAST_COLUMN_FOR_FILTER_ICONS = true
|
17
|
+
|
18
|
+
# The label of the first option of a custom dropdown list meaning 'All items'
|
19
|
+
Wice::Defaults::CUSTOM_FILTER_ALL_LABEL = '--'
|
20
|
+
|
21
|
+
# A list of classes for the table tag of the grid
|
22
|
+
Wice::Defaults::DEFAULT_TABLE_CLASSES = ['table', 'table-bordered', 'table-striped']
|
23
|
+
|
24
|
+
# Allow switching between a single and multiple selection modes in custom filters (dropdown boxes)
|
25
|
+
Wice::Defaults::ALLOW_MULTIPLE_SELECTION = true
|
26
|
+
|
27
|
+
# Show the upper pagination panel by default or not
|
28
|
+
Wice::Defaults::SHOW_UPPER_PAGINATION_PANEL = false
|
29
|
+
|
30
|
+
# Disabling CSV export by default
|
31
|
+
Wice::Defaults::ENABLE_EXPORT_TO_CSV = false
|
32
|
+
|
33
|
+
# Default CSV field separator
|
34
|
+
Wice::Defaults::CSV_FIELD_SEPARATOR = ','
|
35
|
+
|
36
|
+
# The strategy when to show the filter.
|
37
|
+
# * <tt>:when_filtered</tt> - when the table is the result of filtering
|
38
|
+
# * <tt>:always</tt> - show the filter always
|
39
|
+
# * <tt>:no</tt> - never show the filter
|
40
|
+
Wice::Defaults::SHOW_FILTER = :always
|
41
|
+
|
42
|
+
# A boolean value specifying if a change in a filter triggers reloading of the grid.
|
43
|
+
Wice::Defaults::AUTO_RELOAD = false
|
44
|
+
|
45
|
+
# SQL operator used for matching strings in string filters.
|
46
|
+
Wice::Defaults::STRING_MATCHING_OPERATOR = 'LIKE'
|
47
|
+
# STRING_MATCHING_OPERATOR = 'ILIKE' # Use this for Postgresql case-insensitive matching.
|
48
|
+
|
49
|
+
# Defining one string matching operator globally for the whole application turns is not enough
|
50
|
+
# when you connect to two databases one of which is MySQL and the other is Postgresql.
|
51
|
+
# If the key for an adapter is missing it will fall back to Wice::Defaults::STRING_MATCHING_OPERATOR
|
52
|
+
Wice::Defaults::STRING_MATCHING_OPERATORS = {
|
53
|
+
'ActiveRecord::ConnectionAdapters::MysqlAdapter' => 'LIKE',
|
54
|
+
'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' => 'ILIKE'
|
55
|
+
}
|
56
|
+
|
57
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
58
|
+
# Advanced Filters #
|
59
|
+
|
60
|
+
# Switch of the negation checkbox in all text filters
|
61
|
+
Wice::Defaults::NEGATION_IN_STRING_FILTERS = false
|
62
|
+
|
63
|
+
# Each WiceGrid filter column is defined in two classes, one used for rendering the filter, the other
|
64
|
+
# for generating query conditions. All these columns are in lib/wice/columns/*.rb .
|
65
|
+
# File lib/wice/columns/column_processor_index.rb lists all predefined processors.
|
66
|
+
# In most cases a processor is chosen automatically based on the DB column type,
|
67
|
+
# for example, integer columns
|
68
|
+
# can have two of processors, the default one with one input field, and a processor called "range",
|
69
|
+
# with 2 input fields. In this case it is possible to specify a processor in the column definition:
|
70
|
+
#
|
71
|
+
# g.column filter_type: :range
|
72
|
+
#
|
73
|
+
# It is also possible to define you own processors:
|
74
|
+
#
|
75
|
+
# Wice::Defaults::ADDITIONAL_COLUMN_PROCESSORS = {
|
76
|
+
# some_key_identifying_new_column_type: ['AViewColumnProcessorClass', 'ConditionsGeneratorClass'],
|
77
|
+
# another_key_identifying_new_column_type: ['AnotherViewColumnProcessorClass', 'AnotherConditionsGeneratorClass']
|
78
|
+
# }
|
79
|
+
#
|
80
|
+
# Column processor keys/names should not coincide with the existing keys/names (see lib/wice/columns/column_processor_index.rb)
|
81
|
+
# the value is a 2-element array with 2 strings, the first should be a name of view processor class inherited from
|
82
|
+
# Wice::Columns::ViewColumn, the second should be a name of conditions generator class inherited from
|
83
|
+
# Wice::Columns::ConditionsGeneratorColumn .
|
84
|
+
|
85
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
86
|
+
# Showing All Records #
|
87
|
+
|
88
|
+
# Enable or disable showing all records (non-paginated table)
|
89
|
+
Wice::Defaults::ALLOW_SHOWING_ALL_RECORDS = true
|
90
|
+
|
91
|
+
# If number of all queries is more than this value, the user will be given a warning message
|
92
|
+
Wice::Defaults::START_SHOWING_WARNING_FROM = 100
|
93
|
+
|
94
|
+
# Hide the "show all" link if the number of all records is more than...
|
95
|
+
# Force-resets back to pagination starting from this value.
|
96
|
+
# Set to nil to always show it
|
97
|
+
Wice::Defaults::SHOW_ALL_ALLOWED_UP_TO = nil
|
98
|
+
|
99
|
+
#
|
100
|
+
# set to nil to skip the check
|
101
|
+
Wice::Defaults::SWITCH_BACK_TO_PAGINATION_FROM = nil
|
102
|
+
|
103
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
104
|
+
# Saving Queries #
|
105
|
+
|
106
|
+
# ActiveRecord model to store queries. Read the documentation for details
|
107
|
+
# QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
|
108
|
+
Wice::Defaults::QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
|
109
|
+
|
110
|
+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
111
|
+
# Here go settings related to the calendar helpers #
|
112
|
+
|
113
|
+
# The default style of the date and datetime helper
|
114
|
+
# * <tt>:calendar</tt> - JS calendar
|
115
|
+
# * <tt>:html5</tt> - HTML5 date input field
|
116
|
+
# * <tt>:standard</tt> - standard Rails date and datetime helpers
|
117
|
+
# * <tt>:bootstrap</tt> - Bootstrap datepicker helper
|
118
|
+
Wice::Defaults::HELPER_STYLE = :calendar
|
119
|
+
|
120
|
+
# Format of the datetime displayed.
|
121
|
+
# If you change the format, make sure to check if +DATETIME_PARSER+ can still parse this string.
|
122
|
+
Wice::Defaults::DATETIME_FORMAT = '%Y-%m-%d %H:%M'
|
123
|
+
|
124
|
+
# Format of the date displayed.
|
125
|
+
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
|
126
|
+
Wice::Defaults::DATE_FORMAT = '%Y-%m-%d'
|
127
|
+
|
128
|
+
# Format of the date displayed in jQuery's Datepicker
|
129
|
+
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
|
130
|
+
Wice::Defaults::DATE_FORMAT_JQUERY = 'yy-mm-dd'
|
131
|
+
|
132
|
+
# Format of the date displayed in Bootstrap's Datepicker
|
133
|
+
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
|
134
|
+
Wice::Defaults::DATE_FORMAT_BOOTSTRAP = 'yyyy-mm-dd'
|
135
|
+
|
136
|
+
# With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the
|
137
|
+
# format defined by +DATETIME_FORMAT+ and must generate a DateTime object.
|
138
|
+
# In many cases <tt>Time.zone.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
|
139
|
+
# and modify it if needed.
|
140
|
+
Wice::Defaults::DATETIME_PARSER = lambda do |datetime_string|
|
141
|
+
if datetime_string.blank?
|
142
|
+
nil
|
143
|
+
elsif Time.zone
|
144
|
+
Time.zone.parse(datetime_string)
|
145
|
+
else
|
146
|
+
Time.parse(datetime_string)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# The range of years to display in jQuery Datepicker.
|
151
|
+
# It can always be changed dynamically with the following javascript:
|
152
|
+
# $( ".hasDatepicker" ).datepicker( "option", "yearRange", "2000:2042" );
|
153
|
+
Wice::Defaults::DATEPICKER_YEAR_RANGE = (from = Date.current.year - 10).to_s + ':' + (from + 15).to_s
|
154
|
+
|
155
|
+
# With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the
|
156
|
+
# format defined by +DATETIME+ and must generate a Date object.
|
157
|
+
# In many cases <tt>Date.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
|
158
|
+
# and modify it if needed.
|
159
|
+
Wice::Defaults::DATE_PARSER = lambda do |date_string|
|
160
|
+
if date_string.blank?
|
161
|
+
nil
|
162
|
+
else
|
163
|
+
begin
|
164
|
+
Date.parse(date_string)
|
165
|
+
rescue ArgumentError
|
166
|
+
nil
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# The name of the page method (should correspond to Kaminari.config.page_method_name)
|
172
|
+
Wice::Defaults::PAGE_METHOD_NAME = :page
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Wice::GridOutputBuffer do
|
4
|
+
FILTER_COMMON_CODE = 'here filter code'
|
5
|
+
|
6
|
+
|
7
|
+
let(:buffer){Wice::GridOutputBuffer.new}
|
8
|
+
|
9
|
+
it 'should to_s' do
|
10
|
+
expect(buffer.to_s.class).to eq(ActiveSupport::SafeBuffer)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should add_filter' do
|
14
|
+
|
15
|
+
expect(buffer.add_filter('key', FILTER_COMMON_CODE)).to eq(FILTER_COMMON_CODE)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should filter_for' do
|
19
|
+
|
20
|
+
buffer.add_filter('key', FILTER_COMMON_CODE)
|
21
|
+
expect(buffer.filter_for('key')).to eq(FILTER_COMMON_CODE)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should filter_for 2 times' do
|
25
|
+
buffer.add_filter('key', FILTER_COMMON_CODE)
|
26
|
+
|
27
|
+
expect(buffer.filter_for('key')).to eq(FILTER_COMMON_CODE)
|
28
|
+
expect { buffer.filter_for('key') }.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should filter_for without filters' do
|
32
|
+
|
33
|
+
expect { buffer.filter_for('key') }.to raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should filter_for return empty string' do
|
37
|
+
buffer.return_empty_strings_for_nonexistent_filters = true
|
38
|
+
|
39
|
+
expect(buffer.filter_for('key')).to eq('')
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
describe Wice::TableColumnMatrix do
|
4
|
+
let(:general_conditions){ 'conditions' }
|
5
|
+
|
6
|
+
let(:table){ Wice::TableColumnMatrix.new }
|
7
|
+
|
8
|
+
it 'should new' do
|
9
|
+
expect(table.class).to eq(Wice::TableColumnMatrix)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should add_condition' do
|
13
|
+
|
14
|
+
table.add_condition('key', general_conditions)
|
15
|
+
|
16
|
+
expect(table.conditions).to include(general_conditions)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should set default_model_class' do
|
20
|
+
|
21
|
+
table.default_model_class = Dummy
|
22
|
+
|
23
|
+
expect(table.class).to eq(Wice::TableColumnMatrix)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should get column' do
|
27
|
+
|
28
|
+
table.default_model_class = Dummy
|
29
|
+
|
30
|
+
expect(Dummy.columns).to include(table.get_column_by_model_class_and_column_name(Dummy, :name))
|
31
|
+
expect(Dummy.columns).to include(table.get_column_in_default_model_class_by_column_name(:name))
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should get column not initialized' do
|
35
|
+
|
36
|
+
expect { table.get_column_in_default_model_class_by_column_name(:name) }.to raise_error
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
context 'assoc_list_to_hash' do
|
4
|
+
it 'many elements in assocs' do
|
5
|
+
assocs = [:foo1, :foo2, :foo3, :foo4, :foo5]
|
6
|
+
out = Wice.assoc_list_to_hash(assocs)
|
7
|
+
expect(out).to eq(foo1: {foo2: {foo3: {foo4: :foo5}}})
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'one element in assocs' do
|
11
|
+
assocs = [:foo1]
|
12
|
+
out = Wice.assoc_list_to_hash(assocs)
|
13
|
+
expect(out).to eq(:foo1)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'two elements in assocs' do
|
17
|
+
assocs = [:foo1, :foo2]
|
18
|
+
out = Wice.assoc_list_to_hash(assocs)
|
19
|
+
expect(out).to eq(foo1: :foo2)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'build_includes' do
|
24
|
+
|
25
|
+
it 'symbols + existing symbol' do
|
26
|
+
includes = [:a, :b, :c, :d, :e]
|
27
|
+
|
28
|
+
out = Wice.build_includes(includes, [:b])
|
29
|
+
|
30
|
+
expect(out).to eq([:a, :b, :c, :d, :e])
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'symbols + non-existing symbol' do
|
34
|
+
includes = [:a, :b, :c, :d, :e]
|
35
|
+
|
36
|
+
out = Wice.build_includes(includes, [:x])
|
37
|
+
|
38
|
+
expect(out).to eq([:a, :b, :c, :d, :e, :x])
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'symbols + non-existing hash' do
|
42
|
+
includes = [:a, :b, :c, :d, :e]
|
43
|
+
|
44
|
+
out = Wice.build_includes(includes, [:x, :y])
|
45
|
+
|
46
|
+
expect(out).to eq([:a, :b, :c, :d, :e, {x: :y}])
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
it 'symbols + existing hash' do
|
51
|
+
includes = [:a, :b, :c, :d, :e]
|
52
|
+
|
53
|
+
out = Wice.build_includes(includes, [:a, :x])
|
54
|
+
|
55
|
+
expect(out).to eq([{a: :x}, :b, :c, :d, :e])
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'symbols with a hash + simple symbol' do
|
59
|
+
includes = [{a: :x}, :b, :c, :d, :e]
|
60
|
+
|
61
|
+
out = Wice.build_includes(includes, [:a])
|
62
|
+
|
63
|
+
expect(out).to eq([{a: :x}, :b, :c, :d, :e])
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'symbols with a hash + hash' do
|
67
|
+
includes = [{a: :x}, :b, :c, :d, :e]
|
68
|
+
|
69
|
+
out = Wice.build_includes(includes, [:a, :x, :y])
|
70
|
+
|
71
|
+
expect(out).to eq([{a: {x: :y}}, :b, :c, :d, :e])
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'symbols with a hash + hash (2)' do
|
75
|
+
includes = [{a: :x}, :b, :c, :d, :e]
|
76
|
+
|
77
|
+
out = Wice.build_includes(includes, [:a, :x])
|
78
|
+
|
79
|
+
expect(out).to eq([{a: :x}, :b, :c, :d, :e])
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'symbols with a hash + the same hash' do
|
83
|
+
includes = [a: :x]
|
84
|
+
|
85
|
+
out = Wice.build_includes(includes, [:a, :x])
|
86
|
+
|
87
|
+
expect(out).to eq(a: :x)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'symbols with a hash + a deeper hash' do
|
91
|
+
includes = [{a: :x}]
|
92
|
+
|
93
|
+
out = Wice.build_includes(includes, [:a, :x, :y])
|
94
|
+
|
95
|
+
expect(out).to eq(a: {x: :y})
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'a deeper hash + a deeper hash' do
|
99
|
+
includes = [a: {x: :y}]
|
100
|
+
|
101
|
+
out = Wice.build_includes(includes, [:a, :x, :z])
|
102
|
+
|
103
|
+
expect(out).to eq(a: [:y, :z])
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
it 'a deeper hash + the same deeper hash' do
|
108
|
+
includes = [{a: {x: :y}}]
|
109
|
+
|
110
|
+
out = Wice.build_includes(includes, [:a, :x, :y])
|
111
|
+
|
112
|
+
expect(out).to eq(a: {x: :y})
|
113
|
+
end
|
114
|
+
|
115
|
+
it '1 symbol + hash ' do
|
116
|
+
includes = :b
|
117
|
+
|
118
|
+
out = Wice.build_includes(includes, [:a, :x])
|
119
|
+
|
120
|
+
expect(out).to eq([:b, {a: :x}])
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'nil + hash ' do
|
124
|
+
includes = nil
|
125
|
+
|
126
|
+
out = Wice.build_includes(includes, [:a, :x])
|
127
|
+
|
128
|
+
expect(out).to eq(a: :x)
|
129
|
+
end
|
130
|
+
|
131
|
+
it '1 symbol + nothing' do
|
132
|
+
includes = :b
|
133
|
+
|
134
|
+
out = Wice.build_includes(includes, [])
|
135
|
+
|
136
|
+
expect(out).to eq(:b)
|
137
|
+
end
|
138
|
+
|
139
|
+
it '1 symbol array + nothing' do
|
140
|
+
includes = [:b]
|
141
|
+
|
142
|
+
out = Wice.build_includes(includes, [])
|
143
|
+
|
144
|
+
expect(out).to eq(:b)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'validate_query_model' do
|
148
|
+
expect(Wice.get_query_store_model).to eq(WiceGridSerializedQuery)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'get_string_matching_operators' do
|
152
|
+
expect(Wice.get_string_matching_operators(Dummy)).to eq('LIKE')
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'log' do
|
156
|
+
Wice.log('message')
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|