diff options
| author | Robert | 2017-07-06 14:15:25 +0200 | 
|---|---|---|
| committer | Robert | 2017-07-06 14:15:25 +0200 | 
| commit | b055e1266427c8edb8469e7153c64f1d1bf9c54f (patch) | |
| tree | 8a4f38be383ab424bfed8fca4c016d3a81455fef /spec | |
| parent | 1b5b681603f629b901deabffc4c55f654bbcfe14 (diff) | |
| parent | 6f63feeb32883b57d05bed7f3817e01caba12289 (diff) | |
| download | chouette-core-b055e1266427c8edb8469e7153c64f1d1bf9c54f.tar.bz2 | |
Conflict resolved
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/helpers/table_builder_helper_spec.rb | 4 | ||||
| -rw-r--r-- | spec/models/clean_up_spec.rb | 20 | 
2 files changed, 11 insertions, 13 deletions
| diff --git a/spec/helpers/table_builder_helper_spec.rb b/spec/helpers/table_builder_helper_spec.rb index c2c287b99..4f7c1bd69 100644 --- a/spec/helpers/table_builder_helper_spec.rb +++ b/spec/helpers/table_builder_helper_spec.rb @@ -177,7 +177,7 @@ describe TableBuilderHelper, type: :helper do          referential: referential        )        allow(helper).to receive(:current_user).and_return(user_context) -      allow(TableBuilderHelper::URL).to receive(:current_referential) +      allow(helper).to receive(:current_referential)          .and_return(referential)        companies = [company] @@ -286,7 +286,7 @@ describe TableBuilderHelper, type: :helper do          referential: referential        )        allow(helper).to receive(:current_user).and_return(user_context) -      allow(TableBuilderHelper::URL).to receive(:current_referential) +      allow(helper).to receive(:current_referential)          .and_return(referential)        companies = [company] diff --git a/spec/models/clean_up_spec.rb b/spec/models/clean_up_spec.rb index 4dc692ab2..01440be0e 100644 --- a/spec/models/clean_up_spec.rb +++ b/spec/models/clean_up_spec.rb @@ -2,18 +2,17 @@ require 'rails_helper'  RSpec.describe CleanUp, :type => :model do -  it { should validate_presence_of(:begin_date) } -  it { should validate_presence_of(:date_type) } +  it { should validate_presence_of(:date_type).with_message(:presence) } +  it { should validate_presence_of(:begin_date).with_message(:presence) }    it { should belong_to(:referential) }    context '#exclude_dates_in_overlapping_period with :before date_type' do      let(:time_table) { create(:time_table) }      let(:period) { time_table.periods[0] } -    let(:cleaner) { create(:clean_up, date_type: :before) } +    let(:cleaner) { create(:clean_up, date_type: :before, begin_date: period.period_end) }      it 'should add exclude date into period for overlapping period' do        days_in_period = (period.period_start..period.period_end).count -      cleaner.begin_date = period.period_end        expect { cleaner.exclude_dates_in_overlapping_period(period) }.to change {          time_table.dates.where(in_out: false).count @@ -31,11 +30,10 @@ RSpec.describe CleanUp, :type => :model do    context '#exclude_dates_in_overlapping_period with :after date_type' do      let(:time_table) { create(:time_table) }      let(:period) { time_table.periods[0] } -    let(:cleaner) { create(:clean_up, date_type: :after) } +    let(:cleaner) { create(:clean_up, date_type: :after, begin_date: period.period_start + 1.day) }      it 'should add exclude date into period for overlapping period' do        days_in_period = (period.period_start..period.period_end).count -      cleaner.begin_date = period.period_start + 1.day        expect { cleaner.exclude_dates_in_overlapping_period(period) }.to change {          time_table.dates.where(in_out: false).count        }.by(days_in_period - 2) @@ -72,11 +70,11 @@ RSpec.describe CleanUp, :type => :model do    end    context '#overlapping_periods' do -    let(:cleaner) { create(:clean_up, date_type: :before, end_date: nil) }      let(:time_table) { create(:time_table) } +    let(:period) { time_table.periods[0] } +    let(:cleaner) { create(:clean_up, date_type: :before, begin_date: period.period_start) }      it 'should detect overlapping periods' do -      cleaner.begin_date = time_table.periods[0].period_start        expect(cleaner.overlapping_periods).to include(time_table.periods[0])      end @@ -128,7 +126,7 @@ RSpec.describe CleanUp, :type => :model do      it 'should destroy record' do        expect{ cleaner.destroy_time_tables_dates_between }.to change {          Chouette::TimeTableDate.count -      }.by(-time_table.dates.count) +      }.by(-time_table.dates.count + 2)      end      it 'should not destroy record not in range' do @@ -155,7 +153,7 @@ RSpec.describe CleanUp, :type => :model do    context '#destroy_time_tables_between' do      let!(:time_table) { create(:time_table ) } -    let(:cleaner) { create(:clean_up, date_type: :after, begin_date: time_table.start_date, end_date: time_table.end_date) } +    let(:cleaner) { create(:clean_up, date_type: :between, begin_date: time_table.start_date - 1.day, end_date: time_table.end_date + 1.day) }      it 'should destroy time_tables with validity period in purge range' do        expect{ cleaner.destroy_time_tables_between }.to change { @@ -240,7 +238,7 @@ RSpec.describe CleanUp, :type => :model do        }.by(-1)      end -    it 'should not destroy time_tables with end_date > purge begin date' do +    it 'should not destroy time_tables with end_date > purge begin_date' do        cleaner.begin_date = Date.today        expect{ cleaner.destroy_time_tables_before }.to_not change {          Chouette::TimeTable.count | 
