diff --git a/lib/recurrence/event/monthly.rb b/lib/recurrence/event/monthly.rb index 63695f5..4c4f1bf 100644 --- a/lib/recurrence/event/monthly.rb +++ b/lib/recurrence/event/monthly.rb @@ -105,7 +105,7 @@ class Monthly < Base # :nodoc: all end private def shift_to(date) - @options[:on] = date.day + @options[:on] = date.day unless @options[:weekday].present? end private def valid_ordinal?(ordinal) diff --git a/test/recurrence/date_shift_test.rb b/test/recurrence/date_shift_test.rb index b77a3ec..128c5ab 100644 --- a/test/recurrence/date_shift_test.rb +++ b/test/recurrence/date_shift_test.rb @@ -70,4 +70,13 @@ class DateShiftTest < Minitest::Test assert_equal Date.new(2012, 2, 29), r.next end + + test "correctly recurrs for weekdays" do + r = recurrence(every: :month, starts: "2011-01-31", on: "first", + weekday: "monday", shift: true) + + assert_equal Date.new(2011, 2, 7), r.events[0] + assert_equal Date.new(2011, 3, 7), r.events[1] + assert_equal Date.new(2011, 4, 4), r.events[2] + end end