diff options
| author | Robert | 2017-10-29 21:27:46 +0100 |
|---|---|---|
| committer | Robert | 2017-10-31 19:11:05 +0100 |
| commit | 8886b867d549cc501c17e4975ab813ce3fed3ac1 (patch) | |
| tree | 1c4aa09622e96bc07ed3df98e0c252a2ee4ff9d3 /spec/features | |
| parent | b1d432628e36d02a23324015f93d4b76a61433e7 (diff) | |
| download | chouette-core-8886b867d549cc501c17e4975ab813ce3fed3ac1.tar.bz2 | |
Refs: #4774@3h;
Speced feature compliance_control_set/show and filtering on Severity
MISSING: Object Filter needs 2B specified
Diffstat (limited to 'spec/features')
| -rw-r--r-- | spec/features/compliance_control_sets_spec.rb | 67 | ||||
| -rw-r--r-- | spec/features/complience_control_sets_spec.rb | 36 |
2 files changed, 67 insertions, 36 deletions
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 |
