diff --git a/.travis.yml b/.travis.yml index 45d99a55..79ccbae8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,32 +10,12 @@ branches: only: - master rvm: - - 1.9.3 - - 2.0 - - 2.1.10 - - 2.2.6 - - 2.3.3 - - 2.4.0 + - 2.3.7 + - 2.4.4 + - 2.5.1 - ruby-head env: - - RAILS_VERSION='~> 3.2' - RAILS_VERSION='~> 4.2' - RAILS_VERSION='~> 5.0' -matrix: - exclude: - - # Rails 5 only runs on ruby 2.3 and up - - rvm: 1.9.3 - env: RAILS_VERSION='~> 5.0' - - rvm: 2.0 - env: RAILS_VERSION='~> 5.0' - - rvm: 2.1.10 - env: RAILS_VERSION='~> 5.0' - - rvm: 2.2.6 - env: RAILS_VERSION='~> 5.0' - - # Rails 3 no longer runs on ruby 2.4 and up - - rvm: 2.4.0 - env: RAILS_VERSION='~> 3.2' - - rvm: ruby-head - env: RAILS_VERSION='~> 3.2' + - RAILS_VERSION='~> 5.1' + - RAILS_VERSION='~> 5.2' diff --git a/Gemfile b/Gemfile index 022c86be..7e32e2c5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,5 @@ source 'https://rubygems.org' gemspec -compatible_rails_versions = [ - '>= 3.0.0', - ('<5' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2')) -].compact - -gem 'activesupport', (ENV['RAILS_VERSION'] || compatible_rails_versions), require: false +gem 'activesupport', (ENV['RAILS_VERSION'] || '>= 4.2'), require: false gem 'i18n', require: false -gem 'tzinfo', require: false # only needed explicitly for RAILS_VERSION=3 diff --git a/config/locales/sv.yml b/config/locales/sv.yml index e7af6f8a..b7e55c29 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -127,7 +127,7 @@ sv: - Aug - Sep - Okt - - Mov + - Nov - Dec day_names: - Söndag diff --git a/ice_cube.gemspec b/ice_cube.gemspec index 7dd3fd74..82e431cd 100644 --- a/ice_cube.gemspec +++ b/ice_cube.gemspec @@ -1,4 +1,3 @@ -# encoding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'ice_cube/version' @@ -15,9 +14,7 @@ Gem::Specification.new do |s| s.version = IceCube::VERSION s.platform = Gem::Platform::RUBY s.files = Dir['lib/**/*.rb', 'config/**/*.yml'] - s.test_files = Dir.glob('spec/*.rb') s.require_paths = ['lib'] - s.has_rdoc = true s.add_development_dependency('rake') s.add_development_dependency('rspec', '> 3') diff --git a/lib/ice_cube/validations/hour_of_day.rb b/lib/ice_cube/validations/hour_of_day.rb index 291708e6..819c394d 100644 --- a/lib/ice_cube/validations/hour_of_day.rb +++ b/lib/ice_cube/validations/hour_of_day.rb @@ -23,7 +23,7 @@ def realign(opening_time, start_time) first_hour = Array(validations[:hour_of_day]).min_by(&:value) time = TimeUtil::TimeWrapper.new(start_time, false) - if freq > 1 + if freq > 1 && base_interval_validation.type == :hour offset = first_hour.validate(opening_time, start_time) time.add(:hour, offset - freq) else diff --git a/spec/examples/weekly_rule_spec.rb b/spec/examples/weekly_rule_spec.rb index 682a85e4..4c805642 100644 --- a/spec/examples/weekly_rule_spec.rb +++ b/spec/examples/weekly_rule_spec.rb @@ -338,6 +338,26 @@ module IceCube end end end + + # August 2018 + # Su Mo Tu We Th Fr Sa + # 1 2 3 4 + # 5 6 7 8 9 10 11 + # 12 13 14 15 16 17 18 + # 19 20 21 22 23 24 25 + # 26 27 28 29 30 31 + context 'when day of start_time does not align with specified day rule' do + let(:start_time) { Time.utc(2018, 8, 7, 10, 0, 0) } + let(:end_time) { Time.utc(2018, 8, 7, 15, 0, 0) } + let(:biweekly) { IceCube::Rule.weekly(2).day(:saturday).hour_of_day(10) } + let(:schedule) { IceCube::Schedule.new(start_time, end_time: end_time) { |s| s.rrule biweekly } } + let(:range) { [Time.utc(2018, 8, 11, 7, 0, 0), Time.utc(2018, 8, 12, 6, 59, 59)] } + let(:expected_date) { Time.utc(2018, 8, 11, 10, 0, 0) } + + it 'should align to the correct day with the spans option' do + expect(schedule.occurrences_between(range.first, range.last, spans: true)).to include expected_date + end + end end describe "using occurs_between with a weekly schedule" do