/* * Copyright 2000-2014 Vaadin Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.vaadin.ui; import com.vaadin.shared.ui.MarginInfo; import com.vaadin.shared.ui.orderedlayout.FormLayoutState; /** * FormLayout is used by {@link Form} to layout fields. It may also be used * separately without {@link Form}. * * FormLayout is a close relative of {@link VerticalLayout}, but in FormLayout * captions are rendered to the left of their respective components. Required * and validation indicators are shown between the captions and the fields. * * FormLayout by default has component spacing on. Also margin top and margin * bottom are by default on. * */ public class FormLayout extends AbstractOrderedLayout { public FormLayout() { super(); setSpacing(true); setMargin(new MarginInfo(true, false)); setWidth(100, UNITS_PERCENTAGE); } /** * Constructs a FormLayout and adds the given components to it. * * @see AbstractOrderedLayout#addComponents(Component...) * * @param children * Components to add to the FormLayout */ public FormLayout(Component... children) { this(); addComponents(children); } /** * @deprecated This method currently has no effect as expand ratios are not * implemented in FormLayout */ @Override @Deprecated public void setExpandRatio(Component component, float ratio) { super.setExpandRatio(component, ratio); } /** * @deprecated This method currently has no effect as expand ratios are not * implemented in FormLayout */ @Override @Deprecated public float getExpandRatio(Component component) { return super.getExpandRatio(component); } @Override protected FormLayoutState getState() { return (FormLayoutState) super.getState(); } } e/redminewww-data
summaryrefslogtreecommitdiffstats
path: root/test/unit/lib/redmine/helpers/calendar_test.rb
blob: 841a496be9dc2e93dea563a0513e8c4d30efc776 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# frozen_string_literal: true

# Redmine - project management software
# Copyright (C) 2006-2022  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

require File.expand_path('../../../../../test_helper', __FILE__)

class CalendarTest < ActiveSupport::TestCase
  def test_monthly
    c = Redmine::Helpers::Calendar.new(Date.today, :fr, :month)
    assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]

    c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :month)
    assert_equal ['2007-06-25'.to_date, '2007-08-05'.to_date], [c.startdt, c.enddt]

    c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
    assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
  end

  def test_weekly
    c = Redmine::Helpers::Calendar.new(Date.today, :fr, :week)
    assert_equal [1, 7], [c.startdt.cwday, c.enddt.cwday]

    c = Redmine::Helpers::Calendar.new('2007-07-14'.to_date, :fr, :week)
    assert_equal ['2007-07-09'.to_date, '2007-07-15'.to_date], [c.startdt, c.enddt]

    c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
    assert_equal [7, 6], [c.startdt.cwday, c.enddt.cwday]
  end

  def test_monthly_start_day
    [1, 6, 7].each do |day|
      with_settings :start_of_week => day do
        c = Redmine::Helpers::Calendar.new(Date.today, :en, :month)
        assert_equal day, c.startdt.cwday
        assert_equal (day + 5) % 7 + 1, c.enddt.cwday
      end
    end
  end

  def test_weekly_start_day
    [1, 6, 7].each do |day|
      with_settings :start_of_week => day do
        c = Redmine::Helpers::Calendar.new(Date.today, :en, :week)
        assert_equal day, c.startdt.cwday
        assert_equal (day + 5) % 7 + 1, c.enddt.cwday
      end
    end
  end
end