aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/features/line_referentials_permissions_spec.rb30
-rw-r--r--spec/features/stop_area_referentials_permissions_spec.rb30
-rw-r--r--spec/models/calendar/period_spec.rb9
-rw-r--r--spec/models/chouette/journey_pattern_spec.rb27
-rw-r--r--spec/policies/stop_area_referential_policy_spec.rb (renamed from spec/policies/sto_area_referential_policy_spec.rb)0
-rw-r--r--spec/requests/api/v1/netex_import_spec.rb1
-rw-r--r--spec/views/line_referentials/show.html.slim_spec.rb17
-rw-r--r--spec/views/stop_area_referentials/show.html.slim_spec.rb17
8 files changed, 98 insertions, 33 deletions
diff --git a/spec/features/line_referentials_permissions_spec.rb b/spec/features/line_referentials_permissions_spec.rb
new file mode 100644
index 000000000..845ffe9c1
--- /dev/null
+++ b/spec/features/line_referentials_permissions_spec.rb
@@ -0,0 +1,30 @@
+RSpec.describe 'LineReferentials', type: :feature do
+ login_user
+
+ let(:line_referential) { first_workgroup.line_referential }
+
+ describe 'permissions' do
+ before do
+ allow_any_instance_of(LineReferentialPolicy).to receive(:synchronize?).and_return permission
+ visit path
+ end
+
+ context 'on show view' do
+ let( :path ){ line_referential_path(line_referential.id) }
+
+ context 'if present → ' do
+ let( :permission ){ true }
+ it 'shows an edit button' do
+ expect(page).to have_css('a.btn.btn-default', text: I18n.t('actions.sync'))
+ end
+ end
+
+ context 'if absent → ' do
+ let( :permission ){ false }
+ it 'does not show any edit button' do
+ expect(page).not_to have_css('a.btn.btn-default', text: I18n.t('actions.sync'))
+ end
+ end
+ end
+ end
+end
diff --git a/spec/features/stop_area_referentials_permissions_spec.rb b/spec/features/stop_area_referentials_permissions_spec.rb
new file mode 100644
index 000000000..ca7038d51
--- /dev/null
+++ b/spec/features/stop_area_referentials_permissions_spec.rb
@@ -0,0 +1,30 @@
+RSpec.describe 'StopAreaReferentials', type: :feature do
+ login_user
+
+ let(:stop_area_referential) { first_workgroup.stop_area_referential }
+
+ describe 'permissions' do
+ before do
+ allow_any_instance_of(StopAreaReferentialPolicy).to receive(:synchronize?).and_return permission
+ visit path
+ end
+
+ context 'on show view' do
+ let( :path ){ stop_area_referential_path(stop_area_referential.id) }
+
+ context 'if present → ' do
+ let( :permission ){ true }
+ it 'shows an edit button' do
+ expect(page).to have_css('a.btn.btn-default', text: I18n.t('actions.sync'))
+ end
+ end
+
+ context 'if absent → ' do
+ let( :permission ){ false }
+ it 'does not show any edit button' do
+ expect(page).not_to have_css('a.btn.btn-default', text: I18n.t('actions.sync'))
+ end
+ end
+ end
+ end
+end
diff --git a/spec/models/calendar/period_spec.rb b/spec/models/calendar/period_spec.rb
index 233733cbf..0e77c632c 100644
--- a/spec/models/calendar/period_spec.rb
+++ b/spec/models/calendar/period_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe Calendar::Period, type: :model do
def period(attributes = {})
@__period__ ||= {}
- @__period__.fetch(attributes){
+ @__period__.fetch(attributes){
@__period__[attributes] = Calendar::Period.new(attributes)
}
end
@@ -36,12 +36,15 @@ RSpec.describe Calendar::Period, type: :model do
it { is_expected.to validate_presence_of(:begin) }
it { is_expected.to validate_presence_of(:end) }
- it 'should validate that end is greather than or equlals to begin' do
+ it 'should validate that end is greather than to begin' do
expect(period(begin: '2016-11-21', end: '2016-11-22')).to be_valid
- expect(period(begin: '2016-11-21', end: '2016-11-21')).to_not be_valid
expect(period(begin: '2016-11-22', end: '2016-11-21')).to_not be_valid
end
+ it 'should accept a 1-day period' do
+ expect(period(begin: '2016-11-21', end: '2016-11-21')).to be_valid
+ end
+
describe 'intersect?' do
it 'should detect date in common with other date_ranges' do
november = period(begin: '2016-11-01', end: '2016-11-30')
diff --git a/spec/models/chouette/journey_pattern_spec.rb b/spec/models/chouette/journey_pattern_spec.rb
index 02a54f056..57ee5ab4e 100644
--- a/spec/models/chouette/journey_pattern_spec.rb
+++ b/spec/models/chouette/journey_pattern_spec.rb
@@ -41,13 +41,6 @@ describe Chouette::JourneyPattern, :type => :model do
end
context "when the costs are incomplete" do
- context "with a missing distance" do
- before(:each){
- journey_pattern.costs = generate_journey_pattern_costs(->(i){i == 1 ? nil : 10}, 10)
- }
- it { should be_falsy }
- end
-
context "with a missing time" do
before(:each){
journey_pattern.costs = generate_journey_pattern_costs(10, ->(i){i == 1 ? nil : 10})
@@ -56,19 +49,27 @@ describe Chouette::JourneyPattern, :type => :model do
end
end
- context "with a zeroed cost" do
+ context "when all the times are set" do
before(:each){
- journey_pattern.costs = generate_journey_pattern_costs(->(i){i == 1 ? 0 : 10}, 10)
+ journey_pattern.costs = generate_journey_pattern_costs(10, 10)
}
- it { should be_falsy }
+ it { should be_truthy }
end
- context "when all the times are set" do
+ context "with a missing distance" do
before(:each){
- journey_pattern.costs = generate_journey_pattern_costs(10, 10)
+ journey_pattern.costs = generate_journey_pattern_costs(->(i){i == 1 ? nil : 10}, 10)
}
it { should be_truthy }
end
+
+ context "with a zeroed distance" do
+ before(:each){
+ journey_pattern.costs = generate_journey_pattern_costs(->(i){i == 1 ? 0 : 10}, 10)
+ }
+ it { should be_truthy }
+ end
+
end
describe "distance_to" do
@@ -117,7 +118,7 @@ describe Chouette::JourneyPattern, :type => :model do
jp.attributes.slice('name', 'published_name', 'registration_number').tap do |item|
item['object_id'] = jp.objectid
item['stop_points'] = jp.stop_points.map do |sp|
- { 'id' => sp.stop_area_id }
+ { 'id' => sp.stop_area_id, 'position' => sp.position }
end
item['costs'] = jp.costs
end
diff --git a/spec/policies/sto_area_referential_policy_spec.rb b/spec/policies/stop_area_referential_policy_spec.rb
index 5bd6da427..5bd6da427 100644
--- a/spec/policies/sto_area_referential_policy_spec.rb
+++ b/spec/policies/stop_area_referential_policy_spec.rb
diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb
index 14dac9a25..a108b476f 100644
--- a/spec/requests/api/v1/netex_import_spec.rb
+++ b/spec/requests/api/v1/netex_import_spec.rb
@@ -105,7 +105,6 @@ RSpec.describe "Import::Netex", type: :request do
end
end
- it_behaves_like 'illegal attributes', :file
it_behaves_like 'illegal attributes', :workbench_id
# TODO Create a specific test when referential is not created
diff --git a/spec/views/line_referentials/show.html.slim_spec.rb b/spec/views/line_referentials/show.html.slim_spec.rb
index 6734957c8..533b92523 100644
--- a/spec/views/line_referentials/show.html.slim_spec.rb
+++ b/spec/views/line_referentials/show.html.slim_spec.rb
@@ -8,13 +8,14 @@ describe "/line_referentials/show", :type => :view do
render
end
- it "should not present syncing infos and button" do
- expect(view.content_for(:page_header_actions)).to_not have_selector("a[href=\"#{view.sync_line_referential_path(line_referential)}\"]")
- end
+ # FIXME See #6647
+ # it "should not present syncing infos and button" do
+ # expect(view.content_for(:page_header_actions)).to_not have_selector("a[href=\"#{view.sync_line_referential_path(line_referential)}\"]")
+ # end
- with_permission "line_referentials.synchronize" do
- it "should present syncing infos and button" do
- expect(view.content_for(:page_header_actions)).to have_selector("a[href=\"#{view.sync_line_referential_path(line_referential)}\"]", count: 1)
- end
- end
+ # with_permission "line_referentials.synchronize" do
+ # it "should present syncing infos and button" do
+ # expect(view.content_for(:page_header_actions)).to have_selector("a[href=\"#{view.sync_line_referential_path(line_referential)}\"]", count: 1)
+ # end
+ # end
end
diff --git a/spec/views/stop_area_referentials/show.html.slim_spec.rb b/spec/views/stop_area_referentials/show.html.slim_spec.rb
index a7567a969..42e2d761b 100644
--- a/spec/views/stop_area_referentials/show.html.slim_spec.rb
+++ b/spec/views/stop_area_referentials/show.html.slim_spec.rb
@@ -8,13 +8,14 @@ describe "/stop_area_referentials/show", :type => :view do
render
end
- it "should not present syncing infos and button" do
- expect(view.content_for(:page_header_actions)).to_not have_selector("a[href=\"#{view.sync_stop_area_referential_path(stop_area_referential)}\"]")
- end
+ # FIXME See #6647
+ # it "should not present syncing infos and button" do
+ # expect(view.content_for(:page_header_actions)).to_not have_selector("a[href=\"#{view.sync_stop_area_referential_path(stop_area_referential)}\"]")
+ # end
- with_permission "stop_area_referentials.synchronize" do
- it "should present syncing infos and button" do
- expect(view.content_for(:page_header_actions)).to have_selector("a[href=\"#{view.sync_stop_area_referential_path(stop_area_referential)}\"]", count: 1)
- end
- end
+ # with_permission "stop_area_referentials.synchronize" do
+ # it "should present syncing infos and button" do
+ # expect(view.content_for(:page_header_actions)).to have_selector("a[href=\"#{view.sync_stop_area_referential_path(stop_area_referential)}\"]", count: 1)
+ # end
+ # end
end