aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRobert2017-11-06 19:06:57 +0100
committerRobert2017-11-17 14:56:29 +0100
commit76d11c7f973867e305d6841f69c62c5fd37d65a7 (patch)
tree782bf6b84fae75a0645e2de341d1c6469d0b9f23 /spec
parent36fec435004e595e2adbac72c8f634891a531b01 (diff)
downloadchouette-core-76d11c7f973867e305d6841f69c62c5fd37d65a7.tar.bz2
Refs: #4283@16h;
- Implements the view Missing: - Spex failing (xpath navigation inside the display blocks is still faulty) - Links to compliance_checks#show do not work (actually not this page's problem)
Diffstat (limited to 'spec')
-rw-r--r--spec/features/compliance_ckeck_sets_spec.rb78
-rw-r--r--spec/features/compliance_control_sets_spec.rb16
-rw-r--r--spec/models/compliance_check_block_spec.rb5
-rw-r--r--spec/models/compliance_control_block_spec.rb19
-rw-r--r--spec/support/breadcrumb_features.rb15
5 files changed, 116 insertions, 17 deletions
diff --git a/spec/features/compliance_ckeck_sets_spec.rb b/spec/features/compliance_ckeck_sets_spec.rb
index a4a6b2fda..17902ed3f 100644
--- a/spec/features/compliance_ckeck_sets_spec.rb
+++ b/spec/features/compliance_ckeck_sets_spec.rb
@@ -1,14 +1,86 @@
RSpec.describe "ComplianceCheckSets", type: :feature do
+ include ComplianceCheckSetsHelper
+ include TransportModeHelper
+
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( :compliance_check_set ){ create :compliance_check_set }
+ let( :compliance_check_set ){ create :compliance_check_set, name: random_string }
+ let(:blox){
+ 2.times.map{ | _ | create :compliance_check_block, compliance_check_set: compliance_check_set }
+ }
+ let!(:direct_checks){ make_check(nil, times: 2) + make_check(nil, severity: :error) }
+ let!(:indirect_checks){ blox.map{ |block| make_check(block) } }
context 'show' do
- it 'can visit the page' do
- visit(workbench_compliance_check_set_path(compliance_check_set.workbench, compliance_check_set))
+
+ before do
+ blox.first.update transport_mode: 'bus', transport_submode: 'demandAndResponseBus'
+ blox.second.update transport_mode: 'train', transport_submode: 'suburbanRailway'
+ visit(compliance_check_set_path(compliance_check_set))
+ end
+
+ it 'we can see the expected content' do
+ # Breadcrumbs
+ expect_breadcrumb_links "Accueil", "Gestion de l'offre", " Rapports de contrôle"
+
+ # Headline
+ expect( page ).to have_content("Rapport de contrôle #{compliance_check_set.name}")
+
+ # Information Definition List
+ expect( page.first('.dl-term') ).to have_content("Nom")
+ expect( page.first('.dl-def') ).to have_content(compliance_check_set.name)
+
+ # Filters
+ within( 'form.form-filter' ) do
+ expect( page ).to have_content("Groupe de rapport de contrôle")
+ expect( page ).to have_content("Objét")
+ expect( page ).to have_content("Criticité")
+ end
+
+
+ # Checks
+ # Direct Children
+ within(:xpath, xpath_for_div_of_block) do
+ direct_checks.each do | direct_check |
+ expect( page ).to have_content( direct_check.code )
+ expect( page ).to have_content( direct_check.name )
+ expect( page ).to have_content( direct_check.criticity )
+ expect( page ).to have_content( direct_check.comment )
+ end
+
+ end
+ # Indirect Children
+ compliance_check_set.compliance_check_blocks.each do | block |
+ within(:xpath, xpath_for_div_of_block(block)) do
+ block.checks.each do | check |
+ expect( page ).to have_content( check.code )
+ expect( page ).to have_content( check.name )
+ expect( page ).to have_content( check.criticity )
+ expect( page ).to have_content( check.comment )
+ end
+ end
+ end
+ end
+ end
+
+ def make_check ccblock=nil, times: 1, severity: :error
+ times.times.map do
+ make_one_check ccblock, severity
end
end
+
+ def make_one_check ccblock, severity
+ create( :compliance_check,
+ code: random_string,
+ compliance_check_block: ccblock,
+ compliance_check_set: compliance_check_set,
+ criticity: severity)
+ end
+
+ def xpath_for_div_of_block(block = nil)
+ %{.//div[@class="col-lg-12"]/h2[contains(text(),"#{transport_mode_text(block)}")]/../../..}
+ end
end
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
index 500d4ce6f..bcb989cdc 100644
--- a/spec/features/compliance_control_sets_spec.rb
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -25,7 +25,18 @@ RSpec.describe "ComplianceControlSets", type: :feature do
visit compliance_control_set_path( control_set )
end
- it 'we can see the controls inside their blocks' do
+ it 'we can see the expected content' do
+ # Breadcrumb
+ expect_breadcrumb_links "Accueil", "Liste des jeux de contrôles"
+
+ # Headline
+ expect( page ).to have_content("Consulter le jeu de contrôles #{control_set.name}")
+
+ # Information Definition List
+ expect( page.first('.dl-term') ).to have_content("Nom")
+ expect( page.first('.dl-def') ).to have_content(control_set.name)
+
+ # Children
controls.each do | control |
expect( page ).to have_content(control.code)
end
@@ -76,7 +87,8 @@ RSpec.describe "ComplianceControlSets", type: :feature do
create( :generic_attribute_control_min_max,
code: random_string,
compliance_control_block: ccblock,
- compliance_control_set: control_set)
+ compliance_control_set: control_set,
+ criticity: severity)
end
end
diff --git a/spec/models/compliance_check_block_spec.rb b/spec/models/compliance_check_block_spec.rb
index a3d98d459..845056fac 100644
--- a/spec/models/compliance_check_block_spec.rb
+++ b/spec/models/compliance_check_block_spec.rb
@@ -1,9 +1,4 @@
-require 'rails_helper'
-
RSpec.describe ComplianceCheckBlock, type: :model do
- it 'should have a valid factory' do
- expect(FactoryGirl.build(:compliance_check_block)).to be_valid
- end
it { should belong_to :compliance_check_set }
it { should have_many :compliance_checks }
diff --git a/spec/models/compliance_control_block_spec.rb b/spec/models/compliance_control_block_spec.rb
index c7440a5eb..6566baac0 100644
--- a/spec/models/compliance_control_block_spec.rb
+++ b/spec/models/compliance_control_block_spec.rb
@@ -1,13 +1,18 @@
-require 'rails_helper'
-
RSpec.describe ComplianceControlBlock, type: :model do
- subject { create(:compliance_control_block) }
-
- it 'should have a valid factory' do
- expect(FactoryGirl.build(:compliance_control_block)).to be_valid
- end
it { should belong_to :compliance_control_set }
it { should have_many(:compliance_controls).dependent(:destroy) }
it { should validate_presence_of(:transport_mode) }
+
+ xit { should allow_values(*%w{bus metro rail tram funicular}).for(:transport_mode) }
+ xit { should_not allow_values(*%w{bs mtro ril tramm Funicular}).for(:transport_mode) }
+
+
+ xit { should allow_values( *%w{ demandAndResponseBus nightBus airportLinkBus highFrequencyBus expressBus
+ railShuttle suburbanRailway regionalRail interregionalRail })
+ .for(:transport_submode) }
+
+ xit { should_not allow_values( *%w{ demandResponseBus nightus irportLinkBus highrequencyBus expressBUs
+ Shuttle suburban regioalRail interregion4lRail })
+ .for(:transport_submode) }
end
diff --git a/spec/support/breadcrumb_features.rb b/spec/support/breadcrumb_features.rb
new file mode 100644
index 000000000..36bfce19c
--- /dev/null
+++ b/spec/support/breadcrumb_features.rb
@@ -0,0 +1,15 @@
+module BreadcrumbFeatures
+ def expect_breadcrumb_links *link_names
+ within('.breadcrumbs') do
+ all('a').zip( link_names ).each do | link_element, link_content |
+ within(link_element) do | |
+ expect(page).to have_content(link_content)
+ end
+ end
+ end
+ end
+end
+
+RSpec.configure do | conf |
+ conf.include BreadcrumbFeatures, type: :feature
+end