diff options
| author | Robert Dober | 2017-10-31 19:18:56 +0100 |
|---|---|---|
| committer | GitHub | 2017-10-31 19:18:56 +0100 |
| commit | 13553712a18435f16f449a6d0c6a2ade24038797 (patch) | |
| tree | 5e3577a7d8c69f8cbc93ede730d00404b3cd6b24 /spec | |
| parent | b3c941878c8b2224449e7e185d9ea5c7537f0c69 (diff) | |
| parent | 3b0b05930e14992ffab6429e0319f07bc9c6e560 (diff) | |
| download | chouette-core-13553712a18435f16f449a6d0c6a2ade24038797.tar.bz2 | |
Merge pull request #105 from af83/4774-compliance_control_sets-filters
4774 compliance control sets filters
Diffstat (limited to 'spec')
4 files changed, 100 insertions, 5 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..500d4ce6f --- /dev/null +++ b/spec/features/compliance_control_sets_spec.rb @@ -0,0 +1,82 @@ +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 } + } + + 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 severity filter' do + controls.take(2).each do | control | + control.update criticity: 'error' + end + check('error') + click_on('Filtrer') + controls.each do | control | + if control.criticity == 'error' + expect( page ).to have_content(control.code) + else + expect( page ).not_to have_content(control.code) + end + end + end + + it 'we can apply a subclass filter' do + controls.first.update(origin_code: 'x-Route-y') + controls.second.update(origin_code: 'x-Line-y') + + within('#subclass-filter') do + check('Itinéraire') + check('Ligne') + end + click_on('Filtrer') + controls.each do | control | + if control.origin_code[/-Generic-/] + expect( page ).not_to have_content(control.code) + else + expect( page ).to have_content(control.code) + end + 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) + end + +end diff --git a/spec/features/connection_links_spec.rb b/spec/features/connection_links_spec.rb index 7272242fe..2f6283dcd 100644 --- a/spec/features/connection_links_spec.rb +++ b/spec/features/connection_links_spec.rb @@ -1,4 +1,4 @@ -RSpec.describe "ConnectionLinks", :type => :feature do +RSpec.describe "ConnectionLinks", type: :feature do login_user let!(:connection_links) { Array.new(2) { create(:connection_link) } } diff --git a/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb new file mode 100644 index 000000000..868eca984 --- /dev/null +++ b/spec/models/compliance_control_class_level_defaults/compliance_control_subclass_pattern_spec.rb @@ -0,0 +1,17 @@ +RSpec.describe ComplianceControl do + let( :subject ){ described_class.subclass_patterns } + + context 'subclass_patterns' do + it 'are correctly defined' do + expect_it.to eq( + generic: 'Generic', + journey_pattern: 'JourneyPattern', + line: 'Line', + route: 'Route', + routing_constraint_zone: 'RoutingConstraint', + vehicle_journey: 'VehicleJourney' + ) + end + end + +end diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index db73dab21..4267459ea 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -4,10 +4,6 @@ RSpec.describe ComplianceControl, type: :model do let(:compliance_control) { build_stubbed :compliance_control } - it 'should have a valid factory' do - expect(compliance_control).to be_valid - end - it { should belong_to :compliance_control_set } it { should belong_to :compliance_control_block } |
