aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features
diff options
context:
space:
mode:
authorLuc Donnet2018-01-03 11:57:42 +0100
committerLuc Donnet2018-01-03 11:57:42 +0100
commit7cce4762c11e7d1e78433f6f88d2e12928c398dc (patch)
tree3084d95692a70f9c5d5a842aae6f4ec0ea07a1c3 /spec/features
parent6497b23e18385121974f6cbf56d48caf897e69b1 (diff)
parent414d0f6c4dd992696354757c4ae700952a7e4dd9 (diff)
downloadchouette-core-7cce4762c11e7d1e78433f6f88d2e12928c398dc.tar.bz2
Merge branch 'master' into 5024-prevent-duplicate-referentials-from-being-created-during-parallel-db-transactions--rb201711271659
Diffstat (limited to 'spec/features')
-rw-r--r--spec/features/companies_spec.rb2
-rw-r--r--spec/features/compliance_check_sets_spec.rb20
-rw-r--r--spec/features/compliance_control_sets_spec.rb20
-rw-r--r--spec/features/group_of_lines_permissions_spec.rb4
-rw-r--r--spec/features/group_of_lines_spec.rb2
-rw-r--r--spec/features/lines_spec.rb3
-rw-r--r--spec/features/networks_spec.rb2
-rw-r--r--spec/features/purchase_windows_permission_spec.rb59
-rw-r--r--spec/features/purchase_windows_spec.rb69
-rw-r--r--spec/features/routes_permissions_spec.rb3
-rw-r--r--spec/features/stop_areas_spec.rb2
-rw-r--r--spec/features/workbenches/workbenches_permissions_spec.rb (renamed from spec/features/workbenches_permissions_spec.rb)0
-rw-r--r--spec/features/workbenches/workbenches_show_modal_actions_spec.rb29
-rw-r--r--spec/features/workbenches/workbenches_show_spec.rb (renamed from spec/features/workbenches_spec.rb)0
14 files changed, 194 insertions, 21 deletions
diff --git a/spec/features/companies_spec.rb b/spec/features/companies_spec.rb
index 1b9dae56f..4e778b3a0 100644
--- a/spec/features/companies_spec.rb
+++ b/spec/features/companies_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe "Companies", :type => :feature do
login_user
- let(:line_referential) { create :line_referential }
+ let(:line_referential) { create :line_referential, member: @user.organisation }
let!(:companies) { Array.new(2) { create :company, line_referential: line_referential } }
subject { companies.first }
diff --git a/spec/features/compliance_check_sets_spec.rb b/spec/features/compliance_check_sets_spec.rb
index 7ba64b6b8..6b7d7a4f8 100644
--- a/spec/features/compliance_check_sets_spec.rb
+++ b/spec/features/compliance_check_sets_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe "ComplianceCheckSets", type: :feature do
it 'we can see the expected content' do
# Breadcrumbs
- expect_breadcrumb_links "Accueil", "Gestion de l'offre", "Liste des jeux de contrôles"
+ expect_breadcrumb_links "Accueil", "Gestion de l'offre", "Liste des rapports de contrôles"
# Headline
expect( page ).to have_content("Jeu de contrôles exécutés #{compliance_check_set.name}")
@@ -49,10 +49,10 @@ RSpec.describe "ComplianceCheckSets", type: :feature do
# 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 )
+ 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
@@ -60,10 +60,10 @@ RSpec.describe "ComplianceCheckSets", type: :feature do
compliance_check_set.compliance_check_blocks.each do | block |
within(:xpath, xpath_for_div_of_block(block)) do
block.compliance_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 )
+ 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
@@ -86,7 +86,7 @@ RSpec.describe "ComplianceCheckSets", type: :feature do
all_checks.each do | check |
expect( page ).to have_content(check.code)
end
-
+
end
end
diff --git a/spec/features/compliance_control_sets_spec.rb b/spec/features/compliance_control_sets_spec.rb
index bcb989cdc..36dc5c2a9 100644
--- a/spec/features/compliance_control_sets_spec.rb
+++ b/spec/features/compliance_control_sets_spec.rb
@@ -1,4 +1,5 @@
RSpec.describe "ComplianceControlSets", type: :feature do
+ include TransportModeHelper
login_user
@@ -12,7 +13,7 @@ RSpec.describe "ComplianceControlSets", type: :feature do
}
before do
- blox.first.update transport_mode: 'bus', transport_submode: 'bus'
+ blox.first.update transport_mode: 'bus', transport_submode: 'nightBus'
blox.second.update transport_mode: 'train', transport_submode: 'train'
make_control
@@ -21,6 +22,9 @@ RSpec.describe "ComplianceControlSets", type: :feature do
end
describe 'show' do
+ let( :control_button_href ){ select_type_compliance_control_set_compliance_controls_path(control_set) }
+ let( :new_group_button_href ) { new_compliance_control_set_compliance_control_block_path(control_set) }
+
before do
visit compliance_control_set_path( control_set )
end
@@ -40,6 +44,13 @@ RSpec.describe "ComplianceControlSets", type: :feature do
controls.each do | control |
expect( page ).to have_content(control.code)
end
+
+ # Floating Buttons
+ within '.select_toolbox#floating-links' do
+ expect( page ).to have_link("Contrôle", href: control_button_href)
+ expect( page ).to have_link("Groupe de contrôles", href: new_group_button_href)
+ end
+
end
it 'we can apply a severity filter' do
@@ -75,6 +86,13 @@ RSpec.describe "ComplianceControlSets", type: :feature do
end
end
+ context "wthout filter on compliance control block applied" do
+ it "we can see empty blocks" do
+ blox.first.compliance_controls.destroy_all
+ expect(page).to have_content (transport_mode_text(blox.first) )
+ end
+ end
+
end
def make_control ccblock=nil, times: 1, severity: :warning
diff --git a/spec/features/group_of_lines_permissions_spec.rb b/spec/features/group_of_lines_permissions_spec.rb
index 5c03481ec..33d78c0dd 100644
--- a/spec/features/group_of_lines_permissions_spec.rb
+++ b/spec/features/group_of_lines_permissions_spec.rb
@@ -22,7 +22,7 @@ describe "Group of lines", :type => :feature do
context 'on show view' do
let( :path ){ line_referential_group_of_line_path(line_referential, group_of_line, delete: true) }
- context 'if permissions present → ' do
+ context 'if permissions present → ' do
let( :permission ){ true }
it 'shows the appropriate buttons' do
@@ -30,7 +30,7 @@ describe "Group of lines", :type => :feature do
expect( page ).to have_link('Supprimer', href: expected_url)
end
end
- context 'if permissions absent → ' do
+ context 'if permissions absent → ' do
let( :permission ){ false }
it 'shows the appropriate buttons' do
diff --git a/spec/features/group_of_lines_spec.rb b/spec/features/group_of_lines_spec.rb
index 59101ccd5..8b88e6e9e 100644
--- a/spec/features/group_of_lines_spec.rb
+++ b/spec/features/group_of_lines_spec.rb
@@ -10,7 +10,7 @@ describe "Group of lines", :type => :feature do
let!(:group_of_lines) { Array.new(2) { create(:group_of_line, line_referential: line_referential) } }
subject { group_of_lines.first }
- let(:line_referential) { create :line_referential }
+ let(:line_referential) { create :line_referential, member: @user.organisation }
before :each do
subject.lines << line
diff --git a/spec/features/lines_spec.rb b/spec/features/lines_spec.rb
index ecb90668c..f176e34fe 100644
--- a/spec/features/lines_spec.rb
+++ b/spec/features/lines_spec.rb
@@ -1,7 +1,8 @@
+# coding: utf-8
describe "Lines", type: :feature do
login_user
- let(:line_referential) { create :line_referential }
+ let(:line_referential) { create :line_referential, member: @user.organisation }
let!(:network) { create(:network) }
let!(:company) { create(:company) }
let!(:lines) { Array.new(2) { create :line_with_stop_areas, network: network, company: company, line_referential: line_referential } }
diff --git a/spec/features/networks_spec.rb b/spec/features/networks_spec.rb
index 19f17d900..8586b2a16 100644
--- a/spec/features/networks_spec.rb
+++ b/spec/features/networks_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe "Networks", type: :feature do
login_user
- let(:line_referential) { create :line_referential }
+ let(:line_referential) { create :line_referential, member: @user.organisation }
let!(:networks) { Array.new(2) { create(:network, line_referential: line_referential) } }
subject { networks.first }
diff --git a/spec/features/purchase_windows_permission_spec.rb b/spec/features/purchase_windows_permission_spec.rb
new file mode 100644
index 000000000..9f155a1e8
--- /dev/null
+++ b/spec/features/purchase_windows_permission_spec.rb
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+require 'spec_helper'
+
+describe "PurchaseWindows", :type => :feature do
+ login_user
+
+ before do
+ @user.organisation.update features: %w{purchase_windows}
+ end
+
+ let(:purchase_window) { create :purchase_window, referential: first_referential}
+
+ describe 'permissions' do
+ before do
+ allow_any_instance_of(PurchaseWindowPolicy).to receive(:create?).and_return permission
+ allow_any_instance_of(PurchaseWindowPolicy).to receive(:destroy?).and_return permission
+ allow_any_instance_of(PurchaseWindowPolicy).to receive(:update?).and_return permission
+ visit path
+ end
+
+ context 'on show view' do
+ let( :path ){ referential_purchase_window_path(first_referential, purchase_window) }
+
+ context 'if present → ' do
+ let( :permission ){ true }
+ it 'view shows the corresponding buttons' do
+ expect(page).to have_content(I18n.t('purchase_windows.actions.edit'))
+ expect(page).to have_content(I18n.t('purchase_windows.actions.destroy'))
+ end
+ end
+
+ context 'if absent → ' do
+ let( :permission ){ false }
+ it 'view does not show the corresponding buttons' do
+ expect(page).not_to have_content(I18n.t('purchase_windows.actions.edit'))
+ expect(page).not_to have_content(I18n.t('purchase_windows.actions.destroy'))
+ end
+ end
+ end
+
+ context 'on index view' do
+ let( :path ){ referential_purchase_windows_path(first_referential) }
+
+ context 'if present → ' do
+ let( :permission ){ true }
+ it 'index shows an edit button' do
+ expect(page).to have_content(I18n.t('purchase_windows.actions.new'))
+ end
+ end
+
+ context 'if absent → ' do
+ let( :permission ){ false }
+ it 'index does not show any edit button' do
+ expect(page).not_to have_content(I18n.t('purchase_windows.actions.new'))
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/purchase_windows_spec.rb b/spec/features/purchase_windows_spec.rb
new file mode 100644
index 000000000..f797594b7
--- /dev/null
+++ b/spec/features/purchase_windows_spec.rb
@@ -0,0 +1,69 @@
+describe "PurchaseWindows", type: :feature do
+ login_user
+
+ before do
+ @user.organisation.update features: %w{purchase_windows}
+ end
+
+ describe "#index" do
+ with_permissions('purchase_windows.create') do
+ it "allows users to create new purchase windows" do
+ name = 'Test purchase window create'
+
+ visit(referential_purchase_windows_path(first_referential.id))
+
+ click_link(I18n.t('purchase_windows.actions.new'))
+
+ fill_in('purchase_window[name]', with: name)
+ # select('#DD2DAA', from: 'purchase_window[color]')
+
+ click_link(I18n.t('simple_form.labels.purchase_window.add_a_date_range'))
+ click_button(I18n.t('actions.submit'))
+
+ expect(page).to have_content(name)
+ end
+ end
+
+ with_permissions('purchase_windows.update') do
+ it "allows users to update purchase windows" do
+ actual_name = 'Existing purchase window'
+ expected_name = 'Updated purchase window'
+ create(
+ :purchase_window,
+ referential: first_referential,
+ name: actual_name
+ )
+
+ visit(referential_purchase_windows_path(first_referential.id))
+
+ click_link(actual_name)
+
+ click_link(I18n.t('purchase_windows.actions.edit'))
+ fill_in('purchase_window[name]', with: expected_name)
+
+ click_button(I18n.t('actions.submit'))
+
+ expect(page).to have_content(expected_name)
+ end
+ end
+
+ with_permissions('purchase_windows.destroy') do
+ it "allows users to destroy purchase windows" do
+ name = 'Existing purchase window'
+ create(
+ :purchase_window,
+ referential: first_referential,
+ name: name
+ )
+
+ visit(referential_purchase_windows_path(first_referential.id))
+
+ click_link(name)
+
+ click_link(I18n.t('purchase_windows.actions.destroy'))
+
+ expect(page).to_not have_content(name)
+ end
+ end
+ end
+end
diff --git a/spec/features/routes_permissions_spec.rb b/spec/features/routes_permissions_spec.rb
index 36c13b24a..6d3db9d55 100644
--- a/spec/features/routes_permissions_spec.rb
+++ b/spec/features/routes_permissions_spec.rb
@@ -1,6 +1,3 @@
-# -*- coding: utf-8 -*-
-require 'spec_helper'
-
describe "Routes", :type => :feature do
login_user
diff --git a/spec/features/stop_areas_spec.rb b/spec/features/stop_areas_spec.rb
index 6afb22bc6..668eb2fa3 100644
--- a/spec/features/stop_areas_spec.rb
+++ b/spec/features/stop_areas_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe "StopAreas", :type => :feature do
login_user
- let(:stop_area_referential) { create :stop_area_referential }
+ let(:stop_area_referential) { create :stop_area_referential, member: @user.organisation }
let!(:stop_areas) { Array.new(2) { create :stop_area, stop_area_referential: stop_area_referential } }
subject { stop_areas.first }
diff --git a/spec/features/workbenches_permissions_spec.rb b/spec/features/workbenches/workbenches_permissions_spec.rb
index d58293538..d58293538 100644
--- a/spec/features/workbenches_permissions_spec.rb
+++ b/spec/features/workbenches/workbenches_permissions_spec.rb
diff --git a/spec/features/workbenches/workbenches_show_modal_actions_spec.rb b/spec/features/workbenches/workbenches_show_modal_actions_spec.rb
new file mode 100644
index 000000000..ebc48b485
--- /dev/null
+++ b/spec/features/workbenches/workbenches_show_modal_actions_spec.rb
@@ -0,0 +1,29 @@
+RSpec.describe 'Workbenches', type: :feature do
+ login_user
+
+ let(:line_ref) { create :line_referential }
+ let(:line) { create :line, line_referential: line_ref }
+ let(:ref_metadata) { create(:referential_metadata, lines: [line]) }
+
+ let(:workbench) { create :workbench, line_referential: line_ref, organisation: @user.organisation }
+ let!(:referential) { create :workbench_referential,
+ workbench: workbench,
+ metadatas: [ref_metadata],
+ organisation: @user.organisation }
+
+
+ describe 'show' do
+ context 'modal action' do
+ it 'expected behavior' do
+ visit workbench_path(workbench)
+
+ # Modal Action Box: is present
+ within( :css, ".select_toolbox#selected-referentials-action-box span.info-msg > span") do
+ expect( page ).to have_content("0")
+ end
+
+ end
+ end
+ end
+
+end
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches/workbenches_show_spec.rb
index f1151a67b..f1151a67b 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches/workbenches_show_spec.rb