diff options
| author | Luc Donnet | 2017-11-30 21:58:52 +0100 |
|---|---|---|
| committer | Luc Donnet | 2017-11-30 21:58:52 +0100 |
| commit | 69a6bd72fecad790edab7e51e7d6df5ac1c7abba (patch) | |
| tree | dc11c5b787d6f9059c36cc9be56e2b1fcb1c64b0 /spec | |
| parent | 3f5ac4764b859f97f776df565599e312b4584a03 (diff) | |
| parent | 887a5985c6aba4ae65fbdd7c0c40f30186a778f2 (diff) | |
| download | chouette-core-69a6bd72fecad790edab7e51e7d6df5ac1c7abba.tar.bz2 | |
Merge branch 'master' into 5093-fix_import_policy
Diffstat (limited to 'spec')
34 files changed, 33 insertions, 140 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb index a7fe0a162..585636124 100644 --- a/spec/db/schema_spec.rb +++ b/spec/db/schema_spec.rb @@ -44,6 +44,6 @@ Diff: #{diff} def diff RSpec::Support::Differ.new( color: RSpec::Matchers.configuration.color? - ).diff_as_string(@original, @expected) + ).diff_as_string(@expected, @original) end end diff --git a/spec/models/api/v1/api_key_spec.rb b/spec/models/api/v1/api_key_spec.rb index b700429d3..cc483a118 100644 --- a/spec/models/api/v1/api_key_spec.rb +++ b/spec/models/api/v1/api_key_spec.rb @@ -4,6 +4,7 @@ RSpec.describe Api::V1::ApiKey, type: :model do subject { create(:api_key) } it { should validate_presence_of :organisation } + it { is_expected.to be_versioned } it 'should have a valid factory' do expect(build(:api_key)).to be_valid diff --git a/spec/models/calendar_spec.rb b/spec/models/calendar_spec.rb index f5020ebf8..e71c2b081 100644 --- a/spec/models/calendar_spec.rb +++ b/spec/models/calendar_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Calendar, :type => :model do it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:short_name) } it { is_expected.to validate_uniqueness_of(:short_name) } + it { is_expected.to be_versioned } describe '#to_time_table' do let(:calendar) { create(:calendar, date_ranges: [Date.today...(Date.today + 1.month)]) } @@ -29,7 +30,6 @@ RSpec.describe Calendar, :type => :model do end end - describe 'before_validation' do let(:calendar) { create(:calendar, date_ranges: []) } diff --git a/spec/models/chouette/access_link_spec.rb b/spec/models/chouette/access_link_spec.rb index d0f351480..ced99eb1d 100644 --- a/spec/models/chouette/access_link_spec.rb +++ b/spec/models/chouette/access_link_spec.rb @@ -4,6 +4,7 @@ describe Chouette::AccessLink, :type => :model do subject { create(:access_link) } it { is_expected.to validate_uniqueness_of :objectid } + it { is_expected.to be_versioned } describe '#get_objectid' do subject { super().get_objectid } diff --git a/spec/models/chouette/access_point_spec.rb b/spec/models/chouette/access_point_spec.rb index a6798ec3b..c734ecedf 100644 --- a/spec/models/chouette/access_point_spec.rb +++ b/spec/models/chouette/access_point_spec.rb @@ -12,6 +12,7 @@ describe Chouette::AccessPoint, :type => :model do it { is_expected.to validate_presence_of :name } it { is_expected.to validate_numericality_of :latitude } it { is_expected.to validate_numericality_of :longitude } + it { is_expected.to be_versioned } describe ".latitude" do it "should accept -90 value" do diff --git a/spec/models/chouette/company_spec.rb b/spec/models/chouette/company_spec.rb index a3101d79c..34b19eeda 100644 --- a/spec/models/chouette/company_spec.rb +++ b/spec/models/chouette/company_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Chouette::Company, :type => :model do subject { create(:company) } it { should validate_presence_of :name } + it { is_expected.to be_versioned } describe "#nullables empty" do it "should set null empty nullable attributes" do diff --git a/spec/models/chouette/connection_link_spec.rb b/spec/models/chouette/connection_link_spec.rb index 04c15b42e..4ab67d007 100644 --- a/spec/models/chouette/connection_link_spec.rb +++ b/spec/models/chouette/connection_link_spec.rb @@ -8,6 +8,7 @@ describe Chouette::ConnectionLink, :type => :model do subject { create(:connection_link) } it { is_expected.to validate_uniqueness_of :objectid } + it { is_expected.to be_versioned } describe '#get_objectid' do subject { super().get_objectid } diff --git a/spec/models/chouette/group_of_line_spec.rb b/spec/models/chouette/group_of_line_spec.rb index 29b4433c5..d43d75374 100644 --- a/spec/models/chouette/group_of_line_spec.rb +++ b/spec/models/chouette/group_of_line_spec.rb @@ -4,6 +4,7 @@ describe Chouette::GroupOfLine, :type => :model do subject { create(:group_of_line) } it { should validate_presence_of :name } + it { is_expected.to be_versioned } describe "#stop_areas" do let!(:line){create(:line, :group_of_lines => [subject])} diff --git a/spec/models/chouette/journey_pattern_spec.rb b/spec/models/chouette/journey_pattern_spec.rb index 047022ade..ea7c2a2e9 100644 --- a/spec/models/chouette/journey_pattern_spec.rb +++ b/spec/models/chouette/journey_pattern_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Chouette::JourneyPattern, :type => :model do + it { is_expected.to be_versioned } + describe 'checksum' do it_behaves_like 'checksum support', :journey_pattern end diff --git a/spec/models/chouette/line_spec.rb b/spec/models/chouette/line_spec.rb index bc7b6e0c7..056d5da9e 100644 --- a/spec/models/chouette/line_spec.rb +++ b/spec/models/chouette/line_spec.rb @@ -7,6 +7,7 @@ describe Chouette::Line, :type => :model do # it { is_expected.to validate_presence_of :network } # it { is_expected.to validate_presence_of :company } it { should validate_presence_of :name } + it { is_expected.to be_versioned } describe '#display_name' do it 'should display local_id, number, name and company name' do diff --git a/spec/models/chouette/network_spec.rb b/spec/models/chouette/network_spec.rb index 32bacc512..78a4150df 100644 --- a/spec/models/chouette/network_spec.rb +++ b/spec/models/chouette/network_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Chouette::Network, :type => :model do subject { create(:network) } it { should validate_presence_of :name } + it { is_expected.to be_versioned } describe "#stop_areas" do let!(:line){create(:line, :network => subject)} diff --git a/spec/models/chouette/route/route_base_spec.rb b/spec/models/chouette/route/route_base_spec.rb index 79daeb6c2..26f57eae5 100644 --- a/spec/models/chouette/route/route_base_spec.rb +++ b/spec/models/chouette/route/route_base_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Chouette::Route, :type => :model do #it { is_expected.to validate_presence_of :direction_code } it { is_expected.to validate_inclusion_of(:direction).in_array(%i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east)) } it { is_expected.to validate_inclusion_of(:wayback).in_array(%i(outbound inbound)) } + it { is_expected.to be_versioned } context "reordering methods" do let(:bad_stop_point_ids){subject.stop_points.map { |sp| sp.id + 1}} diff --git a/spec/models/chouette/routing_constraint_zone_spec.rb b/spec/models/chouette/routing_constraint_zone_spec.rb index c344642e6..8ebd8695c 100644 --- a/spec/models/chouette/routing_constraint_zone_spec.rb +++ b/spec/models/chouette/routing_constraint_zone_spec.rb @@ -7,6 +7,7 @@ describe Chouette::RoutingConstraintZone, type: :model do it { is_expected.to validate_presence_of :name } # shoulda matcher to validate length of array ? xit { is_expected.to validate_length_of(:stop_point_ids).is_at_least(2) } + it { is_expected.to be_versioned } describe 'checksum' do it_behaves_like 'checksum support', :routing_constraint_zone diff --git a/spec/models/chouette/stop_area_spec.rb b/spec/models/chouette/stop_area_spec.rb index 1e0b4af84..c6aeafaf8 100644 --- a/spec/models/chouette/stop_area_spec.rb +++ b/spec/models/chouette/stop_area_spec.rb @@ -11,6 +11,7 @@ describe Chouette::StopArea, :type => :model do it { should validate_presence_of :name } it { should validate_numericality_of :latitude } it { should validate_numericality_of :longitude } + it { is_expected.to be_versioned } # describe ".latitude" do # it "should accept -90 value" do diff --git a/spec/models/chouette/stop_point_spec.rb b/spec/models/chouette/stop_point_spec.rb index 264fd26fc..6b9e7727f 100644 --- a/spec/models/chouette/stop_point_spec.rb +++ b/spec/models/chouette/stop_point_spec.rb @@ -4,6 +4,7 @@ describe Chouette::StopPoint, :type => :model do it { is_expected.to validate_uniqueness_of :objectid } it { is_expected.to validate_presence_of :stop_area } + it { is_expected.to be_versioned } describe '#objectid' do subject { super().get_objectid } diff --git a/spec/models/chouette/time_table_spec.rb b/spec/models/chouette/time_table_spec.rb index 761c39e5b..677308fc8 100644 --- a/spec/models/chouette/time_table_spec.rb +++ b/spec/models/chouette/time_table_spec.rb @@ -6,6 +6,7 @@ describe Chouette::TimeTable, :type => :model do it { is_expected.to validate_presence_of :comment } it { is_expected.to validate_uniqueness_of :objectid } + it { is_expected.to be_versioned } def create_time_table_periode time_table, start_date, end_date create(:time_table_period, time_table: time_table, :period_start => start_date, :period_end => end_date) diff --git a/spec/models/chouette/timeband_spec.rb b/spec/models/chouette/timeband_spec.rb index 1f812a6e2..b960c203f 100644 --- a/spec/models/chouette/timeband_spec.rb +++ b/spec/models/chouette/timeband_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe Chouette::Timeband, :type => :model do + it { is_expected.to be_versioned } describe '#create' do context 'when valid' do diff --git a/spec/models/chouette/vehicle_journey_spec.rb b/spec/models/chouette/vehicle_journey_spec.rb index 86aa475f0..ac9b21ceb 100644 --- a/spec/models/chouette/vehicle_journey_spec.rb +++ b/spec/models/chouette/vehicle_journey_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe Chouette::VehicleJourney, :type => :model do + it { is_expected.to be_versioned } it "must be valid with an at-stop day offset of 1" do vehicle_journey = create( diff --git a/spec/models/compliance_check_set_spec.rb b/spec/models/compliance_check_set_spec.rb index 0159d1c6b..b981a68bb 100644 --- a/spec/models/compliance_check_set_spec.rb +++ b/spec/models/compliance_check_set_spec.rb @@ -12,6 +12,7 @@ RSpec.describe ComplianceCheckSet, type: :model do it { should have_many :compliance_checks } it { should have_many :compliance_check_blocks } + it { is_expected.to be_versioned } describe "#update_status" do it "updates :status to successful when all resources are OK" do @@ -89,4 +90,13 @@ RSpec.describe ComplianceCheckSet, type: :model do expect(check_set.update_status).to be true end end + + describe 'possibility to delete the associated compliance_control_set' do + let!(:compliance_check_set) { create :compliance_check_set } + + it do + expect{ compliance_check_set.compliance_control_set.delete } + .to change{ ComplianceControlSet.count }.by(-1) + end + end end diff --git a/spec/models/compliance_check_spec.rb b/spec/models/compliance_check_spec.rb index bd797ab09..f83d78c29 100644 --- a/spec/models/compliance_check_spec.rb +++ b/spec/models/compliance_check_spec.rb @@ -1,4 +1,5 @@ RSpec.describe ComplianceCheck, type: :model do + it 'should have a valid factory' do expect(FactoryGirl.build(:compliance_check)).to be_valid end diff --git a/spec/models/compliance_control_set_spec.rb b/spec/models/compliance_control_set_spec.rb index 04d1c418c..c157dcaf3 100644 --- a/spec/models/compliance_control_set_spec.rb +++ b/spec/models/compliance_control_set_spec.rb @@ -10,4 +10,5 @@ RSpec.describe ComplianceControlSet, type: :model do it { should have_many(:compliance_control_blocks).dependent(:destroy) } it { should validate_presence_of :name } + it { is_expected.to be_versioned } end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6d9f4a4a2..47578405e 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -3,6 +3,7 @@ ENV["RAILS_ENV"] ||= 'test' require 'spec_helper' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' + # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6b37b9fa8..9679952df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -34,6 +34,7 @@ require 'webmock/rspec' require 'simplecov' require 'sidekiq/testing' Sidekiq::Testing.fake! +require 'paper_trail/frameworks/rspec' # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are diff --git a/spec/views/companies/edit.html.erb_spec.rb b/spec/views/companies/edit.html.erb_spec.rb index 5abdddf3c..8aaf705ab 100644 --- a/spec/views/companies/edit.html.erb_spec.rb +++ b/spec/views/companies/edit.html.erb_spec.rb @@ -6,13 +6,6 @@ describe "/companies/edit", :type => :view do let!(:companies) { Array.new(2) { create(:company) } } let!(:line_referential) { assign :line_referential, company.line_referential } - describe "test" do - it "should render h2 with the company name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(company.name)) - end - end - describe "form" do it "should render input for name" do render @@ -21,5 +14,4 @@ describe "/companies/edit", :type => :view do end end end - end diff --git a/spec/views/companies/show.html.erb_spec.rb b/spec/views/companies/show.html.erb_spec.rb index dbc544f63..aeb93aebb 100644 --- a/spec/views/companies/show.html.erb_spec.rb +++ b/spec/views/companies/show.html.erb_spec.rb @@ -5,24 +5,8 @@ describe "/companies/show", :type => :view do let!(:company) { assign(:company, create(:company)) } let!(:line_referential) { assign :line_referential, company.line_referential } - it "should render h1 with the company name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(company.name)) - end - # it "should display a map with class 'company'" do # render # expect(rendered).to have_selector("#map", :class => 'company') # end - - it "should render a link to edit the company" do - render - expect(rendered).to have_selector("a[href='#{view.edit_line_referential_company_path(line_referential, company)}']") - end - - it "should render a link to remove the company" do - render - expect(rendered).to have_selector("a[href='#{view.line_referential_company_path(line_referential, company)}']") - end - end diff --git a/spec/views/lines/edit.html.erb_spec.rb b/spec/views/lines/edit.html.erb_spec.rb index ae1614400..2af4df10a 100644 --- a/spec/views/lines/edit.html.erb_spec.rb +++ b/spec/views/lines/edit.html.erb_spec.rb @@ -8,13 +8,6 @@ describe "/lines/edit", :type => :view do let!(:lines) { Array.new(2) { create(:line, :network => network, :company => company) } } let!(:line_referential) { assign :line_referential, line.line_referential } - describe "test" do - it "should render h2 with the group name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(line.name)) - end - end - describe "form" do it "should render input for name" do render diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb index 7bc120f1a..9649d9c8e 100644 --- a/spec/views/lines/show.html.erb_spec.rb +++ b/spec/views/lines/show.html.erb_spec.rb @@ -17,25 +17,4 @@ describe "/lines/show", :type => :view do before do allow(view).to receive_messages(current_organisation: referential.organisation) end - - it "should render h1 with the line name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(line.name)) - end - - # it "should display a map with class 'line'" do - # render - # expect(rendered).to have_selector("#map", :class => 'line') - # end - # FIXME #2018 - xit "should render a link to edit the line" do - render - expect(rendered).to have_selector("a[href='#{view.edit_line_referential_line_path(line_referential, line)}']") - end - - it "should render a link to remove the line" do - render - expect(rendered).to have_selector("a[href='#{view.line_referential_line_path(line_referential, line)}']") - end - end diff --git a/spec/views/networks/edit.html.erb_spec.rb b/spec/views/networks/edit.html.erb_spec.rb index 086988277..aac6d4d28 100644 --- a/spec/views/networks/edit.html.erb_spec.rb +++ b/spec/views/networks/edit.html.erb_spec.rb @@ -5,13 +5,6 @@ describe "/networks/edit", :type => :view do let!(:network) { assign(:network, create(:network) ) } let!(:line_referential) { assign :line_referential, network.line_referential } - describe "test" do - it "should render h2 with the group name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(network.name)) - end - end - describe "form" do it "should render input for name" do render diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb index 72605fb46..3926ead14 100644 --- a/spec/views/networks/show.html.erb_spec.rb +++ b/spec/views/networks/show.html.erb_spec.rb @@ -11,24 +11,8 @@ describe "/networks/show", :type => :view do let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) } let!(:line_referential) { assign :line_referential, network.line_referential } - it "should render h1 with the network name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(network.name)) - end - # it "should display a map with class 'network'" do # render # expect(rendered).to have_selector("#map") # end - - it "should render a link to edit the network" do - render - expect(rendered).to have_selector("a[href='#{view.edit_line_referential_network_path(line_referential, network)}']") - end - - it "should render a link to remove the network" do - render - expect(rendered).to have_selector("a[href='#{view.line_referential_network_path(line_referential, network)}']") - end - end diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb index dae8c9ed3..3bbfaa799 100644 --- a/spec/views/routes/show.html.erb_spec.rb +++ b/spec/views/routes/show.html.erb_spec.rb @@ -22,20 +22,4 @@ RSpec.describe "/routes/show", type: :view do referential )) end - - it "should render h1 with the route name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(route.name)) - end - - it "should render a link to edit the route" do - render - expect(rendered).to have_selector("a[href='#{view.edit_referential_line_route_path(referential, line, route)}']") - end - - it "should render a link to remove the route" do - render - expect(rendered).to have_selector("a[href='#{view.referential_line_route_path(referential, line, route)}']") - end - end diff --git a/spec/views/stop_areas/edit.html.erb_spec.rb b/spec/views/stop_areas/edit.html.erb_spec.rb index 8006fe612..5105bff4b 100644 --- a/spec/views/stop_areas/edit.html.erb_spec.rb +++ b/spec/views/stop_areas/edit.html.erb_spec.rb @@ -6,13 +6,6 @@ describe "/stop_areas/edit", :type => :view do let!(:stop_area) { assign(:stop_area, create(:stop_area)) } let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) } - describe "test" do - it "should render h2 with the group name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(stop_area.name)) - end - end - describe "form" do it "should render input for name" do render diff --git a/spec/views/stop_areas/show.html.erb_spec.rb b/spec/views/stop_areas/show.html.erb_spec.rb index 6fd416128..693d9cf1f 100644 --- a/spec/views/stop_areas/show.html.erb_spec.rb +++ b/spec/views/stop_areas/show.html.erb_spec.rb @@ -7,24 +7,8 @@ describe "/stop_areas/show", :type => :view do let!(:access_points) { assign :access_points, [] } let!(:map) { assign(:map, double(:to_html => '<div id="map"/>'.html_safe)) } - it "should render h1 with the stop_area name" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(stop_area.name)) - end - # it "should display a map with class 'stop_area'" do # render # expect(rendered).to have_selector("#map", :class => 'stop_area') # end - - it "should render a link to edit the stop_area" do - render - expect(rendered).to have_selector("a[href='#{view.edit_stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']") - end - - it "should render a link to remove the stop_area" do - render - expect(rendered).to have_selector("a[href='#{view.stop_area_referential_stop_area_path(stop_area_referential, stop_area)}']") - end - end diff --git a/spec/views/time_tables/edit.html.erb_spec.rb b/spec/views/time_tables/edit.html.erb_spec.rb index c84c5eb74..f431eab7b 100644 --- a/spec/views/time_tables/edit.html.erb_spec.rb +++ b/spec/views/time_tables/edit.html.erb_spec.rb @@ -3,13 +3,5 @@ require 'spec_helper' describe "/time_tables/edit", :type => :view do assign_referential let!(:time_table) { assign(:time_table, create(:time_table) ) } - - describe "test" do - it "should render h1 with the group comment" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(time_table.comment)) - end - end - # No more test for the form, as it is now managed by React/Redux. end diff --git a/spec/views/time_tables/show.html.erb_spec.rb b/spec/views/time_tables/show.html.erb_spec.rb index edfb3f3cc..100c74b90 100644 --- a/spec/views/time_tables/show.html.erb_spec.rb +++ b/spec/views/time_tables/show.html.erb_spec.rb @@ -17,20 +17,4 @@ describe "/time_tables/show", :type => :view do before do allow(view).to receive_messages(current_organisation: referential.organisation) end - - it "should render h2 with the time_table comment" do - render - expect(rendered).to have_selector("h1", :text => Regexp.new(time_table.comment)) - end - - it "should render a link to edit the time_table" do - render - expect(rendered).to have_selector(" a[href='#{view.edit_referential_time_table_path(referential, time_table)}']") - end - - it "should render a link to remove the time_table" do - render - expect(rendered).to have_selector(" a[href='#{view.referential_time_table_path(referential, time_table)}']") - end - end |
