From 3c644876bafb3e3628b9fc8f10186a4913a4d59e Mon Sep 17 00:00:00 2001 From: Marius BALTEANU Date: Mon, 3 Sep 2018 22:31:27 +0000 Subject: [PATCH 2/2] Add "nwday" class to non working days in calendar --- app/controllers/my_controller.rb | 1 + app/helpers/calendars_helper.rb | 3 +++ test/functional/calendars_controller_test.rb | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index d2cc0c5..72b65e4 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -29,6 +29,7 @@ class MyController < ApplicationController helper :custom_fields helper :queries helper :activities + helper :calendars def index page diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb index a807ec4..fe3796c 100644 --- a/app/helpers/calendars_helper.rb +++ b/app/helpers/calendars_helper.rb @@ -18,6 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module CalendarsHelper + include Redmine::Utils::DateCalculation + def link_to_previous_month(year, month, options={}) target_year, target_month = if month == 1 [year - 1, 12] @@ -59,6 +61,7 @@ module CalendarsHelper def calendar_day_css_classes(calendar, day) css = day.month==calendar.month ? 'even' : 'odd' css << " today" if User.current.today == day + css << " nwday" if non_working_week_days.include?(day.cwday) css end end diff --git a/test/functional/calendars_controller_test.rb b/test/functional/calendars_controller_test.rb index a103644..797b3a6 100644 --- a/test/functional/calendars_controller_test.rb +++ b/test/functional/calendars_controller_test.rb @@ -129,8 +129,24 @@ class CalendarsControllerTest < Redmine::ControllerTest get :show, :params => { :query_id => 6 } - + assert_response :success assert_select 'h2', :text => 'Open issues grouped by tracker' end + + def test_show_calendar_day_css_classes + get :show, :params => { + :month => '12', + :year => '2016' + } + assert_response :success + + assert_select 'tr:nth-child(2)' do + assert_select 'td.week-number', :text => '49' + # non working days should have "nwday" CSS class + assert_select 'td.nwday', 2 + assert_select 'td.nwday', :text => '4' + assert_select 'td.nwday', :text => '10' + end + end end -- 2.1.4