diff options
| -rw-r--r-- | app/helpers/compliance_control_blocks_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/compliance_controls/_filters.html.slim | 4 | ||||
| -rw-r--r-- | spec/features/compliance_control_sets_spec.rb | 67 | ||||
| -rw-r--r-- | spec/features/complience_control_sets_spec.rb | 36 |
4 files changed, 70 insertions, 39 deletions
diff --git a/app/helpers/compliance_control_blocks_helper.rb b/app/helpers/compliance_control_blocks_helper.rb index 5c279b33a..311e6fb46 100644 --- a/app/helpers/compliance_control_blocks_helper.rb +++ b/app/helpers/compliance_control_blocks_helper.rb @@ -7,4 +7,4 @@ module ComplianceControlBlocksHelper "[" + t("enumerize.transport_mode.#{transport_mode}") + "]" + "[" + t("enumerize.transport_submode.#{transport_submode}") + "]" end end -end
\ No newline at end of file +end diff --git a/app/views/compliance_controls/_filters.html.slim b/app/views/compliance_controls/_filters.html.slim index 75cb4b7f4..200aede7e 100644 --- a/app/views/compliance_controls/_filters.html.slim +++ b/app/views/compliance_controls/_filters.html.slim @@ -13,7 +13,7 @@ span.fa.fa-search .ffg-row - .form-group.togglable + .form-group.togglable#compliance_control_block-filter = f.label t('activerecord.models.compliance_control_block.one'), required: false, class: 'control-label' = f.input :compliance_control_block_id_eq_any, collection: @compliance_control_set.compliance_control_blocks, @@ -22,7 +22,7 @@ label_method: lambda {|w| ("<span>#{transport_mode(w.transport_mode, w.transport_submode)}</span>").html_safe}, required: false, wrapper_html: {class: 'checkbox_list'} - .form-group.togglable + .form-group.togglable#severity-filter = f.label t('compliance_controls.filters.criticity'), required: false, class: 'control-label' = f.input :criticity_eq_any, collection: ComplianceControl.criticities, diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb new file mode 100644 index 000000000..f52e2737e --- /dev/null +++ b/spec/features/compliance_control_sets_spec.rb @@ -0,0 +1,67 @@ +RSpec.describe "ComplianceControlSets", type: :feature do + + login_user + + # We setup a control_set with two blocks and one direct control (meaning that it is not attached to a block) + # Then we add one control to the first block and two controls to the second block + let( :control_set ){ create :compliance_control_set, organisation: organisation } + let( :controls ){ control_set.compliance_controls } + + let(:blox){ + 2.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set } + } + let( :controls_hash ){ Hash.new{ |h, k| h[k] = [] } } + + + before do + blox.first.update transport_mode: 'bus', transport_submode: 'bus' + blox.second.update transport_mode: 'train', transport_submode: 'train' + + make_control + make_control blox.first, severity: :error + make_control blox.second, times: 2 + end + + describe 'show' do + before do + visit compliance_control_set_path( control_set ) + end + + it 'we can see the controls inside their blocks' do + controls.each do | control | + expect( page ).to have_content(control.code) + end + end + + it 'we can apply a filter' do + within('#severity-filter') do + find('input[value="error"]').click + end + click_on('Filtrer') + controls_hash['error'].each do + expect( page ).to have_content(control.code) + end + controls_hash['warning'].each do + expect( page ).not_to have_content(control.code) + end + end + + end + + def make_control ccblock=nil, times: 1, severity: :warning + times.times do + make_one_control ccblock, severity + end + end + + def make_one_control ccblock, severity + create( :generic_attribute_control_min_max, + code: random_string, + compliance_control_block: ccblock, + compliance_control_set: control_set, + criticity: severity ).tap do | ctrl | + controls_hash[severity] << ctrl + end + end + +end diff --git a/spec/features/complience_control_sets_spec.rb b/spec/features/complience_control_sets_spec.rb deleted file mode 100644 index 0acf42d7f..000000000 --- a/spec/features/complience_control_sets_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -RSpec.describe "ComplianceControlSets", type: :feature do - - login_user - - let( :control_set ){ create :compliance_control_set } - let( :min_max_class ){ GenericAttributeControl::MinMax } - let( :pattern_class ){ GenericAttributeControl::Pattern } - - let( :common_atts ){{ - compliance_control_set: control_set, - }} - - - let(:blox){ - 3.times.map{ | _ | create :compliance_control_block, compliance_control_set: control_set } - } - - before do - blox.each do | block | - create( :generic_attribute_control_min_max, code: random_string, compliance_control_block: block, **common_atts ) - create( :generic_attribute_control_pattern, code: random_string, compliance_control_block: block, **common_atts ) - end - end - - describe 'show' do - it 'check setup' do - each_kind_count = 3 - expect( min_max_class.count ).to eq(each_kind_count) - expect( pattern_class.count ).to eq(each_kind_count) - query = ComplianceControl.group(:compliance_control_block) - require 'pry'; binding.pry - end - - end - -end |
