Fix failing tests for repository states [SCI-4070]

This commit is contained in:
Oleksii Kriuchykhin 2019-11-19 10:33:51 +01:00 committed by Urban Rotnik
parent 338b710d81
commit 73be1181ac
8 changed files with 156 additions and 196 deletions

View file

@ -41,12 +41,12 @@ class RepositoryColumn < ApplicationRecord
# Calculate old_column_index - this can only be done before
# record is deleted when we still have its index
old_column_index = (
Constants::REPOSITORY_TABLE_DEFAULT_STATE[:length] +
Constants::REPOSITORY_TABLE_DEFAULT_STATE['length'] +
repository.repository_columns
.order(id: :asc)
.pluck(:id)
.index(id)
).to_s
)
# Perform the destroy itself
yield

View file

@ -16,13 +16,10 @@ class RepositoryTableStateColumnUpdateService
index = state['columns'].count
# Add new columns, ColReorder, length entries
state['columns'][index.to_s] =
HashUtil.deep_stringify_keys_and_values(
Constants::REPOSITORY_TABLE_STATE_CUSTOM_COLUMN_TEMPLATE
)
state['ColReorder'] << index.to_s
state['length'] = (index + 1).to_s
state['time'] = Time.new.to_i.to_s
state['columns'][index] = Constants::REPOSITORY_TABLE_STATE_CUSTOM_COLUMN_TEMPLATE
state['ColReorder'] << index
state['length'] = (index + 1)
state['time'] = Time.new.to_i
table_state.save
end
end
@ -36,40 +33,27 @@ class RepositoryTableStateColumnUpdateService
).find_each do |table_state|
state = table_state.state
# old_column_index is a String!
# Remove column from ColReorder, columns, length entries
state['columns'].delete(old_column_index)
state['columns'].keys.each do |index|
if index.to_i > old_column_index.to_i
state['columns'][(index.to_i - 1).to_s] =
state['columns'].delete(index.to_s)
end
end
state['columns'].delete_at(old_column_index)
state['ColReorder'].delete(old_column_index)
state['ColReorder'].map! do |index|
if index.to_i > old_column_index.to_i
(index.to_i - 1).to_s
if index > old_column_index
index - 1
else
index
end
end
state['order'].reject! { |_, v| v[0] == old_column_index }
state['order'].each do |k, v|
state['order'][k] = [(v[0].to_i - 1).to_s, v[1]] if v[0].to_i > old_column_index.to_i
end
if state['order'].empty?
if state.dig('order', 0, 0) == old_column_index
# Fallback to default order if user had table ordered by
# the deleted column
state['order'] = HashUtil.deep_stringify_keys_and_values(
Constants::REPOSITORY_TABLE_DEFAULT_STATE[:order]
)
state['order'] = Constants::REPOSITORY_TABLE_DEFAULT_STATE['order']
elsif state.dig('order', 0, 0) > old_column_index
state['order'][0][0] -= 1
end
state['length'] = (state['length'].to_i - 1).to_s
state['time'] = Time.new.to_i.to_s
state['length'] = (state['length'] - 1)
state['time'] = Time.new.to_i
table_state.save
end
end

View file

@ -25,7 +25,7 @@ class RepositoryTableStateService
def update_state(state)
saved_state = load_state
state[:order][0] = [3, 'asc'] if state.dig(:order, 0, 0).to_i < 2
state['order'][0] = [3, 'asc'] if state.dig('order', 0, 0).to_i < 2
return if saved_state.state.except('time') == state.except('time')
@ -46,21 +46,17 @@ class RepositoryTableStateService
private
def generate_default_state
default_columns_num =
Constants::REPOSITORY_TABLE_DEFAULT_STATE[:length]
default_columns_num = Constants::REPOSITORY_TABLE_DEFAULT_STATE['length']
# This state should be strings-only
state = Constants::REPOSITORY_TABLE_DEFAULT_STATE.with_indifferent_access
state = Constants::REPOSITORY_TABLE_DEFAULT_STATE.deep_dup
repository.repository_columns.each_with_index do |_, index|
real_index = default_columns_num + index
state['columns'][real_index.to_s] =
HashUtil.deep_stringify_keys_and_values(
Constants::REPOSITORY_TABLE_STATE_CUSTOM_COLUMN_TEMPLATE
)
state['ColReorder'] << real_index.to_s
state['columns'][real_index] = Constants::REPOSITORY_TABLE_STATE_CUSTOM_COLUMN_TEMPLATE
state['ColReorder'] << real_index
end
state['length'] = state['columns'].length.to_s
state['time'] = Time.new.to_i.to_s
state['length'] = state['columns'].length
state['time'] = Time.new.to_i
state
end
end

View file

@ -944,34 +944,34 @@ class Constants
# Repository default table state
REPOSITORY_TABLE_DEFAULT_STATE = {
time: 0,
start: 0,
length: 6,
order: [[2, 'asc']], # Default sorting by 'ID' column
search: { search: '',
smart: true,
regex: false,
caseInsensitive: true },
columns: {},
assigned: 'assigned',
ColReorder: [*0..5]
'time' => 0,
'start' => 0,
'length' => 6,
'order' => [[2, 'asc']], # Default sorting by 'ID' column
'search' => { 'search' => '',
'smart' => true,
'regex' => false,
'caseInsensitive' => true },
'columns' => [],
'assigned' => 'assigned',
'ColReorder' => [*0..5]
}
6.times do |i|
REPOSITORY_TABLE_DEFAULT_STATE[:columns][i] = {
visible: true,
searchable: i >= 1, # Checkboxes column is not searchable
search: { search: '',
smart: true,
regex: false,
caseInsensitive: true }
REPOSITORY_TABLE_DEFAULT_STATE['columns'] << {
'visible' => true,
'searchable' => (i >= 1), # Checkboxes column is not searchable
'search' => { 'search' => '',
'smart' => true,
'regex' => false,
'caseInsensitive' => true }
}
end
REPOSITORY_TABLE_DEFAULT_STATE.freeze
# For default custom column template, any searchable default
# column can be reused
REPOSITORY_TABLE_STATE_CUSTOM_COLUMN_TEMPLATE =
REPOSITORY_TABLE_DEFAULT_STATE[:columns][1].deep_dup
.freeze
REPOSITORY_TABLE_DEFAULT_STATE['columns'][1].deep_dup
.freeze
EXPORTABLE_ZIP_EXPIRATION_DAYS = 7

View file

@ -34,15 +34,15 @@ describe RepositoryTableStateColumnUpdateService do
last_modified_by: user_2
end
let!(:default_order) do
{ '0' => %w(2 asc) }
[[2, 'asc']]
end
let!(:default_column_def) do
{ 'visible' => 'true',
'searchable' => 'true',
{ 'visible' => true,
'searchable' => true,
'search' => { 'search' => '',
'smart' => 'true',
'regex' => 'false',
'caseInsensitive' => 'true' } }
'smart' => true,
'regex' => false,
'caseInsensitive' => true } }
end
let!(:service) do
subject
@ -70,24 +70,24 @@ describe RepositoryTableStateColumnUpdateService do
end
it 'should calculate correct length' do
expect(initial_state_1.state['length']).to eq '8'
expect(initial_state_2.state['length']).to eq '8'
expect(initial_state_1.state['length']).to eq 8
expect(initial_state_2.state['length']).to eq 8
service.update_states_with_new_column(repository)
service.update_states_with_new_column(repository)
[user_1, user_2].each do |user|
state = RepositoryTableStateService.new(user, repository).load_state
expect(state.state['length']).to eq '10'
expect(state.state['length']).to eq 10
end
end
it 'should keep order as it was' do
initial_state_1.state['order'] = { '0' => %w(3 desc) }
initial_state_1.state['order'] = [[3, 'desc']]
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state
)
initial_state_2.state['order'] = { '0' => %w(4 asc) }
initial_state_2.state['order'] = [[4, 'asc']]
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state
)
@ -96,20 +96,20 @@ describe RepositoryTableStateColumnUpdateService do
service.update_states_with_new_column(repository)
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['order']).to eq('0' => %w(3 desc))
expect(state_1.state['order']).to eq([[3, 'desc']])
state_2 = RepositoryTableStateService.new(user_2, repository).load_state
expect(state_2.state['order']).to eq('0' => %w(4 asc))
expect(state_2.state['order']).to eq([[4, 'asc']])
end
it 'should keep search as it was' do
search_1 = { 'search' => 'lala1', 'smart' => 'true', 'regex' => 'false',
'caseInsensitive' => 'true' }
search_1 = { 'search' => 'lala1', 'smart' => true, 'regex' => false,
'caseInsensitive' => true }
initial_state_1.state['search'] = search_1
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state
)
search_2 = { 'search' => 'lala1', 'smart' => 'true', 'regex' => 'false',
'caseInsensitive' => 'true' }
search_2 = { 'search' => 'lala1', 'smart' => true, 'regex' => false,
'caseInsensitive' => true }
initial_state_2.state['search'] = search_2
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state
@ -133,22 +133,20 @@ describe RepositoryTableStateColumnUpdateService do
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['columns']).to eq(
cols_1.merge('8' => default_column_def, '9' => default_column_def)
cols_1.push(default_column_def, default_column_def)
)
state_2 = RepositoryTableStateService.new(user_2, repository).load_state
expect(state_2.state['columns']).to eq(
cols_2.merge('8' => default_column_def, '9' => default_column_def)
cols_2.push(default_column_def, default_column_def)
)
end
it 'should keep column order as it was' do
initial_state_1.state['ColReorder'] =
%w(5 3 2 0 1 4 6 7)
initial_state_1.state['ColReorder'] = [5, 3, 2, 0, 1, 4, 6, 7]
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state
)
initial_state_2.state['ColReorder'] =
%w(0 6 1 4 5 7 2 3)
initial_state_2.state['ColReorder'] = [0, 6, 1, 4, 5, 7, 2, 3]
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state
)
@ -157,13 +155,9 @@ describe RepositoryTableStateColumnUpdateService do
service.update_states_with_new_column(repository)
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['ColReorder']).to eq(
%w(5 3 2 0 1 4 6 7 8 9)
)
expect(state_1.state['ColReorder']).to eq([5, 3, 2, 0, 1, 4, 6, 7, 8, 9])
state_2 = RepositoryTableStateService.new(user_2, repository).load_state
expect(state_2.state['ColReorder']).to eq(
%w(0 6 1 4 5 7 2 3 8 9)
)
expect(state_2.state['ColReorder']).to eq([0, 6, 1, 4, 5, 7, 2, 3, 8, 9])
end
end
@ -183,8 +177,8 @@ describe RepositoryTableStateColumnUpdateService do
expect(initial_state_1).to be_valid_default_repository_table_state(2)
expect(initial_state_2).to be_valid_default_repository_table_state(2)
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, 6)
service.update_states_with_removed_column(repository, 6)
[user_1, user_2].each do |user|
state = RepositoryTableStateService.new(user, repository).load_state
@ -193,53 +187,53 @@ describe RepositoryTableStateColumnUpdateService do
end
it 'should calculate correct length' do
expect(initial_state_1.state['length']).to eq '8'
expect(initial_state_2.state['length']).to eq '8'
expect(initial_state_1.state['length']).to eq 8
expect(initial_state_2.state['length']).to eq 8
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, 6)
service.update_states_with_removed_column(repository, 6)
[user_1, user_2].each do |user|
state = RepositoryTableStateService.new(user, repository).load_state
expect(state.state['length']).to eq '6'
expect(state.state['length']).to eq 6
end
end
it 'should keep order as it was' do
initial_state_1.state['order'] = { '0' => %w(3 desc) }
initial_state_1.state['order'] = [[3, 'desc']]
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state
)
initial_state_2.state['order'] = { '0' => %w(7 asc) }
initial_state_2.state['order'] = [[7, 'asc']]
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state
)
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, 6)
service.update_states_with_removed_column(repository, 6)
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['order']).to eq('0' => %w(3 desc))
expect(state_1.state['order']).to eq([[3, 'desc']])
state_2 = RepositoryTableStateService.new(user_2, repository).load_state
expect(state_2.state['order']).to eq(default_order)
end
it 'should keep search as it was' do
search_1 = { 'search' => 'lala1', 'smart' => 'true', 'regex' => 'false',
'caseInsensitive' => 'true' }
search_1 = { 'search' => 'lala1', 'smart' => true, 'regex' => false,
'caseInsensitive' => true }
initial_state_1.state['search'] = search_1
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state
)
search_2 = { 'search' => 'lala1', 'smart' => 'true', 'regex' => 'false',
'caseInsensitive' => 'true' }
search_2 = { 'search' => 'lala1', 'smart' => true, 'regex' => false,
'caseInsensitive' => true }
initial_state_2.state['search'] = search_2
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state
)
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, 6)
service.update_states_with_removed_column(repository, 6)
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['search']).to eq search_1
@ -249,20 +243,23 @@ describe RepositoryTableStateColumnUpdateService do
it 'should keep columns as they were' do
cols_1 = initial_state_1.state['columns'].deep_dup
cols_1['4']['visible'] = 'false'
cols_1[4]['visible'] = false
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state.merge('columns' => cols_1)
)
cols_1.except!('6', '7')
cols_1.delete_at(6)
cols_1.delete_at(6)
cols_2 = initial_state_2.state['columns'].deep_dup
cols_2['4']['searchable'] = 'false'
cols_2[4]['searchable'] = false
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state.merge('columns' => cols_2)
)
cols_2.except!('6', '7')
cols_2.delete_at(6)
cols_2.delete_at(6)
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, 6)
service.update_states_with_removed_column(repository, 6)
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['columns']).to eq cols_1
@ -272,26 +269,26 @@ describe RepositoryTableStateColumnUpdateService do
it 'should keep column order as it was' do
initial_state_1.state['ColReorder'] =
%w(5 3 2 0 1 4 6 7)
[5, 3, 2, 0, 1, 4, 6, 7]
RepositoryTableStateService.new(user_1, repository).update_state(
initial_state_1.state
)
initial_state_2.state['ColReorder'] =
%w(0 6 1 4 5 7 2 3)
[0, 6, 1, 4, 5, 7, 2, 3]
RepositoryTableStateService.new(user_2, repository).update_state(
initial_state_2.state
)
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, '6')
service.update_states_with_removed_column(repository, 6)
service.update_states_with_removed_column(repository, 6)
state_1 = RepositoryTableStateService.new(user_1, repository).load_state
expect(state_1.state['ColReorder']).to eq(
%w(5 3 2 0 1 4)
[5, 3, 2, 0, 1, 4]
)
state_2 = RepositoryTableStateService.new(user_2, repository).load_state
expect(state_2.state['ColReorder']).to eq(
%w(0 1 4 5 2 3)
[0, 1, 4, 5, 2, 3]
)
end
end
@ -310,12 +307,12 @@ describe RepositoryTableStateColumnUpdateService do
let!(:initial_state) do
state = RepositoryTableStateService.new(user_1, repository)
.create_default_state
state.state['order'] = { '0' => %w(8 desc) }
state.state['order'] = [[8, 'desc']]
(0..9).each do |idx|
state.state['columns'][idx.to_s]['search']['search'] = "search_#{idx}"
state.state['columns'][idx]['search']['search'] = "search_#{idx}"
end
state.state['ColReorder'] =
%w(0 1 2 9 8 4 7 3 5 6)
[0, 1, 2, 9, 8, 4, 7, 3, 5, 6]
RepositoryTableStateService.new(user_1, repository).update_state(
state.state
)
@ -330,33 +327,33 @@ describe RepositoryTableStateColumnUpdateService do
state = RepositoryTableStateService.new(user_1, repository).load_state
expect(state).to be_valid_repository_table_state(5)
expect(state.state['ColReorder']).to eq(
%w(0 1 2 9 8 4 7 3 5 6 10)
[0, 1, 2, 9, 8, 4, 7, 3, 5, 6, 10]
)
service.update_states_with_removed_column(repository, '7')
service.update_states_with_removed_column(repository, 7)
state = RepositoryTableStateService.new(user_1, repository).load_state
expect(state).to be_valid_repository_table_state(4)
expect(state.state['ColReorder']).to eq(
%w(0 1 2 8 7 4 3 5 6 9)
[0, 1, 2, 8, 7, 4, 3, 5, 6, 9]
)
expect(state.state['order']).to eq('0' => %w(7 desc))
expect(state.state['order']).to eq([[7, 'desc']])
service.update_states_with_removed_column(repository, '7')
service.update_states_with_removed_column(repository, 7)
state = RepositoryTableStateService.new(user_1, repository).load_state
expect(state).to be_valid_repository_table_state(3)
expect(state.state['ColReorder']).to eq(
%w(0 1 2 7 4 3 5 6 8)
[0, 1, 2, 7, 4, 3, 5, 6, 8]
)
expect(state.state['order']).to eq('0' => %w(2 asc))
expect(state.state['order']).to eq([[2, 'asc']])
service.update_states_with_removed_column(repository, '7')
service.update_states_with_removed_column(repository, 7)
state = RepositoryTableStateService.new(user_1, repository).load_state
expect(state).to be_valid_repository_table_state(2)
expect(state.state['ColReorder']).to eq(
%w(0 1 2 4 3 5 6 7)
[0, 1, 2, 4, 3, 5, 6, 7]
)
service.update_states_with_new_column(repository)
@ -365,7 +362,7 @@ describe RepositoryTableStateColumnUpdateService do
state = RepositoryTableStateService.new(user_1, repository).load_state
expect(state).to be_valid_repository_table_state(4)
expect(state.state['ColReorder']).to eq(
%w(0 1 2 4 3 5 6 7 8 9)
[0, 1, 2, 4, 3, 5, 6, 7, 8, 9]
)
end
end

View file

@ -88,7 +88,9 @@ describe RepositoryTableStateService do
describe '#update_state' do
let!(:new_state) do
{ 'my' => 'state' }
initial_state = RepositoryTableStateService.new(user, repository).create_default_state
initial_state.state['columns'][3]['visible'] = false
initial_state.state
end
it 'should update the state' do

View file

@ -8,43 +8,41 @@ RSpec::Matchers.define :be_valid_default_repository_table_state do |nr_of_cols|
state = subject.state
cols_length = 6 + nr_of_cols
cols_str_array = [*0..(5 + nr_of_cols)].collect(&:to_s)
cols_array = [*0..(5 + nr_of_cols)]
expect(state).to be_an_instance_of Hash
expect(state).to include(
'time',
'columns',
'start' => '0',
'length' => cols_length.to_s, # 6 default columns + parameter
'order' => { '0'=> ['2', 'asc'] },
'start' => 0,
'length' => cols_length, # 6 default columns + parameter
'order' => [[2, 'asc']],
'search' => {
'search' => '',
'smart' => 'true',
'regex' => 'false',
'caseInsensitive' => 'true'
'smart' => true,
'regex' => false,
'caseInsensitive' => true
},
'ColReorder' => cols_str_array
'assigned' => 'assigned',
'ColReorder' => cols_array
)
expect(state['columns']).to be_an_instance_of Hash
expect(state['columns'].length).to eq (6 + nr_of_cols)
expect(state['columns'].keys.sort).to eq cols_str_array
state['columns'].each do |key, val|
expect(state['columns']).to be_an_instance_of Array
expect(state['columns'].length).to eq(6 + nr_of_cols)
state['columns'].each_with_index do |val, i|
expect(val).to include(
'visible' => 'true',
'searchable' => (key == '0' ? 'false' : 'true'),
'visible' => true,
'searchable' => (i != 0),
'search' => {
'search' => '', 'smart' => 'true', 'regex' => 'false', 'caseInsensitive' => 'true'
'search' => '', 'smart' => true, 'regex' => false, 'caseInsensitive' => true
}
)
end
expect(state['time']).to be_an_instance_of String
expect { Integer(state['time']) }.to_not raise_error
expect { Time.at(state['time'].to_i) }.to_not raise_error
end
failure_message do
'expected to be valid default repository table state, but was not'
end
end
end

View file

@ -12,85 +12,68 @@ RSpec::Matchers.define :be_valid_repository_table_state do
'time', 'order', 'start', 'length', 'search', 'columns', 'ColReorder'
)
expect(state['time']).to be_an_instance_of String
expect { Integer(state['time']) }.to_not raise_error
expect { Time.at(state['time'].to_i) }.to_not raise_error
expect(state['time']).to be_an_instance_of Integer
expect { Time.at(state['time']) }.to_not raise_error
expect(state['start']).to eq "0"
expect(state['start']).to eq 0
expect { Integer(state['length']) }.to_not raise_error
cols_length = Integer(state['length'])
cols_length = state['length']
# There should always be at least 6 columns
expect(cols_length).to be >= 6
col_indexes = []
expect(state['columns']).to be_an_instance_of Hash
expect(state['columns']).to be_an_instance_of Array
expect(state['columns'].length).to eq cols_length
state['columns'].each do |key, val|
expect(key).to be_an_instance_of String
expect { Integer(key) }.to_not raise_error
state['columns'].each_with_index do |val, i|
expect(val).to be_an_instance_of Hash
expect(val).to include(
'search', 'visible', 'searchable'
)
expect(val['visible']).to eq('true').or eq('false')
expect(val['searchable']).to eq('true').or eq('false')
expect(val['visible']).to eq(true).or eq(false)
expect(val['searchable']).to eq(true).or eq(false)
expect(val['search']).to be_an_instance_of Hash
expect(val['search']).to include(
'regex', 'smart', 'search', 'caseInsensitive'
)
expect(val['search']['regex']).to eq('true').or eq('false')
expect(val['search']['smart']).to eq('true').or eq('false')
expect(val['search']['caseInsensitive']).to eq('true').or eq('false')
expect(val['search']['regex']).to eq(true).or eq(false)
expect(val['search']['smart']).to eq(true).or eq(false)
expect(val['search']['caseInsensitive']).to eq(true).or eq(false)
expect(val['search']['search']).to be_an_instance_of String
col_indexes << Integer(key)
col_indexes << i
end
col_indexes.sort!
# Check if column indexes are 0..N
expect(col_indexes).to eq [*0..(cols_length - 1)]
expect(state['order']).to be_an_instance_of Hash
expect(state['order']).to be_an_instance_of Array
expect(state['order'].length).to be > 0
state['order'].each do |key, val|
expect(key).to be_an_instance_of String
expect { Integer(key) }.to_not raise_error
expect(state['order'][0]).to be_an_instance_of Array
expect(state['order'][0].length).to eq 2
expect(state['order'][0][0]).to be_an_instance_of Integer
expect(state['order'][0][1]).to be_an_instance_of String
expect(state['order'][0][1]).to eq('asc').or eq('desc')
expect(val).to be_an_instance_of Array
expect(val.length).to eq 2
expect(val[0]).to be_an_instance_of String
expect { Integer(val[0]) }.to_not raise_error
expect(val[1]).to be_an_instance_of String
expect(val[1]).to eq('asc').or eq('desc')
# Check that the ordering column exists in columns
expect(col_indexes).to include(Integer(val[0]))
end
# Check that the ordering column exists in columns
expect(col_indexes).to include(state['order'][0][0])
expect(state['search']).to be_an_instance_of Hash
expect(state['search']).to include(
'regex', 'smart', 'search', 'caseInsensitive'
)
expect(state['search']['regex']).to eq('true').or eq('false')
expect(state['search']['smart']).to eq('true').or eq('false')
expect(state['search']['caseInsensitive']).to eq('true').or eq('false')
expect(state['search']['regex']).to eq(true).or eq(false)
expect(state['search']['smart']).to eq(true).or eq(false)
expect(state['search']['caseInsensitive']).to eq(true).or eq(false)
expect(state['search']['search']).to be_an_instance_of String
expect(state['ColReorder']).to be_an_instance_of Array
expect(state['ColReorder'].length).to eq cols_length
state['ColReorder'].each do |col|
expect { Integer(col) }.to_not raise_error
state['ColReorder'].each do |col|
# Column should be in the columns indexes
expect(col_indexes).to include (Integer(col))
expect(col_indexes).to include(col)
end
end
failure_message do
'expected to be valid repository table state, but was not'
end
end
end